Skip to content

Commit e400d99

Browse files
committed
wrangler: test: fix e2e tests regarding recent preview_urls defaulting to false
Fixes existing tests, and adds a new test for `preview_urls = true`.
1 parent 3b78839 commit e400d99

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

packages/wrangler/e2e/versions.test.ts

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
3737
name = "${workerName}"
3838
main = "src/index.ts"
3939
compatibility_date = "2023-01-01"
40-
preview_urls = true
4140
`,
4241
"src/index.ts": dedent`
4342
export default {
@@ -70,7 +69,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
7069
Worker Startup Time: (TIMINGS)
7170
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
7271
Worker Version ID: 00000000-0000-0000-0000-000000000000
73-
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
7472
To deploy this version to production traffic use the command wrangler versions deploy
7573
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
7674
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
@@ -186,7 +184,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
186184
Worker Startup Time: (TIMINGS)
187185
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
188186
Worker Version ID: 00000000-0000-0000-0000-000000000000
189-
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
190187
To deploy this version to production traffic use the command wrangler versions deploy
191188
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
192189
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
@@ -590,7 +587,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
590587
Worker Startup Time: (TIMINGS)
591588
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
592589
Worker Version ID: 00000000-0000-0000-0000-000000000000
593-
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
594590
To deploy this version to production traffic use the command wrangler versions deploy
595591
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
596592
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
@@ -632,7 +628,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
632628
Worker Startup Time: (TIMINGS)
633629
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
634630
Worker Version ID: 00000000-0000-0000-0000-000000000000
635-
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
636631
To deploy this version to production traffic use the command wrangler versions deploy
637632
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
638633
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
@@ -653,6 +648,45 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
653648
`);
654649
});
655650

651+
it("should upload version of Worker with preview_urls enabled", async () => {
652+
await helper.seed({
653+
"wrangler.toml": dedent`
654+
name = "${workerName}"
655+
main = "src/index.ts"
656+
compatibility_date = "2023-01-01"
657+
preview_urls = true
658+
`,
659+
"src/index.ts": dedent`
660+
export default {
661+
fetch(request) {
662+
return new Response("Hello World!")
663+
}
664+
}
665+
`,
666+
"package.json": dedent`
667+
{
668+
"name": "${workerName}",
669+
"version": "0.0.0",
670+
"private": true
671+
}
672+
`,
673+
});
674+
await helper.run("wrangler triggers deploy");
675+
const upload = await helper.run(
676+
`wrangler versions upload --message "Upload via e2e test" --tag "e2e-version-with-preview"`
677+
);
678+
expect(normalize(upload.stdout)).toMatchInlineSnapshot(`
679+
"Total Upload: xx KiB / gzip: xx KiB
680+
Worker Startup Time: (TIMINGS)
681+
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
682+
Worker Version ID: 00000000-0000-0000-0000-000000000000
683+
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
684+
To deploy this version to production traffic use the command wrangler versions deploy
685+
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
686+
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
687+
`);
688+
});
689+
656690
it("should include version preview url in output file", async () => {
657691
const outputFile = path.join(helper.tmpPath, "output.jsonnd");
658692
const upload = await helper.run(
@@ -678,10 +712,10 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
678712
const { stdout } = await helper.run(`wrangler delete`);
679713

680714
expect(normalize(stdout)).toMatchInlineSnapshot(`
681-
"? Are you sure you want to delete tmp-e2e-worker-00000000-0000-0000-0000-000000000000? This action cannot be undone.
682-
🤖 Using fallback value in non-interactive context: yes
683-
Successfully deleted tmp-e2e-worker-00000000-0000-0000-0000-000000000000"
684-
`);
715+
"? Are you sure you want to delete tmp-e2e-worker-00000000-0000-0000-0000-000000000000? This action cannot be undone.
716+
🤖 Using fallback value in non-interactive context: yes
717+
Successfully deleted tmp-e2e-worker-00000000-0000-0000-0000-000000000000"
718+
`);
685719
});
686720
}
687721
);

0 commit comments

Comments
 (0)