wrangler 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/src/__tests__/helpers/mock-dialogs.ts +2 -0
  3. package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -5
  4. package/src/__tests__/helpers/mock-known-routes.ts +7 -2
  5. package/src/__tests__/helpers/mock-kv.ts +29 -16
  6. package/src/__tests__/helpers/mock-oauth-flow.ts +90 -98
  7. package/src/__tests__/helpers/msw/handlers/deployments.ts +18 -0
  8. package/src/__tests__/helpers/msw/index.ts +30 -1
  9. package/src/__tests__/init.test.ts +3 -14
  10. package/src/__tests__/jest.setup.ts +0 -23
  11. package/src/__tests__/pages-deployment-tail.test.ts +72 -1
  12. package/src/__tests__/pages.test.ts +18 -16
  13. package/src/__tests__/publish.test.ts +744 -522
  14. package/src/__tests__/secret.test.ts +1 -9
  15. package/src/__tests__/tail.test.ts +66 -1
  16. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  17. package/src/__tests__/user.test.ts +5 -15
  18. package/src/api/dev.ts +17 -5
  19. package/src/cfetch/internal.ts +0 -3
  20. package/src/d1/backups.tsx +1 -5
  21. package/src/dev/remote.tsx +2 -0
  22. package/src/docs/index.ts +2 -1
  23. package/src/init.ts +1 -1
  24. package/src/pages/dev.ts +57 -62
  25. package/src/pages/functions/buildPlugin.ts +2 -20
  26. package/src/pages/functions/buildWorker.ts +136 -20
  27. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  28. package/src/pages/publish.tsx +36 -9
  29. package/src/publish/publish.ts +29 -4
  30. package/src/tail/createTail.ts +28 -1
  31. package/src/tail/printing.ts +15 -0
  32. package/templates/checked-fetch.js +1 -3
  33. package/wrangler-dist/cli.js +2935 -2824
  34. package/src/__tests__/helpers/mock-cfetch.ts +0 -278
@@ -1,9 +1,11 @@
1
- import { Buffer } from "node:buffer";
1
+ import { Blob, Buffer } from "node:buffer";
2
2
  import { randomFillSync } from "node:crypto";
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
5
  import * as TOML from "@iarna/toml";
6
6
  import * as esbuild from "esbuild";
