Skip to content

Commit 1690d6d

Browse files
committed
test: adjust EF deploy tests to not add netlifyConfig configuration and use inline config, also add cases for internal and framework functions
1 parent 882b3ee commit 1690d6d

File tree

1 file changed

+98
-2
lines changed

1 file changed

+98
-2
lines changed

tests/integration/commands/deploy/deploy.test.ts

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,13 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
178178
.withNetlifyToml({
179179
config: {
180180
build: { publish: 'public', command: 'echo "no op"' },
181-
edge_functions: [{ function: 'edge', path: '/*' }],
182181
},
183182
})
184183
.withEdgeFunction({
185184
handler: async () => new Response('Edge Function works'),
185+
config: {
186+
path: '/*',
187+
},
186188
name: 'edge',
187189
})
188190

@@ -222,13 +224,15 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
222224
.withNetlifyToml({
223225
config: {
224226
build: { publish: 'public', command: 'echo "no op"' },
225-
edge_functions: [{ function: 'edge', path: '/*' }],
226227
},
227228
pathPrefix,
228229
})
229230
.withEdgeFunction({
230231
handler: async () => new Response('Edge Function works'),
231232
name: 'edge',
233+
config: {
234+
path: '/*',
235+
},
232236
pathPrefix,
233237
})
234238

@@ -256,6 +260,98 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
256260
})
257261
})
258262

263+
test('should deploy integrations Edge Functions when directory exists', async (t) => {
264+
await withSiteBuilder(t, async (builder) => {
265+
const content = 'Edge Function works NOT'
266+
builder
267+
.withContentFile({
268+
path: 'public/index.html',
269+
content,
270+
})
271+
.withNetlifyToml({
272+
config: {
273+
build: { publish: 'public', command: 'echo "no op"' },
274+
},
275+
})
276+
.withEdgeFunction({
277+
handler: async () => new Response('Edge Function works'),
278+
config: {
279+
path: '/*',
280+
},
281+
name: 'edge',
282+
path: '.netlify/edge-functions',
283+
})
284+
285+
await builder.build()
286+
287+
const options = {
288+
cwd: builder.directory,
289+
env: { NETLIFY_SITE_ID: context.siteId },
290+
}
291+
292+
await callCli(['build'], options)
293+
const deploy = await callCli(['deploy', '--json', '--no-build'], options).then((output: string) =>
294+
JSON.parse(output),
295+
)
296+
297+
// give edge functions manifest a couple ticks to propagate
298+
await pause(500)
299+
300+
await validateDeploy({
301+
deploy,
302+
siteName: SITE_NAME,
303+
content: 'Edge Function works',
304+
contentMessage: 'Edge function did not execute correctly or was not deployed correctly',
305+
})
306+
})
307+
})
308+
309+
test('should deploy framework Edge Functions when directory exists', async (t) => {
310+
await withSiteBuilder(t, async (builder) => {
311+
const content = 'Edge Function works NOT'
312+
builder
313+
.withContentFile({
314+
path: 'public/index.html',
315+
content,
316+
})
317+
.withNetlifyToml({
318+
config: {
319+
build: { publish: 'public', command: 'echo "no op"' },
320+
},
321+
})
322+
.withEdgeFunction({
323+
handler: async () => new Response('Edge Function works'),
324+
config: {
325+
path: '/*',
326+
},
327+
name: 'edge',
328+
path: '.netlify/v1/edge-functions',
329+
})
330+
331+
await builder.build()
332+
333+
const options = {
334+
cwd: builder.directory,
335+
env: { NETLIFY_SITE_ID: context.siteId },
336+
}
337+
338+
// skipping running build here, because it cleans up frameworks API directories
339+
const deploy = await callCli(['deploy', '--json', '--no-build'], options).then((output: string) =>
340+
JSON.parse(output),
341+
)
342+
343+
// give edge functions manifest a couple ticks to propagate
344+
await pause(500)
345+
346+
await validateDeploy({
347+
deploy,
348+
siteName: SITE_NAME,
349+
content: 'Edge Function works',
350+
contentMessage: 'Edge function did not execute correctly or was not deployed correctly',
351+
})
352+
})
353+
})
354+
259355
test('runs build command before deploy by default', async (t) => {
260356
await withSiteBuilder(t, async (builder) => {
261357
const content = '<h1>⊂◉‿◉つ</h1>'

0 commit comments

Comments
 (0)