apostrophe 4.30.0-alpha.1 → 4.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +15 -0
- package/CHANGELOG.md +30 -2
- package/eslint.config.js +1 -2
- package/lib/mongodb-connect.js +62 -0
- package/modules/@apostrophecms/admin-bar/ui/apos/components/TheAposAdminBar.vue +0 -1
- package/modules/@apostrophecms/admin-bar/ui/apos/components/TheAposAdminBarMenu.vue +25 -8
- package/modules/@apostrophecms/admin-bar/ui/apos/components/TheAposContextBreakpointPreviewMode.vue +9 -0
- package/modules/@apostrophecms/admin-bar/ui/apos/components/TheAposContextTitle.vue +20 -2
- package/modules/@apostrophecms/area/index.js +10 -5
- package/modules/@apostrophecms/area/ui/apos/components/AposAreaWidget.vue +2 -0
- package/modules/@apostrophecms/command-menu/ui/apos/components/TheAposCommandMenu.vue +11 -1
- package/modules/@apostrophecms/db/index.js +27 -68
- package/modules/@apostrophecms/http/index.js +1 -1
- package/modules/@apostrophecms/i18n/i18n/en.json +8 -0
- package/modules/@apostrophecms/i18n/index.js +1 -8
- package/modules/@apostrophecms/image-widget/index.js +29 -1
- package/modules/@apostrophecms/job/index.js +7 -9
- package/modules/@apostrophecms/layout-widget/index.js +124 -2
- package/modules/@apostrophecms/layout-widget/ui/apos/components/AposAreaLayoutEditor.vue +89 -6
- package/modules/@apostrophecms/layout-widget/ui/apos/components/AposGridLayout.vue +2 -2
- package/modules/@apostrophecms/layout-widget/ui/apos/components/AposGridManager.vue +2 -2
- package/modules/@apostrophecms/layout-widget/ui/apos/layout.css +8 -0
- package/modules/@apostrophecms/layout-widget/ui/src/layout.css +1 -1
- package/modules/@apostrophecms/layout-widget/views/widget.html +3 -3
- package/modules/@apostrophecms/login/index.js +13 -15
- package/modules/@apostrophecms/modal/ui/apos/components/AposModal.vue +2 -1
- package/modules/@apostrophecms/oembed/index.js +18 -13
- package/modules/@apostrophecms/recently-edited/ui/apos/components/AposRecentlyEditedIcon.vue +2 -0
- package/modules/@apostrophecms/rich-text-widget/index.js +36 -0
- package/modules/@apostrophecms/schema/ui/apos/logic/AposInputCheckboxes.js +1 -1
- package/modules/@apostrophecms/schema/ui/apos/logic/AposInputRadio.js +1 -1
- package/modules/@apostrophecms/styles/index.js +16 -0
- package/modules/@apostrophecms/styles/lib/handlers.js +6 -0
- package/modules/@apostrophecms/styles/lib/methods.js +93 -0
- package/modules/@apostrophecms/styles/lib/presets.js +17 -0
- package/modules/@apostrophecms/styles/ui/apos/universal/render.mjs +10 -1
- package/modules/@apostrophecms/submitted-draft/ui/apos/components/AposSubmittedDraftIcon.vue +1 -0
- package/modules/@apostrophecms/template/views/outerLayoutBase.html +1 -1
- package/modules/@apostrophecms/ui/ui/apos/components/AposButton.vue +14 -2
- package/modules/@apostrophecms/ui/ui/apos/components/AposContextMenu.vue +29 -5
- package/modules/@apostrophecms/ui/ui/apos/components/AposContextMenuDialog.vue +8 -0
- package/modules/@apostrophecms/ui/ui/apos/components/AposContextMenuItem.vue +5 -2
- package/modules/@apostrophecms/ui/ui/apos/components/AposLocalePicker.vue +14 -1
- package/modules/@apostrophecms/ui/ui/apos/scss/global/_utilities.scss +13 -1
- package/modules/@apostrophecms/util/index.js +4 -0
- package/modules/@apostrophecms/widget-type/index.js +6 -0
- package/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue +32 -0
- package/package.json +13 -13
- package/test/add-missing-schema-fields-project/node_modules/.package-lock.json +131 -0
- package/test/add-missing-schema-fields-project/test.js +3 -11
- package/test/assets.js +67 -110
- package/test/db.js +15 -24
- package/test/job.js +1 -1
- package/test/layout-widget-gap.js +530 -0
- package/test/login.js +122 -1
- package/test/rich-text-widget.js +200 -0
- package/test/styles.js +50 -0
- package/test-lib/util.js +14 -50
- package/claude-tools/detect-handles.js +0 -46
- package/claude-tools/minimal-hang-test.js +0 -28
- package/claude-tools/mongo-close-test.js +0 -11
- package/claude-tools/stdin-ref-test.js +0 -14
- package/test/db-tools.js +0 -365
- package/test/default-adapter.js +0 -256
package/test/assets.js
CHANGED
|
@@ -98,75 +98,15 @@ 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
|
-
|
|
149
101
|
after(async function() {
|
|
150
102
|
await deleteBuiltFolders(publicFolderPath, true);
|
|
151
103
|
await removeCache();
|
|
152
104
|
await t.destroy(apos);
|
|
153
105
|
});
|
|
154
106
|
|
|
155
|
-
afterEach(
|
|
107
|
+
afterEach(function() {
|
|
156
108
|
// Prevent hang forever if particular tests fail while testing prod.
|
|
157
109
|
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
|
-
}
|
|
170
110
|
});
|
|
171
111
|
|
|
172
112
|
this.timeout(5 * 60 * 1000);
|
|
@@ -222,7 +162,6 @@ describe('Assets', function() {
|
|
|
222
162
|
});
|
|
223
163
|
|
|
224
164
|
it('should get webpack extensions from modules and fill extra bundles', async function () {
|
|
225
|
-
await t.destroy(apos);
|
|
226
165
|
const expectedEntryPointsNames = {
|
|
227
166
|
js: [ 'company', 'main', 'another', 'extra', 'extra2' ],
|
|
228
167
|
css: [ 'company', 'main', 'extra' ]
|
|
@@ -370,7 +309,6 @@ describe('Assets', function() {
|
|
|
370
309
|
});
|
|
371
310
|
|
|
372
311
|
it('should build with cache and gain performance', async function() {
|
|
373
|
-
await t.destroy(apos);
|
|
374
312
|
await removeCache();
|
|
375
313
|
await removeCache(cacheFolderPath.replace('/webpack-cache', '/changed'));
|
|
376
314
|
|
|
@@ -408,11 +346,9 @@ describe('Assets', function() {
|
|
|
408
346
|
assert(meta2['default:apos']);
|
|
409
347
|
assert(meta2['default:src']);
|
|
410
348
|
|
|
411
|
-
//
|
|
412
|
-
// low (10%) to avoid flaky failures on loaded CI runners where the
|
|
413
|
-
// cold run can be fast due to OS-level caching.
|
|
349
|
+
// Expect at least 40% gain, in reallity it should be 50+
|
|
414
350
|
const gain = (execTime - execTimeCached) / execTime * 100;
|
|
415
|
-
assert(gain >=
|
|
351
|
+
assert(gain >= 20, `Expected gain >=20%, got ${gain}%`);
|
|
416
352
|
|
|
417
353
|
// Modification times
|
|
418
354
|
assert(meta['default:apos'].mdate);
|
|
@@ -573,11 +509,11 @@ describe('Assets', function() {
|
|
|
573
509
|
assert(apos.asset.restartId);
|
|
574
510
|
assert(!result.builds);
|
|
575
511
|
assert(!result.changes);
|
|
576
|
-
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
577
512
|
|
|
578
513
|
// Modify asset and rebuild
|
|
579
514
|
const assetPath = path.join(process.cwd(), 'test/modules/bundle-page/ui/src/extra.js');
|
|
580
515
|
const assetPathPublic = path.join(process.cwd(), 'test/public/apos-frontend/default/extra-module-bundle.js');
|
|
516
|
+
const assetContent = fs.readFileSync(assetPath, 'utf-8');
|
|
581
517
|
fs.writeFileSync(
|
|
582
518
|
assetPath,
|
|
583
519
|
'export default () => { \'bundle-page-watcher-test-src\'; };\n',
|
|
@@ -588,33 +524,34 @@ describe('Assets', function() {
|
|
|
588
524
|
async () => (await fs.readFile(assetPathPublic, 'utf8')).match(/bundle-page-watcher-test-src/),
|
|
589
525
|
'Unable to verify public asset was rebuilt by the watcher',
|
|
590
526
|
500,
|
|
591
|
-
|
|
527
|
+
10000
|
|
592
528
|
);
|
|
593
529
|
|
|
594
530
|
await retryAssertTrue(
|
|
595
531
|
() => apos.asset.restartId !== restartId,
|
|
596
532
|
'Unable to verify restartId has been changed',
|
|
597
533
|
500,
|
|
598
|
-
|
|
534
|
+
10000
|
|
599
535
|
);
|
|
600
536
|
|
|
601
537
|
await retryAssertTrue(
|
|
602
538
|
() => result.builds.length === 1 && result.builds.includes('src'),
|
|
603
539
|
'Unable to verify build "src" has been triggered',
|
|
604
540
|
50,
|
|
605
|
-
|
|
541
|
+
1000
|
|
606
542
|
);
|
|
607
543
|
|
|
608
544
|
await retryAssertTrue(
|
|
609
545
|
() => result.changes.length === 1 && result.changes[0].includes('modules/bundle-page/ui/src/extra.js'),
|
|
610
546
|
'Unable to verify changes contain the proper file',
|
|
611
547
|
50,
|
|
612
|
-
|
|
548
|
+
1000
|
|
613
549
|
);
|
|
614
550
|
|
|
615
551
|
await t.destroy(apos);
|
|
616
552
|
assert.equal(apos.asset.buildWatcher, null);
|
|
617
553
|
apos = null;
|
|
554
|
+
fs.writeFileSync(assetPath, assetContent, 'utf8');
|
|
618
555
|
});
|
|
619
556
|
|
|
620
557
|
it('should watch and rebuild assets and reload page in development (src)', async function() {
|
|
@@ -630,6 +567,12 @@ describe('Assets', function() {
|
|
|
630
567
|
const assetPathPublicCss = path.join(rootPath, 'test/public/apos-frontend/default/public-bundle.css');
|
|
631
568
|
const assetPathAposJs = path.join(rootPath, 'test/public/apos-frontend/default/apos-module-bundle.js');
|
|
632
569
|
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
|
+
|
|
633
576
|
apos = await t.create({
|
|
634
577
|
root: module,
|
|
635
578
|
autoBuild: true,
|
|
@@ -652,7 +595,6 @@ describe('Assets', function() {
|
|
|
652
595
|
assert(apos.asset.restartId);
|
|
653
596
|
assert(!result.builds);
|
|
654
597
|
assert(!result.changes);
|
|
655
|
-
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
656
598
|
|
|
657
599
|
// * modify assets and rebuild
|
|
658
600
|
fs.writeFileSync(
|
|
@@ -671,13 +613,13 @@ describe('Assets', function() {
|
|
|
671
613
|
async () => (await fs.readFile(assetPathPublicJs, 'utf8')).match(/default-page-watcher-test-src/),
|
|
672
614
|
'Unable to verify public JS asset was rebuilt by the watcher',
|
|
673
615
|
500,
|
|
674
|
-
|
|
616
|
+
10000
|
|
675
617
|
);
|
|
676
618
|
await retryAssertTrue(
|
|
677
619
|
async () => (await fs.readFile(assetPathPublicCss, 'utf8')).match(/\.default-page-watcher-test-src/),
|
|
678
620
|
'Unable to verify public CSS asset was rebuilt by the watcher',
|
|
679
621
|
500,
|
|
680
|
-
|
|
622
|
+
10000
|
|
681
623
|
);
|
|
682
624
|
|
|
683
625
|
// * change is in the apos bundle
|
|
@@ -685,13 +627,13 @@ describe('Assets', function() {
|
|
|
685
627
|
async () => (await fs.readFile(assetPathAposJs, 'utf8')).match(/default-page-watcher-test-src/),
|
|
686
628
|
'Unable to verify apos JS asset was rebuilt by the watcher',
|
|
687
629
|
500,
|
|
688
|
-
|
|
630
|
+
10000
|
|
689
631
|
);
|
|
690
632
|
await retryAssertTrue(
|
|
691
633
|
async () => (await fs.readFile(assetPathAposCss, 'utf8')).match(/\.default-page-watcher-test-src/),
|
|
692
634
|
'Unable to verify apos CSS asset was rebuilt by the watcher',
|
|
693
635
|
500,
|
|
694
|
-
|
|
636
|
+
10000
|
|
695
637
|
);
|
|
696
638
|
|
|
697
639
|
// * page has been restarted
|
|
@@ -699,7 +641,7 @@ describe('Assets', function() {
|
|
|
699
641
|
() => apos.asset.restartId !== restartId,
|
|
700
642
|
'Unable to verify restartId has been changed',
|
|
701
643
|
500,
|
|
702
|
-
|
|
644
|
+
10000
|
|
703
645
|
);
|
|
704
646
|
|
|
705
647
|
// * only src related builds were triggered
|
|
@@ -708,7 +650,7 @@ describe('Assets', function() {
|
|
|
708
650
|
result.builds.includes('src'),
|
|
709
651
|
'Unable to verify build "src" has been triggered',
|
|
710
652
|
50,
|
|
711
|
-
|
|
653
|
+
1000
|
|
712
654
|
);
|
|
713
655
|
|
|
714
656
|
// * changes detected
|
|
@@ -723,12 +665,14 @@ describe('Assets', function() {
|
|
|
723
665
|
.length === 2,
|
|
724
666
|
'Unable to verify changes contain the proper source files',
|
|
725
667
|
50,
|
|
726
|
-
|
|
668
|
+
1000
|
|
727
669
|
);
|
|
728
670
|
|
|
729
671
|
await t.destroy(apos);
|
|
730
672
|
assert.equal(apos.asset.buildWatcher, null);
|
|
731
673
|
apos = null;
|
|
674
|
+
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
675
|
+
fs.writeFileSync(assetPathScss, assetContentScss, 'utf8');
|
|
732
676
|
});
|
|
733
677
|
|
|
734
678
|
it('should watch and rebuild assets and reload page in development (public)', async function() {
|
|
@@ -744,6 +688,12 @@ describe('Assets', function() {
|
|
|
744
688
|
const assetPathPublicCss = path.join(rootPath, 'test/public/apos-frontend/default/public-bundle.css');
|
|
745
689
|
const assetPathAposJs = path.join(rootPath, 'test/public/apos-frontend/default/apos-module-bundle.js');
|
|
746
690
|
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
|
+
|
|
747
697
|
apos = await t.create({
|
|
748
698
|
root: module,
|
|
749
699
|
autoBuild: true,
|
|
@@ -766,7 +716,6 @@ describe('Assets', function() {
|
|
|
766
716
|
assert(apos.asset.restartId);
|
|
767
717
|
assert(!result.builds);
|
|
768
718
|
assert(!result.changes);
|
|
769
|
-
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
770
719
|
|
|
771
720
|
// * modify assets and rebuild
|
|
772
721
|
fs.writeFileSync(
|
|
@@ -785,13 +734,13 @@ describe('Assets', function() {
|
|
|
785
734
|
async () => (await fs.readFile(assetPathPublicJs, 'utf8')).match(/default-page-watcher-test-public/),
|
|
786
735
|
'Unable to verify public JS asset was rebuilt by the watcher',
|
|
787
736
|
500,
|
|
788
|
-
|
|
737
|
+
10000
|
|
789
738
|
);
|
|
790
739
|
await retryAssertTrue(
|
|
791
740
|
async () => (await fs.readFile(assetPathPublicCss, 'utf8')).match(/\.default-page-watcher-test-public/),
|
|
792
741
|
'Unable to verify public CSS asset was rebuilt by the watcher',
|
|
793
742
|
500,
|
|
794
|
-
|
|
743
|
+
10000
|
|
795
744
|
);
|
|
796
745
|
|
|
797
746
|
// * change is in the apos bundle
|
|
@@ -799,13 +748,13 @@ describe('Assets', function() {
|
|
|
799
748
|
async () => (await fs.readFile(assetPathAposJs, 'utf8')).match(/default-page-watcher-test-public/),
|
|
800
749
|
'Unable to verify apos JS asset was rebuilt by the watcher',
|
|
801
750
|
500,
|
|
802
|
-
|
|
751
|
+
10000
|
|
803
752
|
);
|
|
804
753
|
await retryAssertTrue(
|
|
805
754
|
async () => (await fs.readFile(assetPathAposCss, 'utf8')).match(/\.default-page-watcher-test-public/),
|
|
806
755
|
'Unable to verify apos CSS asset was rebuilt by the watcher',
|
|
807
756
|
500,
|
|
808
|
-
|
|
757
|
+
10000
|
|
809
758
|
);
|
|
810
759
|
|
|
811
760
|
// * page has been restarted
|
|
@@ -813,7 +762,7 @@ describe('Assets', function() {
|
|
|
813
762
|
() => apos.asset.restartId !== restartId,
|
|
814
763
|
'Unable to verify restartId has been changed',
|
|
815
764
|
500,
|
|
816
|
-
|
|
765
|
+
10000
|
|
817
766
|
);
|
|
818
767
|
|
|
819
768
|
// * only public build was triggered
|
|
@@ -822,7 +771,7 @@ describe('Assets', function() {
|
|
|
822
771
|
result.builds.includes('public'),
|
|
823
772
|
'Unable to verify build "public" has been triggered',
|
|
824
773
|
50,
|
|
825
|
-
|
|
774
|
+
1000
|
|
826
775
|
);
|
|
827
776
|
|
|
828
777
|
// * changes detected
|
|
@@ -837,12 +786,14 @@ describe('Assets', function() {
|
|
|
837
786
|
.length === 2,
|
|
838
787
|
'Unable to verify changes contain the proper source files',
|
|
839
788
|
50,
|
|
840
|
-
|
|
789
|
+
1000
|
|
841
790
|
);
|
|
842
791
|
|
|
843
792
|
await t.destroy(apos);
|
|
844
793
|
assert.equal(apos.asset.buildWatcher, null);
|
|
845
794
|
apos = null;
|
|
795
|
+
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
796
|
+
fs.writeFileSync(assetPathCss, assetContentScss, 'utf8');
|
|
846
797
|
});
|
|
847
798
|
|
|
848
799
|
it('should watch and rebuild assets and reload page in development (apos)', async function() {
|
|
@@ -885,7 +836,6 @@ describe('Assets', function() {
|
|
|
885
836
|
assert(apos.asset.restartId);
|
|
886
837
|
assert(!result.builds);
|
|
887
838
|
assert(!result.changes);
|
|
888
|
-
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
889
839
|
|
|
890
840
|
// * modify assets and rebuild
|
|
891
841
|
fs.writeFileSync(
|
|
@@ -900,7 +850,7 @@ describe('Assets', function() {
|
|
|
900
850
|
.includes('default-page-watcher-test-apos'),
|
|
901
851
|
'Unable to verify apos JS asset was rebuilt by the watcher',
|
|
902
852
|
500,
|
|
903
|
-
|
|
853
|
+
20000
|
|
904
854
|
);
|
|
905
855
|
|
|
906
856
|
// * page has been restarted
|
|
@@ -908,7 +858,7 @@ describe('Assets', function() {
|
|
|
908
858
|
() => apos.asset.restartId !== restartId,
|
|
909
859
|
'Unable to verify restartId has been changed',
|
|
910
860
|
500,
|
|
911
|
-
|
|
861
|
+
10000
|
|
912
862
|
);
|
|
913
863
|
|
|
914
864
|
// * only apos build was triggered
|
|
@@ -917,7 +867,7 @@ describe('Assets', function() {
|
|
|
917
867
|
result.builds.includes('apos'),
|
|
918
868
|
'Unable to verify build "apos" has been triggered',
|
|
919
869
|
50,
|
|
920
|
-
|
|
870
|
+
1000
|
|
921
871
|
);
|
|
922
872
|
|
|
923
873
|
// * changes detected
|
|
@@ -927,12 +877,13 @@ describe('Assets', function() {
|
|
|
927
877
|
result.changes[0].includes('modules/default-page/ui/apos/components/FakeComponent.vue'),
|
|
928
878
|
'Unable to verify changes contain the proper source files',
|
|
929
879
|
50,
|
|
930
|
-
|
|
880
|
+
1000
|
|
931
881
|
);
|
|
932
882
|
|
|
933
883
|
await t.destroy(apos);
|
|
934
884
|
assert.equal(apos.asset.buildWatcher, null);
|
|
935
885
|
apos = null;
|
|
886
|
+
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
936
887
|
});
|
|
937
888
|
|
|
938
889
|
it('should watch and recover after build error in development', async function() {
|
|
@@ -947,6 +898,9 @@ describe('Assets', function() {
|
|
|
947
898
|
const assetPathScss = path.join(rootPath, 'test/modules/default-page/ui/src/index.scss');
|
|
948
899
|
const assetPathPublicCss = path.join(rootPath, 'test/public/apos-frontend/default/public-bundle.css');
|
|
949
900
|
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');
|
|
950
904
|
|
|
951
905
|
apos = await t.create({
|
|
952
906
|
root: module,
|
|
@@ -970,7 +924,6 @@ describe('Assets', function() {
|
|
|
970
924
|
assert(apos.asset.restartId);
|
|
971
925
|
assert(!result.builds);
|
|
972
926
|
assert(!result.changes);
|
|
973
|
-
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
974
927
|
|
|
975
928
|
// * modify assets and rebuild
|
|
976
929
|
fs.writeFileSync(
|
|
@@ -984,7 +937,7 @@ describe('Assets', function() {
|
|
|
984
937
|
() => called === 1 && result.builds.length === 0,
|
|
985
938
|
'Unable to verify build with error was triggered',
|
|
986
939
|
100,
|
|
987
|
-
|
|
940
|
+
10000
|
|
988
941
|
);
|
|
989
942
|
|
|
990
943
|
// * page has NOT been restarted
|
|
@@ -992,7 +945,7 @@ describe('Assets', function() {
|
|
|
992
945
|
() => apos.asset.restartId === restartId,
|
|
993
946
|
'Unable to verify restartId has been changed',
|
|
994
947
|
100,
|
|
995
|
-
|
|
948
|
+
10000
|
|
996
949
|
);
|
|
997
950
|
|
|
998
951
|
// * modify assets and recover
|
|
@@ -1007,7 +960,7 @@ describe('Assets', function() {
|
|
|
1007
960
|
async () => (await fs.readFile(assetPathPublicCss, 'utf8')).match(/\.default-page-watcher-test-recover/),
|
|
1008
961
|
'Unable to verify public CSS asset was rebuilt by the watcher',
|
|
1009
962
|
500,
|
|
1010
|
-
|
|
963
|
+
10000
|
|
1011
964
|
);
|
|
1012
965
|
|
|
1013
966
|
// * change is in the apos bundle
|
|
@@ -1015,7 +968,7 @@ describe('Assets', function() {
|
|
|
1015
968
|
async () => (await fs.readFile(assetPathAposCss, 'utf8')).match(/\.default-page-watcher-test-recover/),
|
|
1016
969
|
'Unable to verify apos CSS asset was rebuilt by the watcher',
|
|
1017
970
|
500,
|
|
1018
|
-
|
|
971
|
+
10000
|
|
1019
972
|
);
|
|
1020
973
|
|
|
1021
974
|
// * page has been restarted
|
|
@@ -1023,7 +976,7 @@ describe('Assets', function() {
|
|
|
1023
976
|
() => apos.asset.restartId !== restartId,
|
|
1024
977
|
'Unable to verify restartId has been changed',
|
|
1025
978
|
500,
|
|
1026
|
-
|
|
979
|
+
10000
|
|
1027
980
|
);
|
|
1028
981
|
|
|
1029
982
|
// * only src related builds were triggered
|
|
@@ -1032,7 +985,7 @@ describe('Assets', function() {
|
|
|
1032
985
|
result.builds.includes('src'),
|
|
1033
986
|
'Unable to verify build "src" have been triggered',
|
|
1034
987
|
50,
|
|
1035
|
-
|
|
988
|
+
1000
|
|
1036
989
|
);
|
|
1037
990
|
|
|
1038
991
|
// * changes detected
|
|
@@ -1046,12 +999,13 @@ describe('Assets', function() {
|
|
|
1046
999
|
.length === 1,
|
|
1047
1000
|
'Unable to verify changes contain the proper source files',
|
|
1048
1001
|
50,
|
|
1049
|
-
|
|
1002
|
+
1000
|
|
1050
1003
|
);
|
|
1051
1004
|
|
|
1052
1005
|
await t.destroy(apos);
|
|
1053
1006
|
assert.equal(apos.asset.buildWatcher, null);
|
|
1054
1007
|
apos = null;
|
|
1008
|
+
fs.writeFileSync(assetPathScss, assetContentScss, 'utf8');
|
|
1055
1009
|
});
|
|
1056
1010
|
|
|
1057
1011
|
it('should watch but not rebuild assets and not reload page when changes are not in use', async function() {
|
|
@@ -1069,6 +1023,12 @@ describe('Assets', function() {
|
|
|
1069
1023
|
const assetPathPublicCss = path.join(rootPath, 'test/public/apos-frontend/default/public-bundle.css');
|
|
1070
1024
|
const assetPathAposJs = path.join(rootPath, 'test/public/apos-frontend/default/apos-module-bundle.js');
|
|
1071
1025
|
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
|
+
|
|
1072
1032
|
apos = await t.create({
|
|
1073
1033
|
root: module,
|
|
1074
1034
|
autoBuild: true,
|
|
@@ -1091,7 +1051,6 @@ describe('Assets', function() {
|
|
|
1091
1051
|
assert(!result.builds);
|
|
1092
1052
|
assert(!result.changes);
|
|
1093
1053
|
assert.equal(rebuilt, false);
|
|
1094
|
-
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
1095
1054
|
|
|
1096
1055
|
// * modify assets
|
|
1097
1056
|
fs.writeFileSync(
|
|
@@ -1180,6 +1139,8 @@ describe('Assets', function() {
|
|
|
1180
1139
|
await t.destroy(apos);
|
|
1181
1140
|
assert.equal(apos.asset.buildWatcher, null);
|
|
1182
1141
|
apos = null;
|
|
1142
|
+
fs.writeFileSync(assetPathJs, assetContentJs, 'utf8');
|
|
1143
|
+
fs.writeFileSync(assetPathScss, assetContentScss, 'utf8');
|
|
1183
1144
|
});
|
|
1184
1145
|
|
|
1185
1146
|
it('should watch and rebuild assets in a debounced queue', async function() {
|
|
@@ -1206,10 +1167,10 @@ describe('Assets', function() {
|
|
|
1206
1167
|
}
|
|
1207
1168
|
});
|
|
1208
1169
|
assert(apos.asset.buildWatcher);
|
|
1209
|
-
await waitForWatcherReady(apos.asset.buildWatcher);
|
|
1210
1170
|
|
|
1211
1171
|
const assetPath = path.join(process.cwd(), 'test/modules/bundle-page/ui/src/extra.js');
|
|
1212
1172
|
const assetPathPublic = path.join(process.cwd(), 'test/public/apos-frontend/default/extra-module-bundle.js');
|
|
1173
|
+
const assetContent = fs.readFileSync(assetPath, 'utf-8');
|
|
1213
1174
|
|
|
1214
1175
|
// Modify below the debounce rate
|
|
1215
1176
|
for (const i of [ 1, 2, 3 ]) {
|
|
@@ -1234,9 +1195,7 @@ describe('Assets', function() {
|
|
|
1234
1195
|
5000
|
|
1235
1196
|
);
|
|
1236
1197
|
|
|
1237
|
-
// Modify
|
|
1238
|
-
// write triggers its own rebuild. Use 2000ms to avoid flaky
|
|
1239
|
-
// failures on loaded CI runners.
|
|
1198
|
+
// Modify above the debounce rate, test the queue cap
|
|
1240
1199
|
timesRebuilt = 0;
|
|
1241
1200
|
for (const i of [ 1, 2, 3 ]) {
|
|
1242
1201
|
await fs.writeFile(
|
|
@@ -1244,7 +1203,7 @@ describe('Assets', function() {
|
|
|
1244
1203
|
`export default () => { 'bundle-page-watcher-test-${i}0'; };\n`,
|
|
1245
1204
|
'utf8'
|
|
1246
1205
|
);
|
|
1247
|
-
await Promise.delay(
|
|
1206
|
+
await Promise.delay(1050);
|
|
1248
1207
|
}
|
|
1249
1208
|
await retryAssertTrue(
|
|
1250
1209
|
async () => (await fs.readFile(assetPathPublic, 'utf8')).match(/bundle-page-watcher-test-30/),
|
|
@@ -1261,10 +1220,10 @@ describe('Assets', function() {
|
|
|
1261
1220
|
|
|
1262
1221
|
await t.destroy(apos);
|
|
1263
1222
|
apos = null;
|
|
1223
|
+
fs.writeFileSync(assetPath, assetContent, 'utf8');
|
|
1264
1224
|
});
|
|
1265
1225
|
|
|
1266
1226
|
it('should be able to setup the debounce time', async function() {
|
|
1267
|
-
await t.destroy(apos);
|
|
1268
1227
|
|
|
1269
1228
|
apos = await t.create({
|
|
1270
1229
|
root: module,
|
|
@@ -1358,7 +1317,6 @@ describe('Assets', function() {
|
|
|
1358
1317
|
});
|
|
1359
1318
|
|
|
1360
1319
|
it('should pass the right options to webpack extensions from all modules', async function() {
|
|
1361
|
-
await t.destroy(apos);
|
|
1362
1320
|
const { extConfig1, extConfig2 } = getWebpackConfigsForExtensionOptions();
|
|
1363
1321
|
|
|
1364
1322
|
apos = await t.create({
|
|
@@ -1389,7 +1347,6 @@ describe('Assets', function() {
|
|
|
1389
1347
|
});
|
|
1390
1348
|
|
|
1391
1349
|
it('should allow two modules extending each others to pass options to the same webpack extension', async function() {
|
|
1392
|
-
await t.destroy(apos);
|
|
1393
1350
|
const { extConfig1, extConfig2 } = getWebpackConfigsForExtensionOptions();
|
|
1394
1351
|
|
|
1395
1352
|
apos = await t.create({
|
package/test/db.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
const t = require('../test-lib/test.js');
|
|
2
2
|
const assert = require('assert');
|
|
3
3
|
|
|
4
|
-
const bogusUri = t.testDbProtocol === 'postgres'
|
|
5
|
-
? 'postgres://this-will-not-work-unless-db-successfully-overrides-it/fail'
|
|
6
|
-
: 'mongodb://this-will-not-work-unless-db-successfully-overrides-it/fail';
|
|
7
|
-
|
|
8
4
|
describe('Db', function() {
|
|
9
5
|
|
|
10
6
|
let apos, apos2;
|
|
@@ -29,28 +25,23 @@ describe('Db', function() {
|
|
|
29
25
|
assert(doc);
|
|
30
26
|
});
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'@apostrophecms/db': {
|
|
43
|
-
options: {
|
|
44
|
-
client: apos.dbClient,
|
|
45
|
-
uri: bogusUri
|
|
46
|
-
}
|
|
28
|
+
it('should be able to launch a second instance reusing the connection', async function() {
|
|
29
|
+
// Often takes too long otherwise
|
|
30
|
+
this.timeout(10000);
|
|
31
|
+
apos2 = await t.create({
|
|
32
|
+
root: module,
|
|
33
|
+
modules: {
|
|
34
|
+
'@apostrophecms/db': {
|
|
35
|
+
options: {
|
|
36
|
+
client: apos.dbClient,
|
|
37
|
+
uri: 'mongodb://this-will-not-work-unless-db-successfully-overrides-it/fail'
|
|
47
38
|
}
|
|
48
39
|
}
|
|
49
|
-
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
50
42
|
|
|
51
|
-
|
|
43
|
+
const doc = await apos2.doc.db.findOne();
|
|
52
44
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
45
|
+
assert(doc);
|
|
46
|
+
});
|
|
56
47
|
});
|
package/test/job.js
CHANGED
|
@@ -311,7 +311,7 @@ describe('Job module', function() {
|
|
|
311
311
|
req,
|
|
312
312
|
async function(_req, reporters) {
|
|
313
313
|
let count = 1;
|
|
314
|
-
|
|
314
|
+
reporters.setTotal(articleIds.length);
|
|
315
315
|
|
|
316
316
|
for (const id of articleIds) {
|
|
317
317
|
await delay(3);
|