7
+ import { MockedRequest, rest } from "msw";
8
+ import { FormData } from "undici";
7
9
  import {
8
10
  printBundleSize,
9
11
  printOffendingDependencies,
@@ -11,35 +13,40 @@ import {
11
13
  import { writeAuthConfigFile } from "../user";
12
14
  import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
13
15
  import { mockAuthDomain } from "./helpers/mock-auth-domain";
14
- import {
15
- createFetchResult,
16
- setMockRawResponse,
17
- setMockResponse,
18
- unsetAllMocks,
19
- unsetSpecialMockFns,
20
- } from "./helpers/mock-cfetch";
21
16
  import {
22
17
  mockConsoleMethods,
23
18
  normalizeSlashes,
24
19
  normalizeTempDirs,
25
20
  } from "./helpers/mock-console";
26
- import { mockConfirm } from "./helpers/mock-dialogs";
21
+ import { clearDialogs, mockConfirm } from "./helpers/mock-dialogs";
27
22
  import { mockGetZoneFromHostRequest } from "./helpers/mock-get-zone-from-host";
28
23
  import { useMockIsTTY } from "./helpers/mock-istty";
29
24
  import { mockCollectKnownRoutesRequest } from "./helpers/mock-known-routes";
30
25
  import { mockKeyListRequest } from "./helpers/mock-kv";
31
- import { mockGetMemberships, mockOAuthFlow } from "./helpers/mock-oauth-flow";
26
+ import {
27
+ mockExchangeRefreshTokenForAccessToken,
28
+ mockGetMemberships,
29
+ mockOAuthFlow,
30
+ } from "./helpers/mock-oauth-flow";
31
+ import {
32
+ createFetchResult,
33
+ msw,
34
+ mswSuccessDeployments,
35
+ mswSuccessLastDeployment,
36
+ } from "./helpers/msw";
37
+ import { FileReaderSync } from "./helpers/msw/read-file-sync";
32
38
  import { runInTempDir } from "./helpers/run-in-tmp";
33
39
  import { runWrangler } from "./helpers/run-wrangler";
34
40
  import { writeWorkerSource } from "./helpers/write-worker-source";
35
41
  import writeWranglerToml from "./helpers/write-wrangler-toml";
42
+
36
43
  import type { Config } from "../config";
37
44
  import type { WorkerMetadata } from "../create-worker-upload-form";
38
45
  import type { KVNamespaceInfo } from "../kv/helpers";
39
- import type { CustomDomainChangeset, CustomDomain } from "../publish/publish";
46
+ import type { CustomDomain, CustomDomainChangeset } from "../publish/publish";
40
47
  import type { PutConsumerBody } from "../queues/client";
41
48
  import type { CfWorkerInit } from "../worker";
42
- import type { FormData, File } from "undici";
49
+ import type { ResponseComposition, RestContext, RestRequest } from "msw";
43
50
 
44
51
  describe("publish", () => {
45
52
  mockAccountId();
@@ -48,10 +55,9 @@ describe("publish", () => {
48
55
  const { setIsTTY } = useMockIsTTY();
49
56
  const std = mockConsoleMethods();
50
57
  const {
51
- mockDomainUsesAccess,
52
58
  mockOAuthServerCallback,
53
59
  mockGrantAccessToken,
54
- mockGrantAuthorization,
60
+ mockDomainUsesAccess,
55
61
  } = mockOAuthFlow();
56
62
 
57
63
  beforeEach(() => {
@@ -60,28 +66,15 @@ describe("publish", () => {
60
66
  setImmediate(fn);
61
67
  });
62
68
  setIsTTY(true);
63
- setMockResponse(
64
- "/accounts/:accountId/workers/services/:scriptName",
65
- () => ({
66
- default_environment: { script: { last_deployed_from: "wrangler" } },
67
- })
68
- );
69
- setMockResponse(
70
- "/accounts/:accountId/workers/deployments/by-script/:scriptTag",
71
- () => ({
72
- latest: { number: "2" },
73
- })
74
- );
69
+ mockLastDeploymentRequest();
70
+ mockDeploymentsListRequest();
75
71
  });
76
72
 
77
73
  afterEach(() => {
78
- unsetAllMocks();
79
- unsetSpecialMockFns();
74
+ clearDialogs();
80
75
  });
81
76
 
82
77
  describe("output additional script information", () => {
83
- mockApiToken();
84
-
85
78
  it("for first party workers, it should print worker information at log level", async () => {
86
79
  setIsTTY(false);
87
80
  fs.writeFileSync(
@@ -112,7 +105,7 @@ describe("publish", () => {
112
105
  Uploaded test-name (TIMINGS)
113
106
  Published test-name (TIMINGS)
114
107
  https://test-name.test-sub-domain.workers.dev
115
- Current Deployment ID: undefined",
108
+ Current Deployment ID: Galaxy-Class",
116
109
  "warn": "",
117
110
  }
118
111
  `);
@@ -121,6 +114,7 @@ describe("publish", () => {
121
114
 
122
115
  describe("authentication", () => {
123
116
  mockApiToken({ apiToken: null });
117
+
124
118
  beforeEach(() => {
125
119
  // @ts-expect-error disable the mock we'd setup earlier
126
120
  // or else our server won't bother listening for oauth requests
@@ -129,21 +123,18 @@ describe("publish", () => {
129
123
  });
130
124
 
131
125
  it("drops a user into the login flow if they're unauthenticated", async () => {
126
+ setIsTTY(true);
132
127
  writeWranglerToml();
133
128
  writeWorkerSource();
134
129
  mockDomainUsesAccess({ usesAccess: false });
135
130
  mockSubDomainRequest();
136
131
  mockUploadWorkerRequest();
137
- mockOAuthServerCallback();
138
- const accessTokenRequest = mockGrantAccessToken({ respondWith: "ok" });
139
- mockGrantAuthorization({ respondWith: "success" });
132
+ mockExchangeRefreshTokenForAccessToken({ respondWith: "refreshSuccess" });
133
+ mockOAuthServerCallback("success");
134
+ mockDeploymentsListRequest();
140
135
 
141
136
  await expect(runWrangler("publish index.js")).resolves.toBeUndefined();
142
137
 
143
- expect(accessTokenRequest.actual.url).toEqual(
144
- accessTokenRequest.expected.url
145
- );
146
-
147
138
  expect(std.out).toMatchInlineSnapshot(`
148
139
  "Attempting to login via OAuth...
149
140
  Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
@@ -152,7 +143,7 @@ describe("publish", () => {
152
143
  Uploaded test-name (TIMINGS)
153
144
  Published test-name (TIMINGS)
154
145
  https://test-name.test-sub-domain.workers.dev
155
- Current Deployment ID: undefined"
146
+ Current Deployment ID: Galaxy-Class"
156
147
  `);
157
148
  expect(std.warn).toMatchInlineSnapshot(`""`);
158
149
  expect(std.err).toMatchInlineSnapshot(`""`);
@@ -170,18 +161,19 @@ describe("publish", () => {
170
161
  });
171
162
  mockSubDomainRequest();
172
163
  mockUploadWorkerRequest();
173
- mockOAuthServerCallback();
164
+ mockExchangeRefreshTokenForAccessToken({
165
+ respondWith: "refreshSuccess",
166
+ });
174
167
  const accessTokenRequest = mockGrantAccessToken({
175
- domain: "dash.staging.cloudflare.com",
176
168
  respondWith: "ok",
169
+ domain: "dash.staging.cloudflare.com",
177
170
  });
178
- mockGrantAuthorization({ respondWith: "success" });
171
+ mockOAuthServerCallback("success");
172
+ mockDeploymentsListRequest();
179
173
 
180
174
  await expect(runWrangler("publish index.js")).resolves.toBeUndefined();
181
175
 
182
- expect(accessTokenRequest.actual.url).toEqual(
183
- accessTokenRequest.expected.url
184
- );
176
+ expect(accessTokenRequest.actual).toEqual(accessTokenRequest.expected);
185
177
 
186
178
  expect(std.out).toMatchInlineSnapshot(`
187
179
  "Attempting to login via OAuth...
@@ -191,7 +183,7 @@ describe("publish", () => {
191
183
  Uploaded test-name (TIMINGS)
192
184
  Published test-name (TIMINGS)
193
185
  https://test-name.test-sub-domain.workers.dev
194
- Current Deployment ID: undefined"
186
+ Current Deployment ID: Galaxy-Class"
195
187
  `);
196
188
  expect(std.warn).toMatchInlineSnapshot(`""`);
197
189
  expect(std.err).toMatchInlineSnapshot(`""`);
@@ -214,7 +206,7 @@ describe("publish", () => {
214
206
  Uploaded test-name (TIMINGS)
215
207
  Published test-name (TIMINGS)
216
208
  https://test-name.test-sub-domain.workers.dev
217
- Current Deployment ID: undefined"
209
+ Current Deployment ID: Galaxy-Class"
218
210
  `);
219
211
  expect(std.warn).toMatchInlineSnapshot(`
220
212
  "▲ [WARNING] It looks like you have used Wrangler 1's \`config\` command to login with an API token.
@@ -255,7 +247,7 @@ describe("publish", () => {
255
247
  Uploaded test-name (TIMINGS)
256
248
  Published test-name (TIMINGS)
257
249
  https://test-name.test-sub-domain.workers.dev
258
- Current Deployment ID: undefined"
250
+ Current Deployment ID: Galaxy-Class"
259
251
  `);
260
252
  expect(std.err).toMatchInlineSnapshot(`""`);
261
253
  });
@@ -280,7 +272,7 @@ describe("publish", () => {
280
272
  Uploaded test-name (TIMINGS)
281
273
  Published test-name (TIMINGS)
282
274
  https://test-name.test-sub-domain.workers.dev
283
- Current Deployment ID: undefined"
275
+ Current Deployment ID: Galaxy-Class"
284
276
  `);
285
277
  expect(std.err).toMatchInlineSnapshot(`""`);
286
278
  });
@@ -384,7 +376,7 @@ describe("publish", () => {
384
376
  Uploaded test-name-some-env (TIMINGS)
385
377
  Published test-name-some-env (TIMINGS)
386
378
  https://test-name-some-env.test-sub-domain.workers.dev
387
- Current Deployment ID: undefined"
379
+ Current Deployment ID: Galaxy-Class"
388
380
  `);
389
381
  expect(std.err).toMatchInlineSnapshot(`""`);
390
382
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -405,7 +397,7 @@ describe("publish", () => {
405
397
  Uploaded test-name (TIMINGS)
406
398
  Published test-name (TIMINGS)
407
399
  https://test-name.test-sub-domain.workers.dev
408
- Current Deployment ID: undefined"
400
+ Current Deployment ID: Galaxy-Class"
409
401
  `);
410
402
  expect(std.err).toMatchInlineSnapshot(`""`);
411
403
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -426,7 +418,7 @@ describe("publish", () => {
426
418
  Uploaded test-name-some-env (TIMINGS)
427
419
  Published test-name-some-env (TIMINGS)
428
420
  https://test-name-some-env.test-sub-domain.workers.dev
429
- Current Deployment ID: undefined"
421
+ Current Deployment ID: Galaxy-Class"
430
422
  `);
431
423
  expect(std.err).toMatchInlineSnapshot(`""`);
432
424
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -447,7 +439,7 @@ describe("publish", () => {
447
439
  Uploaded test-name-some-env (TIMINGS)
448
440
  Published test-name-some-env (TIMINGS)
449
441
  https://test-name-some-env.test-sub-domain.workers.dev
450
- Current Deployment ID: undefined"
442
+ Current Deployment ID: Galaxy-Class"
451
443
  `);
452
444
  expect(std.err).toMatchInlineSnapshot(`""`);
453
445
  expect(std.warn).toMatchInlineSnapshot(`
@@ -519,7 +511,7 @@ describe("publish", () => {
519
511
  Uploaded test-name (TIMINGS)
520
512
  Published test-name (TIMINGS)
521
513
  https://test-name.test-sub-domain.workers.dev
522
- Current Deployment ID: undefined"
514
+ Current Deployment ID: Galaxy-Class"
523
515
  `);
524
516
  expect(std.err).toMatchInlineSnapshot(`""`);
525
517
  expect(std.warn).toMatchInlineSnapshot(`
@@ -547,7 +539,7 @@ describe("publish", () => {
547
539
  Uploaded test-name (some-env) (TIMINGS)
548
540
  Published test-name (some-env) (TIMINGS)
549
541
  https://some-env.test-name.test-sub-domain.workers.dev
550
- Current Deployment ID: undefined"
542
+ Current Deployment ID: Galaxy-Class"
551
543
  `);
552
544
  expect(std.err).toMatchInlineSnapshot(`""`);
553
545
  expect(std.warn).toMatchInlineSnapshot(`
@@ -594,7 +586,7 @@ describe("publish", () => {
594
586
  Uploaded test-name (TIMINGS)
595
587
  Published test-name (TIMINGS)
596
588
  https://test-name.test-sub-domain.workers.dev
597
- Current Deployment ID: undefined"
589
+ Current Deployment ID: Galaxy-Class"
598
590
  `);
599
591
  expect(std.err).toMatchInlineSnapshot(`""`);
600
592
  });
@@ -629,7 +621,7 @@ describe("publish", () => {
629
621
  Uploaded test-name (TIMINGS)
630
622
  Published test-name (TIMINGS)
631
623
  https://test-name.test-sub-domain.workers.dev
632
- Current Deployment ID: undefined",
624
+ Current Deployment ID: Galaxy-Class",
633
625
  "warn": "▲ [WARNING] Processing wrangler.toml configuration:
634
626
 
635
627
  - The \\"route\\" field in your configuration is an empty string and will be ignored.
@@ -680,7 +672,7 @@ describe("publish", () => {
680
672
  *another-boring-website.com (zone name: some-zone.com)
681
673
  example.com/some-route/* (zone id: JGHFHG654gjcj)
682
674
  more-examples.com/*
683
- Current Deployment ID: undefined",
675
+ Current Deployment ID: Galaxy-Class",
684
676
  "warn": "",
685
677
  }
686
678
  `);
@@ -742,7 +734,7 @@ describe("publish", () => {
742
734
  *another-boring-website.com (zone name: some-zone.com)
743
735
  example.com/some-route/* (zone id: JGHFHG654gjcj)
744
736
  more-examples.com/*
745
- Current Deployment ID: undefined",
737
+ Current Deployment ID: Galaxy-Class",
746
738
  "warn": "▲ [WARNING] Processing wrangler.toml configuration:
747
739
 
748
740
  - Experimental: Service environments are in beta, and their behaviour is guaranteed to change in
@@ -845,7 +837,7 @@ describe("publish", () => {
845
837
  Uploaded test-name (TIMINGS)
846
838
  Published test-name (TIMINGS)
847
839
  example.com/some-route/*
848
- Current Deployment ID: undefined"
840
+ Current Deployment ID: Galaxy-Class"
849
841
  `);
850
842
  });
851
843
 
@@ -1126,7 +1118,7 @@ Update them to point to this script instead?`,
1126
1118
  Uploaded test-name (TIMINGS)
1127
1119
  Published test-name (TIMINGS)
1128
1120
  https://test-name.test-sub-domain.workers.dev
1129
- Current Deployment ID: undefined"
1121
+ Current Deployment ID: Galaxy-Class"
1130
1122
  `);
1131
1123
  expect(std.err).toMatchInlineSnapshot(`""`);
1132
1124
  });
@@ -1144,7 +1136,7 @@ Update them to point to this script instead?`,
1144
1136
  Uploaded test-name (TIMINGS)
1145
1137
  Published test-name (TIMINGS)
1146
1138
  https://test-name.test-sub-domain.workers.dev
1147
- Current Deployment ID: undefined"
1139
+ Current Deployment ID: Galaxy-Class"
1148
1140
  `);
1149
1141
  expect(std.err).toMatchInlineSnapshot(`""`);
1150
1142
  });
@@ -1162,7 +1154,7 @@ Update them to point to this script instead?`,
1162
1154
  Uploaded test-name (TIMINGS)
1163
1155
  Published test-name (TIMINGS)
1164
1156
  https://test-name.test-sub-domain.workers.dev
1165
- Current Deployment ID: undefined"
1157
+ Current Deployment ID: Galaxy-Class"
1166
1158
  `);
1167
1159
  expect(std.err).toMatchInlineSnapshot(`""`);
1168
1160
  });
@@ -1182,7 +1174,7 @@ Update them to point to this script instead?`,
1182
1174
  Uploaded test-name (TIMINGS)
1183
1175
  Published test-name (TIMINGS)
1184
1176
  https://test-name.test-sub-domain.workers.dev
1185
- Current Deployment ID: undefined"
1177
+ Current Deployment ID: Galaxy-Class"
1186
1178
  `);
1187
1179
  expect(std.err).toMatchInlineSnapshot(`""`);
1188
1180
  });
@@ -1200,7 +1192,7 @@ Update them to point to this script instead?`,
1200
1192
  Uploaded test-name (TIMINGS)
1201
1193
  Published test-name (TIMINGS)
1202
1194
  https://test-name.test-sub-domain.workers.dev
1203
- Current Deployment ID: undefined"
1195
+ Current Deployment ID: Galaxy-Class"
1204
1196
  `);
1205
1197
  expect(std.err).toMatchInlineSnapshot(`""`);
1206
1198
  expect(std.warn).toMatchInlineSnapshot(`
@@ -1237,7 +1229,7 @@ Update them to point to this script instead?`,
1237
1229
  Uploaded test-name (TIMINGS)
1238
1230
  Published test-name (TIMINGS)
1239
1231
  https://test-name.test-sub-domain.workers.dev
1240
- Current Deployment ID: undefined"
1232
+ Current Deployment ID: Galaxy-Class"
1241
1233
  `);
1242
1234
  expect(std.err).toMatchInlineSnapshot(`""`);
1243
1235
  expect(std.warn).toMatchInlineSnapshot(`
@@ -1288,7 +1280,7 @@ Update them to point to this script instead?`,
1288
1280
  Uploaded test-name (TIMINGS)
1289
1281
  Published test-name (TIMINGS)
1290
1282
  https://test-name.test-sub-domain.workers.dev
1291
- Current Deployment ID: undefined"
1283
+ Current Deployment ID: Galaxy-Class"
1292
1284
  `);
1293
1285
  expect(std.err).toMatchInlineSnapshot(`""`);
1294
1286
  });
@@ -1308,7 +1300,7 @@ Update them to point to this script instead?`,
1308
1300
  Uploaded test-name (TIMINGS)
1309
1301
  Published test-name (TIMINGS)
1310
1302
  https://test-name.test-sub-domain.workers.dev
1311
- Current Deployment ID: undefined"
1303
+ Current Deployment ID: Galaxy-Class"
1312
1304
  `);
1313
1305
  expect(std.err).toMatchInlineSnapshot(`""`);
1314
1306
  });
@@ -1340,7 +1332,7 @@ export default{
1340
1332
  Uploaded test-name (TIMINGS)
1341
1333
  Published test-name (TIMINGS)
1342
1334
  https://test-name.test-sub-domain.workers.dev
1343
- Current Deployment ID: undefined"
1335
+ Current Deployment ID: Galaxy-Class"
1344
1336
  `);
1345
1337
  expect(std.err).toMatchInlineSnapshot(`""`);
1346
1338
  });
@@ -1358,7 +1350,7 @@ export default{
1358
1350
  Uploaded test-name (TIMINGS)
1359
1351
  Published test-name (TIMINGS)
1360
1352
  https://test-name.test-sub-domain.workers.dev
1361
- Current Deployment ID: undefined"
1353
+ Current Deployment ID: Galaxy-Class"
1362
1354
  `);
1363
1355
  expect(std.err).toMatchInlineSnapshot(`""`);
1364
1356
  });
@@ -1453,7 +1445,7 @@ addEventListener('fetch', event => {});`
1453
1445
  Uploaded test-name (TIMINGS)
1454
1446
  Published test-name (TIMINGS)
1455
1447
  https://test-name.test-sub-domain.workers.dev
1456
- Current Deployment ID: undefined"
1448
+ Current Deployment ID: Galaxy-Class"
1457
1449
  `);
1458
1450
  expect(std.err).toMatchInlineSnapshot(`""`);
1459
1451
  });
@@ -1536,7 +1528,7 @@ addEventListener('fetch', event => {});`
1536
1528
  Uploaded test-name (TIMINGS)
1537
1529
  Published test-name (TIMINGS)
1538
1530
  https://test-name.test-sub-domain.workers.dev
1539
- Current Deployment ID: undefined",
1531
+ Current Deployment ID: Galaxy-Class",
1540
1532
  "warn": "▲ [WARNING] Processing wrangler.toml configuration:
1541
1533
 
1542
1534
  - Deprecation: \\"site.entry-point\\":
@@ -1589,7 +1581,7 @@ addEventListener('fetch', event => {});`
1589
1581
  Uploaded test-name (TIMINGS)
1590
1582
  Published test-name (TIMINGS)
1591
1583
  https://test-name.test-sub-domain.workers.dev
1592
- Current Deployment ID: undefined"
1584
+ Current Deployment ID: Galaxy-Class"
1593
1585
  `);
1594
1586
  expect(std.err).toMatchInlineSnapshot(`""`);
1595
1587
  expect(normalizeSlashes(std.warn)).toMatchInlineSnapshot(`
@@ -1679,7 +1671,7 @@ addEventListener('fetch', event => {});`
1679
1671
  Uploaded test-name (TIMINGS)
1680
1672
  Published test-name (TIMINGS)
1681
1673
  https://test-name.test-sub-domain.workers.dev
1682
- Current Deployment ID: undefined",
1674
+ Current Deployment ID: Galaxy-Class",
1683
1675
  "warn": "▲ [WARNING] The --assets argument is experimental and may change or break at any time
1684
1676
 
1685
1677
 
@@ -1728,7 +1720,7 @@ addEventListener('fetch', event => {});`
1728
1720
  Uploaded test-name (TIMINGS)
1729
1721
  Published test-name (TIMINGS)
1730
1722
  https://test-name.test-sub-domain.workers.dev
1731
- Current Deployment ID: undefined"
1723
+ Current Deployment ID: Galaxy-Class"
1732
1724
  `);
1733
1725
  expect(std.err).toMatchInlineSnapshot(`""`);
1734
1726
  });
@@ -1769,7 +1761,7 @@ addEventListener('fetch', event => {});`
1769
1761
  Uploaded test-name (TIMINGS)
1770
1762
  Published test-name (TIMINGS)
1771
1763
  https://test-name.test-sub-domain.workers.dev
1772
- Current Deployment ID: undefined",
1764
+ Current Deployment ID: Galaxy-Class",
1773
1765
  "warn": "▲ [WARNING] The --assets argument is experimental and may change or break at any time
1774
1766
 
1775
1767
  ",
@@ -1954,7 +1946,7 @@ addEventListener('fetch', event => {});`
1954
1946
  Uploaded test-name (TIMINGS)
1955
1947
  Published test-name (TIMINGS)
1956
1948
  https://test-name.test-sub-domain.workers.dev
1957
- Current Deployment ID: undefined",
1949
+ Current Deployment ID: Galaxy-Class",
1958
1950
  "warn": "▲ [WARNING] The --assets argument is experimental and may change or break at any time
1959
1951
 
1960
1952
  ",
@@ -2001,7 +1993,7 @@ addEventListener('fetch', event => {});`
2001
1993
  Uploaded test-name (TIMINGS)
2002
1994
  Published test-name (TIMINGS)
2003
1995
  https://test-name.test-sub-domain.workers.dev
2004
- Current Deployment ID: undefined",
1996
+ Current Deployment ID: Galaxy-Class",
2005
1997
  "warn": "▲ [WARNING] Processing wrangler.toml configuration:
2006
1998
 
2007
1999
  - \\"assets\\" fields are experimental and may change or break at any time.
@@ -2058,7 +2050,7 @@ addEventListener('fetch', event => {});`
2058
2050
  Uploaded test-name (TIMINGS)
2059
2051
  Published test-name (TIMINGS)
2060
2052
  https://test-name.test-sub-domain.workers.dev
2061
- Current Deployment ID: undefined"
2053
+ Current Deployment ID: Galaxy-Class"
2062
2054
  `);
2063
2055
  expect(std.err).toMatchInlineSnapshot(`""`);
2064
2056
  });
@@ -2116,7 +2108,7 @@ addEventListener('fetch', event => {});`
2116
2108
  Uploaded test-name (TIMINGS)
2117
2109
  Published test-name (TIMINGS)
2118
2110
  https://test-name.test-sub-domain.workers.dev
2119
- Current Deployment ID: undefined"
2111
+ Current Deployment ID: Galaxy-Class"
2120
2112
  `);
2121
2113
  expect(std.err).toMatchInlineSnapshot(`""`);
2122
2114
  });
@@ -2168,7 +2160,7 @@ addEventListener('fetch', event => {});`
2168
2160
  Uploaded test-name (TIMINGS)
2169
2161
  Published test-name (TIMINGS)
2170
2162
  https://test-name.test-sub-domain.workers.dev
2171
- Current Deployment ID: undefined"
2163
+ Current Deployment ID: Galaxy-Class"
2172
2164
  `);
2173
2165
  expect(std.err).toMatchInlineSnapshot(`""`);
2174
2166
  });
@@ -2218,7 +2210,7 @@ addEventListener('fetch', event => {});`
2218
2210
  Uploaded test-name (some-env) (TIMINGS)
2219
2211
  Published test-name (some-env) (TIMINGS)
2220
2212
  https://some-env.test-name.test-sub-domain.workers.dev
2221
- Current Deployment ID: undefined"
2213
+ Current Deployment ID: Galaxy-Class"
2222
2214
  `);
2223
2215
  expect(std.err).toMatchInlineSnapshot(`""`);
2224
2216
  });
@@ -2269,7 +2261,7 @@ addEventListener('fetch', event => {});`
2269
2261
  Uploaded test-name-some-env (TIMINGS)
2270
2262
  Published test-name-some-env (TIMINGS)
2271
2263
  https://test-name-some-env.test-sub-domain.workers.dev
2272
- Current Deployment ID: undefined"
2264
+ Current Deployment ID: Galaxy-Class"
2273
2265
  `);
2274
2266
  expect(std.err).toMatchInlineSnapshot(`""`);
2275
2267
  });
@@ -2313,7 +2305,7 @@ addEventListener('fetch', event => {});`
2313
2305
  Uploaded test-name (TIMINGS)
2314
2306
  Published test-name (TIMINGS)
2315
2307
  https://test-name.test-sub-domain.workers.dev
2316
- Current Deployment ID: undefined"
2308
+ Current Deployment ID: Galaxy-Class"
2317
2309
  `);
2318
2310
  expect(std.err).toMatchInlineSnapshot(`""`);
2319
2311
  });
@@ -2354,7 +2346,7 @@ addEventListener('fetch', event => {});`
2354
2346
  Uploaded test-name (TIMINGS)
2355
2347
  Published test-name (TIMINGS)
2356
2348
  https://test-name.test-sub-domain.workers.dev
2357
- Current Deployment ID: undefined"
2349
+ Current Deployment ID: Galaxy-Class"
2358
2350
  `);
2359
2351
  expect(std.err).toMatchInlineSnapshot(`""`);
2360
2352
  });
@@ -2395,7 +2387,7 @@ addEventListener('fetch', event => {});`
2395
2387
  Uploaded test-name (TIMINGS)
2396
2388
  Published test-name (TIMINGS)
2397
2389
  https://test-name.test-sub-domain.workers.dev
2398
- Current Deployment ID: undefined"
2390
+ Current Deployment ID: Galaxy-Class"
2399
2391
  `);
2400
2392
  expect(std.err).toMatchInlineSnapshot(`""`);
2401
2393
  });
@@ -2437,7 +2429,7 @@ addEventListener('fetch', event => {});`
2437
2429
  Uploaded test-name (TIMINGS)
2438
2430
  Published test-name (TIMINGS)
2439
2431
  https://test-name.test-sub-domain.workers.dev
2440
- Current Deployment ID: undefined"
2432
+ Current Deployment ID: Galaxy-Class"
2441
2433
  `);
2442
2434
  expect(std.err).toMatchInlineSnapshot(`""`);
2443
2435
  });
@@ -2479,7 +2471,7 @@ addEventListener('fetch', event => {});`
2479
2471
  Uploaded test-name (TIMINGS)
2480
2472
  Published test-name (TIMINGS)
2481
2473
  https://test-name.test-sub-domain.workers.dev
2482
- Current Deployment ID: undefined"
2474
+ Current Deployment ID: Galaxy-Class"
2483
2475
  `);
2484
2476
  expect(std.err).toMatchInlineSnapshot(`""`);
2485
2477
  });
@@ -2521,7 +2513,7 @@ addEventListener('fetch', event => {});`
2521
2513
  Uploaded test-name (TIMINGS)
2522
2514
  Published test-name (TIMINGS)
2523
2515
  https://test-name.test-sub-domain.workers.dev
2524
- Current Deployment ID: undefined"
2516
+ Current Deployment ID: Galaxy-Class"
2525
2517
  `);
2526
2518
  expect(std.err).toMatchInlineSnapshot(`""`);
2527
2519
  });
@@ -2563,7 +2555,7 @@ addEventListener('fetch', event => {});`
2563
2555
  Uploaded test-name (TIMINGS)
2564
2556
  Published test-name (TIMINGS)
2565
2557
  https://test-name.test-sub-domain.workers.dev
2566
- Current Deployment ID: undefined"
2558
+ Current Deployment ID: Galaxy-Class"
2567
2559
  `);
2568
2560
  expect(std.err).toMatchInlineSnapshot(`""`);
2569
2561
  });
@@ -2607,7 +2599,7 @@ addEventListener('fetch', event => {});`
2607
2599
  Uploaded test-name (TIMINGS)
2608
2600
  Published test-name (TIMINGS)
2609
2601
  https://test-name.test-sub-domain.workers.dev
2610
- Current Deployment ID: undefined"
2602
+ Current Deployment ID: Galaxy-Class"
2611
2603
  `);
2612
2604
  expect(std.err).toMatchInlineSnapshot(`""`);
2613
2605
  });
@@ -2655,7 +2647,7 @@ addEventListener('fetch', event => {});`
2655
2647
  Uploaded test-name (TIMINGS)
2656
2648
  Published test-name (TIMINGS)
2657
2649
  https://test-name.test-sub-domain.workers.dev
2658
- Current Deployment ID: undefined"
2650
+ Current Deployment ID: Galaxy-Class"
2659
2651
  `);
2660
2652
  expect(std.err).toMatchInlineSnapshot(`""`);
2661
2653
  });
@@ -2805,7 +2797,7 @@ addEventListener('fetch', event => {});`
2805
2797
  Uploaded test-name (TIMINGS)
2806
2798
  Published test-name (TIMINGS)
2807
2799
  https://test-name.test-sub-domain.workers.dev
2808
- Current Deployment ID: undefined",
2800
+ Current Deployment ID: Galaxy-Class",
2809
2801
  "warn": "",
2810
2802
  }
2811
2803
  `);
@@ -2905,7 +2897,7 @@ addEventListener('fetch', event => {});`
2905
2897
  Uploaded test-name (TIMINGS)
2906
2898
  Published test-name (TIMINGS)
2907
2899
  https://test-name.test-sub-domain.workers.dev
2908
- Current Deployment ID: undefined"
2900
+ Current Deployment ID: Galaxy-Class"
2909
2901
  `);
2910
2902
  expect(std.err).toMatchInlineSnapshot(`""`);
2911
2903
  });
@@ -2960,7 +2952,7 @@ addEventListener('fetch', event => {});`
2960
2952
  Uploaded test-name (TIMINGS)
2961
2953
  Published test-name (TIMINGS)
2962
2954
  https://test-name.test-sub-domain.workers.dev
2963
- Current Deployment ID: undefined"
2955
+ Current Deployment ID: Galaxy-Class"
2964
2956
  `);
2965
2957
  expect(std.err).toMatchInlineSnapshot(`""`);
2966
2958
  });
@@ -3002,7 +2994,7 @@ addEventListener('fetch', event => {});`
3002
2994
  Uploaded test-name (TIMINGS)
3003
2995
  Published test-name (TIMINGS)
3004
2996
  https://test-name.test-sub-domain.workers.dev
3005
- Current Deployment ID: undefined",
2997
+ Current Deployment ID: Galaxy-Class",
3006
2998
  "warn": "",
3007
2999
  }
3008
3000
  `);
@@ -3045,7 +3037,7 @@ addEventListener('fetch', event => {});`
3045
3037
  Uploaded test-name (TIMINGS)
3046
3038
  Published test-name (TIMINGS)
3047
3039
  https://test-name.test-sub-domain.workers.dev
3048
- Current Deployment ID: undefined",
3040
+ Current Deployment ID: Galaxy-Class",
3049
3041
  "warn": "▲ [WARNING] The --assets argument is experimental and may change or break at any time
3050
3042
 
3051
3043
  ",
@@ -3068,7 +3060,7 @@ addEventListener('fetch', event => {});`
3068
3060
  Uploaded test-name (TIMINGS)
3069
3061
  Published test-name (TIMINGS)
3070
3062
  https://test-name.test-sub-domain.workers.dev
3071
- Current Deployment ID: undefined"
3063
+ Current Deployment ID: Galaxy-Class"
3072
3064
  `);
3073
3065
  expect(std.err).toMatchInlineSnapshot(`""`);
3074
3066
  });
@@ -3089,7 +3081,7 @@ addEventListener('fetch', event => {});`
3089
3081
  Uploaded test-name (TIMINGS)
3090
3082
  Published test-name (TIMINGS)
3091
3083
  https://test-name.test-sub-domain.workers.dev
3092
- Current Deployment ID: undefined"
3084
+ Current Deployment ID: Galaxy-Class"
3093
3085
  `);
3094
3086
  expect(std.err).toMatchInlineSnapshot(`""`);
3095
3087
  });
@@ -3109,7 +3101,7 @@ addEventListener('fetch', event => {});`
3109
3101
  Uploaded test-name (TIMINGS)
3110
3102
  Published test-name (TIMINGS)
3111
3103
  https://test-name.test-sub-domain.workers.dev
3112
- Current Deployment ID: undefined"
3104
+ Current Deployment ID: Galaxy-Class"
3113
3105
  `);
3114
3106
  expect(std.err).toMatchInlineSnapshot(`""`);
3115
3107
  });
@@ -3128,7 +3120,7 @@ addEventListener('fetch', event => {});`
3128
3120
  "Total Upload: xx KiB / gzip: xx KiB
3129
3121
  Uploaded test-name (TIMINGS)
3130
3122
  No publish targets for test-name (TIMINGS)
3131
- Current Deployment ID: undefined"
3123
+ Current Deployment ID: Galaxy-Class"
3132
3124
  `);
3133
3125
  expect(std.err).toMatchInlineSnapshot(`""`);
3134
3126
  });
@@ -3149,7 +3141,7 @@ addEventListener('fetch', event => {});`
3149
3141
  "Total Upload: xx KiB / gzip: xx KiB
3150
3142
  Uploaded test-name (TIMINGS)
3151
3143
  No publish targets for test-name (TIMINGS)
3152
- Current Deployment ID: undefined"
3144
+ Current Deployment ID: Galaxy-Class"
3153
3145
  `);
3154
3146
  expect(std.err).toMatchInlineSnapshot(`""`);
3155
3147
  });
@@ -3174,7 +3166,7 @@ addEventListener('fetch', event => {});`
3174
3166
  "Total Upload: xx KiB / gzip: xx KiB
3175
3167
  Uploaded test-name (dev) (TIMINGS)
3176
3168
  No publish targets for test-name (dev) (TIMINGS)
3177
- Current Deployment ID: undefined"
3169
+ Current Deployment ID: Galaxy-Class"
3178
3170
  `);
3179
3171
  expect(std.err).toMatchInlineSnapshot(`""`);
3180
3172
  });
@@ -3200,7 +3192,7 @@ addEventListener('fetch', event => {});`
3200
3192
  "Total Upload: xx KiB / gzip: xx KiB
3201
3193
  Uploaded test-name (dev) (TIMINGS)
3202
3194
  No publish targets for test-name (dev) (TIMINGS)
3203
- Current Deployment ID: undefined"
3195
+ Current Deployment ID: Galaxy-Class"
3204
3196
  `);
3205
3197
  expect(std.err).toMatchInlineSnapshot(`""`);
3206
3198
  });
@@ -3227,7 +3219,7 @@ addEventListener('fetch', event => {});`
3227
3219
  Uploaded test-name (dev) (TIMINGS)
3228
3220
  Published test-name (dev) (TIMINGS)
3229
3221
  https://dev.test-name.test-sub-domain.workers.dev
3230
- Current Deployment ID: undefined"
3222
+ Current Deployment ID: Galaxy-Class"
3231
3223
  `);
3232
3224
  expect(std.err).toMatchInlineSnapshot(`""`);
3233
3225
  });
@@ -3255,7 +3247,7 @@ addEventListener('fetch', event => {});`
3255
3247
  Uploaded test-name (dev) (TIMINGS)
3256
3248
  Published test-name (dev) (TIMINGS)
3257
3249
  https://dev.test-name.test-sub-domain.workers.dev
3258
- Current Deployment ID: undefined"
3250
+ Current Deployment ID: Galaxy-Class"
3259
3251
  `);
3260
3252
  expect(std.err).toMatchInlineSnapshot(`""`);
3261
3253
  });
@@ -3284,7 +3276,7 @@ addEventListener('fetch', event => {});`
3284
3276
  Uploaded test-name (dev) (TIMINGS)
3285
3277
  Published test-name (dev) (TIMINGS)
3286
3278
  https://dev.test-name.test-sub-domain.workers.dev
3287
- Current Deployment ID: undefined"
3279
+ Current Deployment ID: Galaxy-Class"
3288
3280
  `);
3289
3281
  expect(std.err).toMatchInlineSnapshot(`""`);
3290
3282
  });
@@ -3316,7 +3308,7 @@ addEventListener('fetch', event => {});`
3316
3308
  Uploaded test-name (dev) (TIMINGS)
3317
3309
  Published test-name (dev) (TIMINGS)
3318
3310
  https://dev.test-name.test-sub-domain.workers.dev
3319
- Current Deployment ID: undefined"
3311
+ Current Deployment ID: Galaxy-Class"
3320
3312
  `);
3321
3313
  expect(std.err).toMatchInlineSnapshot(`""`);
3322
3314
  });
@@ -3350,7 +3342,7 @@ addEventListener('fetch', event => {});`
3350
3342
  Uploaded test-name (dev) (TIMINGS)
3351
3343
  Published test-name (dev) (TIMINGS)
3352
3344
  https://dev.test-name.test-sub-domain.workers.dev
3353
- Current Deployment ID: undefined"
3345
+ Current Deployment ID: Galaxy-Class"
3354
3346
  `);
3355
3347
  expect(std.err).toMatchInlineSnapshot(`""`);
3356
3348
  });
@@ -3411,7 +3403,7 @@ addEventListener('fetch', event => {});`
3411
3403
  Uploaded test-name (TIMINGS)
3412
3404
  Published test-name (TIMINGS)
3413
3405
  https://test-name.test-sub-domain.workers.dev
3414
- Current Deployment ID: undefined"
3406
+ Current Deployment ID: Galaxy-Class"
3415
3407
  `);
3416
3408
  expect(std.err).toMatchInlineSnapshot(`""`);
3417
3409
  });
@@ -3430,7 +3422,7 @@ addEventListener('fetch', event => {});`
3430
3422
  Uploaded test-name (TIMINGS)
3431
3423
  Published test-name (TIMINGS)
3432
3424
  https://test-name.test-sub-domain.workers.dev
3433
- Current Deployment ID: undefined"
3425
+ Current Deployment ID: Galaxy-Class"
3434
3426
  `);
3435
3427
  expect(std.err).toMatchInlineSnapshot(`""`);
3436
3428
  });
@@ -3444,7 +3436,7 @@ addEventListener('fetch', event => {});`
3444
3436
  mockSubDomainRequest("does-not-exist", false);
3445
3437
 
3446
3438
  mockConfirm({
3447
- text: `Would you like to register a workers.dev subdomain now?`,
3439
+ text: "Would you like to register a workers.dev subdomain now?",
3448
3440
  result: false,
3449
3441
  });
3450
3442
 
@@ -3473,7 +3465,7 @@ addEventListener('fetch', event => {});`
3473
3465
  Uploaded test-name (TIMINGS)
3474
3466
  Published test-name (TIMINGS)
3475
3467
  http://example.com/*
3476
- Current Deployment ID: undefined"
3468
+ Current Deployment ID: Galaxy-Class"
3477
3469
  `);
3478
3470
  expect(std.err).toMatchInlineSnapshot(`""`);
3479
3471
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -3508,7 +3500,7 @@ addEventListener('fetch', event => {});`
3508
3500
  Uploaded test-name-production (TIMINGS)
3509
3501
  Published test-name-production (TIMINGS)
3510
3502
  http://production.example.com/*
3511
- Current Deployment ID: undefined"
3503
+ Current Deployment ID: Galaxy-Class"
3512
3504
  `);
3513
3505
  expect(std.err).toMatchInlineSnapshot(`""`);
3514
3506
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -3542,7 +3534,7 @@ addEventListener('fetch', event => {});`
3542
3534
  Uploaded test-name-production (TIMINGS)
3543
3535
  Published test-name-production (TIMINGS)
3544
3536
  http://production.example.com/*
3545
- Current Deployment ID: undefined"
3537
+ Current Deployment ID: Galaxy-Class"
3546
3538
  `);
3547
3539
  expect(std.err).toMatchInlineSnapshot(`""`);
3548
3540
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -3570,7 +3562,7 @@ addEventListener('fetch', event => {});`
3570
3562
  Published test-name (TIMINGS)
3571
3563
  https://test-name.test-sub-domain.workers.dev
3572
3564
  http://example.com/*
3573
- Current Deployment ID: undefined"
3565
+ Current Deployment ID: Galaxy-Class"
3574
3566
  `);
3575
3567
  expect(std.err).toMatchInlineSnapshot(`""`);
3576
3568
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -3606,7 +3598,7 @@ addEventListener('fetch', event => {});`
3606
3598
  Published test-name-production (TIMINGS)
3607
3599
  https://test-name-production.test-sub-domain.workers.dev
3608
3600
  http://production.example.com/*
3609
- Current Deployment ID: undefined"
3601
+ Current Deployment ID: Galaxy-Class"
3610
3602
  `);
3611
3603
  expect(std.err).toMatchInlineSnapshot(`""`);
3612
3604
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -3642,7 +3634,7 @@ addEventListener('fetch', event => {});`
3642
3634
  Published test-name-production (TIMINGS)
3643
3635
  https://test-name-production.test-sub-domain.workers.dev
3644
3636
  http://production.example.com/*
3645
- Current Deployment ID: undefined"
3637
+ Current Deployment ID: Galaxy-Class"
3646
3638
  `);
3647
3639
  expect(std.err).toMatchInlineSnapshot(`""`);
3648
3640
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -3677,7 +3669,7 @@ addEventListener('fetch', event => {});`
3677
3669
  Uploaded test-name-production (TIMINGS)
3678
3670
  Published test-name-production (TIMINGS)
3679
3671
  http://production.example.com/*
3680
- Current Deployment ID: undefined"
3672
+ Current Deployment ID: Galaxy-Class"
3681
3673
  `);
3682
3674
  expect(std.err).toMatchInlineSnapshot(`""`);
3683
3675
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -3712,7 +3704,7 @@ addEventListener('fetch', event => {});`
3712
3704
  Uploaded test-name-production (TIMINGS)
3713
3705
  Published test-name-production (TIMINGS)
3714
3706
  http://production.example.com/*
3715
- Current Deployment ID: undefined"
3707
+ Current Deployment ID: Galaxy-Class"
3716
3708
  `);
3717
3709
  expect(std.err).toMatchInlineSnapshot(`""`);
3718
3710
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -3864,7 +3856,7 @@ addEventListener('fetch', event => {});`
3864
3856
  Uploaded test-name (TIMINGS)
3865
3857
  Published test-name (TIMINGS)
3866
3858
  https://test-name.test-sub-domain.workers.dev
3867
- Current Deployment ID: undefined"
3859
+ Current Deployment ID: Galaxy-Class"
3868
3860
  `);
3869
3861
  expect(std.err).toMatchInlineSnapshot(`""`);
3870
3862
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -3890,7 +3882,7 @@ addEventListener('fetch', event => {});`
3890
3882
  Uploaded test-name (TIMINGS)
3891
3883
  Published test-name (TIMINGS)
3892
3884
  https://test-name.test-sub-domain.workers.dev
3893
- Current Deployment ID: undefined"
3885
+ Current Deployment ID: Galaxy-Class"
3894
3886
  `);
3895
3887
  expect(std.err).toMatchInlineSnapshot(`""`);
3896
3888
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -3997,7 +3989,7 @@ addEventListener('fetch', event => {});`
3997
3989
  Uploaded test-name (TIMINGS)
3998
3990
  Published test-name (TIMINGS)
3999
3991
  https://test-name.test-sub-domain.workers.dev
4000
- Current Deployment ID: undefined"
3992
+ Current Deployment ID: Galaxy-Class"
4001
3993
  `);
4002
3994
  expect(std.err).toMatchInlineSnapshot(`""`);
4003
3995
  });
@@ -4037,7 +4029,7 @@ addEventListener('fetch', event => {});`
4037
4029
  Uploaded test-name (testEnv) (TIMINGS)
4038
4030
  Published test-name (testEnv) (TIMINGS)
4039
4031
  https://testEnv.test-name.test-sub-domain.workers.dev
4040
- Current Deployment ID: undefined"
4032
+ Current Deployment ID: Galaxy-Class"
4041
4033
  `);
4042
4034
  expect(std.err).toMatchInlineSnapshot(`""`);
4043
4035
  });
@@ -4065,7 +4057,7 @@ addEventListener('fetch', event => {});`
4065
4057
  Uploaded test-name (TIMINGS)
4066
4058
  Published test-name (TIMINGS)
4067
4059
  https://test-name.test-sub-domain.workers.dev
4068
- Current Deployment ID: undefined"
4060
+ Current Deployment ID: Galaxy-Class"
4069
4061
  `);
4070
4062
  expect(std.err).toMatchInlineSnapshot(`""`);
4071
4063
  expect(std.warn).toMatchInlineSnapshot(`
@@ -4116,7 +4108,7 @@ addEventListener('fetch', event => {});`
4116
4108
  Uploaded test-name (TIMINGS)
4117
4109
  Published test-name (TIMINGS)
4118
4110
  https://test-name.test-sub-domain.workers.dev
4119
- Current Deployment ID: undefined"
4111
+ Current Deployment ID: Galaxy-Class"
4120
4112
  `);
4121
4113
  expect(std.err).toMatchInlineSnapshot(`""`);
4122
4114
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -4161,7 +4153,7 @@ addEventListener('fetch', event => {});`
4161
4153
  Uploaded test-name (TIMINGS)
4162
4154
  Published test-name (TIMINGS)
4163
4155
  https://test-name.test-sub-domain.workers.dev
4164
- Current Deployment ID: undefined"
4156
+ Current Deployment ID: Galaxy-Class"
4165
4157
  `);
4166
4158
  expect(std.err).toMatchInlineSnapshot(`""`);
4167
4159
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -4213,7 +4205,7 @@ addEventListener('fetch', event => {});`
4213
4205
  Uploaded test-name (TIMINGS)
4214
4206
  Published test-name (TIMINGS)
4215
4207
  https://test-name.test-sub-domain.workers.dev
4216
- Current Deployment ID: undefined",
4208
+ Current Deployment ID: Galaxy-Class",
4217
4209
  "warn": "",
4218
4210
  }
4219
4211
  `);
@@ -4258,7 +4250,7 @@ addEventListener('fetch', event => {});`
4258
4250
  Uploaded test-name (TIMINGS)
4259
4251
  Published test-name (TIMINGS)
4260
4252
  https://test-name.test-sub-domain.workers.dev
4261
- Current Deployment ID: undefined",
4253
+ Current Deployment ID: Galaxy-Class",
4262
4254
  "warn": "",
4263
4255
  }
4264
4256
  `);
@@ -4305,7 +4297,7 @@ addEventListener('fetch', event => {});`
4305
4297
  Uploaded test-name (TIMINGS)
4306
4298
  Published test-name (TIMINGS)
4307
4299
  https://test-name.test-sub-domain.workers.dev
4308
- Current Deployment ID: undefined"
4300
+ Current Deployment ID: Galaxy-Class"
4309
4301
  `);
4310
4302
  expect(std.err).toMatchInlineSnapshot(`""`);
4311
4303
  expect(std.warn).toMatchInlineSnapshot(`
@@ -4369,7 +4361,7 @@ addEventListener('fetch', event => {});`
4369
4361
  Uploaded test-name (xyz) (TIMINGS)
4370
4362
  Published test-name (xyz) (TIMINGS)
4371
4363
  https://xyz.test-name.test-sub-domain.workers.dev
4372
- Current Deployment ID: undefined"
4364
+ Current Deployment ID: Galaxy-Class"
4373
4365
  `);
4374
4366
  expect(std.err).toMatchInlineSnapshot(`""`);
4375
4367
  expect(std.warn).toMatchInlineSnapshot(`
@@ -4383,7 +4375,6 @@ addEventListener('fetch', event => {});`
4383
4375
  });
4384
4376
 
4385
4377
  it("should use a script's current migration tag when publishing migrations", async () => {
4386
- unsetAllMocks();
4387
4378
  writeWranglerToml({
4388
4379
  durable_objects: {
4389
4380
  bindings: [
@@ -4402,26 +4393,22 @@ addEventListener('fetch', event => {});`
4402
4393
  );
4403
4394
  mockSubDomainRequest();
4404
4395
  mockServiceScriptData({
4405
- script: { id: "test-name", migration_tag: "v1" },
4396
+ script: { id: "test-name", migration_tag: "v2" },
4406
4397
  });
4407
4398
  mockUploadWorkerRequest({
4408
4399
  legacyEnv: false,
4409
4400
  expectedMigrations: {
4410
- old_tag: "v1",
4411
4401
  new_tag: "v2",
4412
4402
  steps: [
4403
+ {
4404
+ new_classes: ["SomeClass"],
4405
+ },
4413
4406
  {
4414
4407
  new_classes: ["SomeOtherClass"],
4415
4408
  },
4416
4409
  ],
4417
4410
  },
4418
4411
  });
4419
- setMockResponse(
4420
- "/accounts/:accountId/workers/deployments/by-script/:scriptTag",
4421
- () => ({
4422
- latest: { number: "2" },
4423
- })
4424
- );
4425
4412
 
4426
4413
  await runWrangler("publish index.js --legacy-env false");
4427
4414
  expect(std).toMatchInlineSnapshot(`
@@ -4436,7 +4423,7 @@ addEventListener('fetch', event => {});`
4436
4423
  Uploaded test-name (TIMINGS)
4437
4424
  Published test-name (TIMINGS)
4438
4425
  https://test-name.test-sub-domain.workers.dev
4439
- Current Deployment ID: undefined",
4426
+ Current Deployment ID: Galaxy-Class",
4440
4427
  "warn": "▲ [WARNING] Processing wrangler.toml configuration:
4441
4428
 
4442
4429
  - Experimental: Service environments are in beta, and their behaviour is guaranteed to change in
@@ -4506,7 +4493,7 @@ addEventListener('fetch', event => {});`
4506
4493
  Uploaded test-name (xyz) (TIMINGS)
4507
4494
  Published test-name (xyz) (TIMINGS)
4508
4495
  https://xyz.test-name.test-sub-domain.workers.dev
4509
- Current Deployment ID: undefined",
4496
+ Current Deployment ID: Galaxy-Class",
4510
4497
  "warn": "▲ [WARNING] Processing wrangler.toml configuration:
4511
4498
 
4512
4499
  - Experimental: Service environments are in beta, and their behaviour is guaranteed to change in
@@ -4742,7 +4729,7 @@ addEventListener('fetch', event => {});`
4742
4729
  Uploaded test-name (TIMINGS)
4743
4730
  Published test-name (TIMINGS)
4744
4731
  https://test-name.test-sub-domain.workers.dev
4745
- Current Deployment ID: undefined"
4732
+ Current Deployment ID: Galaxy-Class"
4746
4733
  `);
4747
4734
  expect(std.err).toMatchInlineSnapshot(`""`);
4748
4735
  expect(std.warn).toMatchInlineSnapshot(`
@@ -5163,7 +5150,7 @@ addEventListener('fetch', event => {});`
5163
5150
  Uploaded test-name (TIMINGS)
5164
5151
  Published test-name (TIMINGS)
5165
5152
  https://test-name.test-sub-domain.workers.dev
5166
- Current Deployment ID: undefined"
5153
+ Current Deployment ID: Galaxy-Class"
5167
5154
  `);
5168
5155
  expect(std.err).toMatchInlineSnapshot(`""`);
5169
5156
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5234,7 +5221,7 @@ addEventListener('fetch', event => {});`
5234
5221
  Uploaded test-name (TIMINGS)
5235
5222
  Published test-name (TIMINGS)
5236
5223
  https://test-name.test-sub-domain.workers.dev
5237
- Current Deployment ID: undefined"
5224
+ Current Deployment ID: Galaxy-Class"
5238
5225
  `);
5239
5226
  expect(std.err).toMatchInlineSnapshot(`""`);
5240
5227
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5268,7 +5255,7 @@ addEventListener('fetch', event => {});`
5268
5255
  Uploaded test-name (TIMINGS)
5269
5256
  Published test-name (TIMINGS)
5270
5257
  https://test-name.test-sub-domain.workers.dev
5271
- Current Deployment ID: undefined"
5258
+ Current Deployment ID: Galaxy-Class"
5272
5259
  `);
5273
5260
  expect(std.err).toMatchInlineSnapshot(`""`);
5274
5261
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5306,7 +5293,7 @@ addEventListener('fetch', event => {});`
5306
5293
  Uploaded test-name (TIMINGS)
5307
5294
  Published test-name (TIMINGS)
5308
5295
  https://test-name.test-sub-domain.workers.dev
5309
- Current Deployment ID: undefined"
5296
+ Current Deployment ID: Galaxy-Class"
5310
5297
  `);
5311
5298
  expect(std.err).toMatchInlineSnapshot(`""`);
5312
5299
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5381,7 +5368,7 @@ addEventListener('fetch', event => {});`
5381
5368
  Uploaded test-name (TIMINGS)
5382
5369
  Published test-name (TIMINGS)
5383
5370
  https://test-name.test-sub-domain.workers.dev
5384
- Current Deployment ID: undefined"
5371
+ Current Deployment ID: Galaxy-Class"
5385
5372
  `);
5386
5373
  expect(std.err).toMatchInlineSnapshot(`""`);
5387
5374
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5419,7 +5406,7 @@ addEventListener('fetch', event => {});`
5419
5406
  Uploaded test-name (TIMINGS)
5420
5407
  Published test-name (TIMINGS)
5421
5408
  https://test-name.test-sub-domain.workers.dev
5422
- Current Deployment ID: undefined"
5409
+ Current Deployment ID: Galaxy-Class"
5423
5410
  `);
5424
5411
  expect(std.err).toMatchInlineSnapshot(`""`);
5425
5412
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5494,7 +5481,7 @@ addEventListener('fetch', event => {});`
5494
5481
  Uploaded test-name (TIMINGS)
5495
5482
  Published test-name (TIMINGS)
5496
5483
  https://test-name.test-sub-domain.workers.dev
5497
- Current Deployment ID: undefined"
5484
+ Current Deployment ID: Galaxy-Class"
5498
5485
  `);
5499
5486
  expect(std.err).toMatchInlineSnapshot(`""`);
5500
5487
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5538,7 +5525,7 @@ addEventListener('fetch', event => {});`
5538
5525
  Uploaded test-name (TIMINGS)
5539
5526
  Published test-name (TIMINGS)
5540
5527
  https://test-name.test-sub-domain.workers.dev
5541
- Current Deployment ID: undefined"
5528
+ Current Deployment ID: Galaxy-Class"
5542
5529
  `);
5543
5530
  expect(std.err).toMatchInlineSnapshot(`""`);
5544
5531
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5562,7 +5549,7 @@ addEventListener('fetch', event => {});`
5562
5549
  Uploaded test-name (TIMINGS)
5563
5550
  Published test-name (TIMINGS)
5564
5551
  https://test-name.test-sub-domain.workers.dev
5565
- Current Deployment ID: undefined",
5552
+ Current Deployment ID: Galaxy-Class",
5566
5553
  "warn": "",
5567
5554
  }
5568
5555
  `);
@@ -5591,7 +5578,7 @@ addEventListener('fetch', event => {});`
5591
5578
  Uploaded test-name (TIMINGS)
5592
5579
  Published test-name (TIMINGS)
5593
5580
  https://test-name.test-sub-domain.workers.dev
5594
- Current Deployment ID: undefined"
5581
+ Current Deployment ID: Galaxy-Class"
5595
5582
  `);
5596
5583
  expect(std.err).toMatchInlineSnapshot(`""`);
5597
5584
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5644,7 +5631,7 @@ addEventListener('fetch', event => {});`
5644
5631
  Uploaded test-name (TIMINGS)
5645
5632
  Published test-name (TIMINGS)
5646
5633
  https://test-name.test-sub-domain.workers.dev
5647
- Current Deployment ID: undefined"
5634
+ Current Deployment ID: Galaxy-Class"
5648
5635
  `);
5649
5636
  expect(std.err).toMatchInlineSnapshot(`""`);
5650
5637
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5691,7 +5678,7 @@ addEventListener('fetch', event => {});`
5691
5678
  Uploaded test-name (TIMINGS)
5692
5679
  Published test-name (TIMINGS)
5693
5680
  https://test-name.test-sub-domain.workers.dev
5694
- Current Deployment ID: undefined"
5681
+ Current Deployment ID: Galaxy-Class"
5695
5682
  `);
5696
5683
  expect(std.err).toMatchInlineSnapshot(`""`);
5697
5684
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5732,7 +5719,7 @@ addEventListener('fetch', event => {});`
5732
5719
  Uploaded test-name (TIMINGS)
5733
5720
  Published test-name (TIMINGS)
5734
5721
  https://test-name.test-sub-domain.workers.dev
5735
- Current Deployment ID: undefined"
5722
+ Current Deployment ID: Galaxy-Class"
5736
5723
  `);
5737
5724
  expect(std.err).toMatchInlineSnapshot(`""`);
5738
5725
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5778,7 +5765,7 @@ addEventListener('fetch', event => {});`
5778
5765
  Uploaded test-name (TIMINGS)
5779
5766
  Published test-name (TIMINGS)
5780
5767
  https://test-name.test-sub-domain.workers.dev
5781
- Current Deployment ID: undefined"
5768
+ Current Deployment ID: Galaxy-Class"
5782
5769
  `);
5783
5770
  expect(std.err).toMatchInlineSnapshot(`""`);
5784
5771
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5842,7 +5829,7 @@ addEventListener('fetch', event => {});`
5842
5829
  Uploaded test-name (TIMINGS)
5843
5830
  Published test-name (TIMINGS)
5844
5831
  https://test-name.test-sub-domain.workers.dev
5845
- Current Deployment ID: undefined"
5832
+ Current Deployment ID: Galaxy-Class"
5846
5833
  `);
5847
5834
  expect(std.err).toMatchInlineSnapshot(`""`);
5848
5835
  expect(std.warn).toMatchInlineSnapshot(`
@@ -5879,7 +5866,7 @@ addEventListener('fetch', event => {});`
5879
5866
  Uploaded test-name (TIMINGS)
5880
5867
  Published test-name (TIMINGS)
5881
5868
  https://test-name.test-sub-domain.workers.dev
5882
- Current Deployment ID: undefined"
5869
+ Current Deployment ID: Galaxy-Class"
5883
5870
  `);
5884
5871
  expect(std.err).toMatchInlineSnapshot(`""`);
5885
5872
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5916,7 +5903,7 @@ addEventListener('fetch', event => {});`
5916
5903
  Uploaded test-name (TIMINGS)
5917
5904
  Published test-name (TIMINGS)
5918
5905
  https://test-name.test-sub-domain.workers.dev
5919
- Current Deployment ID: undefined"
5906
+ Current Deployment ID: Galaxy-Class"
5920
5907
  `);
5921
5908
  expect(std.err).toMatchInlineSnapshot(`""`);
5922
5909
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -5957,7 +5944,7 @@ addEventListener('fetch', event => {});`
5957
5944
  Uploaded test-name (TIMINGS)
5958
5945
  Published test-name (TIMINGS)
5959
5946
  https://test-name.test-sub-domain.workers.dev
5960
- Current Deployment ID: undefined"
5947
+ Current Deployment ID: Galaxy-Class"
5961
5948
  `);
5962
5949
  expect(std.err).toMatchInlineSnapshot(`""`);
5963
5950
  expect(std.warn).toMatchInlineSnapshot(`
@@ -6001,7 +5988,7 @@ addEventListener('fetch', event => {});`
6001
5988
  Uploaded test-name (TIMINGS)
6002
5989
  Published test-name (TIMINGS)
6003
5990
  https://test-name.test-sub-domain.workers.dev
6004
- Current Deployment ID: undefined"
5991
+ Current Deployment ID: Galaxy-Class"
6005
5992
  `);
6006
5993
  expect(std.err).toMatchInlineSnapshot(`""`);
6007
5994
  expect(std.warn).toMatchInlineSnapshot(`
@@ -6048,7 +6035,7 @@ addEventListener('fetch', event => {});`
6048
6035
  Uploaded test-name (TIMINGS)
6049
6036
  Published test-name (TIMINGS)
6050
6037
  https://test-name.test-sub-domain.workers.dev
6051
- Current Deployment ID: undefined"
6038
+ Current Deployment ID: Galaxy-Class"
6052
6039
  `);
6053
6040
  expect(std.err).toMatchInlineSnapshot(`""`);
6054
6041
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -6078,7 +6065,7 @@ addEventListener('fetch', event => {});`
6078
6065
  Uploaded test-name (TIMINGS)
6079
6066
  Published test-name (TIMINGS)
6080
6067
  https://test-name.test-sub-domain.workers.dev
6081
- Current Deployment ID: undefined"
6068
+ Current Deployment ID: Galaxy-Class"
6082
6069
  `);
6083
6070
  expect(std.err).toMatchInlineSnapshot(`""`);
6084
6071
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -6112,7 +6099,7 @@ addEventListener('fetch', event => {});`
6112
6099
  Uploaded test-name (TIMINGS)
6113
6100
  Published test-name (TIMINGS)
6114
6101
  https://test-name.test-sub-domain.workers.dev
6115
- Current Deployment ID: undefined"
6102
+ Current Deployment ID: Galaxy-Class"
6116
6103
  `);
6117
6104
  expect(std.err).toMatchInlineSnapshot(`""`);
6118
6105
  expect(std.warn).toMatchInlineSnapshot(`
@@ -6162,7 +6149,7 @@ addEventListener('fetch', event => {});`
6162
6149
  Uploaded test-name (TIMINGS)
6163
6150
  Published test-name (TIMINGS)
6164
6151
  https://test-name.test-sub-domain.workers.dev
6165
- Current Deployment ID: undefined"
6152
+ Current Deployment ID: Galaxy-Class"
6166
6153
  `);
6167
6154
  expect(std.err).toMatchInlineSnapshot(`""`);
6168
6155
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -6260,7 +6247,7 @@ addEventListener('fetch', event => {});`
6260
6247
  Uploaded test-name (TIMINGS)
6261
6248
  Published test-name (TIMINGS)
6262
6249
  https://test-name.test-sub-domain.workers.dev
6263
- Current Deployment ID: undefined"
6250
+ Current Deployment ID: Galaxy-Class"
6264
6251
  `);
6265
6252
  expect(std.err).toMatchInlineSnapshot(`""`);
6266
6253
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -6291,7 +6278,7 @@ addEventListener('fetch', event => {});`
6291
6278
  Uploaded test-name (TIMINGS)
6292
6279
  Published test-name (TIMINGS)
6293
6280
  https://test-name.test-sub-domain.workers.dev
6294
- Current Deployment ID: undefined"
6281
+ Current Deployment ID: Galaxy-Class"
6295
6282
  `);
6296
6283
  expect(std.err).toMatchInlineSnapshot(`""`);
6297
6284
  expect(std.warn).toMatchInlineSnapshot(`
@@ -6321,7 +6308,7 @@ addEventListener('fetch', event => {});`
6321
6308
  Uploaded test-name (TIMINGS)
6322
6309
  Published test-name (TIMINGS)
6323
6310
  https://test-name.test-sub-domain.workers.dev
6324
- Current Deployment ID: undefined"
6311
+ Current Deployment ID: Galaxy-Class"
6325
6312
  `);
6326
6313
  expect(std.err).toMatchInlineSnapshot(`""`);
6327
6314
  expect(std.warn).toMatchInlineSnapshot(`
@@ -6353,7 +6340,7 @@ addEventListener('fetch', event => {});`
6353
6340
  Uploaded test-name (TIMINGS)
6354
6341
  Published test-name (TIMINGS)
6355
6342
  https://test-name.test-sub-domain.workers.dev
6356
- Current Deployment ID: undefined"
6343
+ Current Deployment ID: Galaxy-Class"
6357
6344
  `);
6358
6345
  expect(std.err).toMatchInlineSnapshot(`""`);
6359
6346
  expect(std.warn).toMatchInlineSnapshot(`
@@ -6383,7 +6370,7 @@ addEventListener('fetch', event => {});`
6383
6370
  Uploaded test-name (TIMINGS)
6384
6371
  Published test-name (TIMINGS)
6385
6372
  https://test-name.test-sub-domain.workers.dev
6386
- Current Deployment ID: undefined"
6373
+ Current Deployment ID: Galaxy-Class"
6387
6374
  `);
6388
6375
  expect(std.err).toMatchInlineSnapshot(`""`);
6389
6376
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -6425,7 +6412,7 @@ addEventListener('fetch', event => {});`
6425
6412
  Uploaded test-name (TIMINGS)
6426
6413
  Published test-name (TIMINGS)
6427
6414
  https://test-name.test-sub-domain.workers.dev
6428
- Current Deployment ID: undefined",
6415
+ Current Deployment ID: Galaxy-Class",
6429
6416
  "warn": "",
6430
6417
  }
6431
6418
  `);
@@ -6456,7 +6443,7 @@ addEventListener('fetch', event => {});`
6456
6443
  Uploaded test-name (TIMINGS)
6457
6444
  Published test-name (TIMINGS)
6458
6445
  https://test-name.test-sub-domain.workers.dev
6459
- Current Deployment ID: undefined",
6446
+ Current Deployment ID: Galaxy-Class",
6460
6447
  "warn": "",
6461
6448
  }
6462
6449
  `);
@@ -6480,7 +6467,7 @@ addEventListener('fetch', event => {});`
6480
6467
  Uploaded test-name (TIMINGS)
6481
6468
  Published test-name (TIMINGS)
6482
6469
  https://test-name.test-sub-domain.workers.dev
6483
- Current Deployment ID: undefined",
6470
+ Current Deployment ID: Galaxy-Class",
6484
6471
  "warn": "",
6485
6472
  }
6486
6473
  `);
@@ -6617,6 +6604,7 @@ addEventListener('fetch', event => {});`
6617
6604
  mockSubDomainRequest();
6618
6605
  mockUploadWorkerRequest();
6619
6606
  await runWrangler("publish");
6607
+
6620
6608
  expect(std).toMatchInlineSnapshot(`
6621
6609
  Object {
6622
6610
  "debug": "",
@@ -6625,26 +6613,35 @@ addEventListener('fetch', event => {});`
6625
6613
  Uploaded test-name (TIMINGS)
6626
6614
  Published test-name (TIMINGS)
6627
6615
  https://test-name.test-sub-domain.workers.dev
6628
- Current Deployment ID: undefined",
6616
+ Current Deployment ID: Galaxy-Class",
6629
6617
  "warn": "",
6630
6618
  }
6631
6619
  `);
6632
6620
  });
6633
6621
 
6634
6622
  it("should print the bundle size, with API errors", async () => {
6635
- setMockRawResponse(
6636
- "/accounts/:accountId/workers/scripts/:scriptName",
6637
- "PUT",
6638
- () => {
6639
- return createFetchResult({}, false, [
6640
- {
6641
- code: 11337,
6642
- message:
6643
- "Script startup timed out. This could be due to script exceeding size limits or expensive code in the global scope.",
6644
- },
6645
- ]);
6646
- }
6623
+ mockSubDomainRequest();
6624
+ mockUploadWorkerRequest();
6625
+ // Override PUT call to error out from previous helper functions
6626
+ msw.use(
6627
+ rest.put(
6628
+ "*/accounts/:accountId/workers/scripts/:scriptName",
6629
+ (_, res, ctx) => {
6630
+ return res(
6631
+ ctx.json(
6632
+ createFetchResult(null, false, [
6633
+ {
6634
+ code: 11337,
6635
+ message:
6636
+ "Script startup timed out. This could be due to script exceeding size limits or expensive code in the global scope.",
6637
+ },
6638
+ ])
6639
+ )
6640
+ );
6641
+ }
6642
+ )
6647
6643
  );
6644
+
6648
6645
  fs.writeFileSync(
6649
6646
  "./hello.html",
6650
6647
  `<!DOCTYPE html>
@@ -6665,11 +6662,11 @@ addEventListener('fetch', event => {});`
6665
6662
  },
6666
6663
  };`
6667
6664
  );
6665
+
6668
6666
  writeWranglerToml({
6669
6667
  main: "index.js",
6670
6668
  });
6671
- mockSubDomainRequest();
6672
- mockUploadWorkerRequest();
6669
+
6673
6670
  await expect(runWrangler("publish")).rejects.toMatchInlineSnapshot(
6674
6671
  `[ParseError: A request to the Cloudflare API (/accounts/some-account-id/workers/scripts/test-name) failed.]`
6675
6672
  );
@@ -6694,6 +6691,27 @@ addEventListener('fetch', event => {});`
6694
6691
  });
6695
6692
 
6696
6693
  test("should check biggest dependencies when upload fails with script size error", async () => {
6694
+ mockSubDomainRequest();
6695
+ mockUploadWorkerRequest();
6696
+ // Override PUT call to error out from previous helper functions
6697
+ msw.use(
6698
+ rest.put(
6699
+ "*/accounts/:accountId/workers/scripts/:scriptName",
6700
+ (req, res, ctx) => {
6701
+ return res(
6702
+ ctx.json(
6703
+ createFetchResult({}, false, [
6704
+ {
6705
+ code: 10027,
6706
+ message: "workers.api.error.script_too_large",
6707
+ },
6708
+ ])
6709
+ )
6710
+ );
6711
+ }
6712
+ )
6713
+ );
6714
+
6697
6715
  fs.writeFileSync("dependency.js", `export const thing = "a string dep";`);
6698
6716
 
6699
6717
  fs.writeFileSync(
@@ -6706,23 +6724,15 @@ addEventListener('fetch', event => {});`
6706
6724
  }
6707
6725
  }`
6708
6726
  );
6709
- setMockRawResponse(
6710
- "/accounts/:accountId/workers/scripts/:scriptName",
6711
- "PUT",
6712
- () => {
6713
- return createFetchResult({}, false, [
6714
- { code: 10027, message: "workers.api.error.script_too_large" },
6715
- ]);
6716
- }
6717
- );
6727
+
6718
6728
  writeWranglerToml({
6719
6729
  main: "index.js",
6720
6730
  });
6721
- mockSubDomainRequest();
6722
- mockUploadWorkerRequest();
6731
+
6723
6732
  await expect(runWrangler("publish")).rejects.toMatchInlineSnapshot(
6724
6733
  `[ParseError: A request to the Cloudflare API (/accounts/some-account-id/workers/scripts/test-name) failed.]`
6725
6734
  );
6735
+
6726
6736
  expect(std).toMatchInlineSnapshot(`
6727
6737
  Object {
6728
6738
  "debug": "",
@@ -6748,7 +6758,27 @@ addEventListener('fetch', event => {});`
6748
6758
  `);
6749
6759
  });
6750
6760
 
6751
- test("should check biggest dependencies when upload fails with script startup error", async () => {
6761
+ test("should offer some helpful advice when upload fails with script startup error", async () => {
6762
+ mockSubDomainRequest();
6763
+ mockUploadWorkerRequest();
6764
+ // Override PUT call to error out from previous helper functions
6765
+ msw.use(
6766
+ rest.put(
6767
+ "*/accounts/:accountId/workers/scripts/:scriptName",
6768
+ (req, res, ctx) => {
6769
+ return res(
6770
+ ctx.json(
6771
+ createFetchResult({}, false, [
6772
+ {
6773
+ code: 10021,
6774
+ message: "Error: Script startup exceeded CPU time limit.",
6775
+ },
6776
+ ])
6777
+ )
6778
+ );
6779
+ }
6780
+ )
6781
+ );
6752
6782
  fs.writeFileSync("dependency.js", `export const thing = "a string dep";`);
6753
6783
 
6754
6784
  fs.writeFileSync(
@@ -6761,23 +6791,11 @@ addEventListener('fetch', event => {});`
6761
6791
  }
6762
6792
  }`
6763
6793
  );
6764
- setMockRawResponse(
6765
- "/accounts/:accountId/workers/scripts/:scriptName",
6766
- "PUT",
6767
- () => {
6768
- return createFetchResult({}, false, [
6769
- {
6770
- code: 10021,
6771
- message: "Error: Script startup exceeded CPU time limit.",
6772
- },
6773
- ]);
6774
- }
6775
- );
6794
+
6776
6795
  writeWranglerToml({
6777
6796
  main: "index.js",
6778
6797
  });
6779
- mockSubDomainRequest();
6780
- mockUploadWorkerRequest();
6798
+
6781
6799
  await expect(runWrangler("publish")).rejects.toMatchInlineSnapshot(
6782
6800
  `[ParseError: A request to the Cloudflare API (/accounts/some-account-id/workers/scripts/test-name) failed.]`
6783
6801
  );
@@ -6795,11 +6813,13 @@ addEventListener('fetch', event => {});`
6795
6813
  https://github.com/cloudflare/wrangler2/issues/new/choose
6796
6814
 
6797
6815
  ",
6798
- "warn": "▲ [WARNING] Here are the 2 largest dependencies included in your script:
6816
+ "warn": "▲ [WARNING] Your Worker failed validation because it exceeded startup limits.
6799
6817
 
6800
- - index.js - xx KiB
6801
- - dependency.js - xx KiB
6802
- If these are unnecessary, consider removing them
6818
+ To ensure fast responses, we place constraints on Worker startup -- like how much CPU it can use,
6819
+ or how long it can take.
6820
+ Your Worker failed validation, which means it hit one of these startup limits.
6821
+ Try reducing the amount of work done during startup (outside the event handler), either by
6822
+ removing code or relocating it inside the event handler.
6803
6823
 
6804
6824
  ",
6805
6825
  }
@@ -6991,25 +7011,35 @@ addEventListener('fetch', event => {});`
6991
7011
  });
6992
7012
 
6993
7013
  it("should publish if the last deployed source check fails", async () => {
6994
- unsetAllMocks();
6995
7014
  writeWorkerSource();
6996
7015
  writeWranglerToml();
6997
7016
  mockSubDomainRequest();
6998
7017
  mockUploadWorkerRequest();
6999
- setMockResponse(
7000
- "/accounts/:accountId/workers/deployments/by-script/:scriptTag",
7001
- () => ({
7002
- latest: { number: "2" },
7003
- })
7004
- );
7005
- setMockRawResponse(
7006
- "/accounts/:accountId/workers/services/:scriptName",
7007
- "GET",
7008
- () => {
7009
- return createFetchResult(null, false, [
7010
- { code: 10090, message: "workers.api.error.service_not_found" },
7011
- ]);
7012
- }
7018
+ msw.use(
7019
+ rest.get(
7020
+ "*/accounts/:accountId/workers/deployments/by-script/:scriptTag",
7021
+ (_, res, ctx) => {
7022
+ return res(
7023
+ ctx.json(
7024
+ createFetchResult({
7025
+ latest: { number: "2" },
7026
+ })
7027
+ )
7028
+ );
7029
+ }
7030
+ ),
7031
+ rest.get(
7032
+ "*/accounts/:accountId/workers/services/:scriptName",
7033
+ (_, res, ctx) => {
7034
+ return res(
7035
+ ctx.json(
7036
+ createFetchResult(null, false, [
7037
+ { code: 10090, message: "workers.api.error.service_not_found" },
7038
+ ])
7039
+ )
7040
+ );
7041
+ }
7042
+ )
7013
7043
  );
7014
7044
 
7015
7045
  await runWrangler("publish index.js");
@@ -7028,25 +7058,36 @@ addEventListener('fetch', event => {});`
7028
7058
  });
7029
7059
 
7030
7060
  it("should not publish if there's any other kind of error when checking deployment source", async () => {
7031
- unsetAllMocks();
7032
7061
  writeWorkerSource();
7033
7062
  writeWranglerToml();
7034
7063
  mockSubDomainRequest();
7035
7064
  mockUploadWorkerRequest();
7036
- setMockRawResponse(
7037
- "/accounts/:accountId/workers/services/:scriptName",
7038
- "GET",
7039
- () => {
7040
- return createFetchResult(null, false, [
7041
- { code: 10000, message: "Authentication error" },
7042
- ]);
7043
- }
7044
- );
7045
- setMockResponse(
7046
- "/accounts/:accountId/workers/deployments/by-script/:scriptTag",
7047
- () => ({
7048
- latest: { number: "2" },
7049
- })
7065
+
7066
+ msw.use(
7067
+ rest.get(
7068
+ "*/accounts/:accountId/workers/services/:scriptName",
7069
+ (_, res, ctx) => {
7070
+ return res(
7071
+ ctx.json(
7072
+ createFetchResult(null, false, [
7073
+ { code: 10000, message: "Authentication error" },
7074
+ ])
7075
+ )
7076
+ );
7077
+ }
7078
+ ),
7079
+ rest.get(
7080
+ "*/accounts/:accountId/workers/deployments/by-script/:scriptTag",
7081
+ (_, res, ctx) => {
7082
+ return res(
7083
+ ctx.json(
7084
+ createFetchResult({
7085
+ latest: { number: "2" },
7086
+ })
7087
+ )
7088
+ );
7089
+ }
7090
+ )
7050
7091
  );
7051
7092
 
7052
7093
  await runWrangler("publish index.js");
@@ -7084,7 +7125,7 @@ addEventListener('fetch', event => {});`
7084
7125
  Uploaded test-name (TIMINGS)
7085
7126
  Published test-name (TIMINGS)
7086
7127
  https://test-name.test-sub-domain.workers.dev
7087
- Current Deployment ID: undefined"
7128
+ Current Deployment ID: Galaxy-Class"
7088
7129
  `);
7089
7130
  });
7090
7131
 
@@ -7121,7 +7162,7 @@ addEventListener('fetch', event => {});`
7121
7162
  Published test-name (TIMINGS)
7122
7163
  https://test-name.test-sub-domain.workers.dev
7123
7164
  Consumer for queue1
7124
- Current Deployment ID: undefined"
7165
+ Current Deployment ID: Galaxy-Class"
7125
7166
  `);
7126
7167
  });
7127
7168
 
@@ -7193,7 +7234,7 @@ addEventListener('fetch', event => {});`
7193
7234
  Uploaded test-name (TIMINGS)
7194
7235
  Published test-name (TIMINGS)
7195
7236
  https://test-name.test-sub-domain.workers.dev
7196
- Current Deployment ID: undefined"
7237
+ Current Deployment ID: Galaxy-Class"
7197
7238
  `);
7198
7239
  expect(std.err).toMatchInlineSnapshot(`""`);
7199
7240
  });
@@ -7218,7 +7259,7 @@ addEventListener('fetch', event => {});`
7218
7259
  Uploaded test-name (TIMINGS)
7219
7260
  Published test-name (TIMINGS)
7220
7261
  https://test-name.test-sub-domain.workers.dev
7221
- Current Deployment ID: undefined"
7262
+ Current Deployment ID: Galaxy-Class"
7222
7263
  `);
7223
7264
  expect(std.err).toMatchInlineSnapshot(`""`);
7224
7265
  });
@@ -7238,6 +7279,13 @@ function writeAssets(
7238
7279
  fs.writeFileSync(filePathDestination, asset.content);
7239
7280
  }
7240
7281
  }
7282
+ function mockDeploymentsListRequest() {
7283
+ msw.use(...mswSuccessDeployments);
7284
+ }
7285
+
7286
+ function mockLastDeploymentRequest() {
7287
+ msw.use(...mswSuccessLastDeployment);
7288
+ }
7241
7289
 
7242
7290
  /** Create a mock handler for the request to upload a worker script. */
7243
7291
  function mockUploadWorkerRequest(
@@ -7273,73 +7321,90 @@ function mockUploadWorkerRequest(
7273
7321
  sendScriptIds,
7274
7322
  keepVars,
7275
7323
  } = options;
7276
- setMockResponse(
7277
- env && !legacyEnv
7278
- ? "/accounts/:accountId/workers/services/:scriptName/environments/:envName"
7279
- : "/accounts/:accountId/workers/scripts/:scriptName",
7280
- "PUT",
7281
- async ([_url, accountId, scriptName, envName], { body }, queryParams) => {
7282
- expect(accountId).toEqual("some-account-id");
7283
- expect(scriptName).toEqual(
7284
- legacyEnv && env ? `test-name-${env}` : "test-name"
7285
- );
7286
- if (!legacyEnv) {
7287
- expect(envName).toEqual(env);
7288
- }
7289
- expect(queryParams.get("include_subdomain_availability")).toEqual("true");
7290
- expect(queryParams.get("excludeScript")).toEqual("true");
7291
- const formBody = body as FormData;
7292
- if (expectedEntry !== undefined) {
7293
- expect(await (formBody.get("index.js") as File).text()).toMatch(
7294
- expectedEntry
7295
- );
7296
- }
7297
- const metadata = JSON.parse(
7298
- formBody.get("metadata") as string
7299
- ) as WorkerMetadata;
7300
- if (expectedType === "esm") {
7301
- expect(metadata.main_module).toEqual(expectedMainModule);
7302
- } else {
7303
- expect(metadata.body_part).toEqual("index.js");
7304
- }
7324
+ if (env && !legacyEnv) {
7325
+ msw.use(
7326
+ rest.put(
7327
+ "*/accounts/:accountId/workers/services/:scriptName/environments/:envName",
7328
+ handleUpload
7329
+ )
7330
+ );
7331
+ } else {
7332
+ msw.use(
7333
+ rest.put(
7334
+ "*/accounts/:accountId/workers/scripts/:scriptName",
7335
+ handleUpload
7336
+ )
7337
+ );
7338
+ }
7305
7339
 
7306
- if (keepVars) {
7307
- expect(metadata.keep_bindings).toEqual(["plain_text", "json"]);
7308
- } else {
7309
- expect(metadata.keep_bindings).toBeFalsy();
7310
- }
7340
+ async function handleUpload(
7341
+ req: RestRequest,
7342
+ res: ResponseComposition,
7343
+ ctx: RestContext
7344
+ ) {
7345
+ expect(req.params.accountId).toEqual("some-account-id");
7346
+ expect(req.params.scriptName).toEqual(
7347
+ legacyEnv && env ? `test-name-${env}` : "test-name"
7348
+ );
7349
+ if (!legacyEnv) {
7350
+ expect(req.params.envName).toEqual(env);
7351
+ }
7352
+ expect(req.url.searchParams.get("include_subdomain_availability")).toEqual(
7353
+ "true"
7354
+ );
7355
+ expect(req.url.searchParams.get("excludeScript")).toEqual("true");
7311
7356
 
7312
- if ("expectedBindings" in options) {
7313
- expect(metadata.bindings).toEqual(expectedBindings);
7314
- }
7315
- if ("expectedCompatibilityDate" in options) {
7316
- expect(metadata.compatibility_date).toEqual(expectedCompatibilityDate);
7317
- }
7318
- if ("expectedCompatibilityFlags" in options) {
7319
- expect(metadata.compatibility_flags).toEqual(
7320
- expectedCompatibilityFlags
7321
- );
7322
- }
7323
- if ("expectedMigrations" in options) {
7324
- expect(metadata.migrations).toEqual(expectedMigrations);
7325
- }
7326
- for (const [name, content] of Object.entries(expectedModules)) {
7327
- expect(await (formBody.get(name) as File).text()).toEqual(content);
7328
- }
7357
+ const formBody = await (
7358
+ req as MockedRequest as RestRequestWithFormData
7359
+ ).formData();
7360
+ if (expectedEntry !== undefined) {
7361
+ expect(formBody.get("index.js")).toMatch(expectedEntry);
7362
+ }
7363
+ const metadata = JSON.parse(
7364
+ formBody.get("metadata") as string
7365
+ ) as WorkerMetadata;
7366
+ if (expectedType === "esm") {
7367
+ expect(metadata.main_module).toEqual(expectedMainModule);
7368
+ } else {
7369
+ expect(metadata.body_part).toEqual("index.js");
7370
+ }
7329
7371
 
7330
- return {
7331
- available_on_subdomain,
7332
- ...(sendScriptIds
7333
- ? {
7334
- id: "abc12345",
7335
- etag: "etag98765",
7336
- pipeline_hash: "hash9999",
7337
- tag: "sample-tag",
7338
- }
7339
- : {}),
7340
- };
7372
+ if (keepVars) {
7373
+ expect(metadata.keep_bindings).toEqual(["plain_text", "json"]);
7374
+ } else {
7375
+ expect(metadata.keep_bindings).toBeFalsy();
7341
7376
  }
7342
- );
7377
+
7378
+ if ("expectedBindings" in options) {
7379
+ expect(metadata.bindings).toEqual(expectedBindings);
7380
+ }
7381
+ if ("expectedCompatibilityDate" in options) {
7382
+ expect(metadata.compatibility_date).toEqual(expectedCompatibilityDate);
7383
+ }
7384
+ if ("expectedCompatibilityFlags" in options) {
7385
+ expect(metadata.compatibility_flags).toEqual(expectedCompatibilityFlags);
7386
+ }
7387
+ if ("expectedMigrations" in options) {
7388
+ expect(metadata.migrations).toEqual(expectedMigrations);
7389
+ }
7390
+ for (const [name, content] of Object.entries(expectedModules)) {
7391
+ expect(formBody.get(name)).toEqual(content);
7392
+ }
7393
+
7394
+ return res(
7395
+ ctx.json(
7396
+ createFetchResult({
7397
+ available_on_subdomain,
7398
+ ...(sendScriptIds && {
7399
+ id: "abc12345",
7400
+ etag: "etag98765",
7401
+ pipeline_hash: "hash9999",
7402
+ tag: "sample-tag",
7403
+ }),
7404
+ })
7405
+ )
7406
+ );
7407
+ }
7343
7408
  }
7344
7409
 
7345
7410
  /** Create a mock handler for the request to get the account's subdomain. */
@@ -7348,18 +7413,30 @@ function mockSubDomainRequest(
7348
7413
  registeredWorkersDev = true
7349
7414
  ) {
7350
7415
  if (registeredWorkersDev) {
7351
- setMockResponse("/accounts/:accountId/workers/subdomain", "GET", () => {
7352
- return { subdomain };
7353
- });
7416
+ msw.use(
7417
+ rest.get("*/accounts/:accountId/workers/subdomain", (req, res, ctx) => {
7418
+ return res.once(ctx.json(createFetchResult({ subdomain })));
7419
+ })
7420
+ );
7354
7421
  } else {
7355
- setMockRawResponse("/accounts/:accountId/workers/subdomain", "GET", () => {
7356
- return createFetchResult(null, false, [
7357
- { code: 10007, message: "haven't registered workers.dev" },
7358
- ]);
7359
- });
7422
+ msw.use(
7423
+ rest.get("*/accounts/:accountId/workers/subdomain", (req, res, ctx) => {
7424
+ return res.once(
7425
+ ctx.json(
7426
+ createFetchResult(null, false, [
7427
+ { code: 10007, message: "haven't registered workers.dev" },
7428
+ ])
7429
+ )
7430
+ );
7431
+ })
7432
+ );
7360
7433
  }
7361
7434
  }
7362
-
7435
+ //
7436
+ //
7437
+ //
7438
+ //
7439
+ //
7363
7440
  /** Create a mock handler to toggle a <script>.<user>.workers.dev subdomain */
7364
7441
  function mockUpdateWorkerRequest({
7365
7442
  env,
@@ -7373,20 +7450,22 @@ function mockUpdateWorkerRequest({
7373
7450
  const requests = { count: 0 };
7374
7451
  const servicesOrScripts = env && !legacyEnv ? "services" : "scripts";
7375
7452
  const environment = env && !legacyEnv ? "/environments/:envName" : "";
7376
- setMockResponse(
7377
- `/accounts/:accountId/workers/${servicesOrScripts}/:scriptName${environment}/subdomain`,
7378
- "POST",
7379
- ([_url, accountId, scriptName, envName], { body }) => {
7380
- expect(accountId).toEqual("some-account-id");
7381
- expect(scriptName).toEqual(
7382
- legacyEnv && env ? `test-name-${env}` : "test-name"
7383
- );
7384
- if (!legacyEnv) {
7385
- expect(envName).toEqual(env);
7453
+ msw.use(
7454
+ rest.post(
7455
+ `*/accounts/:accountId/workers/${servicesOrScripts}/:scriptName${environment}/subdomain`,
7456
+ async (req, res, ctx) => {
7457
+ expect(req.params.accountId).toEqual("some-account-id");
7458
+ expect(req.params.scriptName).toEqual(
7459
+ legacyEnv && env ? `test-name-${env}` : "test-name"
7460
+ );
7461
+ if (!legacyEnv) {
7462
+ expect(req.params.envName).toEqual(env);
7463
+ }
7464
+ const body = await req.json();
7465
+ expect(body).toEqual({ enabled });
7466
+ return res.once(ctx.json(createFetchResult(null)));
7386
7467
  }
7387
- expect(JSON.parse(body as string)).toEqual({ enabled });
7388
- return null;
7389
- }
7468
+ )
7390
7469
  );
7391
7470
  return requests;
7392
7471
  }
@@ -7403,25 +7482,26 @@ function mockPublishRoutesRequest({
7403
7482
  const servicesOrScripts = env && !legacyEnv ? "services" : "scripts";
7404
7483
  const environment = env && !legacyEnv ? "/environments/:envName" : "";
7405
7484
 
7406
- setMockResponse(
7407
- `/accounts/:accountId/workers/${servicesOrScripts}/:scriptName${environment}/routes`,
7408
- "PUT",
7409
- ([_url, accountId, scriptName, envName], { body }) => {
7410
- expect(accountId).toEqual("some-account-id");
7411
- expect(scriptName).toEqual(
7412
- legacyEnv && env ? `test-name-${env}` : "test-name"
7413
- );
7414
- if (!legacyEnv) {
7415
- expect(envName).toEqual(env);
7485
+ msw.use(
7486
+ rest.put(
7487
+ `*/accounts/:accountId/workers/${servicesOrScripts}/:scriptName${environment}/routes`,
7488
+ async (req, res, ctx) => {
7489
+ expect(req.params.accountId).toEqual("some-account-id");
7490
+ expect(req.params.scriptName).toEqual(
7491
+ legacyEnv && env ? `test-name-${env}` : "test-name"
7492
+ );
7493
+ if (!legacyEnv) {
7494
+ expect(req.params.envName).toEqual(env);
7495
+ }
7496
+ const body = await req.json();
7497
+ expect(body).toEqual(
7498
+ routes.map((route) =>
7499
+ typeof route !== "object" ? { pattern: route } : route
7500
+ )
7501
+ );
7502
+ return res.once(ctx.json(createFetchResult(null)));
7416
7503
  }
7417
-
7418
- expect(JSON.parse(body as string)).toEqual(
7419
- routes.map((route) =>
7420
- typeof route !== "object" ? { pattern: route } : route
7421
- )
7422
- );
7423
- return null;
7424
- }
7504
+ )
7425
7505
  );
7426
7506
  }
7427
7507
 
@@ -7435,13 +7515,19 @@ function mockUnauthorizedPublishRoutesRequest({
7435
7515
  const servicesOrScripts = env && !legacyEnv ? "services" : "scripts";
7436
7516
  const environment = env && !legacyEnv ? "/environments/:envName" : "";
7437
7517
 
7438
- setMockRawResponse(
7439
- `/accounts/:accountId/workers/${servicesOrScripts}/:scriptName${environment}/routes`,
7440
- "PUT",
7441
- () =>
7442
- createFetchResult(null, false, [
7443
- { message: "Authentication error", code: 10000 },
7444
- ])
7518
+ msw.use(
7519
+ rest.put(
7520
+ `*/accounts/:accountId/workers/${servicesOrScripts}/:scriptName${environment}/routes`,
7521
+ (req, res, ctx) => {
7522
+ return res.once(
7523
+ ctx.json(
7524
+ createFetchResult(null, false, [
7525
+ { message: "Authentication error", code: 10000 },
7526
+ ])
7527
+ )
7528
+ );
7529
+ }
7530
+ )
7445
7531
  );
7446
7532
  }
7447
7533
 
@@ -7449,22 +7535,27 @@ function mockPublishRoutesFallbackRequest(route: {
7449
7535
  pattern: string;
7450
7536
  script: string;
7451
7537
  }) {
7452
- setMockResponse(`/zones/:zoneId/workers/routes`, "POST", (_url, { body }) => {
7453
- expect(JSON.parse(body as string)).toEqual(route);
7454
- return route.pattern;
7455
- });
7538
+ msw.use(
7539
+ rest.post(`*/zones/:zoneId/workers/routes`, async (req, res, ctx) => {
7540
+ const body = await req.json();
7541
+ expect(body).toEqual(route);
7542
+ return res.once(ctx.json(createFetchResult(route.pattern)));
7543
+ })
7544
+ );
7456
7545
  }
7457
7546
 
7458
7547
  function mockCustomDomainLookup(origin: CustomDomain) {
7459
- setMockResponse(
7460
- `/accounts/:accountId/workers/domains/records/:domainTag`,
7461
- "GET",
7462
- ([_url, accountId, domainTag]) => {
7463
- expect(accountId).toEqual("some-account-id");
7464
- expect(domainTag).toEqual(origin.id);
7465
-
7466
- return origin;
7467
- }
7548
+ msw.use(
7549
+ rest.get(
7550
+ `*/accounts/:accountId/workers/domains/records/:domainTag`,
7551
+
7552
+ (req, res, ctx) => {
7553
+ expect(req.params.accountId).toEqual("some-account-id");
7554
+ expect(req.params.domainTag).toEqual(origin.id);
7555
+
7556
+ return res.once(ctx.json(createFetchResult(origin)));
7557
+ }
7558
+ )
7468
7559
  );
7469
7560
  }
7470
7561
 
@@ -7481,47 +7572,47 @@ function mockCustomDomainsChangesetRequest({
7481
7572
  }) {
7482
7573
  const servicesOrScripts = env && !legacyEnv ? "services" : "scripts";
7483
7574
  const environment = env && !legacyEnv ? "/environments/:envName" : "";
7575
+ msw.use(
7576
+ rest.post(
7577
+ `*/accounts/:accountId/workers/${servicesOrScripts}/:scriptName${environment}/domains/changeset`,
7578
+ async (req, res, ctx) => {
7579
+ expect(req.params.accountId).toEqual("some-account-id");
7580
+ expect(req.params.scriptName).toEqual(
7581
+ legacyEnv && env ? `test-name-${env}` : "test-name"
7582
+ );
7583
+ if (!legacyEnv) {
7584
+ expect(req.params.envName).toEqual(env);
7585
+ }
7484
7586
 
7485
- setMockResponse(
7486
- `/accounts/:accountId/workers/${servicesOrScripts}/:scriptName${environment}/domains/changeset`,
7487
- "POST",
7488
- ([_url, accountId, scriptName, envName], { body }) => {
7489
- expect(accountId).toEqual("some-account-id");
7490
- expect(scriptName).toEqual(
7491
- legacyEnv && env ? `test-name-${env}` : "test-name"
7492
- );
7493
- if (!legacyEnv) {
7494
- expect(envName).toEqual(env);
7495
- }
7587
+ const domains: Array<
7588
+ { hostname: string } & ({ zone_id?: string } | { zone_name?: string })
7589
+ > = await req.json();
7496
7590
 
7497
- const domains: Array<
7498
- { hostname: string } & ({ zone_id?: string } | { zone_name?: string })
7499
- > = JSON.parse(body as string);
7500
-
7501
- const changeset: CustomDomainChangeset = {
7502
- added: domains.map((domain) => {
7503
- return {
7504
- ...domain,
7505
- id: "",
7506
- service: scriptName,
7507
- environment: envName,
7508
- zone_name: "",
7509
- zone_id: "",
7510
- };
7511
- }),
7512
- removed: [],
7513
- updated:
7514
- originConflicts?.map((domain) => {
7591
+ const changeset: CustomDomainChangeset = {
7592
+ added: domains.map((domain) => {
7515
7593
  return {
7516
7594
  ...domain,
7517
- modified: true,
7595
+ id: "",
7596
+ service: req.params.scriptName as string,
7597
+ environment: req.params.envName as string,
7598
+ zone_name: "",
7599
+ zone_id: "",
7518
7600
  };
7519
- }) ?? [],
7520
- conflicting: dnsRecordConflicts,
7521
- };
7601
+ }),
7602
+ removed: [],
7603
+ updated:
7604
+ originConflicts?.map((domain) => {
7605
+ return {
7606
+ ...domain,
7607
+ modified: true,
7608
+ };
7609
+ }) ?? [],
7610
+ conflicting: dnsRecordConflicts,
7611
+ };
7522
7612
 
7523
- return changeset;
7524
- }
7613
+ return res.once(ctx.json(createFetchResult(changeset)));
7614
+ }
7615
+ )
7525
7616
  );
7526
7617
  }
7527
7618
 
@@ -7545,37 +7636,36 @@ function mockPublishCustomDomainsRequest({
7545
7636
  const servicesOrScripts = env && !legacyEnv ? "services" : "scripts";
7546
7637
  const environment = env && !legacyEnv ? "/environments/:envName" : "";
7547
7638
 
7548
- setMockResponse(
7549
- `/accounts/:accountId/workers/${servicesOrScripts}/:scriptName${environment}/domains/records`,
7550
- "PUT",
7551
- ([_url, accountId, scriptName, envName], { body }) => {
7552
- expect(accountId).toEqual("some-account-id");
7553
- expect(scriptName).toEqual(
7554
- legacyEnv && env ? `test-name-${env}` : "test-name"
7555
- );
7556
- if (!legacyEnv) {
7557
- expect(envName).toEqual(env);
7558
- }
7559
-
7560
- expect(JSON.parse(body as string)).toEqual({
7561
- ...publishFlags,
7562
- origins: domains,
7563
- });
7639
+ msw.use(
7640
+ rest.put(
7641
+ `*/accounts/:accountId/workers/${servicesOrScripts}/:scriptName${environment}/domains/records`,
7642
+ async (req, res, ctx) => {
7643
+ expect(req.params.accountId).toEqual("some-account-id");
7644
+ expect(req.params.scriptName).toEqual(
7645
+ legacyEnv && env ? `test-name-${env}` : "test-name"
7646
+ );
7647
+ if (!legacyEnv) {
7648
+ expect(req.params.envName).toEqual(env);
7649
+ }
7650
+ const body = await req.json();
7651
+ expect(body).toEqual({
7652
+ ...publishFlags,
7653
+ origins: domains,
7654
+ });
7564
7655
 
7565
- return null;
7566
- }
7656
+ return res.once(ctx.json(createFetchResult(null)));
7657
+ }
7658
+ )
7567
7659
  );
7568
7660
  }
7569
7661
 
7570
7662
  /** Create a mock handler for the request to get a list of all KV namespaces. */
7571
7663
  function mockListKVNamespacesRequest(...namespaces: KVNamespaceInfo[]) {
7572
- setMockResponse(
7573
- "/accounts/:accountId/storage/kv/namespaces",
7574
- "GET",
7575
- ([_url, accountId]) => {
7576
- expect(accountId).toEqual("some-account-id");
7577
- return namespaces;
7578
- }
7664
+ msw.use(
7665
+ rest.get("*/accounts/:accountId/storage/kv/namespaces", (req, res, ctx) => {
7666
+ expect(req.params.accountId).toEqual("some-account-id");
7667
+ return res.once(ctx.json(createFetchResult(namespaces)));
7668
+ })
7579
7669
  );
7580
7670
  }
7581
7671
 
@@ -7594,6 +7684,7 @@ interface StaticAssetUpload {
7594
7684
  }
7595
7685
 
7596
7686
  /** Create a mock handler for the request that tries to do a bulk upload of assets to a KV namespace. */
7687
+ //TODO: This is getting called multiple times in the test, we need to check if that is happening in Production --Jacob 2021-03-02
7597
7688
  function mockUploadAssetsToKVRequest(
7598
7689
  expectedNamespaceId: string,
7599
7690
  assets?: ExpectedAsset[]
@@ -7601,22 +7692,24 @@ function mockUploadAssetsToKVRequest(
7601
7692
  const requests: {
7602
7693
  uploads: StaticAssetUpload[];
7603
7694
  }[] = [];
7604
- setMockResponse(
7605
- "/accounts/:accountId/storage/kv/namespaces/:namespaceId/bulk",
7606
- "PUT",
7607
- ([_url, accountId, namespaceId], { body }) => {
7608
- expect(accountId).toEqual("some-account-id");
7609
- expect(namespaceId).toEqual(expectedNamespaceId);
7610
- const uploads = JSON.parse(body as string);
7611
- if (assets) {
7612
- expect(assets.length).toEqual(uploads.length);
7613
- for (let i = 0; i < uploads.length; i++) {
7614
- checkAssetUpload(assets[i], uploads[i]);
7695
+ msw.use(
7696
+ rest.put(
7697
+ "*/accounts/:accountId/storage/kv/namespaces/:namespaceId/bulk",
7698
+ async (req, res, ctx) => {
7699
+ expect(req.params.accountId).toEqual("some-account-id");
7700
+ expect(req.params.namespaceId).toEqual(expectedNamespaceId);
7701
+ const uploads = await req.json();
7702
+ if (assets) {
7703
+ expect(assets.length).toEqual(uploads.length);
7704
+ for (let i = 0; i < uploads.length; i++) {
7705
+ checkAssetUpload(assets[i], uploads[i]);
7706
+ }
7615
7707
  }
7616
- } else {
7708
+
7617
7709
  requests.push({ uploads });
7710
+ return res(ctx.json(createFetchResult([])));
7618
7711
  }
7619
- }
7712
+ )
7620
7713
  );
7621
7714
  return requests;
7622
7715
  }
@@ -7640,16 +7733,24 @@ function mockDeleteUnusedAssetsRequest(
7640
7733
  expectedNamespaceId: string,
7641
7734
  assets: string[]
7642
7735
  ) {
7643
- setMockResponse(
7644
- "/accounts/:accountId/storage/kv/namespaces/:namespaceId/bulk",
7645
- "DELETE",
7646
- ([_url, accountId, namespaceId], { body }) => {
7647
- expect(accountId).toEqual("some-account-id");
7648
- expect(namespaceId).toEqual(expectedNamespaceId);
7649
- const deletes = JSON.parse(body as string);
7650
- expect(assets).toEqual(deletes);
7651
- return null;
7652
- }
7736
+ msw.use(
7737
+ rest.delete(
7738
+ "*/accounts/:accountId/storage/kv/namespaces/:namespaceId/bulk",
7739
+ async (req, res, ctx) => {
7740
+ expect(req.params.accountId).toEqual("some-account-id");
7741
+ expect(req.params.namespaceId).toEqual(expectedNamespaceId);
7742
+ const deletes = await req.json();
7743
+ expect(assets).toEqual(deletes);
7744
+ return res.once(
7745
+ ctx.json({
7746
+ success: true,
7747
+ errors: [],
7748
+ messages: [],
7749
+ result: null,
7750
+ })
7751
+ );
7752
+ }
7753
+ )
7653
7754
  );
7654
7755
  }
7655
7756
 
@@ -7657,13 +7758,18 @@ type LegacyScriptInfo = { id: string; migration_tag?: string };
7657
7758
 
7658
7759
  function mockLegacyScriptData(options: { scripts: LegacyScriptInfo[] }) {
7659
7760
  const { scripts } = options;
7660
- setMockResponse(
7661
- "/accounts/:accountId/workers/scripts",
7662
- "GET",
7663
- ([_url, accountId]) => {
7664
- expect(accountId).toEqual("some-account-id");
7665
- return scripts;
7666
- }
7761
+ msw.use(
7762
+ rest.get("*/accounts/:accountId/workers/scripts", (req, res, ctx) => {
7763
+ expect(req.params.accountId).toEqual("some-account-id");
7764
+ return res.once(
7765
+ ctx.json({
7766
+ success: true,
7767
+ errors: [],
7768
+ messages: [],
7769
+ result: scripts,
7770
+ })
7771
+ );
7772
+ })
7667
7773
  );
7668
7774
  }
7669
7775
 
@@ -7677,74 +7783,140 @@ function mockServiceScriptData(options: {
7677
7783
  const { script } = options;
7678
7784
  if (options.env) {
7679
7785
  if (!script) {
7680
- setMockRawResponse(
7681
- "/accounts/:accountId/workers/services/:scriptName/environments/:envName",
7682
- "GET",
7683
- () => {
7684
- return createFetchResult(null, false, [
7685
- { code: 10092, message: "workers.api.error.environment_not_found" },
7686
- ]);
7687
- }
7786
+ msw.use(
7787
+ rest.get(
7788
+ "*/accounts/:accountId/workers/services/:scriptName/environments/:envName",
7789
+ (_, res, ctx) => {
7790
+ return res.once(
7791
+ ctx.json({
7792
+ success: false,
7793
+ errors: [
7794
+ {
7795
+ code: 10092,
7796
+ message: "workers.api.error.environment_not_found",
7797
+ },
7798
+ ],
7799
+ messages: [],
7800
+ result: null,
7801
+ })
7802
+ );
7803
+ }
7804
+ )
7688
7805
  );
7689
7806
  return;
7690
7807
  }
7691
- setMockResponse(
7692
- "/accounts/:accountId/workers/services/:scriptName/environments/:envName",
7693
- "GET",
7694
- ([_url, accountId, scriptName, envName]) => {
7695
- expect(accountId).toEqual("some-account-id");
7696
- expect(scriptName).toEqual(options.scriptName || "test-name");
7697
- expect(envName).toEqual(options.env);
7698
- return { script };
7699
- }
7808
+ msw.use(
7809
+ rest.get(
7810
+ "*/accounts/:accountId/workers/services/:scriptName/environments/:envName",
7811
+ (req, res, ctx) => {
7812
+ expect(req.params.accountId).toEqual("some-account-id");
7813
+ expect(req.params.scriptName).toEqual(
7814
+ options.scriptName || "test-name"
7815
+ );
7816
+ expect(req.params.envName).toEqual(options.env);
7817
+ return res.once(
7818
+ ctx.json({
7819
+ success: true,
7820
+ errors: [],
7821
+ messages: [],
7822
+ result: { script },
7823
+ })
7824
+ );
7825
+ }
7826
+ )
7700
7827
  );
7701
7828
  } else {
7702
7829
  if (!script) {
7703
- setMockRawResponse(
7704
- "/accounts/:accountId/workers/services/:scriptName",
7705
- "GET",
7706
- () => {
7707
- return createFetchResult(null, false, [
7708
- { code: 10090, message: "workers.api.error.service_not_found" },
7709
- ]);
7710
- }
7830
+ msw.use(
7831
+ rest.get(
7832
+ "*/accounts/:accountId/workers/services/:scriptName",
7833
+ (req, res, ctx) => {
7834
+ return res.once(
7835
+ ctx.json({
7836
+ success: false,
7837
+ errors: [
7838
+ {
7839
+ code: 10090,
7840
+ message: "workers.api.error.service_not_found",
7841
+ },
7842
+ ],
7843
+ messages: [],
7844
+ result: null,
7845
+ })
7846
+ );
7847
+ }
7848
+ )
7711
7849
  );
7712
7850
  return;
7713
7851
  }
7714
- setMockResponse(
7715
- "/accounts/:accountId/workers/services/:scriptName",
7716
- "GET",
7717
- ([_url, accountId, scriptName]) => {
7718
- expect(accountId).toEqual("some-account-id");
7719
- expect(scriptName).toEqual(options.scriptName || "test-name");
7720
- return { default_environment: { script } };
7721
- }
7852
+ msw.use(
7853
+ rest.get(
7854
+ "*/accounts/:accountId/workers/services/:scriptName",
7855
+ (req, res, ctx) => {
7856
+ expect(req.params.accountId).toEqual("some-account-id");
7857
+ expect(req.params.scriptName).toEqual(
7858
+ options.scriptName || "test-name"
7859
+ );
7860
+ return res.once(
7861
+ ctx.json({
7862
+ success: true,
7863
+ errors: [],
7864
+ messages: [],
7865
+ result: { default_environment: { script } },
7866
+ })
7867
+ );
7868
+ }
7869
+ )
7722
7870
  );
7723
7871
  }
7724
7872
  }
7725
7873
 
7726
7874
  function mockGetQueue(expectedQueueName: string) {
7727
7875
  const requests = { count: 0 };
7728
- setMockResponse(
7729
- `/accounts/:accountId/workers/queues/${expectedQueueName}`,
7730
- "GET",
7731
- ([_url, accountId]) => {
7732
- expect(accountId).toEqual("some-account-id");
7733
- requests.count += 1;
7734
- return { queue: expectedQueueName };
7735
- }
7876
+ msw.use(
7877
+ rest.get(
7878
+ `*/accounts/:accountId/workers/queues/${expectedQueueName}`,
7879
+ (req, res, ctx) => {
7880
+ expect(req.params.accountId).toEqual("some-account-id");
7881
+ requests.count += 1;
7882
+ return res(
7883
+ ctx.json({
7884
+ success: true,
7885
+ errors: [],
7886
+ messages: [],
7887
+ result: { queue: expectedQueueName },
7888
+ })
7889
+ );
7890
+ }
7891
+ )
7736
7892
  );
7737
7893
  return requests;
7738
7894
  }
7739
7895
 
7740
7896
  function mockGetQueueMissing(expectedQueueName: string) {
7741
7897
  const requests = { count: 0 };
7742
- setMockResponse(
7743
- `/accounts/:accountId/workers/queues/${expectedQueueName}`,
7744
- "GET",
7745
- ([_url, _accountId]) => {
7746
- throw { code: 11000 };
7747
- }
7898
+ msw.use(
7899
+ rest.get(
7900
+ `*/accounts/:accountId/workers/queues/${expectedQueueName}`,
7901
+ (req, res, ctx) => {
7902
+ requests.count += 1;
7903
+ expect(req.params.accountId).toEqual("some-account-id");
7904
+
7905
+ return res(
7906
+ ctx.json({
7907
+ success: false,
7908
+ errors: [
7909
+ {
7910
+ code: 11000,
7911
+ message: "workers.api.error.queue_not_found",
7912
+ },
7913
+ ],
7914
+ messages: [],
7915
+ result: null,
7916
+ })
7917
+ );
7918
+ }
7919
+ )
7748
7920
  );
7749
7921
  return requests;
7750
7922
  }
@@ -7755,15 +7927,65 @@ function mockPutQueueConsumer(
7755
7927
  expectedBody: PutConsumerBody
7756
7928
  ) {
7757
7929
  const requests = { count: 0 };
7758
- setMockResponse(
7759
- `/accounts/:accountId/workers/queues/${expectedQueueName}/consumers/${expectedConsumerName}`,
7760
- "PUT",
7761
- ([_url, accountId], { body }) => {
7762
- expect(accountId).toEqual("some-account-id");
7763
- expect(JSON.parse(body as string)).toEqual(expectedBody);
7764
- requests.count += 1;
7765
- return { queue: expectedQueueName };
7766
- }
7930
+ msw.use(
7931
+ rest.put(
7932
+ `*/accounts/:accountId/workers/queues/${expectedQueueName}/consumers/${expectedConsumerName}`,
7933
+ async (req, res, ctx) => {
7934
+ const body = await req.json();
7935
+ expect(req.params.accountId).toEqual("some-account-id");
7936
+ expect(body).toEqual(expectedBody);
7937
+ requests.count += 1;
7938
+ return res(
7939
+ ctx.json({
7940
+ success: true,
7941
+ errors: [],
7942
+ messages: [],
7943
+ result: { queue: expectedQueueName },
7944
+ })
7945
+ );
7946
+ }
7947
+ )
7767
7948
  );
7768
7949
  return requests;
7769
7950
  }
7951
+
7952
+ // MSW FormData & Blob polyfills to test FormData requests
7953
+ function mockFormDataToString(this: FormData) {
7954
+ const entries = [];
7955
+ for (const [key, value] of this.entries()) {
7956
+ if (value instanceof Blob) {
7957
+ const reader = new FileReaderSync();
7958
+ reader.readAsText(value);
7959
+ const result = reader.result;
7960
+ entries.push([key, result]);
7961
+ } else {
7962
+ entries.push([key, value]);
7963
+ }
7964
+ }
7965
+ return JSON.stringify({
7966
+ __formdata: entries,
7967
+ });
7968
+ }
7969
+
7970
+ async function mockFormDataFromString(this: MockedRequest): Promise<FormData> {
7971
+ const { __formdata } = await this.json();
7972
+ expect(__formdata).toBeInstanceOf(Array);
7973
+
7974
+ const form = new FormData();
7975
+ for (const [key, value] of __formdata) {
7976
+ form.set(key, value);
7977
+ }
7978
+ return form;
7979
+ }
7980
+
7981
+ // The following two functions workaround the fact that MSW does not yet support FormData in requests.
7982
+ // We use the fact that MSW relies upon `node-fetch` internally, which will call `toString()` on the FormData object,
7983
+ // rather than passing it through or serializing it as a proper FormData object.
7984
+ // The hack is to serialize FormData to a JSON string by overriding `FormData.toString()`.
7985
+ // And then to deserialize back to a FormData object by monkey-patching a `formData()` helper onto `MockedRequest`.
7986
+ FormData.prototype.toString = mockFormDataToString;
7987
+ export interface RestRequestWithFormData extends MockedRequest, RestRequest {
7988
+ formData(): Promise<FormData>;
7989
+ }
7990
+ (MockedRequest.prototype as RestRequestWithFormData).formData =
7991
+ mockFormDataFromString;