@adobe/spacecat-shared-tokowaka-client 1.5.6 → 1.5.8
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-tokowaka-client-v1.5.8](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.5.7...@adobe/spacecat-shared-tokowaka-client-v1.5.8) (2026-01-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* rename x-edge-optimize to x-edgeoptimize ([#1284](https://github.com/adobe/spacecat-shared/issues/1284)) ([63ba2ac](https://github.com/adobe/spacecat-shared/commit/63ba2ac9141612a5f581b0162cb1b30343c5980c))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-tokowaka-client-v1.5.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.5.6...@adobe/spacecat-shared-tokowaka-client-v1.5.7) (2026-01-22)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* headings mapper for invalid headings ([#1281](https://github.com/adobe/spacecat-shared/issues/1281)) ([01734df](https://github.com/adobe/spacecat-shared/commit/01734df0de2f9d43bb6c2ee0636449c26d336ca7))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-tokowaka-client-v1.5.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.5.5...@adobe/spacecat-shared-tokowaka-client-v1.5.6) (2026-01-22)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -67,6 +67,10 @@ export default class HeadingsMapper extends BaseOpportunityMapper {
|
|
|
67
67
|
patch.tag = transformRules.tag;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
if (checkType === 'heading-order-invalid') {
|
|
71
|
+
patch.value = transformRules.value;
|
|
72
|
+
patch.valueFormat = transformRules.valueFormat;
|
|
73
|
+
}
|
|
70
74
|
patches.push(patch);
|
|
71
75
|
});
|
|
72
76
|
|
|
@@ -52,14 +52,14 @@ async function fetchWithRetry(url, options, maxRetries, retryDelayMs, log, fetch
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// Check for edge optimize headers
|
|
55
|
-
const cacheHeader = response.headers.get('x-
|
|
56
|
-
const proxyHeader = response.headers.get('x-
|
|
55
|
+
const cacheHeader = response.headers.get('x-edgeoptimize-cache');
|
|
56
|
+
const proxyHeader = response.headers.get('x-edgeoptimize-proxy');
|
|
57
57
|
|
|
58
58
|
log.debug(`Headers - cache: ${cacheHeader || 'none'}, proxy: ${proxyHeader || 'none'}`);
|
|
59
59
|
|
|
60
60
|
// Case 1: Cache header present (regardless of proxy) -> Success
|
|
61
61
|
if (cacheHeader) {
|
|
62
|
-
log.debug(`Cache header found (x-
|
|
62
|
+
log.debug(`Cache header found (x-edgeoptimize-cache: ${cacheHeader}), stopping retry logic`);
|
|
63
63
|
return response;
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -80,7 +80,7 @@ async function fetchWithRetry(url, options, maxRetries, retryDelayMs, log, fetch
|
|
|
80
80
|
} else {
|
|
81
81
|
// Last attempt - throw error
|
|
82
82
|
log.error(`Max retries (${maxRetries}) exhausted. Proxy header present but cache header not found`);
|
|
83
|
-
throw new Error(`Cache header (x-
|
|
83
|
+
throw new Error(`Cache header (x-edgeoptimize-cache) not found after ${maxRetries} retries`);
|
|
84
84
|
}
|
|
85
85
|
} catch (error) {
|
|
86
86
|
log.warn(`Attempt ${attempt} failed for ${fetchType} HTML, error: ${error.message}`);
|
|
@@ -158,15 +158,15 @@ export async function fetchHtmlWithWarmup(
|
|
|
158
158
|
|
|
159
159
|
const headers = {
|
|
160
160
|
'x-forwarded-host': forwardedHost,
|
|
161
|
-
'x-
|
|
162
|
-
'x-
|
|
161
|
+
'x-edgeoptimize-api-key': apiKey,
|
|
162
|
+
'x-edgeoptimize-url': urlPath,
|
|
163
163
|
'Accept-Encoding': 'identity', // Disable compression to avoid content-length: 0 issue
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
if (isOptimized) {
|
|
167
167
|
// Add tokowakaPreview param for optimized HTML
|
|
168
168
|
fullUrl = `${fullUrl}?tokowakaPreview=true`;
|
|
169
|
-
headers['x-
|
|
169
|
+
headers['x-edgeoptimize-url'] = `${urlPath}?tokowakaPreview=true`;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
const fetchOptions = {
|
package/test/index.test.js
CHANGED
|
@@ -2692,7 +2692,7 @@ describe('TokowakaClient', () => {
|
|
|
2692
2692
|
status: 200,
|
|
2693
2693
|
statusText: 'OK',
|
|
2694
2694
|
headers: {
|
|
2695
|
-
get: (name) => (name === 'x-
|
|
2695
|
+
get: (name) => (name === 'x-edgeoptimize-cache' ? 'HIT' : null),
|
|
2696
2696
|
},
|
|
2697
2697
|
text: async () => '<html><body>Test HTML</body></html>',
|
|
2698
2698
|
});
|
|
@@ -98,11 +98,12 @@ describe('HeadingsMapper', () => {
|
|
|
98
98
|
const suggestion = {
|
|
99
99
|
getData: () => ({
|
|
100
100
|
checkType: 'heading-order-invalid',
|
|
101
|
-
recommendedAction:
|
|
101
|
+
recommendedAction: 'Adjust heading levels to maintain proper hierarchy.',
|
|
102
102
|
transformRules: {
|
|
103
103
|
action: 'replaceWith',
|
|
104
104
|
selector: '.invalid-section',
|
|
105
105
|
valueFormat: 'hast',
|
|
106
|
+
value: { type: 'element', tagName: 'h2', children: [] },
|
|
106
107
|
},
|
|
107
108
|
}),
|
|
108
109
|
};
|
|
@@ -254,11 +255,12 @@ describe('HeadingsMapper', () => {
|
|
|
254
255
|
const suggestion = {
|
|
255
256
|
getData: () => ({
|
|
256
257
|
checkType: 'heading-order-invalid',
|
|
257
|
-
recommendedAction:
|
|
258
|
+
recommendedAction: 'Adjust heading levels to maintain proper hierarchy.',
|
|
258
259
|
transformRules: {
|
|
259
260
|
action: 'replace',
|
|
260
261
|
selector: '.invalid-section',
|
|
261
262
|
valueFormat: 'hast',
|
|
263
|
+
value: { type: 'element', tagName: 'h2', children: [] },
|
|
262
264
|
},
|
|
263
265
|
}),
|
|
264
266
|
};
|
|
@@ -275,10 +277,11 @@ describe('HeadingsMapper', () => {
|
|
|
275
277
|
const suggestion = {
|
|
276
278
|
getData: () => ({
|
|
277
279
|
checkType: 'heading-order-invalid',
|
|
278
|
-
recommendedAction:
|
|
280
|
+
recommendedAction: 'Adjust heading levels to maintain proper hierarchy.',
|
|
279
281
|
transformRules: {
|
|
280
282
|
action: 'replaceWith',
|
|
281
283
|
selector: '.invalid-section',
|
|
284
|
+
value: { type: 'element', tagName: 'h2', children: [] },
|
|
282
285
|
},
|
|
283
286
|
}),
|
|
284
287
|
};
|
|
@@ -295,11 +298,12 @@ describe('HeadingsMapper', () => {
|
|
|
295
298
|
const suggestion = {
|
|
296
299
|
getData: () => ({
|
|
297
300
|
checkType: 'heading-order-invalid',
|
|
298
|
-
recommendedAction:
|
|
301
|
+
recommendedAction: 'Adjust heading levels to maintain proper hierarchy.',
|
|
299
302
|
transformRules: {
|
|
300
303
|
action: 'replaceWith',
|
|
301
304
|
selector: '.invalid-section',
|
|
302
305
|
valueFormat: 'text',
|
|
306
|
+
value: { type: 'element', tagName: 'h2', children: [] },
|
|
303
307
|
},
|
|
304
308
|
}),
|
|
305
309
|
};
|
|
@@ -447,11 +451,12 @@ describe('HeadingsMapper', () => {
|
|
|
447
451
|
getUpdatedAt: () => '2025-01-15T10:00:00.000Z',
|
|
448
452
|
getData: () => ({
|
|
449
453
|
checkType: 'heading-order-invalid',
|
|
450
|
-
recommendedAction:
|
|
454
|
+
recommendedAction: 'Adjust heading levels to maintain proper hierarchy.',
|
|
451
455
|
transformRules: {
|
|
452
456
|
action: 'replaceWith',
|
|
453
457
|
selector: '.content-section',
|
|
454
458
|
valueFormat: 'hast',
|
|
459
|
+
value: hastValue,
|
|
455
460
|
},
|
|
456
461
|
}),
|
|
457
462
|
};
|
|
@@ -464,6 +469,7 @@ describe('HeadingsMapper', () => {
|
|
|
464
469
|
op: 'replaceWith',
|
|
465
470
|
selector: '.content-section',
|
|
466
471
|
value: hastValue,
|
|
472
|
+
valueFormat: 'hast',
|
|
467
473
|
opportunityId: 'opp-101',
|
|
468
474
|
suggestionId: 'sugg-101',
|
|
469
475
|
prerenderRequired: true,
|
|
@@ -477,7 +483,7 @@ describe('HeadingsMapper', () => {
|
|
|
477
483
|
getId: () => 'sugg-102',
|
|
478
484
|
getData: () => ({
|
|
479
485
|
checkType: 'heading-order-invalid',
|
|
480
|
-
recommendedAction:
|
|
486
|
+
recommendedAction: 'Adjust heading levels to maintain proper hierarchy.',
|
|
481
487
|
}),
|
|
482
488
|
};
|
|
483
489
|
|
|
@@ -490,11 +496,12 @@ describe('HeadingsMapper', () => {
|
|
|
490
496
|
getId: () => 'sugg-103',
|
|
491
497
|
getData: () => ({
|
|
492
498
|
checkType: 'heading-order-invalid',
|
|
493
|
-
recommendedAction:
|
|
499
|
+
recommendedAction: 'Adjust heading levels to maintain proper hierarchy.',
|
|
494
500
|
transformRules: {
|
|
495
501
|
action: 'replace',
|
|
496
502
|
selector: '.content-section',
|
|
497
503
|
valueFormat: 'hast',
|
|
504
|
+
value: { type: 'element', tagName: 'h2', children: [] },
|
|
498
505
|
},
|
|
499
506
|
}),
|
|
500
507
|
};
|
|
@@ -503,6 +510,233 @@ describe('HeadingsMapper', () => {
|
|
|
503
510
|
expect(patches.length).to.equal(0);
|
|
504
511
|
});
|
|
505
512
|
|
|
513
|
+
it('should create patch for heading-order-invalid with real-world HAST structure', () => {
|
|
514
|
+
const hastValue = {
|
|
515
|
+
type: 'root',
|
|
516
|
+
children: [
|
|
517
|
+
{
|
|
518
|
+
type: 'element',
|
|
519
|
+
tagName: 'h2',
|
|
520
|
+
children: [
|
|
521
|
+
{
|
|
522
|
+
type: 'text',
|
|
523
|
+
value: 'Complete Cover Sets',
|
|
524
|
+
},
|
|
525
|
+
],
|
|
526
|
+
properties: {},
|
|
527
|
+
},
|
|
528
|
+
],
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
const suggestion = {
|
|
532
|
+
getId: () => 'sugg-104',
|
|
533
|
+
getUpdatedAt: () => '2026-01-03T06:24:06.229Z',
|
|
534
|
+
getData: () => ({
|
|
535
|
+
checkType: 'heading-order-invalid',
|
|
536
|
+
recommendedAction: 'Adjust heading levels to maintain proper hierarchy.',
|
|
537
|
+
transformRules: {
|
|
538
|
+
action: 'replaceWith',
|
|
539
|
+
selector: 'h4#complete-cover-sets',
|
|
540
|
+
valueFormat: 'hast',
|
|
541
|
+
value: hastValue,
|
|
542
|
+
scrapedAt: '2026-01-03T06:24:06.229Z',
|
|
543
|
+
currValue: 'Complete Cover Sets',
|
|
544
|
+
},
|
|
545
|
+
}),
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
const patches = mapper.suggestionsToPatches('/path', [suggestion], 'opp-104');
|
|
549
|
+
expect(patches.length).to.equal(1);
|
|
550
|
+
const patch = patches[0];
|
|
551
|
+
|
|
552
|
+
expect(patch).to.deep.include({
|
|
553
|
+
op: 'replaceWith',
|
|
554
|
+
selector: 'h4#complete-cover-sets',
|
|
555
|
+
value: hastValue,
|
|
556
|
+
valueFormat: 'hast',
|
|
557
|
+
opportunityId: 'opp-104',
|
|
558
|
+
suggestionId: 'sugg-104',
|
|
559
|
+
prerenderRequired: true,
|
|
560
|
+
});
|
|
561
|
+
expect(patch.lastUpdated).to.be.a('number');
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
it('should create patch for heading-order-invalid with complex selector', () => {
|
|
565
|
+
const hastValue = {
|
|
566
|
+
type: 'root',
|
|
567
|
+
children: [
|
|
568
|
+
{
|
|
569
|
+
type: 'element',
|
|
570
|
+
tagName: 'h3',
|
|
571
|
+
properties: { id: 'section-title' },
|
|
572
|
+
children: [{ type: 'text', value: 'Updated Section' }],
|
|
573
|
+
},
|
|
574
|
+
],
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
const suggestion = {
|
|
578
|
+
getId: () => 'sugg-105',
|
|
579
|
+
getUpdatedAt: () => '2025-01-15T10:00:00.000Z',
|
|
580
|
+
getData: () => ({
|
|
581
|
+
checkType: 'heading-order-invalid',
|
|
582
|
+
recommendedAction: 'Fix heading hierarchy from h5 to h3.',
|
|
583
|
+
transformRules: {
|
|
584
|
+
action: 'replaceWith',
|
|
585
|
+
selector: 'body > main > section:nth-child(2) > h5',
|
|
586
|
+
valueFormat: 'hast',
|
|
587
|
+
value: hastValue,
|
|
588
|
+
},
|
|
589
|
+
}),
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
const patches = mapper.suggestionsToPatches('/path', [suggestion], 'opp-105');
|
|
593
|
+
expect(patches.length).to.equal(1);
|
|
594
|
+
const patch = patches[0];
|
|
595
|
+
|
|
596
|
+
expect(patch.selector).to.equal('body > main > section:nth-child(2) > h5');
|
|
597
|
+
expect(patch.value).to.deep.equal(hastValue);
|
|
598
|
+
expect(patch.valueFormat).to.equal('hast');
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
it('should handle multiple heading-order-invalid suggestions', () => {
|
|
602
|
+
const suggestions = [
|
|
603
|
+
{
|
|
604
|
+
getId: () => 'sugg-106',
|
|
605
|
+
getUpdatedAt: () => '2025-01-15T10:00:00.000Z',
|
|
606
|
+
getData: () => ({
|
|
607
|
+
checkType: 'heading-order-invalid',
|
|
608
|
+
recommendedAction: 'Fix heading hierarchy.',
|
|
609
|
+
transformRules: {
|
|
610
|
+
action: 'replaceWith',
|
|
611
|
+
selector: 'h4.title',
|
|
612
|
+
valueFormat: 'hast',
|
|
613
|
+
value: {
|
|
614
|
+
type: 'root',
|
|
615
|
+
children: [
|
|
616
|
+
{
|
|
617
|
+
type: 'element',
|
|
618
|
+
tagName: 'h2',
|
|
619
|
+
properties: { class: 'title' },
|
|
620
|
+
children: [{ type: 'text', value: 'Title 1' }],
|
|
621
|
+
},
|
|
622
|
+
],
|
|
623
|
+
},
|
|
624
|
+
},
|
|
625
|
+
}),
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
getId: () => 'sugg-107',
|
|
629
|
+
getUpdatedAt: () => '2025-01-15T10:00:00.000Z',
|
|
630
|
+
getData: () => ({
|
|
631
|
+
checkType: 'heading-order-invalid',
|
|
632
|
+
recommendedAction: 'Fix another heading.',
|
|
633
|
+
transformRules: {
|
|
634
|
+
action: 'replaceWith',
|
|
635
|
+
selector: 'h5.subtitle',
|
|
636
|
+
valueFormat: 'hast',
|
|
637
|
+
value: {
|
|
638
|
+
type: 'root',
|
|
639
|
+
children: [
|
|
640
|
+
{
|
|
641
|
+
type: 'element',
|
|
642
|
+
tagName: 'h3',
|
|
643
|
+
properties: { class: 'subtitle' },
|
|
644
|
+
children: [{ type: 'text', value: 'Subtitle' }],
|
|
645
|
+
},
|
|
646
|
+
],
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
}),
|
|
650
|
+
},
|
|
651
|
+
];
|
|
652
|
+
|
|
653
|
+
const patches = mapper.suggestionsToPatches('/path', suggestions, 'opp-106');
|
|
654
|
+
expect(patches.length).to.equal(2);
|
|
655
|
+
expect(patches[0].selector).to.equal('h4.title');
|
|
656
|
+
expect(patches[1].selector).to.equal('h5.subtitle');
|
|
657
|
+
expect(patches[0].valueFormat).to.equal('hast');
|
|
658
|
+
expect(patches[1].valueFormat).to.equal('hast');
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
it('should not use text valueFormat for heading-order-invalid', () => {
|
|
662
|
+
const hastValue = {
|
|
663
|
+
type: 'root',
|
|
664
|
+
children: [
|
|
665
|
+
{ type: 'element', tagName: 'h2', children: [{ type: 'text', value: 'Heading' }] },
|
|
666
|
+
],
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
const suggestion = {
|
|
670
|
+
getId: () => 'sugg-108',
|
|
671
|
+
getUpdatedAt: () => '2025-01-15T10:00:00.000Z',
|
|
672
|
+
getData: () => ({
|
|
673
|
+
checkType: 'heading-order-invalid',
|
|
674
|
+
recommendedAction: 'Fix heading hierarchy.',
|
|
675
|
+
transformRules: {
|
|
676
|
+
action: 'replaceWith',
|
|
677
|
+
selector: 'h4',
|
|
678
|
+
valueFormat: 'hast',
|
|
679
|
+
value: hastValue,
|
|
680
|
+
},
|
|
681
|
+
}),
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
const patches = mapper.suggestionsToPatches('/path', [suggestion], 'opp-108');
|
|
685
|
+
expect(patches.length).to.equal(1);
|
|
686
|
+
const patch = patches[0];
|
|
687
|
+
|
|
688
|
+
// Verify it uses HAST format, not text
|
|
689
|
+
expect(patch.valueFormat).to.equal('hast');
|
|
690
|
+
expect(patch.value).to.be.an('object');
|
|
691
|
+
expect(patch.value).to.deep.equal(hastValue);
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
it('should include currValue when currentValue is not null for heading-empty', () => {
|
|
695
|
+
const suggestion = {
|
|
696
|
+
getId: () => 'sugg-109',
|
|
697
|
+
getUpdatedAt: () => '2025-01-15T10:00:00.000Z',
|
|
698
|
+
getData: () => ({
|
|
699
|
+
checkType: 'heading-empty',
|
|
700
|
+
recommendedAction: 'New Heading Text',
|
|
701
|
+
currentValue: 'Old Heading',
|
|
702
|
+
transformRules: {
|
|
703
|
+
action: 'replace',
|
|
704
|
+
selector: 'h2.empty',
|
|
705
|
+
},
|
|
706
|
+
}),
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
const patches = mapper.suggestionsToPatches('/path', [suggestion], 'opp-109');
|
|
710
|
+
expect(patches.length).to.equal(1);
|
|
711
|
+
const patch = patches[0];
|
|
712
|
+
|
|
713
|
+
expect(patch.currValue).to.equal('Old Heading');
|
|
714
|
+
expect(patch.value).to.equal('New Heading Text');
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
it('should not include currValue when currentValue is null', () => {
|
|
718
|
+
const suggestion = {
|
|
719
|
+
getId: () => 'sugg-110',
|
|
720
|
+
getUpdatedAt: () => '2025-01-15T10:00:00.000Z',
|
|
721
|
+
getData: () => ({
|
|
722
|
+
checkType: 'heading-empty',
|
|
723
|
+
recommendedAction: 'New Heading Text',
|
|
724
|
+
currentValue: null,
|
|
725
|
+
transformRules: {
|
|
726
|
+
action: 'replace',
|
|
727
|
+
selector: 'h2.empty',
|
|
728
|
+
},
|
|
729
|
+
}),
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
const patches = mapper.suggestionsToPatches('/path', [suggestion], 'opp-110');
|
|
733
|
+
expect(patches.length).to.equal(1);
|
|
734
|
+
const patch = patches[0];
|
|
735
|
+
|
|
736
|
+
expect(patch.currValue).to.be.undefined;
|
|
737
|
+
expect(patch.value).to.equal('New Heading Text');
|
|
738
|
+
});
|
|
739
|
+
|
|
506
740
|
it('should return empty array for heading-missing-h1 without transformRules', () => {
|
|
507
741
|
const suggestion = {
|
|
508
742
|
getId: () => 'sugg-999',
|
|
@@ -104,7 +104,7 @@ describe('HTML Utils', () => {
|
|
|
104
104
|
status: 200,
|
|
105
105
|
statusText: 'OK',
|
|
106
106
|
headers: {
|
|
107
|
-
get: (name) => (name === 'x-
|
|
107
|
+
get: (name) => (name === 'x-edgeoptimize-cache' ? 'HIT' : null),
|
|
108
108
|
},
|
|
109
109
|
text: async () => '<html>Test HTML</html>',
|
|
110
110
|
});
|
|
@@ -129,7 +129,7 @@ describe('HTML Utils', () => {
|
|
|
129
129
|
status: 200,
|
|
130
130
|
statusText: 'OK',
|
|
131
131
|
headers: {
|
|
132
|
-
get: (name) => (name === 'x-
|
|
132
|
+
get: (name) => (name === 'x-edgeoptimize-cache' ? 'HIT' : null),
|
|
133
133
|
},
|
|
134
134
|
text: async () => '<html>Optimized HTML</html>',
|
|
135
135
|
});
|
|
@@ -208,7 +208,7 @@ describe('HTML Utils', () => {
|
|
|
208
208
|
status: 200,
|
|
209
209
|
statusText: 'OK',
|
|
210
210
|
headers: {
|
|
211
|
-
get: (name) => (name === 'x-
|
|
211
|
+
get: (name) => (name === 'x-edgeoptimize-proxy' ? 'true' : null),
|
|
212
212
|
},
|
|
213
213
|
text: async () => '<html>Proxy only 1</html>',
|
|
214
214
|
});
|
|
@@ -217,7 +217,7 @@ describe('HTML Utils', () => {
|
|
|
217
217
|
status: 200,
|
|
218
218
|
statusText: 'OK',
|
|
219
219
|
headers: {
|
|
220
|
-
get: (name) => (name === 'x-
|
|
220
|
+
get: (name) => (name === 'x-edgeoptimize-proxy' ? 'true' : null),
|
|
221
221
|
},
|
|
222
222
|
text: async () => '<html>Proxy only 2</html>',
|
|
223
223
|
});
|
|
@@ -226,7 +226,7 @@ describe('HTML Utils', () => {
|
|
|
226
226
|
status: 200,
|
|
227
227
|
statusText: 'OK',
|
|
228
228
|
headers: {
|
|
229
|
-
get: (name) => (name === 'x-
|
|
229
|
+
get: (name) => (name === 'x-edgeoptimize-proxy' ? 'true' : null),
|
|
230
230
|
},
|
|
231
231
|
text: async () => '<html>Proxy only 3</html>',
|
|
232
232
|
});
|
|
@@ -244,7 +244,7 @@ describe('HTML Utils', () => {
|
|
|
244
244
|
expect.fail('Should have thrown error');
|
|
245
245
|
} catch (error) {
|
|
246
246
|
expect(error.message).to.include('Failed to fetch optimized HTML');
|
|
247
|
-
expect(error.message).to.include('Cache header (x-
|
|
247
|
+
expect(error.message).to.include('Cache header (x-edgeoptimize-cache) not found after 2 retries');
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// Should have tried 3 times (initial + 2 retries) plus warmup
|
|
@@ -268,7 +268,7 @@ describe('HTML Utils', () => {
|
|
|
268
268
|
status: 200,
|
|
269
269
|
statusText: 'OK',
|
|
270
270
|
headers: {
|
|
271
|
-
get: (name) => (name === 'x-
|
|
271
|
+
get: (name) => (name === 'x-edgeoptimize-proxy' ? 'true' : null),
|
|
272
272
|
},
|
|
273
273
|
text: async () => '<html>Proxy only</html>',
|
|
274
274
|
});
|
|
@@ -278,7 +278,7 @@ describe('HTML Utils', () => {
|
|
|
278
278
|
status: 200,
|
|
279
279
|
statusText: 'OK',
|
|
280
280
|
headers: {
|
|
281
|
-
get: (name) => (name === 'x-
|
|
281
|
+
get: (name) => (name === 'x-edgeoptimize-cache' ? 'HIT' : null),
|
|
282
282
|
},
|
|
283
283
|
text: async () => '<html>Cached HTML</html>',
|
|
284
284
|
});
|
|
@@ -483,7 +483,7 @@ describe('HTML Utils', () => {
|
|
|
483
483
|
status: 200,
|
|
484
484
|
statusText: 'OK',
|
|
485
485
|
headers: {
|
|
486
|
-
get: (name) => (name === 'x-
|
|
486
|
+
get: (name) => (name === 'x-edgeoptimize-proxy' ? 'true' : null),
|
|
487
487
|
},
|
|
488
488
|
text: async () => '<html>Proxy only</html>',
|
|
489
489
|
});
|
|
@@ -494,8 +494,8 @@ describe('HTML Utils', () => {
|
|
|
494
494
|
statusText: 'OK',
|
|
495
495
|
headers: {
|
|
496
496
|
get: (name) => {
|
|
497
|
-
if (name === 'x-
|
|
498
|
-
if (name === 'x-
|
|
497
|
+
if (name === 'x-edgeoptimize-cache') return 'HIT';
|
|
498
|
+
if (name === 'x-edgeoptimize-proxy') return 'true';
|
|
499
499
|
return null;
|
|
500
500
|
},
|
|
501
501
|
},
|
|
@@ -534,7 +534,7 @@ describe('HTML Utils', () => {
|
|
|
534
534
|
status: 200,
|
|
535
535
|
statusText: 'OK',
|
|
536
536
|
headers: {
|
|
537
|
-
get: (name) => (name === 'x-
|
|
537
|
+
get: (name) => (name === 'x-edgeoptimize-proxy' ? 'true' : null),
|
|
538
538
|
},
|
|
539
539
|
text: async () => '<html>Proxy only 1</html>',
|
|
540
540
|
});
|
|
@@ -543,7 +543,7 @@ describe('HTML Utils', () => {
|
|
|
543
543
|
status: 200,
|
|
544
544
|
statusText: 'OK',
|
|
545
545
|
headers: {
|
|
546
|
-
get: (name) => (name === 'x-
|
|
546
|
+
get: (name) => (name === 'x-edgeoptimize-proxy' ? 'true' : null),
|
|
547
547
|
},
|
|
548
548
|
text: async () => '<html>Proxy only 2</html>',
|
|
549
549
|
});
|
|
@@ -552,7 +552,7 @@ describe('HTML Utils', () => {
|
|
|
552
552
|
status: 200,
|
|
553
553
|
statusText: 'OK',
|
|
554
554
|
headers: {
|
|
555
|
-
get: (name) => (name === 'x-
|
|
555
|
+
get: (name) => (name === 'x-edgeoptimize-proxy' ? 'true' : null),
|
|
556
556
|
},
|
|
557
557
|
text: async () => '<html>Proxy only 3</html>',
|
|
558
558
|
});
|
|
@@ -570,7 +570,7 @@ describe('HTML Utils', () => {
|
|
|
570
570
|
expect.fail('Should have thrown error');
|
|
571
571
|
} catch (error) {
|
|
572
572
|
expect(error.message).to.include('Failed to fetch original HTML');
|
|
573
|
-
expect(error.message).to.include('Cache header (x-
|
|
573
|
+
expect(error.message).to.include('Cache header (x-edgeoptimize-cache) not found after 2 retries');
|
|
574
574
|
}
|
|
575
575
|
|
|
576
576
|
// Should have tried 3 times (initial + 2 retries) plus warmup
|
|
@@ -594,7 +594,7 @@ describe('HTML Utils', () => {
|
|
|
594
594
|
status: 200,
|
|
595
595
|
statusText: 'OK',
|
|
596
596
|
headers: {
|
|
597
|
-
get: (name) => (name === 'x-
|
|
597
|
+
get: (name) => (name === 'x-edgeoptimize-cache' ? 'HIT' : null),
|
|
598
598
|
},
|
|
599
599
|
text: async () => '<html>Cached HTML</html>',
|
|
600
600
|
});
|
|
@@ -632,8 +632,8 @@ describe('HTML Utils', () => {
|
|
|
632
632
|
statusText: 'OK',
|
|
633
633
|
headers: {
|
|
634
634
|
get: (name) => {
|
|
635
|
-
if (name === 'x-
|
|
636
|
-
if (name === 'x-
|
|
635
|
+
if (name === 'x-edgeoptimize-cache') return 'HIT';
|
|
636
|
+
if (name === 'x-edgeoptimize-proxy') return 'true';
|
|
637
637
|
return null;
|
|
638
638
|
},
|
|
639
639
|
},
|
|
@@ -672,7 +672,7 @@ describe('HTML Utils', () => {
|
|
|
672
672
|
status: 200,
|
|
673
673
|
statusText: 'OK',
|
|
674
674
|
headers: {
|
|
675
|
-
get: (name) => (name === 'x-
|
|
675
|
+
get: (name) => (name === 'x-edgeoptimize-cache' ? 'HIT' : null),
|
|
676
676
|
},
|
|
677
677
|
text: async () => '<html>Cache only HTML</html>',
|
|
678
678
|
});
|