@merchi/cart 1.4.79 → 1.4.81
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.
- package/esm/CartProvider.js +31 -22
- package/esm/CartProvider.load.test.js +603 -548
- package/lib/CartProvider.js +31 -22
- package/package.json +4 -4
- package/src/CartProvider.load.test.tsx +17 -1
- package/src/CartProvider.tsx +8 -0
|
@@ -13,6 +13,7 @@ import { createRoot } from 'react-dom/client';
|
|
|
13
13
|
import { act } from 'react-dom/test-utils';
|
|
14
14
|
import CartProvider, { useCartContext } from './CartProvider';
|
|
15
15
|
import { getCartCookie, setCartCookie } from './utilities/cookie';
|
|
16
|
+
import { cartNeedsSourceUpdate } from './utilities/job_source';
|
|
16
17
|
import { reportCartFailure, CART_FAILURE_SOURCES } from './utilities/reportFailure';
|
|
17
18
|
import { tabIdClearCart, tabIdItems } from './utilities/tabs';
|
|
18
19
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -99,9 +100,9 @@ jest.mock('./utilities/job_source', function () {
|
|
|
99
100
|
jobSourceFieldsForApi: function jobSourceFieldsForApi() {
|
|
100
101
|
return {};
|
|
101
102
|
},
|
|
102
|
-
cartNeedsSourceUpdate: function
|
|
103
|
+
cartNeedsSourceUpdate: jest.fn(function () {
|
|
103
104
|
return false;
|
|
104
|
-
},
|
|
105
|
+
}),
|
|
105
106
|
appendJobSourceToFormData: function appendJobSourceToFormData(form) {
|
|
106
107
|
return form;
|
|
107
108
|
}
|
|
@@ -142,6 +143,7 @@ describe('cart load and replacement failures', function () {
|
|
|
142
143
|
delete window[name];
|
|
143
144
|
}
|
|
144
145
|
jest.clearAllMocks();
|
|
146
|
+
cartNeedsSourceUpdate.mockReturnValue(false);
|
|
145
147
|
mockGet.mockReset();
|
|
146
148
|
mockPost.mockReset();
|
|
147
149
|
mockCreateItem.mockReset();
|
|
@@ -196,15 +198,15 @@ describe('cart load and replacement failures', function () {
|
|
|
196
198
|
return _mount.apply(this, arguments);
|
|
197
199
|
}
|
|
198
200
|
function _mount() {
|
|
199
|
-
_mount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
200
|
-
return _regenerator().w(function (
|
|
201
|
-
while (1) switch (
|
|
201
|
+
_mount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86(error) {
|
|
202
|
+
return _regenerator().w(function (_context86) {
|
|
203
|
+
while (1) switch (_context86.n) {
|
|
202
204
|
case 0:
|
|
203
205
|
mockGet.mockRejectedValue(error);
|
|
204
|
-
|
|
205
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
206
|
-
return _regenerator().w(function (
|
|
207
|
-
while (1) switch (
|
|
206
|
+
_context86.n = 1;
|
|
207
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85() {
|
|
208
|
+
return _regenerator().w(function (_context85) {
|
|
209
|
+
while (1) switch (_context85.n) {
|
|
208
210
|
case 0:
|
|
209
211
|
root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
210
212
|
domainId: 5,
|
|
@@ -218,14 +220,14 @@ describe('cart load and replacement failures', function () {
|
|
|
218
220
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
219
221
|
}));
|
|
220
222
|
case 1:
|
|
221
|
-
return
|
|
223
|
+
return _context85.a(2);
|
|
222
224
|
}
|
|
223
|
-
},
|
|
225
|
+
}, _callee85);
|
|
224
226
|
})));
|
|
225
227
|
case 1:
|
|
226
|
-
return
|
|
228
|
+
return _context86.a(2);
|
|
227
229
|
}
|
|
228
|
-
},
|
|
230
|
+
}, _callee86);
|
|
229
231
|
}));
|
|
230
232
|
return _mount.apply(this, arguments);
|
|
231
233
|
}
|
|
@@ -233,9 +235,9 @@ describe('cart load and replacement failures', function () {
|
|
|
233
235
|
return _mountSavedCart.apply(this, arguments);
|
|
234
236
|
}
|
|
235
237
|
function _mountSavedCart() {
|
|
236
|
-
_mountSavedCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
237
|
-
return _regenerator().w(function (
|
|
238
|
-
while (1) switch (
|
|
238
|
+
_mountSavedCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89() {
|
|
239
|
+
return _regenerator().w(function (_context89) {
|
|
240
|
+
while (1) switch (_context89.n) {
|
|
239
241
|
case 0:
|
|
240
242
|
mockGet.mockResolvedValue({
|
|
241
243
|
toJson: function toJson() {
|
|
@@ -248,10 +250,10 @@ describe('cart load and replacement failures', function () {
|
|
|
248
250
|
};
|
|
249
251
|
}
|
|
250
252
|
});
|
|
251
|
-
|
|
252
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
253
|
-
return _regenerator().w(function (
|
|
254
|
-
while (1) switch (
|
|
253
|
+
_context89.n = 1;
|
|
254
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87() {
|
|
255
|
+
return _regenerator().w(function (_context87) {
|
|
256
|
+
while (1) switch (_context87.n) {
|
|
255
257
|
case 0:
|
|
256
258
|
root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
257
259
|
domainId: 5,
|
|
@@ -259,31 +261,84 @@ describe('cart load and replacement failures', function () {
|
|
|
259
261
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
260
262
|
}));
|
|
261
263
|
case 1:
|
|
262
|
-
return
|
|
264
|
+
return _context87.a(2);
|
|
263
265
|
}
|
|
264
|
-
},
|
|
266
|
+
}, _callee87);
|
|
265
267
|
})));
|
|
266
268
|
case 1:
|
|
267
|
-
|
|
268
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
269
|
-
return _regenerator().w(function (
|
|
270
|
-
while (1) switch (
|
|
269
|
+
_context89.n = 2;
|
|
270
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88() {
|
|
271
|
+
return _regenerator().w(function (_context88) {
|
|
272
|
+
while (1) switch (_context88.n) {
|
|
271
273
|
case 0:
|
|
272
|
-
return
|
|
274
|
+
return _context88.a(2, context.setActiveTabIndex(tabIdClearCart));
|
|
273
275
|
}
|
|
274
|
-
},
|
|
276
|
+
}, _callee88);
|
|
275
277
|
})));
|
|
276
278
|
case 2:
|
|
277
|
-
return
|
|
279
|
+
return _context89.a(2);
|
|
278
280
|
}
|
|
279
|
-
},
|
|
281
|
+
}, _callee89);
|
|
280
282
|
}));
|
|
281
283
|
return _mountSavedCart.apply(this, arguments);
|
|
282
284
|
}
|
|
283
|
-
it('
|
|
285
|
+
it('restores a paid cart without writing new attribution to the closed order', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
286
|
+
var paidCart;
|
|
287
|
+
return _regenerator().w(function (_context4) {
|
|
288
|
+
while (1) switch (_context4.n) {
|
|
289
|
+
case 0:
|
|
290
|
+
paidCart = {
|
|
291
|
+
id: 42,
|
|
292
|
+
isTest: false,
|
|
293
|
+
invoice: {
|
|
294
|
+
unpaid: false
|
|
295
|
+
},
|
|
296
|
+
cartItems: [{
|
|
297
|
+
id: 7
|
|
298
|
+
}]
|
|
299
|
+
};
|
|
300
|
+
mockGet.mockResolvedValue({
|
|
301
|
+
id: 42,
|
|
302
|
+
toJson: function toJson() {
|
|
303
|
+
return paidCart;
|
|
304
|
+
},
|
|
305
|
+
toFormData: function toFormData() {
|
|
306
|
+
return new FormData();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
cartNeedsSourceUpdate.mockReturnValue(true);
|
|
310
|
+
mockPost.mockRejectedValue({
|
|
311
|
+
statusCode: 401,
|
|
312
|
+
message: 'Authentication required'
|
|
313
|
+
});
|
|
314
|
+
_context4.n = 1;
|
|
315
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
316
|
+
return _regenerator().w(function (_context3) {
|
|
317
|
+
while (1) switch (_context3.n) {
|
|
318
|
+
case 0:
|
|
319
|
+
root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
320
|
+
domainId: 5,
|
|
321
|
+
createCartAndCookie: function createCartAndCookie() {},
|
|
322
|
+
children: /*#__PURE__*/_jsx(Probe, {})
|
|
323
|
+
}));
|
|
324
|
+
case 1:
|
|
325
|
+
return _context3.a(2);
|
|
326
|
+
}
|
|
327
|
+
}, _callee3);
|
|
328
|
+
})));
|
|
329
|
+
case 1:
|
|
330
|
+
expect(context.cart).toEqual(paidCart);
|
|
331
|
+
expect(mockPost).not.toHaveBeenCalled();
|
|
332
|
+
expect(reportCartFailure).not.toHaveBeenCalled();
|
|
333
|
+
case 2:
|
|
334
|
+
return _context4.a(2);
|
|
335
|
+
}
|
|
336
|
+
}, _callee4);
|
|
337
|
+
})));
|
|
338
|
+
it('does not expose cart operations until a suspended provider commits', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
284
339
|
var ready, release, gate, Suspender, _i2, _bindingNames2, name, _i3, _bindingNames3, _name, _t;
|
|
285
|
-
return _regenerator().w(function (
|
|
286
|
-
while (1) switch (
|
|
340
|
+
return _regenerator().w(function (_context8) {
|
|
341
|
+
while (1) switch (_context8.n) {
|
|
287
342
|
case 0:
|
|
288
343
|
Suspender = function _Suspender() {
|
|
289
344
|
if (!ready) throw gate;
|
|
@@ -295,12 +350,12 @@ describe('cart load and replacement failures', function () {
|
|
|
295
350
|
gate = new Promise(function (resolve) {
|
|
296
351
|
release = resolve;
|
|
297
352
|
});
|
|
298
|
-
|
|
299
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
300
|
-
return _regenerator().w(function (
|
|
301
|
-
while (1) switch (
|
|
353
|
+
_context8.n = 1;
|
|
354
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
355
|
+
return _regenerator().w(function (_context5) {
|
|
356
|
+
while (1) switch (_context5.n) {
|
|
302
357
|
case 0:
|
|
303
|
-
return
|
|
358
|
+
return _context5.a(2, root.render(/*#__PURE__*/_jsx(React.Suspense, {
|
|
304
359
|
fallback: /*#__PURE__*/_jsx("span", {
|
|
305
360
|
children: "Loading"
|
|
306
361
|
}),
|
|
@@ -311,7 +366,7 @@ describe('cart load and replacement failures', function () {
|
|
|
311
366
|
})
|
|
312
367
|
})));
|
|
313
368
|
}
|
|
314
|
-
},
|
|
369
|
+
}, _callee5);
|
|
315
370
|
})));
|
|
316
371
|
case 1:
|
|
317
372
|
for (_i2 = 0, _bindingNames2 = bindingNames; _i2 < _bindingNames2.length; _i2++) {
|
|
@@ -319,70 +374,70 @@ describe('cart load and replacement failures', function () {
|
|
|
319
374
|
expect(window[name]).toBeUndefined();
|
|
320
375
|
}
|
|
321
376
|
expect(mockPost).not.toHaveBeenCalled();
|
|
322
|
-
|
|
323
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
324
|
-
return _regenerator().w(function (
|
|
325
|
-
while (1) switch (
|
|
377
|
+
_context8.n = 2;
|
|
378
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
379
|
+
return _regenerator().w(function (_context6) {
|
|
380
|
+
while (1) switch (_context6.n) {
|
|
326
381
|
case 0:
|
|
327
382
|
ready = true;
|
|
328
383
|
release();
|
|
329
384
|
case 1:
|
|
330
|
-
return
|
|
385
|
+
return _context6.a(2);
|
|
331
386
|
}
|
|
332
|
-
},
|
|
387
|
+
}, _callee6);
|
|
333
388
|
})));
|
|
334
389
|
case 2:
|
|
335
390
|
for (_i3 = 0, _bindingNames3 = bindingNames; _i3 < _bindingNames3.length; _i3++) {
|
|
336
391
|
_name = _bindingNames3[_i3];
|
|
337
392
|
expect(window[_name]).toBeInstanceOf(Function);
|
|
338
393
|
}
|
|
339
|
-
|
|
340
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
341
|
-
return _regenerator().w(function (
|
|
342
|
-
while (1) switch (
|
|
394
|
+
_context8.n = 3;
|
|
395
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
396
|
+
return _regenerator().w(function (_context7) {
|
|
397
|
+
while (1) switch (_context7.n) {
|
|
343
398
|
case 0:
|
|
344
|
-
|
|
399
|
+
_context7.n = 1;
|
|
345
400
|
return window.getCart();
|
|
346
401
|
case 1:
|
|
347
|
-
return
|
|
402
|
+
return _context7.a(2);
|
|
348
403
|
}
|
|
349
|
-
},
|
|
404
|
+
}, _callee7);
|
|
350
405
|
})));
|
|
351
406
|
case 3:
|
|
352
407
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
353
408
|
_t = expect;
|
|
354
|
-
|
|
409
|
+
_context8.n = 4;
|
|
355
410
|
return window.getMerchiCartValues();
|
|
356
411
|
case 4:
|
|
357
|
-
_t(
|
|
412
|
+
_t(_context8.v.cart.id).toBe(99);
|
|
358
413
|
expect(context.cart.id).toBe(99);
|
|
359
414
|
case 5:
|
|
360
|
-
return
|
|
415
|
+
return _context8.a(2);
|
|
361
416
|
}
|
|
362
|
-
},
|
|
417
|
+
}, _callee8);
|
|
363
418
|
})));
|
|
364
|
-
it('preserves committed operations when another provider suspends and is abandoned', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
419
|
+
it('preserves committed operations when another provider suspends and is abandoned', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
365
420
|
var committed, otherRoot, gate, Suspender, _t2;
|
|
366
|
-
return _regenerator().w(function (
|
|
367
|
-
while (1) switch (
|
|
421
|
+
return _regenerator().w(function (_context11) {
|
|
422
|
+
while (1) switch (_context11.p = _context11.n) {
|
|
368
423
|
case 0:
|
|
369
424
|
Suspender = function _Suspender2() {
|
|
370
425
|
throw gate;
|
|
371
426
|
};
|
|
372
427
|
setUserAgent(headlessUserAgent);
|
|
373
428
|
getCartCookie.mockResolvedValue(undefined);
|
|
374
|
-
|
|
375
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
376
|
-
return _regenerator().w(function (
|
|
377
|
-
while (1) switch (
|
|
429
|
+
_context11.n = 1;
|
|
430
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
431
|
+
return _regenerator().w(function (_context9) {
|
|
432
|
+
while (1) switch (_context9.n) {
|
|
378
433
|
case 0:
|
|
379
|
-
return
|
|
434
|
+
return _context9.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
380
435
|
domainId: 5,
|
|
381
436
|
createCartAndCookie: function createCartAndCookie() {},
|
|
382
437
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
383
438
|
})));
|
|
384
439
|
}
|
|
385
|
-
},
|
|
440
|
+
}, _callee9);
|
|
386
441
|
})));
|
|
387
442
|
case 1:
|
|
388
443
|
committed = bindingNames.map(function (name) {
|
|
@@ -390,13 +445,13 @@ describe('cart load and replacement failures', function () {
|
|
|
390
445
|
});
|
|
391
446
|
otherRoot = createRoot(document.createElement('div'));
|
|
392
447
|
gate = new Promise(function () {});
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
396
|
-
return _regenerator().w(function (
|
|
397
|
-
while (1) switch (
|
|
448
|
+
_context11.p = 2;
|
|
449
|
+
_context11.n = 3;
|
|
450
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
451
|
+
return _regenerator().w(function (_context0) {
|
|
452
|
+
while (1) switch (_context0.n) {
|
|
398
453
|
case 0:
|
|
399
|
-
return
|
|
454
|
+
return _context0.a(2, otherRoot.render(/*#__PURE__*/_jsx(React.Suspense, {
|
|
400
455
|
fallback: null,
|
|
401
456
|
children: /*#__PURE__*/_jsx(CartProvider, {
|
|
402
457
|
domainId: 6,
|
|
@@ -405,67 +460,67 @@ describe('cart load and replacement failures', function () {
|
|
|
405
460
|
})
|
|
406
461
|
})));
|
|
407
462
|
}
|
|
408
|
-
},
|
|
463
|
+
}, _callee0);
|
|
409
464
|
})));
|
|
410
465
|
case 3:
|
|
411
466
|
bindingNames.forEach(function (name, index) {
|
|
412
467
|
return expect(window[name]).toBe(committed[index]);
|
|
413
468
|
});
|
|
414
|
-
|
|
415
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
416
|
-
return _regenerator().w(function (
|
|
417
|
-
while (1) switch (
|
|
469
|
+
_context11.n = 4;
|
|
470
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
471
|
+
return _regenerator().w(function (_context1) {
|
|
472
|
+
while (1) switch (_context1.n) {
|
|
418
473
|
case 0:
|
|
419
|
-
|
|
474
|
+
_context1.n = 1;
|
|
420
475
|
return window.getCart();
|
|
421
476
|
case 1:
|
|
422
|
-
return
|
|
477
|
+
return _context1.a(2);
|
|
423
478
|
}
|
|
424
|
-
},
|
|
479
|
+
}, _callee1);
|
|
425
480
|
})));
|
|
426
481
|
case 4:
|
|
427
482
|
expect(context.cart.id).toBe(99);
|
|
428
483
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
429
484
|
case 5:
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
433
|
-
return _regenerator().w(function (
|
|
434
|
-
while (1) switch (
|
|
485
|
+
_context11.p = 5;
|
|
486
|
+
_context11.n = 6;
|
|
487
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
488
|
+
return _regenerator().w(function (_context10) {
|
|
489
|
+
while (1) switch (_context10.n) {
|
|
435
490
|
case 0:
|
|
436
|
-
return
|
|
491
|
+
return _context10.a(2, otherRoot.unmount());
|
|
437
492
|
}
|
|
438
|
-
},
|
|
493
|
+
}, _callee10);
|
|
439
494
|
})));
|
|
440
495
|
case 6:
|
|
441
|
-
return
|
|
496
|
+
return _context11.f(5);
|
|
442
497
|
case 7:
|
|
443
498
|
_t2 = expect;
|
|
444
|
-
|
|
499
|
+
_context11.n = 8;
|
|
445
500
|
return window.getMerchiCartValues();
|
|
446
501
|
case 8:
|
|
447
|
-
_t2(
|
|
502
|
+
_t2(_context11.v.cart.id).toBe(99);
|
|
448
503
|
case 9:
|
|
449
|
-
return
|
|
504
|
+
return _context11.a(2);
|
|
450
505
|
}
|
|
451
|
-
},
|
|
506
|
+
}, _callee11, null, [[2,, 5, 7]]);
|
|
452
507
|
})));
|
|
453
|
-
it('removes its own global operations on unmount', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
508
|
+
it('removes its own global operations on unmount', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
454
509
|
var _i4, _bindingNames4, name;
|
|
455
|
-
return _regenerator().w(function (
|
|
456
|
-
while (1) switch (
|
|
510
|
+
return _regenerator().w(function (_context13) {
|
|
511
|
+
while (1) switch (_context13.n) {
|
|
457
512
|
case 0:
|
|
458
|
-
|
|
513
|
+
_context13.n = 1;
|
|
459
514
|
return mountSavedCart();
|
|
460
515
|
case 1:
|
|
461
|
-
|
|
462
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
463
|
-
return _regenerator().w(function (
|
|
464
|
-
while (1) switch (
|
|
516
|
+
_context13.n = 2;
|
|
517
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
518
|
+
return _regenerator().w(function (_context12) {
|
|
519
|
+
while (1) switch (_context12.n) {
|
|
465
520
|
case 0:
|
|
466
|
-
return
|
|
521
|
+
return _context12.a(2, root.render(null));
|
|
467
522
|
}
|
|
468
|
-
},
|
|
523
|
+
}, _callee12);
|
|
469
524
|
})));
|
|
470
525
|
case 2:
|
|
471
526
|
for (_i4 = 0, _bindingNames4 = bindingNames; _i4 < _bindingNames4.length; _i4++) {
|
|
@@ -473,14 +528,14 @@ describe('cart load and replacement failures', function () {
|
|
|
473
528
|
expect(window[name]).toBeUndefined();
|
|
474
529
|
}
|
|
475
530
|
case 3:
|
|
476
|
-
return
|
|
531
|
+
return _context13.a(2);
|
|
477
532
|
}
|
|
478
|
-
},
|
|
533
|
+
}, _callee13);
|
|
479
534
|
})));
|
|
480
|
-
it('keeps the committed domain bindings during a suspended transition', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
535
|
+
it('keeps the committed domain bindings during a suspended transition', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
481
536
|
var gate, Suspender, tree, committed, _t3;
|
|
482
|
-
return _regenerator().w(function (
|
|
483
|
-
while (1) switch (
|
|
537
|
+
return _regenerator().w(function (_context16) {
|
|
538
|
+
while (1) switch (_context16.n) {
|
|
484
539
|
case 0:
|
|
485
540
|
Suspender = function _Suspender3() {
|
|
486
541
|
throw gate;
|
|
@@ -505,129 +560,129 @@ describe('cart load and replacement failures', function () {
|
|
|
505
560
|
})
|
|
506
561
|
});
|
|
507
562
|
};
|
|
508
|
-
|
|
509
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
510
|
-
return _regenerator().w(function (
|
|
511
|
-
while (1) switch (
|
|
563
|
+
_context16.n = 1;
|
|
564
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
565
|
+
return _regenerator().w(function (_context14) {
|
|
566
|
+
while (1) switch (_context14.n) {
|
|
512
567
|
case 0:
|
|
513
|
-
return
|
|
568
|
+
return _context14.a(2, root.render(tree(5, false)));
|
|
514
569
|
}
|
|
515
|
-
},
|
|
570
|
+
}, _callee14);
|
|
516
571
|
})));
|
|
517
572
|
case 1:
|
|
518
573
|
committed = bindingNames.map(function (name) {
|
|
519
574
|
return window[name];
|
|
520
575
|
});
|
|
521
|
-
|
|
522
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
523
|
-
return _regenerator().w(function (
|
|
524
|
-
while (1) switch (
|
|
576
|
+
_context16.n = 2;
|
|
577
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
578
|
+
return _regenerator().w(function (_context15) {
|
|
579
|
+
while (1) switch (_context15.n) {
|
|
525
580
|
case 0:
|
|
526
581
|
React.startTransition(function () {
|
|
527
582
|
return root.render(tree(6, true));
|
|
528
583
|
});
|
|
529
584
|
case 1:
|
|
530
|
-
return
|
|
585
|
+
return _context15.a(2);
|
|
531
586
|
}
|
|
532
|
-
},
|
|
587
|
+
}, _callee15);
|
|
533
588
|
})));
|
|
534
589
|
case 2:
|
|
535
590
|
bindingNames.forEach(function (name, index) {
|
|
536
591
|
return expect(window[name]).toBe(committed[index]);
|
|
537
592
|
});
|
|
538
593
|
_t3 = expect;
|
|
539
|
-
|
|
594
|
+
_context16.n = 3;
|
|
540
595
|
return window.getMerchiCartValues();
|
|
541
596
|
case 3:
|
|
542
|
-
_t3(
|
|
597
|
+
_t3(_context16.v.cart.id).toBe(42);
|
|
543
598
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
544
599
|
expect(mockPost).not.toHaveBeenCalled();
|
|
545
600
|
case 4:
|
|
546
|
-
return
|
|
601
|
+
return _context16.a(2);
|
|
547
602
|
}
|
|
548
|
-
},
|
|
603
|
+
}, _callee16);
|
|
549
604
|
})));
|
|
550
|
-
it('does not remove global operations owned by another committed provider', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
605
|
+
it('does not remove global operations owned by another committed provider', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
|
|
551
606
|
var otherRoot, otherBindings, _i5, _bindingNames5, name, _t4;
|
|
552
|
-
return _regenerator().w(function (
|
|
553
|
-
while (1) switch (
|
|
607
|
+
return _regenerator().w(function (_context20) {
|
|
608
|
+
while (1) switch (_context20.p = _context20.n) {
|
|
554
609
|
case 0:
|
|
555
|
-
|
|
610
|
+
_context20.n = 1;
|
|
556
611
|
return mountSavedCart();
|
|
557
612
|
case 1:
|
|
558
613
|
otherRoot = createRoot(document.createElement('div'));
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
562
|
-
return _regenerator().w(function (
|
|
563
|
-
while (1) switch (
|
|
614
|
+
_context20.p = 2;
|
|
615
|
+
_context20.n = 3;
|
|
616
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
617
|
+
return _regenerator().w(function (_context17) {
|
|
618
|
+
while (1) switch (_context17.n) {
|
|
564
619
|
case 0:
|
|
565
|
-
return
|
|
620
|
+
return _context17.a(2, otherRoot.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
566
621
|
domainId: 6,
|
|
567
622
|
createCartAndCookie: function createCartAndCookie() {},
|
|
568
623
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
569
624
|
})));
|
|
570
625
|
}
|
|
571
|
-
},
|
|
626
|
+
}, _callee17);
|
|
572
627
|
})));
|
|
573
628
|
case 3:
|
|
574
629
|
otherBindings = bindingNames.map(function (name) {
|
|
575
630
|
return window[name];
|
|
576
631
|
});
|
|
577
|
-
|
|
578
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
579
|
-
return _regenerator().w(function (
|
|
580
|
-
while (1) switch (
|
|
632
|
+
_context20.n = 4;
|
|
633
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
|
|
634
|
+
return _regenerator().w(function (_context18) {
|
|
635
|
+
while (1) switch (_context18.n) {
|
|
581
636
|
case 0:
|
|
582
|
-
return
|
|
637
|
+
return _context18.a(2, root.render(null));
|
|
583
638
|
}
|
|
584
|
-
},
|
|
639
|
+
}, _callee18);
|
|
585
640
|
})));
|
|
586
641
|
case 4:
|
|
587
642
|
bindingNames.forEach(function (name, index) {
|
|
588
643
|
return expect(window[name]).toBe(otherBindings[index]);
|
|
589
644
|
});
|
|
590
645
|
_t4 = expect;
|
|
591
|
-
|
|
646
|
+
_context20.n = 5;
|
|
592
647
|
return window.getMerchiCartValues();
|
|
593
648
|
case 5:
|
|
594
|
-
_t4(
|
|
649
|
+
_t4(_context20.v.cart.id).toBe(42);
|
|
595
650
|
case 6:
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
599
|
-
return _regenerator().w(function (
|
|
600
|
-
while (1) switch (
|
|
651
|
+
_context20.p = 6;
|
|
652
|
+
_context20.n = 7;
|
|
653
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
|
|
654
|
+
return _regenerator().w(function (_context19) {
|
|
655
|
+
while (1) switch (_context19.n) {
|
|
601
656
|
case 0:
|
|
602
|
-
return
|
|
657
|
+
return _context19.a(2, otherRoot.unmount());
|
|
603
658
|
}
|
|
604
|
-
},
|
|
659
|
+
}, _callee19);
|
|
605
660
|
})));
|
|
606
661
|
case 7:
|
|
607
|
-
return
|
|
662
|
+
return _context20.f(6);
|
|
608
663
|
case 8:
|
|
609
664
|
for (_i5 = 0, _bindingNames5 = bindingNames; _i5 < _bindingNames5.length; _i5++) {
|
|
610
665
|
name = _bindingNames5[_i5];
|
|
611
666
|
expect(window[name]).toBeUndefined();
|
|
612
667
|
}
|
|
613
668
|
case 9:
|
|
614
|
-
return
|
|
669
|
+
return _context20.a(2);
|
|
615
670
|
}
|
|
616
|
-
},
|
|
671
|
+
}, _callee20, null, [[2,, 6, 8]]);
|
|
617
672
|
})));
|
|
618
|
-
it('keeps globals usable after StrictMode setup and cleanup replay', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
673
|
+
it('keeps globals usable after StrictMode setup and cleanup replay', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23() {
|
|
619
674
|
var _t5;
|
|
620
|
-
return _regenerator().w(function (
|
|
621
|
-
while (1) switch (
|
|
675
|
+
return _regenerator().w(function (_context23) {
|
|
676
|
+
while (1) switch (_context23.n) {
|
|
622
677
|
case 0:
|
|
623
678
|
setUserAgent(headlessUserAgent);
|
|
624
679
|
getCartCookie.mockResolvedValue(undefined);
|
|
625
|
-
|
|
626
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
627
|
-
return _regenerator().w(function (
|
|
628
|
-
while (1) switch (
|
|
680
|
+
_context23.n = 1;
|
|
681
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
|
|
682
|
+
return _regenerator().w(function (_context21) {
|
|
683
|
+
while (1) switch (_context21.n) {
|
|
629
684
|
case 0:
|
|
630
|
-
return
|
|
685
|
+
return _context21.a(2, root.render(/*#__PURE__*/_jsx(React.StrictMode, {
|
|
631
686
|
children: /*#__PURE__*/_jsx(CartProvider, {
|
|
632
687
|
domainId: 5,
|
|
633
688
|
createCartAndCookie: function createCartAndCookie() {},
|
|
@@ -635,52 +690,52 @@ describe('cart load and replacement failures', function () {
|
|
|
635
690
|
})
|
|
636
691
|
})));
|
|
637
692
|
}
|
|
638
|
-
},
|
|
693
|
+
}, _callee21);
|
|
639
694
|
})));
|
|
640
695
|
case 1:
|
|
641
|
-
|
|
642
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
643
|
-
return _regenerator().w(function (
|
|
644
|
-
while (1) switch (
|
|
696
|
+
_context23.n = 2;
|
|
697
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22() {
|
|
698
|
+
return _regenerator().w(function (_context22) {
|
|
699
|
+
while (1) switch (_context22.n) {
|
|
645
700
|
case 0:
|
|
646
|
-
|
|
701
|
+
_context22.n = 1;
|
|
647
702
|
return window.getCart();
|
|
648
703
|
case 1:
|
|
649
|
-
return
|
|
704
|
+
return _context22.a(2);
|
|
650
705
|
}
|
|
651
|
-
},
|
|
706
|
+
}, _callee22);
|
|
652
707
|
})));
|
|
653
708
|
case 2:
|
|
654
709
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
655
710
|
_t5 = expect;
|
|
656
|
-
|
|
711
|
+
_context23.n = 3;
|
|
657
712
|
return window.getMerchiCartValues();
|
|
658
713
|
case 3:
|
|
659
|
-
_t5(
|
|
714
|
+
_t5(_context23.v.cart.id).toBe(99);
|
|
660
715
|
case 4:
|
|
661
|
-
return
|
|
716
|
+
return _context23.a(2);
|
|
662
717
|
}
|
|
663
|
-
},
|
|
718
|
+
}, _callee23);
|
|
664
719
|
})));
|
|
665
720
|
it.each(['Mozilla/5.0 (X11; Linux x86_64) HeadlessChrome/153.0.8010.0 Safari/537.36', 'Mozilla/5.0 (compatible; Baiduspider-render/2.0)'])('does not create an unused cart on automated startup: %s', /*#__PURE__*/function () {
|
|
666
|
-
var
|
|
667
|
-
return _regenerator().w(function (
|
|
668
|
-
while (1) switch (
|
|
721
|
+
var _ref24 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(userAgent) {
|
|
722
|
+
return _regenerator().w(function (_context25) {
|
|
723
|
+
while (1) switch (_context25.n) {
|
|
669
724
|
case 0:
|
|
670
725
|
setUserAgent(userAgent);
|
|
671
726
|
getCartCookie.mockResolvedValue(undefined);
|
|
672
|
-
|
|
673
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
674
|
-
return _regenerator().w(function (
|
|
675
|
-
while (1) switch (
|
|
727
|
+
_context25.n = 1;
|
|
728
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24() {
|
|
729
|
+
return _regenerator().w(function (_context24) {
|
|
730
|
+
while (1) switch (_context24.n) {
|
|
676
731
|
case 0:
|
|
677
|
-
return
|
|
732
|
+
return _context24.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
678
733
|
domainId: 5,
|
|
679
734
|
createCartAndCookie: function createCartAndCookie() {},
|
|
680
735
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
681
736
|
})));
|
|
682
737
|
}
|
|
683
|
-
},
|
|
738
|
+
}, _callee24);
|
|
684
739
|
})));
|
|
685
740
|
case 1:
|
|
686
741
|
expect(mockGet).not.toHaveBeenCalled();
|
|
@@ -688,60 +743,60 @@ describe('cart load and replacement failures', function () {
|
|
|
688
743
|
expect(context.fetchingCart).toBe(false);
|
|
689
744
|
expect(reportCartFailure).not.toHaveBeenCalled();
|
|
690
745
|
case 2:
|
|
691
|
-
return
|
|
746
|
+
return _context25.a(2);
|
|
692
747
|
}
|
|
693
|
-
},
|
|
748
|
+
}, _callee25);
|
|
694
749
|
}));
|
|
695
750
|
return function (_x2) {
|
|
696
|
-
return
|
|
751
|
+
return _ref24.apply(this, arguments);
|
|
697
752
|
};
|
|
698
753
|
}());
|
|
699
|
-
it('allows explicit cart opening and concurrent callers in an automated browser', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
700
|
-
return _regenerator().w(function (
|
|
701
|
-
while (1) switch (
|
|
754
|
+
it('allows explicit cart opening and concurrent callers in an automated browser', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28() {
|
|
755
|
+
return _regenerator().w(function (_context28) {
|
|
756
|
+
while (1) switch (_context28.n) {
|
|
702
757
|
case 0:
|
|
703
758
|
setUserAgent(headlessUserAgent);
|
|
704
759
|
getCartCookie.mockResolvedValue(undefined);
|
|
705
|
-
|
|
706
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
707
|
-
return _regenerator().w(function (
|
|
708
|
-
while (1) switch (
|
|
760
|
+
_context28.n = 1;
|
|
761
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26() {
|
|
762
|
+
return _regenerator().w(function (_context26) {
|
|
763
|
+
while (1) switch (_context26.n) {
|
|
709
764
|
case 0:
|
|
710
|
-
return
|
|
765
|
+
return _context26.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
711
766
|
domainId: 5,
|
|
712
767
|
createCartAndCookie: function createCartAndCookie() {},
|
|
713
768
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
714
769
|
})));
|
|
715
770
|
}
|
|
716
|
-
},
|
|
771
|
+
}, _callee26);
|
|
717
772
|
})));
|
|
718
773
|
case 1:
|
|
719
774
|
expect(mockPost).not.toHaveBeenCalled();
|
|
720
|
-
|
|
721
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
722
|
-
return _regenerator().w(function (
|
|
723
|
-
while (1) switch (
|
|
775
|
+
_context28.n = 2;
|
|
776
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27() {
|
|
777
|
+
return _regenerator().w(function (_context27) {
|
|
778
|
+
while (1) switch (_context27.n) {
|
|
724
779
|
case 0:
|
|
725
780
|
context.toggleCartModal();
|
|
726
|
-
|
|
781
|
+
_context27.n = 1;
|
|
727
782
|
return Promise.all([window.getCart(), window.refetchCart()]);
|
|
728
783
|
case 1:
|
|
729
|
-
return
|
|
784
|
+
return _context27.a(2);
|
|
730
785
|
}
|
|
731
|
-
},
|
|
786
|
+
}, _callee27);
|
|
732
787
|
})));
|
|
733
788
|
case 2:
|
|
734
789
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
735
790
|
expect(context.cart.id).toBe(99);
|
|
736
791
|
case 3:
|
|
737
|
-
return
|
|
792
|
+
return _context28.a(2);
|
|
738
793
|
}
|
|
739
|
-
},
|
|
794
|
+
}, _callee28);
|
|
740
795
|
})));
|
|
741
|
-
it('creates once when explicit interaction joins a pending passive cookie lookup', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
796
|
+
it('creates once when explicit interaction joins a pending passive cookie lookup', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee32() {
|
|
742
797
|
var finishCookie, first, second;
|
|
743
|
-
return _regenerator().w(function (
|
|
744
|
-
while (1) switch (
|
|
798
|
+
return _regenerator().w(function (_context32) {
|
|
799
|
+
while (1) switch (_context32.n) {
|
|
745
800
|
case 0:
|
|
746
801
|
setUserAgent(headlessUserAgent);
|
|
747
802
|
getCartCookie.mockImplementationOnce(function () {
|
|
@@ -749,60 +804,60 @@ describe('cart load and replacement failures', function () {
|
|
|
749
804
|
finishCookie = resolve;
|
|
750
805
|
});
|
|
751
806
|
}).mockResolvedValue(undefined);
|
|
752
|
-
|
|
753
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
754
|
-
return _regenerator().w(function (
|
|
755
|
-
while (1) switch (
|
|
807
|
+
_context32.n = 1;
|
|
808
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee29() {
|
|
809
|
+
return _regenerator().w(function (_context29) {
|
|
810
|
+
while (1) switch (_context29.n) {
|
|
756
811
|
case 0:
|
|
757
|
-
return
|
|
812
|
+
return _context29.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
758
813
|
domainId: 5,
|
|
759
814
|
createCartAndCookie: function createCartAndCookie() {},
|
|
760
815
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
761
816
|
})));
|
|
762
817
|
}
|
|
763
|
-
},
|
|
818
|
+
}, _callee29);
|
|
764
819
|
})));
|
|
765
820
|
case 1:
|
|
766
|
-
|
|
767
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
768
|
-
return _regenerator().w(function (
|
|
769
|
-
while (1) switch (
|
|
821
|
+
_context32.n = 2;
|
|
822
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee30() {
|
|
823
|
+
return _regenerator().w(function (_context30) {
|
|
824
|
+
while (1) switch (_context30.n) {
|
|
770
825
|
case 0:
|
|
771
826
|
first = window.getCart();
|
|
772
827
|
second = window.getCart();
|
|
773
828
|
context.toggleCartModal();
|
|
774
829
|
case 1:
|
|
775
|
-
return
|
|
830
|
+
return _context30.a(2);
|
|
776
831
|
}
|
|
777
|
-
},
|
|
832
|
+
}, _callee30);
|
|
778
833
|
})));
|
|
779
834
|
case 2:
|
|
780
835
|
expect(mockPost).not.toHaveBeenCalled();
|
|
781
|
-
|
|
782
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
783
|
-
return _regenerator().w(function (
|
|
784
|
-
while (1) switch (
|
|
836
|
+
_context32.n = 3;
|
|
837
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee31() {
|
|
838
|
+
return _regenerator().w(function (_context31) {
|
|
839
|
+
while (1) switch (_context31.n) {
|
|
785
840
|
case 0:
|
|
786
841
|
finishCookie(undefined);
|
|
787
|
-
|
|
842
|
+
_context31.n = 1;
|
|
788
843
|
return Promise.all([first, second]);
|
|
789
844
|
case 1:
|
|
790
|
-
return
|
|
845
|
+
return _context31.a(2);
|
|
791
846
|
}
|
|
792
|
-
},
|
|
847
|
+
}, _callee31);
|
|
793
848
|
})));
|
|
794
849
|
case 3:
|
|
795
850
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
796
851
|
expect(context.cart.id).toBe(99);
|
|
797
852
|
case 4:
|
|
798
|
-
return
|
|
853
|
+
return _context32.a(2);
|
|
799
854
|
}
|
|
800
|
-
},
|
|
855
|
+
}, _callee32);
|
|
801
856
|
})));
|
|
802
|
-
it('restores saved carts for automated clients without duplicating an active read', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
857
|
+
it('restores saved carts for automated clients without duplicating an active read', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee36() {
|
|
803
858
|
var finish, read;
|
|
804
|
-
return _regenerator().w(function (
|
|
805
|
-
while (1) switch (
|
|
859
|
+
return _regenerator().w(function (_context36) {
|
|
860
|
+
while (1) switch (_context36.n) {
|
|
806
861
|
case 0:
|
|
807
862
|
setUserAgent(headlessUserAgent);
|
|
808
863
|
mockGet.mockImplementationOnce(function () {
|
|
@@ -810,38 +865,38 @@ describe('cart load and replacement failures', function () {
|
|
|
810
865
|
finish = resolve;
|
|
811
866
|
});
|
|
812
867
|
});
|
|
813
|
-
|
|
814
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
815
|
-
return _regenerator().w(function (
|
|
816
|
-
while (1) switch (
|
|
868
|
+
_context36.n = 1;
|
|
869
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee33() {
|
|
870
|
+
return _regenerator().w(function (_context33) {
|
|
871
|
+
while (1) switch (_context33.n) {
|
|
817
872
|
case 0:
|
|
818
|
-
return
|
|
873
|
+
return _context33.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
819
874
|
domainId: 5,
|
|
820
875
|
createCartAndCookie: function createCartAndCookie() {},
|
|
821
876
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
822
877
|
})));
|
|
823
878
|
}
|
|
824
|
-
},
|
|
879
|
+
}, _callee33);
|
|
825
880
|
})));
|
|
826
881
|
case 1:
|
|
827
|
-
|
|
828
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
829
|
-
return _regenerator().w(function (
|
|
830
|
-
while (1) switch (
|
|
882
|
+
_context36.n = 2;
|
|
883
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee34() {
|
|
884
|
+
return _regenerator().w(function (_context34) {
|
|
885
|
+
while (1) switch (_context34.n) {
|
|
831
886
|
case 0:
|
|
832
887
|
read = window.getCart();
|
|
833
888
|
context.toggleCartModal();
|
|
834
889
|
case 1:
|
|
835
|
-
return
|
|
890
|
+
return _context34.a(2);
|
|
836
891
|
}
|
|
837
|
-
},
|
|
892
|
+
}, _callee34);
|
|
838
893
|
})));
|
|
839
894
|
case 2:
|
|
840
895
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
841
|
-
|
|
842
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
843
|
-
return _regenerator().w(function (
|
|
844
|
-
while (1) switch (
|
|
896
|
+
_context36.n = 3;
|
|
897
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee35() {
|
|
898
|
+
return _regenerator().w(function (_context35) {
|
|
899
|
+
while (1) switch (_context35.n) {
|
|
845
900
|
case 0:
|
|
846
901
|
finish({
|
|
847
902
|
toJson: function toJson() {
|
|
@@ -854,108 +909,108 @@ describe('cart load and replacement failures', function () {
|
|
|
854
909
|
};
|
|
855
910
|
}
|
|
856
911
|
});
|
|
857
|
-
|
|
912
|
+
_context35.n = 1;
|
|
858
913
|
return read;
|
|
859
914
|
case 1:
|
|
860
|
-
return
|
|
915
|
+
return _context35.a(2);
|
|
861
916
|
}
|
|
862
|
-
},
|
|
917
|
+
}, _callee35);
|
|
863
918
|
})));
|
|
864
919
|
case 3:
|
|
865
920
|
expect(mockPost).not.toHaveBeenCalled();
|
|
866
921
|
expect(context.cart.cartItems).toHaveLength(1);
|
|
867
922
|
case 4:
|
|
868
|
-
return
|
|
923
|
+
return _context36.a(2);
|
|
869
924
|
}
|
|
870
|
-
},
|
|
925
|
+
}, _callee36);
|
|
871
926
|
})));
|
|
872
|
-
it('keeps explicit retry available after an automated client creation fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
873
|
-
return _regenerator().w(function (
|
|
874
|
-
while (1) switch (
|
|
927
|
+
it('keeps explicit retry available after an automated client creation fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee40() {
|
|
928
|
+
return _regenerator().w(function (_context40) {
|
|
929
|
+
while (1) switch (_context40.n) {
|
|
875
930
|
case 0:
|
|
876
931
|
setUserAgent(headlessUserAgent);
|
|
877
932
|
getCartCookie.mockResolvedValue(undefined);
|
|
878
933
|
mockPost.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
|
879
|
-
|
|
880
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
881
|
-
return _regenerator().w(function (
|
|
882
|
-
while (1) switch (
|
|
934
|
+
_context40.n = 1;
|
|
935
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee37() {
|
|
936
|
+
return _regenerator().w(function (_context37) {
|
|
937
|
+
while (1) switch (_context37.n) {
|
|
883
938
|
case 0:
|
|
884
|
-
return
|
|
939
|
+
return _context37.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
885
940
|
domainId: 5,
|
|
886
941
|
createCartAndCookie: function createCartAndCookie() {},
|
|
887
942
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
888
943
|
})));
|
|
889
944
|
}
|
|
890
|
-
},
|
|
945
|
+
}, _callee37);
|
|
891
946
|
})));
|
|
892
947
|
case 1:
|
|
893
948
|
expect(mockPost).not.toHaveBeenCalled();
|
|
894
|
-
|
|
895
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
896
|
-
return _regenerator().w(function (
|
|
897
|
-
while (1) switch (
|
|
949
|
+
_context40.n = 2;
|
|
950
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee38() {
|
|
951
|
+
return _regenerator().w(function (_context38) {
|
|
952
|
+
while (1) switch (_context38.n) {
|
|
898
953
|
case 0:
|
|
899
|
-
|
|
954
|
+
_context38.n = 1;
|
|
900
955
|
return window.getCart();
|
|
901
956
|
case 1:
|
|
902
|
-
return
|
|
957
|
+
return _context38.a(2);
|
|
903
958
|
}
|
|
904
|
-
},
|
|
959
|
+
}, _callee38);
|
|
905
960
|
})));
|
|
906
961
|
case 2:
|
|
907
962
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
908
963
|
expect(context.fetchingCart).toBe(false);
|
|
909
964
|
expect(context.alert.show).toBe(true);
|
|
910
|
-
|
|
911
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
912
|
-
return _regenerator().w(function (
|
|
913
|
-
while (1) switch (
|
|
965
|
+
_context40.n = 3;
|
|
966
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee39() {
|
|
967
|
+
return _regenerator().w(function (_context39) {
|
|
968
|
+
while (1) switch (_context39.n) {
|
|
914
969
|
case 0:
|
|
915
|
-
|
|
970
|
+
_context39.n = 1;
|
|
916
971
|
return window.getCart();
|
|
917
972
|
case 1:
|
|
918
|
-
return
|
|
973
|
+
return _context39.a(2);
|
|
919
974
|
}
|
|
920
|
-
},
|
|
975
|
+
}, _callee39);
|
|
921
976
|
})));
|
|
922
977
|
case 3:
|
|
923
978
|
expect(mockPost).toHaveBeenCalledTimes(2);
|
|
924
979
|
expect(context.cart.id).toBe(99);
|
|
925
980
|
expect(context.alert.show).toBe(false);
|
|
926
981
|
case 4:
|
|
927
|
-
return
|
|
982
|
+
return _context40.a(2);
|
|
928
983
|
}
|
|
929
|
-
},
|
|
984
|
+
}, _callee40);
|
|
930
985
|
})));
|
|
931
|
-
it('initializes a cart for a direct item operation without a storefront readiness helper', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
986
|
+
it('initializes a cart for a direct item operation without a storefront readiness helper', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee43() {
|
|
932
987
|
var onSuccess, onError;
|
|
933
|
-
return _regenerator().w(function (
|
|
934
|
-
while (1) switch (
|
|
988
|
+
return _regenerator().w(function (_context43) {
|
|
989
|
+
while (1) switch (_context43.n) {
|
|
935
990
|
case 0:
|
|
936
991
|
setUserAgent(headlessUserAgent);
|
|
937
992
|
getCartCookie.mockResolvedValue(undefined);
|
|
938
|
-
|
|
939
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
940
|
-
return _regenerator().w(function (
|
|
941
|
-
while (1) switch (
|
|
993
|
+
_context43.n = 1;
|
|
994
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee41() {
|
|
995
|
+
return _regenerator().w(function (_context41) {
|
|
996
|
+
while (1) switch (_context41.n) {
|
|
942
997
|
case 0:
|
|
943
|
-
return
|
|
998
|
+
return _context41.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
944
999
|
domainId: 5,
|
|
945
1000
|
createCartAndCookie: function createCartAndCookie() {},
|
|
946
1001
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
947
1002
|
})));
|
|
948
1003
|
}
|
|
949
|
-
},
|
|
1004
|
+
}, _callee41);
|
|
950
1005
|
})));
|
|
951
1006
|
case 1:
|
|
952
1007
|
onSuccess = jest.fn(), onError = jest.fn();
|
|
953
|
-
|
|
954
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
955
|
-
return _regenerator().w(function (
|
|
956
|
-
while (1) switch (
|
|
1008
|
+
_context43.n = 2;
|
|
1009
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee42() {
|
|
1010
|
+
return _regenerator().w(function (_context42) {
|
|
1011
|
+
while (1) switch (_context42.n) {
|
|
957
1012
|
case 0:
|
|
958
|
-
|
|
1013
|
+
_context42.n = 1;
|
|
959
1014
|
return window.addCartItem({
|
|
960
1015
|
product: {
|
|
961
1016
|
id: 44
|
|
@@ -963,9 +1018,9 @@ describe('cart load and replacement failures', function () {
|
|
|
963
1018
|
quantity: 100
|
|
964
1019
|
}, onSuccess, onError);
|
|
965
1020
|
case 1:
|
|
966
|
-
return
|
|
1021
|
+
return _context42.a(2);
|
|
967
1022
|
}
|
|
968
|
-
},
|
|
1023
|
+
}, _callee42);
|
|
969
1024
|
})));
|
|
970
1025
|
case 2:
|
|
971
1026
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
@@ -978,39 +1033,39 @@ describe('cart load and replacement failures', function () {
|
|
|
978
1033
|
});
|
|
979
1034
|
expect(onError).not.toHaveBeenCalled();
|
|
980
1035
|
case 3:
|
|
981
|
-
return
|
|
1036
|
+
return _context43.a(2);
|
|
982
1037
|
}
|
|
983
|
-
},
|
|
1038
|
+
}, _callee43);
|
|
984
1039
|
})));
|
|
985
|
-
it('rejects a direct item operation when initialization fails without posting an item', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1040
|
+
it('rejects a direct item operation when initialization fails without posting an item', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee46() {
|
|
986
1041
|
var onSuccess, onError;
|
|
987
|
-
return _regenerator().w(function (
|
|
988
|
-
while (1) switch (
|
|
1042
|
+
return _regenerator().w(function (_context46) {
|
|
1043
|
+
while (1) switch (_context46.n) {
|
|
989
1044
|
case 0:
|
|
990
1045
|
setUserAgent(headlessUserAgent);
|
|
991
1046
|
getCartCookie.mockResolvedValue(undefined);
|
|
992
1047
|
mockPost.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
|
993
|
-
|
|
994
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
995
|
-
return _regenerator().w(function (
|
|
996
|
-
while (1) switch (
|
|
1048
|
+
_context46.n = 1;
|
|
1049
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee44() {
|
|
1050
|
+
return _regenerator().w(function (_context44) {
|
|
1051
|
+
while (1) switch (_context44.n) {
|
|
997
1052
|
case 0:
|
|
998
|
-
return
|
|
1053
|
+
return _context44.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
999
1054
|
domainId: 5,
|
|
1000
1055
|
createCartAndCookie: function createCartAndCookie() {},
|
|
1001
1056
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
1002
1057
|
})));
|
|
1003
1058
|
}
|
|
1004
|
-
},
|
|
1059
|
+
}, _callee44);
|
|
1005
1060
|
})));
|
|
1006
1061
|
case 1:
|
|
1007
1062
|
onSuccess = jest.fn(), onError = jest.fn();
|
|
1008
|
-
|
|
1009
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1010
|
-
return _regenerator().w(function (
|
|
1011
|
-
while (1) switch (
|
|
1063
|
+
_context46.n = 2;
|
|
1064
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee45() {
|
|
1065
|
+
return _regenerator().w(function (_context45) {
|
|
1066
|
+
while (1) switch (_context45.n) {
|
|
1012
1067
|
case 0:
|
|
1013
|
-
|
|
1068
|
+
_context45.n = 1;
|
|
1014
1069
|
return window.addCartItem({
|
|
1015
1070
|
product: {
|
|
1016
1071
|
id: 44
|
|
@@ -1018,9 +1073,9 @@ describe('cart load and replacement failures', function () {
|
|
|
1018
1073
|
quantity: 100
|
|
1019
1074
|
}, onSuccess, onError);
|
|
1020
1075
|
case 1:
|
|
1021
|
-
return
|
|
1076
|
+
return _context45.a(2);
|
|
1022
1077
|
}
|
|
1023
|
-
},
|
|
1078
|
+
}, _callee45);
|
|
1024
1079
|
})));
|
|
1025
1080
|
case 2:
|
|
1026
1081
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
@@ -1029,14 +1084,14 @@ describe('cart load and replacement failures', function () {
|
|
|
1029
1084
|
expect(onError).toHaveBeenCalledTimes(1);
|
|
1030
1085
|
expect(context.fetchingCart).toBe(false);
|
|
1031
1086
|
case 3:
|
|
1032
|
-
return
|
|
1087
|
+
return _context46.a(2);
|
|
1033
1088
|
}
|
|
1034
|
-
},
|
|
1089
|
+
}, _callee46);
|
|
1035
1090
|
})));
|
|
1036
|
-
it('waits for ordinary startup before concurrent direct item operations', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1091
|
+
it('waits for ordinary startup before concurrent direct item operations', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee50() {
|
|
1037
1092
|
var finish, onSuccess, onError, first, second;
|
|
1038
|
-
return _regenerator().w(function (
|
|
1039
|
-
while (1) switch (
|
|
1093
|
+
return _regenerator().w(function (_context50) {
|
|
1094
|
+
while (1) switch (_context50.n) {
|
|
1040
1095
|
case 0:
|
|
1041
1096
|
getCartCookie.mockResolvedValue(undefined);
|
|
1042
1097
|
mockPost.mockImplementationOnce(function () {
|
|
@@ -1044,26 +1099,26 @@ describe('cart load and replacement failures', function () {
|
|
|
1044
1099
|
finish = resolve;
|
|
1045
1100
|
});
|
|
1046
1101
|
});
|
|
1047
|
-
|
|
1048
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1049
|
-
return _regenerator().w(function (
|
|
1050
|
-
while (1) switch (
|
|
1102
|
+
_context50.n = 1;
|
|
1103
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee47() {
|
|
1104
|
+
return _regenerator().w(function (_context47) {
|
|
1105
|
+
while (1) switch (_context47.n) {
|
|
1051
1106
|
case 0:
|
|
1052
|
-
return
|
|
1107
|
+
return _context47.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
1053
1108
|
domainId: 5,
|
|
1054
1109
|
createCartAndCookie: function createCartAndCookie() {},
|
|
1055
1110
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
1056
1111
|
})));
|
|
1057
1112
|
}
|
|
1058
|
-
},
|
|
1113
|
+
}, _callee47);
|
|
1059
1114
|
})));
|
|
1060
1115
|
case 1:
|
|
1061
1116
|
onSuccess = jest.fn(), onError = jest.fn();
|
|
1062
|
-
|
|
1063
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1117
|
+
_context50.n = 2;
|
|
1118
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee48() {
|
|
1064
1119
|
var job;
|
|
1065
|
-
return _regenerator().w(function (
|
|
1066
|
-
while (1) switch (
|
|
1120
|
+
return _regenerator().w(function (_context48) {
|
|
1121
|
+
while (1) switch (_context48.n) {
|
|
1067
1122
|
case 0:
|
|
1068
1123
|
job = {
|
|
1069
1124
|
product: {
|
|
@@ -1074,16 +1129,16 @@ describe('cart load and replacement failures', function () {
|
|
|
1074
1129
|
first = window.addCartItem(job, onSuccess, onError);
|
|
1075
1130
|
second = window.addCartItem(job, onSuccess, onError);
|
|
1076
1131
|
case 1:
|
|
1077
|
-
return
|
|
1132
|
+
return _context48.a(2);
|
|
1078
1133
|
}
|
|
1079
|
-
},
|
|
1134
|
+
}, _callee48);
|
|
1080
1135
|
})));
|
|
1081
1136
|
case 2:
|
|
1082
1137
|
expect(mockCreateItem).not.toHaveBeenCalled();
|
|
1083
|
-
|
|
1084
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1085
|
-
return _regenerator().w(function (
|
|
1086
|
-
while (1) switch (
|
|
1138
|
+
_context50.n = 3;
|
|
1139
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee49() {
|
|
1140
|
+
return _regenerator().w(function (_context49) {
|
|
1141
|
+
while (1) switch (_context49.n) {
|
|
1087
1142
|
case 0:
|
|
1088
1143
|
finish({
|
|
1089
1144
|
cart: {
|
|
@@ -1091,12 +1146,12 @@ describe('cart load and replacement failures', function () {
|
|
|
1091
1146
|
token: 'new-token'
|
|
1092
1147
|
}
|
|
1093
1148
|
});
|
|
1094
|
-
|
|
1149
|
+
_context49.n = 1;
|
|
1095
1150
|
return Promise.all([first, second]);
|
|
1096
1151
|
case 1:
|
|
1097
|
-
return
|
|
1152
|
+
return _context49.a(2);
|
|
1098
1153
|
}
|
|
1099
|
-
},
|
|
1154
|
+
}, _callee49);
|
|
1100
1155
|
})));
|
|
1101
1156
|
case 3:
|
|
1102
1157
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
@@ -1105,30 +1160,30 @@ describe('cart load and replacement failures', function () {
|
|
|
1105
1160
|
})).toEqual([99, 99]);
|
|
1106
1161
|
expect(onError).not.toHaveBeenCalled();
|
|
1107
1162
|
case 4:
|
|
1108
|
-
return
|
|
1163
|
+
return _context50.a(2);
|
|
1109
1164
|
}
|
|
1110
|
-
},
|
|
1165
|
+
}, _callee50);
|
|
1111
1166
|
})));
|
|
1112
|
-
it('does not automatically repeat a failed item write after explicit initialization', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1167
|
+
it('does not automatically repeat a failed item write after explicit initialization', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee54() {
|
|
1113
1168
|
var onSuccess, onError, job;
|
|
1114
|
-
return _regenerator().w(function (
|
|
1115
|
-
while (1) switch (
|
|
1169
|
+
return _regenerator().w(function (_context54) {
|
|
1170
|
+
while (1) switch (_context54.n) {
|
|
1116
1171
|
case 0:
|
|
1117
1172
|
setUserAgent(headlessUserAgent);
|
|
1118
1173
|
getCartCookie.mockResolvedValue(undefined);
|
|
1119
1174
|
mockCreateItem.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
|
1120
|
-
|
|
1121
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1122
|
-
return _regenerator().w(function (
|
|
1123
|
-
while (1) switch (
|
|
1175
|
+
_context54.n = 1;
|
|
1176
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee51() {
|
|
1177
|
+
return _regenerator().w(function (_context51) {
|
|
1178
|
+
while (1) switch (_context51.n) {
|
|
1124
1179
|
case 0:
|
|
1125
|
-
return
|
|
1180
|
+
return _context51.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
1126
1181
|
domainId: 5,
|
|
1127
1182
|
createCartAndCookie: function createCartAndCookie() {},
|
|
1128
1183
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
1129
1184
|
})));
|
|
1130
1185
|
}
|
|
1131
|
-
},
|
|
1186
|
+
}, _callee51);
|
|
1132
1187
|
})));
|
|
1133
1188
|
case 1:
|
|
1134
1189
|
onSuccess = jest.fn(), onError = jest.fn();
|
|
@@ -1138,34 +1193,34 @@ describe('cart load and replacement failures', function () {
|
|
|
1138
1193
|
},
|
|
1139
1194
|
quantity: 100
|
|
1140
1195
|
};
|
|
1141
|
-
|
|
1142
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1143
|
-
return _regenerator().w(function (
|
|
1144
|
-
while (1) switch (
|
|
1196
|
+
_context54.n = 2;
|
|
1197
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee52() {
|
|
1198
|
+
return _regenerator().w(function (_context52) {
|
|
1199
|
+
while (1) switch (_context52.n) {
|
|
1145
1200
|
case 0:
|
|
1146
|
-
|
|
1201
|
+
_context52.n = 1;
|
|
1147
1202
|
return window.addCartItem(job, onSuccess, onError);
|
|
1148
1203
|
case 1:
|
|
1149
|
-
return
|
|
1204
|
+
return _context52.a(2);
|
|
1150
1205
|
}
|
|
1151
|
-
},
|
|
1206
|
+
}, _callee52);
|
|
1152
1207
|
})));
|
|
1153
1208
|
case 2:
|
|
1154
1209
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
1155
1210
|
expect(mockCreateItem).toHaveBeenCalledTimes(1);
|
|
1156
1211
|
expect(onSuccess).not.toHaveBeenCalled();
|
|
1157
1212
|
expect(onError).toHaveBeenCalledTimes(1);
|
|
1158
|
-
|
|
1159
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1160
|
-
return _regenerator().w(function (
|
|
1161
|
-
while (1) switch (
|
|
1213
|
+
_context54.n = 3;
|
|
1214
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee53() {
|
|
1215
|
+
return _regenerator().w(function (_context53) {
|
|
1216
|
+
while (1) switch (_context53.n) {
|
|
1162
1217
|
case 0:
|
|
1163
|
-
|
|
1218
|
+
_context53.n = 1;
|
|
1164
1219
|
return window.addCartItem(job, onSuccess, onError);
|
|
1165
1220
|
case 1:
|
|
1166
|
-
return
|
|
1221
|
+
return _context53.a(2);
|
|
1167
1222
|
}
|
|
1168
|
-
},
|
|
1223
|
+
}, _callee53);
|
|
1169
1224
|
})));
|
|
1170
1225
|
case 3:
|
|
1171
1226
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
@@ -1177,14 +1232,14 @@ describe('cart load and replacement failures', function () {
|
|
|
1177
1232
|
}
|
|
1178
1233
|
});
|
|
1179
1234
|
case 4:
|
|
1180
|
-
return
|
|
1235
|
+
return _context54.a(2);
|
|
1181
1236
|
}
|
|
1182
|
-
},
|
|
1237
|
+
}, _callee54);
|
|
1183
1238
|
})));
|
|
1184
|
-
it('shares cold initialization with opening the modal and concurrent getCart callers', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1239
|
+
it('shares cold initialization with opening the modal and concurrent getCart callers', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee58() {
|
|
1185
1240
|
var finish, first, second;
|
|
1186
|
-
return _regenerator().w(function (
|
|
1187
|
-
while (1) switch (
|
|
1241
|
+
return _regenerator().w(function (_context58) {
|
|
1242
|
+
while (1) switch (_context58.n) {
|
|
1188
1243
|
case 0:
|
|
1189
1244
|
getCartCookie.mockResolvedValue(undefined);
|
|
1190
1245
|
mockPost.mockImplementationOnce(function () {
|
|
@@ -1192,40 +1247,40 @@ describe('cart load and replacement failures', function () {
|
|
|
1192
1247
|
finish = resolve;
|
|
1193
1248
|
});
|
|
1194
1249
|
});
|
|
1195
|
-
|
|
1196
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1197
|
-
return _regenerator().w(function (
|
|
1198
|
-
while (1) switch (
|
|
1250
|
+
_context58.n = 1;
|
|
1251
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee55() {
|
|
1252
|
+
return _regenerator().w(function (_context55) {
|
|
1253
|
+
while (1) switch (_context55.n) {
|
|
1199
1254
|
case 0:
|
|
1200
|
-
return
|
|
1255
|
+
return _context55.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
1201
1256
|
domainId: 5,
|
|
1202
1257
|
createCartAndCookie: function createCartAndCookie() {},
|
|
1203
1258
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
1204
1259
|
})));
|
|
1205
1260
|
}
|
|
1206
|
-
},
|
|
1261
|
+
}, _callee55);
|
|
1207
1262
|
})));
|
|
1208
1263
|
case 1:
|
|
1209
|
-
|
|
1210
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1211
|
-
return _regenerator().w(function (
|
|
1212
|
-
while (1) switch (
|
|
1264
|
+
_context58.n = 2;
|
|
1265
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee56() {
|
|
1266
|
+
return _regenerator().w(function (_context56) {
|
|
1267
|
+
while (1) switch (_context56.n) {
|
|
1213
1268
|
case 0:
|
|
1214
1269
|
context.toggleCartModal();
|
|
1215
1270
|
first = window.getCart();
|
|
1216
1271
|
second = window.getCart();
|
|
1217
1272
|
case 1:
|
|
1218
|
-
return
|
|
1273
|
+
return _context56.a(2);
|
|
1219
1274
|
}
|
|
1220
|
-
},
|
|
1275
|
+
}, _callee56);
|
|
1221
1276
|
})));
|
|
1222
1277
|
case 2:
|
|
1223
1278
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
1224
1279
|
expect(context.fetchingCart).toBe(true);
|
|
1225
|
-
|
|
1226
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1227
|
-
return _regenerator().w(function (
|
|
1228
|
-
while (1) switch (
|
|
1280
|
+
_context58.n = 3;
|
|
1281
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee57() {
|
|
1282
|
+
return _regenerator().w(function (_context57) {
|
|
1283
|
+
while (1) switch (_context57.n) {
|
|
1229
1284
|
case 0:
|
|
1230
1285
|
finish({
|
|
1231
1286
|
cart: {
|
|
@@ -1233,26 +1288,26 @@ describe('cart load and replacement failures', function () {
|
|
|
1233
1288
|
token: 'new-token'
|
|
1234
1289
|
}
|
|
1235
1290
|
});
|
|
1236
|
-
|
|
1291
|
+
_context57.n = 1;
|
|
1237
1292
|
return Promise.all([first, second]);
|
|
1238
1293
|
case 1:
|
|
1239
|
-
return
|
|
1294
|
+
return _context57.a(2);
|
|
1240
1295
|
}
|
|
1241
|
-
},
|
|
1296
|
+
}, _callee57);
|
|
1242
1297
|
})));
|
|
1243
1298
|
case 3:
|
|
1244
1299
|
expect(context.cart.id).toBe(99);
|
|
1245
1300
|
expect(context.fetchingCart).toBe(false);
|
|
1246
1301
|
expect(setCartCookie).toHaveBeenCalledTimes(1);
|
|
1247
1302
|
case 4:
|
|
1248
|
-
return
|
|
1303
|
+
return _context58.a(2);
|
|
1249
1304
|
}
|
|
1250
|
-
},
|
|
1305
|
+
}, _callee58);
|
|
1251
1306
|
})));
|
|
1252
|
-
it('shares an active saved-cart read and allows a later refresh', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1307
|
+
it('shares an active saved-cart read and allows a later refresh', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee63() {
|
|
1253
1308
|
var finish, saved, read;
|
|
1254
|
-
return _regenerator().w(function (
|
|
1255
|
-
while (1) switch (
|
|
1309
|
+
return _regenerator().w(function (_context63) {
|
|
1310
|
+
while (1) switch (_context63.n) {
|
|
1256
1311
|
case 0:
|
|
1257
1312
|
saved = {
|
|
1258
1313
|
toJson: function toJson() {
|
|
@@ -1270,116 +1325,116 @@ describe('cart load and replacement failures', function () {
|
|
|
1270
1325
|
finish = resolve;
|
|
1271
1326
|
});
|
|
1272
1327
|
}).mockResolvedValue(saved);
|
|
1273
|
-
|
|
1274
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1275
|
-
return _regenerator().w(function (
|
|
1276
|
-
while (1) switch (
|
|
1328
|
+
_context63.n = 1;
|
|
1329
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee59() {
|
|
1330
|
+
return _regenerator().w(function (_context59) {
|
|
1331
|
+
while (1) switch (_context59.n) {
|
|
1277
1332
|
case 0:
|
|
1278
|
-
return
|
|
1333
|
+
return _context59.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
1279
1334
|
domainId: 5,
|
|
1280
1335
|
createCartAndCookie: function createCartAndCookie() {},
|
|
1281
1336
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
1282
1337
|
})));
|
|
1283
1338
|
}
|
|
1284
|
-
},
|
|
1339
|
+
}, _callee59);
|
|
1285
1340
|
})));
|
|
1286
1341
|
case 1:
|
|
1287
|
-
|
|
1288
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1289
|
-
return _regenerator().w(function (
|
|
1290
|
-
while (1) switch (
|
|
1342
|
+
_context63.n = 2;
|
|
1343
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee60() {
|
|
1344
|
+
return _regenerator().w(function (_context60) {
|
|
1345
|
+
while (1) switch (_context60.n) {
|
|
1291
1346
|
case 0:
|
|
1292
1347
|
context.toggleCartModal();
|
|
1293
1348
|
read = window.getCart();
|
|
1294
1349
|
case 1:
|
|
1295
|
-
return
|
|
1350
|
+
return _context60.a(2);
|
|
1296
1351
|
}
|
|
1297
|
-
},
|
|
1352
|
+
}, _callee60);
|
|
1298
1353
|
})));
|
|
1299
1354
|
case 2:
|
|
1300
1355
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
1301
|
-
|
|
1302
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1303
|
-
return _regenerator().w(function (
|
|
1304
|
-
while (1) switch (
|
|
1356
|
+
_context63.n = 3;
|
|
1357
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee61() {
|
|
1358
|
+
return _regenerator().w(function (_context61) {
|
|
1359
|
+
while (1) switch (_context61.n) {
|
|
1305
1360
|
case 0:
|
|
1306
1361
|
finish(saved);
|
|
1307
|
-
|
|
1362
|
+
_context61.n = 1;
|
|
1308
1363
|
return read;
|
|
1309
1364
|
case 1:
|
|
1310
|
-
return
|
|
1365
|
+
return _context61.a(2);
|
|
1311
1366
|
}
|
|
1312
|
-
},
|
|
1367
|
+
}, _callee61);
|
|
1313
1368
|
})));
|
|
1314
1369
|
case 3:
|
|
1315
|
-
|
|
1316
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1317
|
-
return _regenerator().w(function (
|
|
1318
|
-
while (1) switch (
|
|
1370
|
+
_context63.n = 4;
|
|
1371
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee62() {
|
|
1372
|
+
return _regenerator().w(function (_context62) {
|
|
1373
|
+
while (1) switch (_context62.n) {
|
|
1319
1374
|
case 0:
|
|
1320
|
-
|
|
1375
|
+
_context62.n = 1;
|
|
1321
1376
|
return window.getCart();
|
|
1322
1377
|
case 1:
|
|
1323
|
-
return
|
|
1378
|
+
return _context62.a(2);
|
|
1324
1379
|
}
|
|
1325
|
-
},
|
|
1380
|
+
}, _callee62);
|
|
1326
1381
|
})));
|
|
1327
1382
|
case 4:
|
|
1328
1383
|
expect(mockGet).toHaveBeenCalledTimes(2);
|
|
1329
1384
|
expect(mockPost).not.toHaveBeenCalled();
|
|
1330
1385
|
expect(context.cart.cartItems).toHaveLength(1);
|
|
1331
1386
|
case 5:
|
|
1332
|
-
return
|
|
1387
|
+
return _context63.a(2);
|
|
1333
1388
|
}
|
|
1334
|
-
},
|
|
1389
|
+
}, _callee63);
|
|
1335
1390
|
})));
|
|
1336
|
-
it('releases failed initialization so an explicit retry can create the cart', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1337
|
-
return _regenerator().w(function (
|
|
1338
|
-
while (1) switch (
|
|
1391
|
+
it('releases failed initialization so an explicit retry can create the cart', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee66() {
|
|
1392
|
+
return _regenerator().w(function (_context66) {
|
|
1393
|
+
while (1) switch (_context66.n) {
|
|
1339
1394
|
case 0:
|
|
1340
1395
|
getCartCookie.mockResolvedValue(undefined);
|
|
1341
1396
|
mockPost.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
|
1342
|
-
|
|
1343
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1344
|
-
return _regenerator().w(function (
|
|
1345
|
-
while (1) switch (
|
|
1397
|
+
_context66.n = 1;
|
|
1398
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee64() {
|
|
1399
|
+
return _regenerator().w(function (_context64) {
|
|
1400
|
+
while (1) switch (_context64.n) {
|
|
1346
1401
|
case 0:
|
|
1347
|
-
return
|
|
1402
|
+
return _context64.a(2, root.render(/*#__PURE__*/_jsx(CartProvider, {
|
|
1348
1403
|
domainId: 5,
|
|
1349
1404
|
createCartAndCookie: function createCartAndCookie() {},
|
|
1350
1405
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
1351
1406
|
})));
|
|
1352
1407
|
}
|
|
1353
|
-
},
|
|
1408
|
+
}, _callee64);
|
|
1354
1409
|
})));
|
|
1355
1410
|
case 1:
|
|
1356
1411
|
expect(mockPost).toHaveBeenCalledTimes(1);
|
|
1357
1412
|
expect(context.fetchingCart).toBe(false);
|
|
1358
|
-
|
|
1359
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1360
|
-
return _regenerator().w(function (
|
|
1361
|
-
while (1) switch (
|
|
1413
|
+
_context66.n = 2;
|
|
1414
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee65() {
|
|
1415
|
+
return _regenerator().w(function (_context65) {
|
|
1416
|
+
while (1) switch (_context65.n) {
|
|
1362
1417
|
case 0:
|
|
1363
|
-
|
|
1418
|
+
_context65.n = 1;
|
|
1364
1419
|
return Promise.all([window.getCart(), window.getCart()]);
|
|
1365
1420
|
case 1:
|
|
1366
|
-
return
|
|
1421
|
+
return _context65.a(2);
|
|
1367
1422
|
}
|
|
1368
|
-
},
|
|
1423
|
+
}, _callee65);
|
|
1369
1424
|
})));
|
|
1370
1425
|
case 2:
|
|
1371
1426
|
expect(mockPost).toHaveBeenCalledTimes(2);
|
|
1372
1427
|
expect(context.cart.id).toBe(99);
|
|
1373
1428
|
expect(context.fetchingCart).toBe(false);
|
|
1374
1429
|
case 3:
|
|
1375
|
-
return
|
|
1430
|
+
return _context66.a(2);
|
|
1376
1431
|
}
|
|
1377
|
-
},
|
|
1432
|
+
}, _callee66);
|
|
1378
1433
|
})));
|
|
1379
|
-
it('initializes a changed domain independently of the previous pending domain', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1434
|
+
it('initializes a changed domain independently of the previous pending domain', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72() {
|
|
1380
1435
|
var finish, view, current;
|
|
1381
|
-
return _regenerator().w(function (
|
|
1382
|
-
while (1) switch (
|
|
1436
|
+
return _regenerator().w(function (_context72) {
|
|
1437
|
+
while (1) switch (_context72.n) {
|
|
1383
1438
|
case 0:
|
|
1384
1439
|
finish = {};
|
|
1385
1440
|
getCartCookie.mockImplementation(function (id) {
|
|
@@ -1397,33 +1452,33 @@ describe('cart load and replacement failures', function () {
|
|
|
1397
1452
|
children: /*#__PURE__*/_jsx(Probe, {})
|
|
1398
1453
|
});
|
|
1399
1454
|
};
|
|
1400
|
-
|
|
1401
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1402
|
-
return _regenerator().w(function (
|
|
1403
|
-
while (1) switch (
|
|
1455
|
+
_context72.n = 1;
|
|
1456
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee67() {
|
|
1457
|
+
return _regenerator().w(function (_context67) {
|
|
1458
|
+
while (1) switch (_context67.n) {
|
|
1404
1459
|
case 0:
|
|
1405
|
-
return
|
|
1460
|
+
return _context67.a(2, root.render(view(5)));
|
|
1406
1461
|
}
|
|
1407
|
-
},
|
|
1462
|
+
}, _callee67);
|
|
1408
1463
|
})));
|
|
1409
1464
|
case 1:
|
|
1410
|
-
|
|
1411
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1412
|
-
return _regenerator().w(function (
|
|
1413
|
-
while (1) switch (
|
|
1465
|
+
_context72.n = 2;
|
|
1466
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee68() {
|
|
1467
|
+
return _regenerator().w(function (_context68) {
|
|
1468
|
+
while (1) switch (_context68.n) {
|
|
1414
1469
|
case 0:
|
|
1415
|
-
return
|
|
1470
|
+
return _context68.a(2, root.render(view(6)));
|
|
1416
1471
|
}
|
|
1417
|
-
},
|
|
1472
|
+
}, _callee68);
|
|
1418
1473
|
})));
|
|
1419
1474
|
case 2:
|
|
1420
1475
|
expect(mockGet).toHaveBeenCalledTimes(2);
|
|
1421
|
-
|
|
1422
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1423
|
-
return _regenerator().w(function (
|
|
1424
|
-
while (1) switch (
|
|
1476
|
+
_context72.n = 3;
|
|
1477
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69() {
|
|
1478
|
+
return _regenerator().w(function (_context69) {
|
|
1479
|
+
while (1) switch (_context69.n) {
|
|
1425
1480
|
case 0:
|
|
1426
|
-
return
|
|
1481
|
+
return _context69.a(2, finish[5]({
|
|
1427
1482
|
toJson: function toJson() {
|
|
1428
1483
|
return {
|
|
1429
1484
|
id: 5,
|
|
@@ -1432,26 +1487,26 @@ describe('cart load and replacement failures', function () {
|
|
|
1432
1487
|
}
|
|
1433
1488
|
}));
|
|
1434
1489
|
}
|
|
1435
|
-
},
|
|
1490
|
+
}, _callee69);
|
|
1436
1491
|
})));
|
|
1437
1492
|
case 3:
|
|
1438
|
-
|
|
1439
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1440
|
-
return _regenerator().w(function (
|
|
1441
|
-
while (1) switch (
|
|
1493
|
+
_context72.n = 4;
|
|
1494
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70() {
|
|
1495
|
+
return _regenerator().w(function (_context70) {
|
|
1496
|
+
while (1) switch (_context70.n) {
|
|
1442
1497
|
case 0:
|
|
1443
1498
|
current = window.getCart();
|
|
1444
1499
|
case 1:
|
|
1445
|
-
return
|
|
1500
|
+
return _context70.a(2);
|
|
1446
1501
|
}
|
|
1447
|
-
},
|
|
1502
|
+
}, _callee70);
|
|
1448
1503
|
})));
|
|
1449
1504
|
case 4:
|
|
1450
1505
|
expect(mockGet).toHaveBeenCalledTimes(2);
|
|
1451
|
-
|
|
1452
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1453
|
-
return _regenerator().w(function (
|
|
1454
|
-
while (1) switch (
|
|
1506
|
+
_context72.n = 5;
|
|
1507
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71() {
|
|
1508
|
+
return _regenerator().w(function (_context71) {
|
|
1509
|
+
while (1) switch (_context71.n) {
|
|
1455
1510
|
case 0:
|
|
1456
1511
|
finish[6]({
|
|
1457
1512
|
toJson: function toJson() {
|
|
@@ -1461,19 +1516,19 @@ describe('cart load and replacement failures', function () {
|
|
|
1461
1516
|
};
|
|
1462
1517
|
}
|
|
1463
1518
|
});
|
|
1464
|
-
|
|
1519
|
+
_context71.n = 1;
|
|
1465
1520
|
return current;
|
|
1466
1521
|
case 1:
|
|
1467
|
-
return
|
|
1522
|
+
return _context71.a(2);
|
|
1468
1523
|
}
|
|
1469
|
-
},
|
|
1524
|
+
}, _callee71);
|
|
1470
1525
|
})));
|
|
1471
1526
|
case 5:
|
|
1472
1527
|
expect(context.cart.id).toBe(6);
|
|
1473
1528
|
case 6:
|
|
1474
|
-
return
|
|
1529
|
+
return _context72.a(2);
|
|
1475
1530
|
}
|
|
1476
|
-
},
|
|
1531
|
+
}, _callee72);
|
|
1477
1532
|
})));
|
|
1478
1533
|
it.each([new TypeError('Load failed'), {
|
|
1479
1534
|
statusCode: 502,
|
|
@@ -1482,11 +1537,11 @@ describe('cart load and replacement failures', function () {
|
|
|
1482
1537
|
statusCode: 403,
|
|
1483
1538
|
message: 'Forbidden'
|
|
1484
1539
|
}])('preserves the saved cart and never POSTs a replacement after %s', /*#__PURE__*/function () {
|
|
1485
|
-
var
|
|
1486
|
-
return _regenerator().w(function (
|
|
1487
|
-
while (1) switch (
|
|
1540
|
+
var _ref73 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(error) {
|
|
1541
|
+
return _regenerator().w(function (_context73) {
|
|
1542
|
+
while (1) switch (_context73.n) {
|
|
1488
1543
|
case 0:
|
|
1489
|
-
|
|
1544
|
+
_context73.n = 1;
|
|
1490
1545
|
return mount(error);
|
|
1491
1546
|
case 1:
|
|
1492
1547
|
expect(getCartCookie).toHaveBeenCalledWith(5);
|
|
@@ -1502,20 +1557,20 @@ describe('cart load and replacement failures', function () {
|
|
|
1502
1557
|
expect(context.fetchingCart).toBe(false);
|
|
1503
1558
|
expect(reportCartFailure).toHaveBeenCalledWith(error, CART_FAILURE_SOURCES.load);
|
|
1504
1559
|
case 2:
|
|
1505
|
-
return
|
|
1560
|
+
return _context73.a(2);
|
|
1506
1561
|
}
|
|
1507
|
-
},
|
|
1562
|
+
}, _callee73);
|
|
1508
1563
|
}));
|
|
1509
1564
|
return function (_x3) {
|
|
1510
|
-
return
|
|
1565
|
+
return _ref73.apply(this, arguments);
|
|
1511
1566
|
};
|
|
1512
1567
|
}());
|
|
1513
1568
|
it.each([404, 410])('replaces a genuinely missing cart after HTTP %s', /*#__PURE__*/function () {
|
|
1514
|
-
var
|
|
1515
|
-
return _regenerator().w(function (
|
|
1516
|
-
while (1) switch (
|
|
1569
|
+
var _ref74 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(statusCode) {
|
|
1570
|
+
return _regenerator().w(function (_context74) {
|
|
1571
|
+
while (1) switch (_context74.n) {
|
|
1517
1572
|
case 0:
|
|
1518
|
-
|
|
1573
|
+
_context74.n = 1;
|
|
1519
1574
|
return mount({
|
|
1520
1575
|
statusCode: statusCode
|
|
1521
1576
|
});
|
|
@@ -1526,19 +1581,19 @@ describe('cart load and replacement failures', function () {
|
|
|
1526
1581
|
}));
|
|
1527
1582
|
expect(setCartCookie).toHaveBeenCalledTimes(1);
|
|
1528
1583
|
case 2:
|
|
1529
|
-
return
|
|
1584
|
+
return _context74.a(2);
|
|
1530
1585
|
}
|
|
1531
|
-
},
|
|
1586
|
+
}, _callee74);
|
|
1532
1587
|
}));
|
|
1533
1588
|
return function (_x4) {
|
|
1534
|
-
return
|
|
1589
|
+
return _ref74.apply(this, arguments);
|
|
1535
1590
|
};
|
|
1536
1591
|
}());
|
|
1537
|
-
it('allows an explicit retry to restore the same cart without creating another', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1538
|
-
return _regenerator().w(function (
|
|
1539
|
-
while (1) switch (
|
|
1592
|
+
it('allows an explicit retry to restore the same cart without creating another', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76() {
|
|
1593
|
+
return _regenerator().w(function (_context76) {
|
|
1594
|
+
while (1) switch (_context76.n) {
|
|
1540
1595
|
case 0:
|
|
1541
|
-
|
|
1596
|
+
_context76.n = 1;
|
|
1542
1597
|
return mount(new TypeError('Load failed'));
|
|
1543
1598
|
case 1:
|
|
1544
1599
|
mockGet.mockResolvedValue({
|
|
@@ -1552,17 +1607,17 @@ describe('cart load and replacement failures', function () {
|
|
|
1552
1607
|
};
|
|
1553
1608
|
}
|
|
1554
1609
|
});
|
|
1555
|
-
|
|
1556
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1557
|
-
return _regenerator().w(function (
|
|
1558
|
-
while (1) switch (
|
|
1610
|
+
_context76.n = 2;
|
|
1611
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75() {
|
|
1612
|
+
return _regenerator().w(function (_context75) {
|
|
1613
|
+
while (1) switch (_context75.n) {
|
|
1559
1614
|
case 0:
|
|
1560
|
-
|
|
1615
|
+
_context75.n = 1;
|
|
1561
1616
|
return window.getCart();
|
|
1562
1617
|
case 1:
|
|
1563
|
-
return
|
|
1618
|
+
return _context75.a(2);
|
|
1564
1619
|
}
|
|
1565
|
-
},
|
|
1620
|
+
}, _callee75);
|
|
1566
1621
|
})));
|
|
1567
1622
|
case 2:
|
|
1568
1623
|
expect(context.cart.id).toBe(42);
|
|
@@ -1570,25 +1625,25 @@ describe('cart load and replacement failures', function () {
|
|
|
1570
1625
|
expect(mockPost).not.toHaveBeenCalled();
|
|
1571
1626
|
expect(context.alert.show).toBe(false);
|
|
1572
1627
|
case 3:
|
|
1573
|
-
return
|
|
1628
|
+
return _context76.a(2);
|
|
1574
1629
|
}
|
|
1575
|
-
},
|
|
1630
|
+
}, _callee76);
|
|
1576
1631
|
})));
|
|
1577
|
-
it('preserves an unrelated alert when a cart read succeeds', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1578
|
-
return _regenerator().w(function (
|
|
1579
|
-
while (1) switch (
|
|
1632
|
+
it('preserves an unrelated alert when a cart read succeeds', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79() {
|
|
1633
|
+
return _regenerator().w(function (_context79) {
|
|
1634
|
+
while (1) switch (_context79.n) {
|
|
1580
1635
|
case 0:
|
|
1581
|
-
|
|
1636
|
+
_context79.n = 1;
|
|
1582
1637
|
return mount(new TypeError('Load failed'));
|
|
1583
1638
|
case 1:
|
|
1584
|
-
|
|
1585
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1586
|
-
return _regenerator().w(function (
|
|
1587
|
-
while (1) switch (
|
|
1639
|
+
_context79.n = 2;
|
|
1640
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77() {
|
|
1641
|
+
return _regenerator().w(function (_context77) {
|
|
1642
|
+
while (1) switch (_context77.n) {
|
|
1588
1643
|
case 0:
|
|
1589
|
-
return
|
|
1644
|
+
return _context77.a(2, context.alertError('The discount could not be applied.'));
|
|
1590
1645
|
}
|
|
1591
|
-
},
|
|
1646
|
+
}, _callee77);
|
|
1592
1647
|
})));
|
|
1593
1648
|
case 2:
|
|
1594
1649
|
mockGet.mockResolvedValue({
|
|
@@ -1602,49 +1657,49 @@ describe('cart load and replacement failures', function () {
|
|
|
1602
1657
|
};
|
|
1603
1658
|
}
|
|
1604
1659
|
});
|
|
1605
|
-
|
|
1606
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1607
|
-
return _regenerator().w(function (
|
|
1608
|
-
while (1) switch (
|
|
1660
|
+
_context79.n = 3;
|
|
1661
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78() {
|
|
1662
|
+
return _regenerator().w(function (_context78) {
|
|
1663
|
+
while (1) switch (_context78.n) {
|
|
1609
1664
|
case 0:
|
|
1610
|
-
|
|
1665
|
+
_context78.n = 1;
|
|
1611
1666
|
return window.getCart();
|
|
1612
1667
|
case 1:
|
|
1613
|
-
return
|
|
1668
|
+
return _context78.a(2);
|
|
1614
1669
|
}
|
|
1615
|
-
},
|
|
1670
|
+
}, _callee78);
|
|
1616
1671
|
})));
|
|
1617
1672
|
case 3:
|
|
1618
1673
|
expect(context.alert.show).toBe(true);
|
|
1619
1674
|
expect(context.alert.message).toBe('The discount could not be applied.');
|
|
1620
1675
|
case 4:
|
|
1621
|
-
return
|
|
1676
|
+
return _context79.a(2);
|
|
1622
1677
|
}
|
|
1623
|
-
},
|
|
1678
|
+
}, _callee79);
|
|
1624
1679
|
})));
|
|
1625
1680
|
it.each([new TypeError('Failed to fetch'), {
|
|
1626
1681
|
statusCode: 503,
|
|
1627
1682
|
message: 'Service unavailable'
|
|
1628
1683
|
}, null, undefined])('keeps the clear-cart panel and saved cart when replacement fails with %s', /*#__PURE__*/function () {
|
|
1629
|
-
var
|
|
1630
|
-
return _regenerator().w(function (
|
|
1631
|
-
while (1) switch (
|
|
1684
|
+
var _ref80 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(error) {
|
|
1685
|
+
return _regenerator().w(function (_context81) {
|
|
1686
|
+
while (1) switch (_context81.n) {
|
|
1632
1687
|
case 0:
|
|
1633
|
-
|
|
1688
|
+
_context81.n = 1;
|
|
1634
1689
|
return mountSavedCart();
|
|
1635
1690
|
case 1:
|
|
1636
1691
|
mockPost.mockRejectedValueOnce(error);
|
|
1637
|
-
|
|
1638
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1639
|
-
return _regenerator().w(function (
|
|
1640
|
-
while (1) switch (
|
|
1692
|
+
_context81.n = 2;
|
|
1693
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80() {
|
|
1694
|
+
return _regenerator().w(function (_context80) {
|
|
1695
|
+
while (1) switch (_context80.n) {
|
|
1641
1696
|
case 0:
|
|
1642
|
-
|
|
1697
|
+
_context80.n = 1;
|
|
1643
1698
|
return context.clearCart();
|
|
1644
1699
|
case 1:
|
|
1645
|
-
return
|
|
1700
|
+
return _context80.a(2);
|
|
1646
1701
|
}
|
|
1647
|
-
},
|
|
1702
|
+
}, _callee80);
|
|
1648
1703
|
})));
|
|
1649
1704
|
case 2:
|
|
1650
1705
|
expect(context.activeTabIndex).toBe(tabIdClearCart);
|
|
@@ -1662,47 +1717,47 @@ describe('cart load and replacement failures', function () {
|
|
|
1662
1717
|
expect(context.alert.message).toBe((error === null || error === void 0 ? void 0 : error.message) || 'Unable to fetch cart.');
|
|
1663
1718
|
expect(context.fetchingCart).toBe(false);
|
|
1664
1719
|
case 3:
|
|
1665
|
-
return
|
|
1720
|
+
return _context81.a(2);
|
|
1666
1721
|
}
|
|
1667
|
-
},
|
|
1722
|
+
}, _callee81);
|
|
1668
1723
|
}));
|
|
1669
1724
|
return function (_x5) {
|
|
1670
|
-
return
|
|
1725
|
+
return _ref80.apply(this, arguments);
|
|
1671
1726
|
};
|
|
1672
1727
|
}());
|
|
1673
|
-
it('finishes clearing only after an explicit retry successfully creates the replacement', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1674
|
-
return _regenerator().w(function (
|
|
1675
|
-
while (1) switch (
|
|
1728
|
+
it('finishes clearing only after an explicit retry successfully creates the replacement', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84() {
|
|
1729
|
+
return _regenerator().w(function (_context84) {
|
|
1730
|
+
while (1) switch (_context84.n) {
|
|
1676
1731
|
case 0:
|
|
1677
|
-
|
|
1732
|
+
_context84.n = 1;
|
|
1678
1733
|
return mountSavedCart();
|
|
1679
1734
|
case 1:
|
|
1680
1735
|
mockPost.mockRejectedValueOnce(new TypeError('Failed to fetch'));
|
|
1681
|
-
|
|
1682
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1683
|
-
return _regenerator().w(function (
|
|
1684
|
-
while (1) switch (
|
|
1736
|
+
_context84.n = 2;
|
|
1737
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82() {
|
|
1738
|
+
return _regenerator().w(function (_context82) {
|
|
1739
|
+
while (1) switch (_context82.n) {
|
|
1685
1740
|
case 0:
|
|
1686
|
-
|
|
1741
|
+
_context82.n = 1;
|
|
1687
1742
|
return context.clearCart();
|
|
1688
1743
|
case 1:
|
|
1689
|
-
return
|
|
1744
|
+
return _context82.a(2);
|
|
1690
1745
|
}
|
|
1691
|
-
},
|
|
1746
|
+
}, _callee82);
|
|
1692
1747
|
})));
|
|
1693
1748
|
case 2:
|
|
1694
1749
|
expect(context.activeTabIndex).toBe(tabIdClearCart);
|
|
1695
|
-
|
|
1696
|
-
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1697
|
-
return _regenerator().w(function (
|
|
1698
|
-
while (1) switch (
|
|
1750
|
+
_context84.n = 3;
|
|
1751
|
+
return act(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83() {
|
|
1752
|
+
return _regenerator().w(function (_context83) {
|
|
1753
|
+
while (1) switch (_context83.n) {
|
|
1699
1754
|
case 0:
|
|
1700
|
-
|
|
1755
|
+
_context83.n = 1;
|
|
1701
1756
|
return context.clearCart();
|
|
1702
1757
|
case 1:
|
|
1703
|
-
return
|
|
1758
|
+
return _context83.a(2);
|
|
1704
1759
|
}
|
|
1705
|
-
},
|
|
1760
|
+
}, _callee83);
|
|
1706
1761
|
})));
|
|
1707
1762
|
case 3:
|
|
1708
1763
|
expect(mockPost).toHaveBeenCalledTimes(2);
|
|
@@ -1712,8 +1767,8 @@ describe('cart load and replacement failures', function () {
|
|
|
1712
1767
|
expect(context.alert.show).toBe(false);
|
|
1713
1768
|
expect(context.fetchingCart).toBe(false);
|
|
1714
1769
|
case 4:
|
|
1715
|
-
return
|
|
1770
|
+
return _context84.a(2);
|
|
1716
1771
|
}
|
|
1717
|
-
},
|
|
1772
|
+
}, _callee84);
|
|
1718
1773
|
})));
|
|
1719
1774
|
});
|