apostrophe 4.29.0 → 4.30.0-alpha.1
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 +6 -0
- package/claude-tools/detect-handles.js +46 -0
- package/claude-tools/minimal-hang-test.js +28 -0
- package/claude-tools/mongo-close-test.js +11 -0
- package/claude-tools/stdin-ref-test.js +14 -0
- package/eslint.config.js +2 -1
- package/modules/@apostrophecms/db/index.js +68 -27
- package/modules/@apostrophecms/http/index.js +1 -1
- package/modules/@apostrophecms/job/index.js +9 -7
- package/package.json +11 -11
- package/test/add-missing-schema-fields-project/test.js +11 -3
- package/test/assets.js +110 -67
- package/test/db-tools.js +365 -0
- package/test/db.js +24 -15
- package/test/default-adapter.js +256 -0
- package/test/job.js +1 -1
- package/test-lib/util.js +50 -14
- package/lib/mongodb-connect.js +0 -62
- package/test/add-missing-schema-fields-project/node_modules/.package-lock.json +0 -131
package/test/assets.js
CHANGED
|
@@ -98,15 +98,75 @@ describe('Assets', function() {
|
|
|
98
98
|
retryAssertTrue
|
|
99
99
|
} = loadUtils();
|
|
100
100
|
|
|
101
|
+
// Wait for the chokidar watcher to be ready before writing files.
|
|
102
|
+
// Without this, writes can happen before chokidar has finished its
|
|
103
|
+
// initial scan, so the change event is never emitted. This is
|
|
104
|
+
// especially visible with slower adapters like sqlite.
|
|
105
|
+
function waitForWatcherReady(watcher, timeoutMs = 10000) {
|
|
106
|
+
if (watcher._readyEmitted) {
|
|
107
|
+
return Promise.resolve();
|
|
108
|
+
}
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
const timer = setTimeout(() => reject(new Error('Watcher ready timeout')), timeoutMs);
|
|
111
|
+
watcher.on('ready', () => {
|
|
112
|
+
clearTimeout(timer);
|
|
113
|
+
resolve();
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Many asset tests modify source files in test/modules/ to trigger
|
|
119
|
+
// rebuilds, then restore them at the end. If a test fails mid-execution
|
|
120
|
+
// the files stay dirty and poison subsequent runs. To prevent this we
|
|
121
|
+
// snapshot every mutable file before the suite and restore them
|
|
122
|
+
// automatically after each test via afterEach. The before hook also
|
|
123
|
+
// cleans up build artifacts and webpack cache from prior runs.
|
|
124
|
+
const mutableFiles = [
|
|
125
|
+
'test/modules/bundle-page/ui/src/extra.js',
|
|
126
|
+
'test/modules/default-page/ui/src/index.js',
|
|
127
|
+
'test/modules/default-page/ui/src/index.scss',
|
|
128
|
+
'test/modules/default-page/ui/public/index.js',
|
|
129
|
+
'test/modules/default-page/ui/public/index.css',
|
|
130
|
+
'test/modules/default-page/ui/apos/components/FakeComponent.vue',
|
|
131
|
+
'test/package-lock.json'
|
|
132
|
+
].map((rel) => path.join(process.cwd(), rel));
|
|
133
|
+
const snapshots = new Map();
|
|
134
|
+
|
|
135
|
+
before(async function() {
|
|
136
|
+
// Snapshot every mutable file so afterEach can restore them
|
|
137
|
+
for (const file of mutableFiles) {
|
|
138
|
+
try {
|
|
139
|
+
snapshots.set(file, await fs.readFile(file));
|
|
140
|
+
} catch (e) {
|
|
141
|
+
// File might not exist yet, that's OK
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Start clean: remove build artifacts and cache from prior runs
|
|
145
|
+
await deleteBuiltFolders(publicFolderPath, true);
|
|
146
|
+
await removeCache();
|
|
147
|
+
});
|
|
148
|
+
|
|
101
149
|
after(async function() {
|
|
102
150
|
await deleteBuiltFolders(publicFolderPath, true);
|
|
103
151
|
await removeCache();
|
|
104
152
|
await t.destroy(apos);
|
|
105
153
|
});
|
|
106
154
|
|
|
107
|
-
afterEach(function() {
|
|
155
|
+
afterEach(async function() {
|
|
108
156
|
// Prevent hang forever if particular tests fail while testing prod.
|
|
109
157
|
process.env.NODE_ENV = 'development';
|
|
158
|
+
// Restore any files that were modified by the test
|
|
159
|
+
for (const [ file, content ] of snapshots) {
|
|
160
|
+
try {
|
|
161
|
+
const current = await fs.readFile(file);
|
|
162
|
+
if (!current.equals(content)) {
|
|
163
|
+
await fs.writeFile(file, content);
|
|
164
|
+
}
|
|
165
|
+
} catch (e) {
|
|
166
|
+
// If the file was deleted, restore it
|
|
167
|
+
await fs.writeFile(file, content);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
110
170
|
});
|
|
111
171
|
|
|
112
172
|
this.timeout(5 * 60 * 1000);
|
|
@@ -162,6 +222,7 @@ describe('Assets', function() {
|
|
|
162
222
|
});
|
|
163
223
|
|
|
164
224
|
it('should get webpack extensions from modules and fill extra bundles', async function () {
|
|
225
|
+
await t.destroy(apos);
|
|
165
226
|
const expectedEntryPointsNames = {
|
|
166
227
|
js: [ 'company', 'main', 'another', 'extra', 'extra2' ],
|
|
167
228
|
css: [ 'company', 'main', 'extra' ]
|
|
@@ -309,6 +370,7 @@ describe('Assets', function() {
|
|
|
309
370
|
});
|
|
310
371
|
|
|
311
372
|
it('should build with cache and gain performance', async function() {
|
|
373
|
+
await t.destroy(apos);
|
|
312
374
|
await removeCache();
|
|
313
375
|
await removeCache(cacheFolderPath.replace('/webpack-cache', '/changed'));
|
|
314
376
|
|
|
@@ -346,9 +408,11 @@ describe('Assets', function() {
|
|
|
346
408
|
assert(meta2['default:apos']);
|
|
347
409
|
assert(meta2['default:src']);
|
|
348
410
|
|
|
349
|
-
//
|
|
411
|
+
// Caching should provide a measurable speedup. The threshold is kept
|
|
412
|
+
// low (10%) to avoid flaky failures on loaded CI runners where the
|
|
413
|
+
// cold run can be fast due to OS-level caching.
|
|
350
414
|
const gain = (execTime - execTimeCached) / execTime * 100;
|
|
351
|
-
assert(gain >=
|
|
415
|
+
assert(gain >= 10, `Expected gain >=10%, got ${gain}%`);
|
|
352
416
|
|
|
353
417
|
// Modification times
|
|
354
418
|
assert(meta['default:apos'].mdate);
|
|
@@ -509,11 +573,11 @@ describe('Assets', function() {
|
|
|
509
573
|
assert(apos.asset.restartId);
|
|
510
574
|
assert(!result.builds);
|
|
511
575
|
assert(!result.changes);
|
|
576
|
+
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
512
577
|
|
|
513
578
|
// Modify asset and rebuild
|
|
514
579
|
const assetPath = path.join(process.cwd(), 'test/modules/bundle-page/ui/src/extra.js');
|
|
515
580
|
const assetPathPublic = path.join(process.cwd(), 'test/public/apos-frontend/default/extra-module-bundle.js');
|
|
516
|
-
const assetContent = fs.readFileSync(assetPath, 'utf-8');
|
|
517
581
|
fs.writeFileSync(
|
|
518
582
|
assetPath,
|
|
519
583
|
'export default () => { \'bundle-page-watcher-test-src\'; };\n',
|
|
@@ -524,34 +588,33 @@ describe('Assets', function() {
|
|
|
524
588
|
async () => (await fs.readFile(assetPathPublic, 'utf8')).match(/bundle-page-watcher-test-src/),
|
|
525
589
|
'Unable to verify public asset was rebuilt by the watcher',
|
|
526
590
|
500,
|
|
527
|
-
|
|
591
|
+
20000
|
|
528
592
|
);
|
|
529
593
|
|
|
530
594
|
await retryAssertTrue(
|
|
531
595
|
() => apos.asset.restartId !== restartId,
|
|
532
596
|
'Unable to verify restartId has been changed',
|
|
533
597
|
500,
|
|
534
|
-
|
|
598
|
+
20000
|
|
535
599
|
);
|
|
536
600
|
|
|
537
601
|
await retryAssertTrue(
|
|
538
602
|
() => result.builds.length === 1 && result.builds.includes('src'),
|
|
539
603
|
'Unable to verify build "src" has been triggered',
|
|
540
604
|
50,
|
|
541
|
-
|
|
605
|
+
2000
|
|
542
606
|
);
|
|
543
607
|
|
|
544
608
|
await retryAssertTrue(
|
|
545
609
|
() => result.changes.length === 1 && result.changes[0].includes('modules/bundle-page/ui/src/extra.js'),
|
|
546
610
|
'Unable to verify changes contain the proper file',
|
|
547
611
|
50,
|
|
548
|
-
|
|
612
|
+
2000
|
|
549
613
|
);
|
|
550
614
|
|
|
551
615
|
await t.destroy(apos);
|
|
552
616
|
assert.equal(apos.asset.buildWatcher, null);
|
|
553
617
|
apos = null;
|
|
554
|
-
fs.writeFileSync(assetPath, assetContent, 'utf8');
|
|
555
618
|
});
|
|
556
619
|
|
|
557
620
|
it('should watch and rebuild assets and reload page in development (src)', async function() {
|
|
@@ -567,12 +630,6 @@ describe('Assets', function() {
|
|
|
567
630
|
const assetPathPublicCss = path.join(rootPath, 'test/public/apos-frontend/default/public-bundle.css');
|
|
568
631
|
const assetPathAposJs = path.join(rootPath, 'test/public/apos-frontend/default/apos-module-bundle.js');
|
|
569
632
|
const assetPathAposCss = path.join(rootPath, 'test/public/apos-frontend/default/apos-bundle.css');
|
|
570
|
-
const assetContentJs = fs.readFileSync(assetPathJs, 'utf-8');
|
|
571
|
-
const assetContentScss = fs.readFileSync(assetPathScss, 'utf-8');
|
|
572
|
-
// Resurrect the default assets content if test has failed
|
|
573
|
-
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
574
|
-
fs.writeFileSync(assetPathScss, assetContentScss, 'utf8');
|
|
575
|
-
|
|
576
633
|
apos = await t.create({
|
|
577
634
|
root: module,
|
|
578
635
|
autoBuild: true,
|
|
@@ -595,6 +652,7 @@ describe('Assets', function() {
|
|
|
595
652
|
assert(apos.asset.restartId);
|
|
596
653
|
assert(!result.builds);
|
|
597
654
|
assert(!result.changes);
|
|
655
|
+
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
598
656
|
|
|
599
657
|
// * modify assets and rebuild
|
|
600
658
|
fs.writeFileSync(
|
|
@@ -613,13 +671,13 @@ describe('Assets', function() {
|
|
|
613
671
|
async () => (await fs.readFile(assetPathPublicJs, 'utf8')).match(/default-page-watcher-test-src/),
|
|
614
672
|
'Unable to verify public JS asset was rebuilt by the watcher',
|
|
615
673
|
500,
|
|
616
|
-
|
|
674
|
+
20000
|
|
617
675
|
);
|
|
618
676
|
await retryAssertTrue(
|
|
619
677
|
async () => (await fs.readFile(assetPathPublicCss, 'utf8')).match(/\.default-page-watcher-test-src/),
|
|
620
678
|
'Unable to verify public CSS asset was rebuilt by the watcher',
|
|
621
679
|
500,
|
|
622
|
-
|
|
680
|
+
20000
|
|
623
681
|
);
|
|
624
682
|
|
|
625
683
|
// * change is in the apos bundle
|
|
@@ -627,13 +685,13 @@ describe('Assets', function() {
|
|
|
627
685
|
async () => (await fs.readFile(assetPathAposJs, 'utf8')).match(/default-page-watcher-test-src/),
|
|
628
686
|
'Unable to verify apos JS asset was rebuilt by the watcher',
|
|
629
687
|
500,
|
|
630
|
-
|
|
688
|
+
20000
|
|
631
689
|
);
|
|
632
690
|
await retryAssertTrue(
|
|
633
691
|
async () => (await fs.readFile(assetPathAposCss, 'utf8')).match(/\.default-page-watcher-test-src/),
|
|
634
692
|
'Unable to verify apos CSS asset was rebuilt by the watcher',
|
|
635
693
|
500,
|
|
636
|
-
|
|
694
|
+
20000
|
|
637
695
|
);
|
|
638
696
|
|
|
639
697
|
// * page has been restarted
|
|
@@ -641,7 +699,7 @@ describe('Assets', function() {
|
|
|
641
699
|
() => apos.asset.restartId !== restartId,
|
|
642
700
|
'Unable to verify restartId has been changed',
|
|
643
701
|
500,
|
|
644
|
-
|
|
702
|
+
20000
|
|
645
703
|
);
|
|
646
704
|
|
|
647
705
|
// * only src related builds were triggered
|
|
@@ -650,7 +708,7 @@ describe('Assets', function() {
|
|
|
650
708
|
result.builds.includes('src'),
|
|
651
709
|
'Unable to verify build "src" has been triggered',
|
|
652
710
|
50,
|
|
653
|
-
|
|
711
|
+
2000
|
|
654
712
|
);
|
|
655
713
|
|
|
656
714
|
// * changes detected
|
|
@@ -665,14 +723,12 @@ describe('Assets', function() {
|
|
|
665
723
|
.length === 2,
|
|
666
724
|
'Unable to verify changes contain the proper source files',
|
|
667
725
|
50,
|
|
668
|
-
|
|
726
|
+
2000
|
|
669
727
|
);
|
|
670
728
|
|
|
671
729
|
await t.destroy(apos);
|
|
672
730
|
assert.equal(apos.asset.buildWatcher, null);
|
|
673
731
|
apos = null;
|
|
674
|
-
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
675
|
-
fs.writeFileSync(assetPathScss, assetContentScss, 'utf8');
|
|
676
732
|
});
|
|
677
733
|
|
|
678
734
|
it('should watch and rebuild assets and reload page in development (public)', async function() {
|
|
@@ -688,12 +744,6 @@ describe('Assets', function() {
|
|
|
688
744
|
const assetPathPublicCss = path.join(rootPath, 'test/public/apos-frontend/default/public-bundle.css');
|
|
689
745
|
const assetPathAposJs = path.join(rootPath, 'test/public/apos-frontend/default/apos-module-bundle.js');
|
|
690
746
|
const assetPathAposCss = path.join(rootPath, 'test/public/apos-frontend/default/apos-bundle.css');
|
|
691
|
-
const assetContentJs = fs.readFileSync(assetPathJs, 'utf-8');
|
|
692
|
-
const assetContentScss = fs.readFileSync(assetPathCss, 'utf-8');
|
|
693
|
-
// Resurrect the default assets content if test has failed
|
|
694
|
-
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
695
|
-
fs.writeFileSync(assetPathCss, assetContentScss, 'utf8');
|
|
696
|
-
|
|
697
747
|
apos = await t.create({
|
|
698
748
|
root: module,
|
|
699
749
|
autoBuild: true,
|
|
@@ -716,6 +766,7 @@ describe('Assets', function() {
|
|
|
716
766
|
assert(apos.asset.restartId);
|
|
717
767
|
assert(!result.builds);
|
|
718
768
|
assert(!result.changes);
|
|
769
|
+
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
719
770
|
|
|
720
771
|
// * modify assets and rebuild
|
|
721
772
|
fs.writeFileSync(
|
|
@@ -734,13 +785,13 @@ describe('Assets', function() {
|
|
|
734
785
|
async () => (await fs.readFile(assetPathPublicJs, 'utf8')).match(/default-page-watcher-test-public/),
|
|
735
786
|
'Unable to verify public JS asset was rebuilt by the watcher',
|
|
736
787
|
500,
|
|
737
|
-
|
|
788
|
+
20000
|
|
738
789
|
);
|
|
739
790
|
await retryAssertTrue(
|
|
740
791
|
async () => (await fs.readFile(assetPathPublicCss, 'utf8')).match(/\.default-page-watcher-test-public/),
|
|
741
792
|
'Unable to verify public CSS asset was rebuilt by the watcher',
|
|
742
793
|
500,
|
|
743
|
-
|
|
794
|
+
20000
|
|
744
795
|
);
|
|
745
796
|
|
|
746
797
|
// * change is in the apos bundle
|
|
@@ -748,13 +799,13 @@ describe('Assets', function() {
|
|
|
748
799
|
async () => (await fs.readFile(assetPathAposJs, 'utf8')).match(/default-page-watcher-test-public/),
|
|
749
800
|
'Unable to verify apos JS asset was rebuilt by the watcher',
|
|
750
801
|
500,
|
|
751
|
-
|
|
802
|
+
20000
|
|
752
803
|
);
|
|
753
804
|
await retryAssertTrue(
|
|
754
805
|
async () => (await fs.readFile(assetPathAposCss, 'utf8')).match(/\.default-page-watcher-test-public/),
|
|
755
806
|
'Unable to verify apos CSS asset was rebuilt by the watcher',
|
|
756
807
|
500,
|
|
757
|
-
|
|
808
|
+
20000
|
|
758
809
|
);
|
|
759
810
|
|
|
760
811
|
// * page has been restarted
|
|
@@ -762,7 +813,7 @@ describe('Assets', function() {
|
|
|
762
813
|
() => apos.asset.restartId !== restartId,
|
|
763
814
|
'Unable to verify restartId has been changed',
|
|
764
815
|
500,
|
|
765
|
-
|
|
816
|
+
20000
|
|
766
817
|
);
|
|
767
818
|
|
|
768
819
|
// * only public build was triggered
|
|
@@ -771,7 +822,7 @@ describe('Assets', function() {
|
|
|
771
822
|
result.builds.includes('public'),
|
|
772
823
|
'Unable to verify build "public" has been triggered',
|
|
773
824
|
50,
|
|
774
|
-
|
|
825
|
+
2000
|
|
775
826
|
);
|
|
776
827
|
|
|
777
828
|
// * changes detected
|
|
@@ -786,14 +837,12 @@ describe('Assets', function() {
|
|
|
786
837
|
.length === 2,
|
|
787
838
|
'Unable to verify changes contain the proper source files',
|
|
788
839
|
50,
|
|
789
|
-
|
|
840
|
+
2000
|
|
790
841
|
);
|
|
791
842
|
|
|
792
843
|
await t.destroy(apos);
|
|
793
844
|
assert.equal(apos.asset.buildWatcher, null);
|
|
794
845
|
apos = null;
|
|
795
|
-
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
796
|
-
fs.writeFileSync(assetPathCss, assetContentScss, 'utf8');
|
|
797
846
|
});
|
|
798
847
|
|
|
799
848
|
it('should watch and rebuild assets and reload page in development (apos)', async function() {
|
|
@@ -836,6 +885,7 @@ describe('Assets', function() {
|
|
|
836
885
|
assert(apos.asset.restartId);
|
|
837
886
|
assert(!result.builds);
|
|
838
887
|
assert(!result.changes);
|
|
888
|
+
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
839
889
|
|
|
840
890
|
// * modify assets and rebuild
|
|
841
891
|
fs.writeFileSync(
|
|
@@ -850,7 +900,7 @@ describe('Assets', function() {
|
|
|
850
900
|
.includes('default-page-watcher-test-apos'),
|
|
851
901
|
'Unable to verify apos JS asset was rebuilt by the watcher',
|
|
852
902
|
500,
|
|
853
|
-
|
|
903
|
+
40000
|
|
854
904
|
);
|
|
855
905
|
|
|
856
906
|
// * page has been restarted
|
|
@@ -858,7 +908,7 @@ describe('Assets', function() {
|
|
|
858
908
|
() => apos.asset.restartId !== restartId,
|
|
859
909
|
'Unable to verify restartId has been changed',
|
|
860
910
|
500,
|
|
861
|
-
|
|
911
|
+
20000
|
|
862
912
|
);
|
|
863
913
|
|
|
864
914
|
// * only apos build was triggered
|
|
@@ -867,7 +917,7 @@ describe('Assets', function() {
|
|
|
867
917
|
result.builds.includes('apos'),
|
|
868
918
|
'Unable to verify build "apos" has been triggered',
|
|
869
919
|
50,
|
|
870
|
-
|
|
920
|
+
2000
|
|
871
921
|
);
|
|
872
922
|
|
|
873
923
|
// * changes detected
|
|
@@ -877,13 +927,12 @@ describe('Assets', function() {
|
|
|
877
927
|
result.changes[0].includes('modules/default-page/ui/apos/components/FakeComponent.vue'),
|
|
878
928
|
'Unable to verify changes contain the proper source files',
|
|
879
929
|
50,
|
|
880
|
-
|
|
930
|
+
2000
|
|
881
931
|
);
|
|
882
932
|
|
|
883
933
|
await t.destroy(apos);
|
|
884
934
|
assert.equal(apos.asset.buildWatcher, null);
|
|
885
935
|
apos = null;
|
|
886
|
-
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
887
936
|
});
|
|
888
937
|
|
|
889
938
|
it('should watch and recover after build error in development', async function() {
|
|
@@ -898,9 +947,6 @@ describe('Assets', function() {
|
|
|
898
947
|
const assetPathScss = path.join(rootPath, 'test/modules/default-page/ui/src/index.scss');
|
|
899
948
|
const assetPathPublicCss = path.join(rootPath, 'test/public/apos-frontend/default/public-bundle.css');
|
|
900
949
|
const assetPathAposCss = path.join(rootPath, 'test/public/apos-frontend/default/apos-bundle.css');
|
|
901
|
-
const assetContentScss = '.default-page {color:red;}\n';
|
|
902
|
-
// Resurrect the default assets content if test has failed
|
|
903
|
-
fs.writeFileSync(assetPathScss, assetContentScss, 'utf8');
|
|
904
950
|
|
|
905
951
|
apos = await t.create({
|
|
906
952
|
root: module,
|
|
@@ -924,6 +970,7 @@ describe('Assets', function() {
|
|
|
924
970
|
assert(apos.asset.restartId);
|
|
925
971
|
assert(!result.builds);
|
|
926
972
|
assert(!result.changes);
|
|
973
|
+
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
927
974
|
|
|
928
975
|
// * modify assets and rebuild
|
|
929
976
|
fs.writeFileSync(
|
|
@@ -937,7 +984,7 @@ describe('Assets', function() {
|
|
|
937
984
|
() => called === 1 && result.builds.length === 0,
|
|
938
985
|
'Unable to verify build with error was triggered',
|
|
939
986
|
100,
|
|
940
|
-
|
|
987
|
+
20000
|
|
941
988
|
);
|
|
942
989
|
|
|
943
990
|
// * page has NOT been restarted
|
|
@@ -945,7 +992,7 @@ describe('Assets', function() {
|
|
|
945
992
|
() => apos.asset.restartId === restartId,
|
|
946
993
|
'Unable to verify restartId has been changed',
|
|
947
994
|
100,
|
|
948
|
-
|
|
995
|
+
20000
|
|
949
996
|
);
|
|
950
997
|
|
|
951
998
|
// * modify assets and recover
|
|
@@ -960,7 +1007,7 @@ describe('Assets', function() {
|
|
|
960
1007
|
async () => (await fs.readFile(assetPathPublicCss, 'utf8')).match(/\.default-page-watcher-test-recover/),
|
|
961
1008
|
'Unable to verify public CSS asset was rebuilt by the watcher',
|
|
962
1009
|
500,
|
|
963
|
-
|
|
1010
|
+
20000
|
|
964
1011
|
);
|
|
965
1012
|
|
|
966
1013
|
// * change is in the apos bundle
|
|
@@ -968,7 +1015,7 @@ describe('Assets', function() {
|
|
|
968
1015
|
async () => (await fs.readFile(assetPathAposCss, 'utf8')).match(/\.default-page-watcher-test-recover/),
|
|
969
1016
|
'Unable to verify apos CSS asset was rebuilt by the watcher',
|
|
970
1017
|
500,
|
|
971
|
-
|
|
1018
|
+
20000
|
|
972
1019
|
);
|
|
973
1020
|
|
|
974
1021
|
// * page has been restarted
|
|
@@ -976,7 +1023,7 @@ describe('Assets', function() {
|
|
|
976
1023
|
() => apos.asset.restartId !== restartId,
|
|
977
1024
|
'Unable to verify restartId has been changed',
|
|
978
1025
|
500,
|
|
979
|
-
|
|
1026
|
+
20000
|
|
980
1027
|
);
|
|
981
1028
|
|
|
982
1029
|
// * only src related builds were triggered
|
|
@@ -985,7 +1032,7 @@ describe('Assets', function() {
|
|
|
985
1032
|
result.builds.includes('src'),
|
|
986
1033
|
'Unable to verify build "src" have been triggered',
|
|
987
1034
|
50,
|
|
988
|
-
|
|
1035
|
+
2000
|
|
989
1036
|
);
|
|
990
1037
|
|
|
991
1038
|
// * changes detected
|
|
@@ -999,13 +1046,12 @@ describe('Assets', function() {
|
|
|
999
1046
|
.length === 1,
|
|
1000
1047
|
'Unable to verify changes contain the proper source files',
|
|
1001
1048
|
50,
|
|
1002
|
-
|
|
1049
|
+
2000
|
|
1003
1050
|
);
|
|
1004
1051
|
|
|
1005
1052
|
await t.destroy(apos);
|
|
1006
1053
|
assert.equal(apos.asset.buildWatcher, null);
|
|
1007
1054
|
apos = null;
|
|
1008
|
-
fs.writeFileSync(assetPathScss, assetContentScss, 'utf8');
|
|
1009
1055
|
});
|
|
1010
1056
|
|
|
1011
1057
|
it('should watch but not rebuild assets and not reload page when changes are not in use', async function() {
|
|
@@ -1023,12 +1069,6 @@ describe('Assets', function() {
|
|
|
1023
1069
|
const assetPathPublicCss = path.join(rootPath, 'test/public/apos-frontend/default/public-bundle.css');
|
|
1024
1070
|
const assetPathAposJs = path.join(rootPath, 'test/public/apos-frontend/default/apos-module-bundle.js');
|
|
1025
1071
|
const assetPathAposCss = path.join(rootPath, 'test/public/apos-frontend/default/apos-bundle.css');
|
|
1026
|
-
const assetContentJs = fs.readFileSync(assetPathJs, 'utf-8');
|
|
1027
|
-
const assetContentScss = fs.readFileSync(assetPathScss, 'utf-8');
|
|
1028
|
-
// Resurrect the default assets content if test has failed
|
|
1029
|
-
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
1030
|
-
fs.writeFileSync(assetPathScss, assetContentScss, 'utf8');
|
|
1031
|
-
|
|
1032
1072
|
apos = await t.create({
|
|
1033
1073
|
root: module,
|
|
1034
1074
|
autoBuild: true,
|
|
@@ -1051,6 +1091,7 @@ describe('Assets', function() {
|
|
|
1051
1091
|
assert(!result.builds);
|
|
1052
1092
|
assert(!result.changes);
|
|
1053
1093
|
assert.equal(rebuilt, false);
|
|
1094
|
+
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
1054
1095
|
|
|
1055
1096
|
// * modify assets
|
|
1056
1097
|
fs.writeFileSync(
|
|
@@ -1139,8 +1180,6 @@ describe('Assets', function() {
|
|
|
1139
1180
|
await t.destroy(apos);
|
|
1140
1181
|
assert.equal(apos.asset.buildWatcher, null);
|
|
1141
1182
|
apos = null;
|
|
1142
|
-
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
1143
|
-
fs.writeFileSync(assetPathScss, assetContentScss, 'utf8');
|
|
1144
1183
|
});
|
|
1145
1184
|
|
|
1146
1185
|
it('should watch and rebuild assets in a debounced queue', async function() {
|
|
@@ -1167,10 +1206,10 @@ describe('Assets', function() {
|
|
|
1167
1206
|
}
|
|
1168
1207
|
});
|
|
1169
1208
|
assert(apos.asset.buildWatcher);
|
|
1209
|
+
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
1170
1210
|
|
|
1171
1211
|
const assetPath = path.join(process.cwd(), 'test/modules/bundle-page/ui/src/extra.js');
|
|
1172
1212
|
const assetPathPublic = path.join(process.cwd(), 'test/public/apos-frontend/default/extra-module-bundle.js');
|
|
1173
|
-
const assetContent = fs.readFileSync(assetPath, 'utf-8');
|
|
1174
1213
|
|
|
1175
1214
|
// Modify below the debounce rate
|
|
1176
1215
|
for (const i of [ 1, 2, 3 ]) {
|
|
@@ -1195,7 +1234,9 @@ describe('Assets', function() {
|
|
|
1195
1234
|
5000
|
|
1196
1235
|
);
|
|
1197
1236
|
|
|
1198
|
-
// Modify above the debounce rate
|
|
1237
|
+
// Modify well above the debounce rate (default 1000ms) so each
|
|
1238
|
+
// write triggers its own rebuild. Use 2000ms to avoid flaky
|
|
1239
|
+
// failures on loaded CI runners.
|
|
1199
1240
|
timesRebuilt = 0;
|
|
1200
1241
|
for (const i of [ 1, 2, 3 ]) {
|
|
1201
1242
|
await fs.writeFile(
|
|
@@ -1203,7 +1244,7 @@ describe('Assets', function() {
|
|
|
1203
1244
|
`export default () => { 'bundle-page-watcher-test-${i}0'; };\n`,
|
|
1204
1245
|
'utf8'
|
|
1205
1246
|
);
|
|
1206
|
-
await Promise.delay(
|
|
1247
|
+
await Promise.delay(2000);
|
|
1207
1248
|
}
|
|
1208
1249
|
await retryAssertTrue(
|
|
1209
1250
|
async () => (await fs.readFile(assetPathPublic, 'utf8')).match(/bundle-page-watcher-test-30/),
|
|
@@ -1220,10 +1261,10 @@ describe('Assets', function() {
|
|
|
1220
1261
|
|
|
1221
1262
|
await t.destroy(apos);
|
|
1222
1263
|
apos = null;
|
|
1223
|
-
fs.writeFileSync(assetPath, assetContent, 'utf8');
|
|
1224
1264
|
});
|
|
1225
1265
|
|
|
1226
1266
|
it('should be able to setup the debounce time', async function() {
|
|
1267
|
+
await t.destroy(apos);
|
|
1227
1268
|
|
|
1228
1269
|
apos = await t.create({
|
|
1229
1270
|
root: module,
|
|
@@ -1317,6 +1358,7 @@ describe('Assets', function() {
|
|
|
1317
1358
|
});
|
|
1318
1359
|
|
|
1319
1360
|
it('should pass the right options to webpack extensions from all modules', async function() {
|
|
1361
|
+
await t.destroy(apos);
|
|
1320
1362
|
const { extConfig1, extConfig2 } = getWebpackConfigsForExtensionOptions();
|
|
1321
1363
|
|
|
1322
1364
|
apos = await t.create({
|
|
@@ -1347,6 +1389,7 @@ describe('Assets', function() {
|
|
|
1347
1389
|
});
|
|
1348
1390
|
|
|
1349
1391
|
it('should allow two modules extending each others to pass options to the same webpack extension', async function() {
|
|
1392
|
+
await t.destroy(apos);
|
|
1350
1393
|
const { extConfig1, extConfig2 } = getWebpackConfigsForExtensionOptions();
|
|
1351
1394
|
|
|
1352
1395
|
apos = await t.create({
|