apostrophe 3.17.0 → 3.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/.editorconfig +3 -0
  2. package/.eslintrc +4 -3
  3. package/.github/workflows/main.yml +2 -2
  4. package/.stylelintrc +12 -2
  5. package/CHANGELOG.md +34 -2
  6. package/defaults.js +2 -2
  7. package/index.js +124 -33
  8. package/lib/escape-host.js +8 -0
  9. package/lib/mongodb-connect.js +55 -0
  10. package/lib/opentelemetry.js +144 -0
  11. package/modules/@apostrophecms/area/ui/apos/apps/AposAreas.js +2 -0
  12. package/modules/@apostrophecms/area/ui/apos/components/AposAreaEditor.vue +20 -8
  13. package/modules/@apostrophecms/area/ui/apos/components/AposAreaWidget.vue +10 -0
  14. package/modules/@apostrophecms/asset/lib/globalIcons.js +1 -0
  15. package/modules/@apostrophecms/attachment/index.js +81 -29
  16. package/modules/@apostrophecms/db/index.js +7 -10
  17. package/modules/@apostrophecms/doc/index.js +138 -23
  18. package/modules/@apostrophecms/doc-type/index.js +162 -63
  19. package/modules/@apostrophecms/doc-type/ui/apos/components/AposDocContextMenu.vue +39 -1
  20. package/modules/@apostrophecms/doc-type/ui/apos/components/AposDocEditor.vue +11 -1
  21. package/modules/@apostrophecms/email/index.js +1 -1
  22. package/modules/@apostrophecms/express/index.js +2 -2
  23. package/modules/@apostrophecms/http/index.js +2 -1
  24. package/modules/@apostrophecms/i18n/i18n/en.json +10 -0
  25. package/modules/@apostrophecms/i18n/i18n/es.json +7 -0
  26. package/modules/@apostrophecms/i18n/i18n/pt-BR.json +7 -0
  27. package/modules/@apostrophecms/i18n/i18n/sk.json +7 -0
  28. package/modules/@apostrophecms/image/index.js +182 -1
  29. package/modules/@apostrophecms/image/ui/apos/apps/AposImageRelationshipQueryFilter.js +13 -0
  30. package/modules/@apostrophecms/image/ui/apos/components/AposImageCropper.vue +460 -0
  31. package/modules/@apostrophecms/image/ui/apos/components/AposImageRelationshipEditor.vue +510 -0
  32. package/modules/@apostrophecms/image/ui/apos/components/AposMediaManager.vue +5 -1
  33. package/modules/@apostrophecms/image/ui/apos/lib/aspectRatios.js +26 -0
  34. package/modules/@apostrophecms/image-widget/views/widget.html +5 -2
  35. package/modules/@apostrophecms/modal/ui/apos/mixins/AposEditorMixin.js +45 -1
  36. package/modules/@apostrophecms/module/index.js +98 -17
  37. package/modules/@apostrophecms/module/lib/events.js +46 -11
  38. package/modules/@apostrophecms/page/index.js +55 -22
  39. package/modules/@apostrophecms/piece-page-type/index.js +1 -0
  40. package/modules/@apostrophecms/piece-type/index.js +13 -4
  41. package/modules/@apostrophecms/piece-type/ui/apos/components/AposRelationshipEditor.vue +2 -2
  42. package/modules/@apostrophecms/rich-text-widget/index.js +1 -3
  43. package/modules/@apostrophecms/rich-text-widget/ui/apos/components/AposRichTextWidgetEditor.vue +4 -0
  44. package/modules/@apostrophecms/schema/index.js +79 -73
  45. package/modules/@apostrophecms/schema/ui/apos/components/AposInputArea.vue +10 -0
  46. package/modules/@apostrophecms/schema/ui/apos/components/AposInputObject.vue +22 -3
  47. package/modules/@apostrophecms/schema/ui/apos/components/AposInputRelationship.vue +72 -36
  48. package/modules/@apostrophecms/schema/ui/apos/components/AposInputSelect.vue +7 -26
  49. package/modules/@apostrophecms/schema/ui/apos/components/AposInputString.vue +8 -0
  50. package/modules/@apostrophecms/schema/ui/apos/components/AposSchema.vue +45 -15
  51. package/modules/@apostrophecms/task/index.js +106 -52
  52. package/modules/@apostrophecms/template/index.js +111 -76
  53. package/modules/@apostrophecms/template/lib/custom-tags/component.js +42 -22
  54. package/modules/@apostrophecms/ui/ui/apos/components/AposSelect.vue +61 -0
  55. package/modules/@apostrophecms/ui/ui/apos/components/AposSlat.vue +46 -11
  56. package/modules/@apostrophecms/ui/ui/apos/components/AposSlatList.vue +10 -0
  57. package/modules/@apostrophecms/ui/ui/apos/components/AposTreeHeader.vue +2 -22
  58. package/modules/@apostrophecms/ui/ui/apos/utils/index.js +9 -0
  59. package/modules/@apostrophecms/widget-type/index.js +2 -23
  60. package/modules/@apostrophecms/widget-type/ui/apos/components/AposWidget.vue +1 -1
  61. package/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue +20 -1
  62. package/modules/@apostrophecms/widget-type/ui/apos/mixins/AposWidgetMixin.js +0 -9
  63. package/package.json +16 -12
  64. package/scripts/lint-i18n.js +2 -2
  65. package/test/assets.js +2 -1
  66. package/test/attachments.js +119 -26
  67. package/test/bundle.js +1 -1
  68. package/test/content-i18n.js +6 -6
  69. package/test/docs.js +244 -4
  70. package/test/draft-published.js +41 -41
  71. package/test/express.js +1 -1
  72. package/test/http.js +2 -2
  73. package/test/images.js +94 -4
  74. package/test/job.js +1 -1
  75. package/test/locks.js +1 -1
  76. package/test/middleware-and-route-order.js +3 -3
  77. package/test/pages-public-api.js +48 -4
  78. package/test/pages-rest.js +20 -20
  79. package/test/pages.js +377 -11
  80. package/test/parked-pages.js +1 -1
  81. package/test/permissions.js +10 -10
  82. package/test/pieces-public-api.js +130 -6
  83. package/test/pieces.js +247 -60
  84. package/test/recursionGuard.js +6 -6
  85. package/test/restApiRoutes.js +6 -6
  86. package/test/schemaBuilders.js +7 -7
  87. package/test/schemas.js +59 -59
  88. package/test/search.js +3 -3
  89. package/test/soft-redirects.js +13 -13
  90. package/test/static-i18n.js +1 -1
  91. package/test/templates.js +10 -10
  92. package/test/urls.js +2 -2
  93. package/test/users.js +21 -21
  94. package/test/utils.js +13 -13
  95. package/test/widgets.js +2 -2
  96. package/test-lib/util.js +2 -5
  97. package/modules/@apostrophecms/rich-text-widget/ui/apos/components/AposRichTextWidget.vue +0 -26
package/test/docs.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const t = require('../test-lib/test.js');
2
2
  const assert = require('assert');
3
3
  const _ = require('lodash');
4
+
4
5
  let apos;
5
6
 
6
7
  describe('Docs', function() {
@@ -30,6 +31,20 @@ describe('Docs', function() {
30
31
  }
31
32
  }
32
33
  }
34
+ },
35
+ '@apostrophecms/page': {
36
+ options: {
37
+ park: [],
38
+ types: [
39
+ {
40
+ name: 'test-page',
41
+ label: 'Test Page'
42
+ }
43
+ ]
44
+ }
45
+ },
46
+ 'test-page': {
47
+ extend: '@apostrophecms/page-type'
33
48
  }
34
49
  }
35
50
  });
@@ -144,6 +159,68 @@ describe('Docs', function() {
144
159
  assert(person._friends[0].slug === 'larry');
145
160
  });
146
161
 
162
+ it('should support custom context menu (required only)', async function() {
163
+ const operation = {
164
+ context: 'update',
165
+ action: 'test',
166
+ label: 'Menu Label',
167
+ modal: 'SomeModalComponent'
168
+ };
169
+ assert.strictEqual(apos.doc.contextOperations.length, 0);
170
+
171
+ apos.doc.addContextOperation('test-people', operation);
172
+ assert.strictEqual(apos.doc.contextOperations.length, 1);
173
+ assert.deepStrictEqual(apos.doc.contextOperations[0], {
174
+ ...operation,
175
+ moduleName: 'test-people'
176
+ });
177
+ });
178
+
179
+ it('should support custom context menu (with optional)', async function() {
180
+ apos.doc.contextOperations = [];
181
+ const operation = {
182
+ context: 'update',
183
+ action: 'test',
184
+ label: 'Menu Label',
185
+ modal: 'SomeModalComponent',
186
+ manuallyPublished: true,
187
+ modifiers: [ 'danger' ]
188
+ };
189
+ assert.strictEqual(apos.doc.contextOperations.length, 0);
190
+
191
+ apos.doc.addContextOperation('test-people', operation);
192
+ assert.strictEqual(apos.doc.contextOperations.length, 1);
193
+ assert.deepStrictEqual(apos.doc.contextOperations[0], {
194
+ ...operation,
195
+ moduleName: 'test-people'
196
+ });
197
+ });
198
+
199
+ it('should override custom context menu', async function() {
200
+ apos.doc.contextOperations = [];
201
+ const operation1 = {
202
+ context: 'update',
203
+ action: 'test',
204
+ label: 'Op1',
205
+ modal: 'SomeModalComponent'
206
+ };
207
+ const operation2 = {
208
+ context: 'update',
209
+ action: 'test',
210
+ label: 'Op2',
211
+ modal: 'SomeModalComponent'
212
+ };
213
+ assert.strictEqual(apos.doc.contextOperations.length, 0);
214
+
215
+ apos.doc.addContextOperation('test-people', operation1);
216
+ apos.doc.addContextOperation('test-people', operation2);
217
+ assert.strictEqual(apos.doc.contextOperations.length, 1);
218
+ assert.deepStrictEqual(apos.doc.contextOperations[0], {
219
+ ...operation2,
220
+ moduleName: 'test-people'
221
+ });
222
+ });
223
+
147
224
  /// ///
148
225
  // UNIQUENESS
149
226
  /// ///
@@ -299,7 +376,7 @@ describe('Docs', function() {
299
376
  assert(doc.slug.match(/^one\d+$/));
300
377
  });
301
378
 
302
- it('should add the aposDocId to the related documents\' relatedReverseIds field', async () => {
379
+ it('should add the aposDocId to the related documents\' relatedReverseIds field and update their `cacheInvalidatedAt` field', async function() {
303
380
  const object = {
304
381
  aposDocId: 'paul',
305
382
  aposLocale: 'en:published',
@@ -314,7 +391,7 @@ describe('Docs', function() {
314
391
  _friends: [ { _id: 'carl:en:published' }, { _id: 'larry:en:published' } ]
315
392
  };
316
393
 
317
- await apos.doc.insert(apos.task.getReq(), object);
394
+ const response = await apos.doc.insert(apos.task.getReq(), object);
318
395
 
319
396
  const carlDoc = await apos.doc.db.findOne({
320
397
  slug: 'carl',
@@ -328,9 +405,11 @@ describe('Docs', function() {
328
405
 
329
406
  assert(carlDoc.relatedReverseIds.length === 1);
330
407
  assert(carlDoc.relatedReverseIds[0] === 'paul');
408
+ assert(carlDoc.cacheInvalidatedAt.getTime() === response.updatedAt.getTime());
331
409
 
332
410
  assert(larryDoc.relatedReverseIds.length === 1);
333
411
  assert(larryDoc.relatedReverseIds[0] === 'paul');
412
+ assert(larryDoc.cacheInvalidatedAt.getTime() === response.updatedAt.getTime());
334
413
  });
335
414
 
336
415
  it('should not allow you to call the insert method if you are not an admin', async function() {
@@ -419,7 +498,7 @@ describe('Docs', function() {
419
498
  assert(counts.Lori === 2);
420
499
  });
421
500
 
422
- it('should remove the aposDocId from the related documents\' relatedReverseIds field', async () => {
501
+ it('should remove the aposDocId from the related documents\' relatedReverseIds field and update their `cacheInvalidatedAt` field', async function() {
423
502
  const paulDoc = await apos.doc.db.findOne({
424
503
  slug: 'paul',
425
504
  aposLocale: 'en:published'
@@ -432,7 +511,7 @@ describe('Docs', function() {
432
511
  _friends: [ { _id: 'larry:en:published' } ]
433
512
  };
434
513
 
435
- await apos.doc.update(apos.task.getReq(), object);
514
+ const response = await apos.doc.update(apos.task.getReq(), object);
436
515
 
437
516
  const carlDoc = await apos.doc.db.findOne({
438
517
  slug: 'carl',
@@ -445,9 +524,79 @@ describe('Docs', function() {
445
524
  });
446
525
 
447
526
  assert(carlDoc.relatedReverseIds.length === 0);
527
+ assert(carlDoc.cacheInvalidatedAt.getTime() === response.updatedAt.getTime());
448
528
 
449
529
  assert(larryDoc.relatedReverseIds.length === 1);
450
530
  assert(larryDoc.relatedReverseIds[0] === 'paul');
531
+ assert(larryDoc.cacheInvalidatedAt.getTime() === response.updatedAt.getTime());
532
+ });
533
+
534
+ it('should update the related reverse documents\' `cacheInvalidatedAt` field', async function() {
535
+ const object = {
536
+ aposDocId: 'john',
537
+ aposLocale: 'en:published',
538
+ slug: 'john',
539
+ visibility: 'public',
540
+ type: 'test-people',
541
+ firstName: 'John',
542
+ lastName: 'McClane',
543
+ age: 40,
544
+ alive: true,
545
+ friendsIds: [ 'carl' ],
546
+ _friends: [ { _id: 'carl:en:published' } ]
547
+ };
548
+
549
+ await apos.doc.insert(apos.task.getReq(), object);
550
+
551
+ const carlDoc = await apos.doc.db.findOne({
552
+ slug: 'carl',
553
+ aposLocale: 'en:published'
554
+ });
555
+
556
+ // update carl, now john (related reverse friend) should have its `cacheInvalidatedAt` field updated as well
557
+ const response = await apos.doc.update(apos.task.getReq(), {
558
+ ...carlDoc,
559
+ alive: false
560
+ });
561
+
562
+ const johnDoc = await apos.doc.db.findOne({
563
+ slug: 'john',
564
+ aposLocale: 'en:published'
565
+ });
566
+
567
+ assert(johnDoc.cacheInvalidatedAt.getTime() === response.updatedAt.getTime());
568
+ });
569
+
570
+ it('should update the pieces parent page\'s `cacheInvalidatedAt` field', async function() {
571
+ const page = {
572
+ slug: '/parent/new-page',
573
+ visibility: 'public',
574
+ type: 'test-page',
575
+ title: 'New Page'
576
+ };
577
+
578
+ const object = {
579
+ aposDocId: 'bruce',
580
+ aposLocale: 'en:published',
581
+ slug: 'bruce',
582
+ visibility: 'public',
583
+ type: 'test-people',
584
+ firstName: 'Bruce',
585
+ lastName: 'Lee',
586
+ age: 30,
587
+ alive: false,
588
+ _parentSlug: '/parent/new-page'
589
+ };
590
+
591
+ await apos.doc.insert(apos.task.getReq(), page);
592
+ const response = await apos.doc.insert(apos.task.getReq(), object);
593
+
594
+ const pageDoc = await apos.doc.db.findOne({
595
+ slug: '/parent/new-page',
596
+ aposLocale: 'en:published'
597
+ });
598
+
599
+ assert(pageDoc.cacheInvalidatedAt.getTime() === response.updatedAt.getTime());
451
600
  });
452
601
 
453
602
  it('should not allow you to call the update method if you are not an admin', async function() {
@@ -687,4 +836,95 @@ describe('Docs', function() {
687
836
  await apos.doc.createTextIndex();
688
837
  });
689
838
 
839
+ /// ///
840
+ // MIGRATIONS
841
+ /// ///
842
+
843
+ it('should add via a migration the `cacheInvalidatedAt` field to any doc and set it to equal the doc\'s `updatedAt` field', async function() {
844
+ const objects = [
845
+ {
846
+ slug: 'test-for-cacheInvalidatedAt-field-migration1',
847
+ visibility: 'public',
848
+ type: 'test-people',
849
+ firstName: 'Kurt',
850
+ lastName: 'Cobain',
851
+ age: 27,
852
+ alive: false,
853
+ updatedAt: '2022-03-28T12:57:03.685Z'
854
+ },
855
+ {
856
+ slug: 'test-for-cacheInvalidatedAt-field-migration2',
857
+ visibility: 'public',
858
+ type: 'test-people',
859
+ firstName: 'Jim',
860
+ lastName: 'Morrison',
861
+ age: 27,
862
+ alive: false,
863
+ updatedAt: '2020-08-29T12:57:03.685Z'
864
+ }
865
+ ];
866
+
867
+ await apos.doc.db.insertMany(objects);
868
+ await apos.doc.setCacheField();
869
+
870
+ const docs = await apos.doc.db.find({ slug: /test-for-cacheInvalidatedAt-field-migration/ }).toArray();
871
+ docs.forEach((doc, index) => {
872
+ const timestamps = {
873
+ doc: new Date(doc.cacheInvalidatedAt).toString(),
874
+ expected: new Date(objects[index].updatedAt).toString()
875
+
876
+ };
877
+ assert(timestamps.doc === timestamps.expected);
878
+ });
879
+ });
880
+
881
+ it('should not add via a migration the `cacheInvalidatedAt` field to docs that already have it', async function() {
882
+ const object = {
883
+ slug: 'test-for-cacheInvalidatedAt-field-migration3',
884
+ visibility: 'public',
885
+ type: 'test-people',
886
+ firstName: 'Janis',
887
+ lastName: 'Joplin',
888
+ age: 27,
889
+ alive: false,
890
+ updatedAt: '2018-08-29T12:57:03.685Z',
891
+ cacheInvalidatedAt: '2019-08-29T12:57:03.685Z'
892
+ };
893
+
894
+ await apos.doc.db.insert(object);
895
+ await apos.doc.setCacheField();
896
+
897
+ const doc = await apos.doc.db.findOne({ slug: 'test-for-cacheInvalidatedAt-field-migration3' });
898
+ const timestamps = {
899
+ doc: new Date(doc.cacheInvalidatedAt).toString(),
900
+ expected: new Date(object.cacheInvalidatedAt).toString()
901
+ };
902
+
903
+ assert(timestamps.doc === timestamps.expected);
904
+ });
905
+
906
+ /// ///
907
+ // CACHING
908
+ /// ///
909
+
910
+ it('should add a `cacheInvalidatedAt` field and set it to equal `updatedAt` field when saving a doc', async function() {
911
+ const object = {
912
+ slug: 'test-for-cacheInvalidatedAt-field',
913
+ visibility: 'public',
914
+ type: 'test-people',
915
+ firstName: 'Michael',
916
+ lastName: 'Jackson',
917
+ age: 64,
918
+ alive: true
919
+ };
920
+
921
+ const response = await apos.doc.insert(apos.task.getReq(), object);
922
+ const draft = await apos.doc.db.findOne({
923
+ _id: `${response.aposDocId}:en:draft`
924
+ });
925
+
926
+ assert(response.cacheInvalidatedAt.getTime() === response.updatedAt.getTime());
927
+ assert(draft.cacheInvalidatedAt.getTime() === draft.updatedAt.getTime());
928
+ });
929
+
690
930
  });
@@ -15,7 +15,7 @@ describe('Draft / Published', function() {
15
15
  // EXISTENCE
16
16
  /// ///
17
17
 
18
- it('should initialize with a schema', async () => {
18
+ it('should initialize with a schema', async function() {
19
19
  apos = await t.create({
20
20
  root: module,
21
21
 
@@ -122,7 +122,7 @@ describe('Draft / Published', function() {
122
122
 
123
123
  let testDraftProduct;
124
124
 
125
- it('should be able to create and insert a draft product', async () => {
125
+ it('should be able to create and insert a draft product', async function() {
126
126
  const product = apos.product.newInstance();
127
127
  product.title = 'Test Product';
128
128
  testDraftProduct = await apos.product.insert(apos.task.getReq({
@@ -131,19 +131,19 @@ describe('Draft / Published', function() {
131
131
  assert(testDraftProduct.modified);
132
132
  });
133
133
 
134
- it('published should not exist yet', async () => {
134
+ it('published should not exist yet', async function() {
135
135
  assert(!await apos.doc.db.findOne({
136
136
  _id: testDraftProduct._id.replace(':draft', ':published')
137
137
  }));
138
138
  });
139
139
 
140
- it('should be able to publish the product', async () => {
140
+ it('should be able to publish the product', async function() {
141
141
  await apos.product.publish(apos.task.getReq({
142
142
  mode: 'draft'
143
143
  }), testDraftProduct);
144
144
  });
145
145
 
146
- it('published product should exist and be the same', async () => {
146
+ it('published product should exist and be the same', async function() {
147
147
  const product = await apos.product.find(apos.task.getReq({
148
148
  mode: 'published'
149
149
  }), {
@@ -155,7 +155,7 @@ describe('Draft / Published', function() {
155
155
  assert(product.title === testDraftProduct.title);
156
156
  });
157
157
 
158
- it('original product should no longer be modified', async () => {
158
+ it('original product should no longer be modified', async function() {
159
159
  testDraftProduct = await apos.product.find(apos.task.getReq({
160
160
  mode: 'draft'
161
161
  }), {
@@ -165,14 +165,14 @@ describe('Draft / Published', function() {
165
165
  assert(!testDraftProduct.modified);
166
166
  });
167
167
 
168
- it('original product still shows as unmodified if we update it with no changes', async () => {
168
+ it('original product still shows as unmodified if we update it with no changes', async function() {
169
169
  testDraftProduct = await apos.product.update(apos.task.getReq({
170
170
  mode: 'draft'
171
171
  }), testDraftProduct);
172
172
  assert(!testDraftProduct.modified);
173
173
  });
174
174
 
175
- it('original product shows as modified if we make a change to it', async () => {
175
+ it('original product shows as modified if we make a change to it', async function() {
176
176
  testDraftProduct.title = 'Another Title';
177
177
  testDraftProduct = await apos.product.update(apos.task.getReq({
178
178
  mode: 'draft'
@@ -180,7 +180,7 @@ describe('Draft / Published', function() {
180
180
  assert(testDraftProduct.modified);
181
181
  });
182
182
 
183
- it('can revert the draft to published', async () => {
183
+ it('can revert the draft to published', async function() {
184
184
  testDraftProduct = await apos.product.revertDraftToPublished(apos.task.getReq({
185
185
  mode: 'draft'
186
186
  }), testDraftProduct);
@@ -189,13 +189,13 @@ describe('Draft / Published', function() {
189
189
  assert(testDraftProduct.title === 'Test Product');
190
190
  });
191
191
 
192
- it('cannot revert the draft again', async () => {
192
+ it('cannot revert the draft again', async function() {
193
193
  assert(!await apos.product.revertDraftToPublished(apos.task.getReq({
194
194
  mode: 'draft'
195
195
  }), testDraftProduct));
196
196
  });
197
197
 
198
- it('original product shows as modified if we make another change to it', async () => {
198
+ it('original product shows as modified if we make another change to it', async function() {
199
199
  testDraftProduct.title = 'Title 3';
200
200
  testDraftProduct = await apos.product.update(apos.task.getReq({
201
201
  mode: 'draft'
@@ -203,13 +203,13 @@ describe('Draft / Published', function() {
203
203
  assert(testDraftProduct.modified);
204
204
  });
205
205
 
206
- it('should be able to publish the product', async () => {
206
+ it('should be able to publish the product again', async function() {
207
207
  await apos.product.publish(apos.task.getReq({
208
208
  mode: 'draft'
209
209
  }), testDraftProduct);
210
210
  });
211
211
 
212
- it('"previous published" should be deduplicated at this point', async () => {
212
+ it('"previous published" should be deduplicated at this point', async function() {
213
213
  const previous = await apos.doc.db.findOne({
214
214
  _id: testDraftProduct._id.replace(':draft', ':previous')
215
215
  });
@@ -217,7 +217,7 @@ describe('Draft / Published', function() {
217
217
  assert.strictEqual(previous.slug, `deduplicate-${previous.aposDocId}-test-product`);
218
218
  });
219
219
 
220
- it('original product shows as modified if we make a third change to it', async () => {
220
+ it('original product shows as modified if we make a third change to it', async function() {
221
221
  testDraftProduct.title = 'Title 4';
222
222
  testDraftProduct = await apos.product.update(apos.task.getReq({
223
223
  mode: 'draft'
@@ -225,7 +225,7 @@ describe('Draft / Published', function() {
225
225
  assert(testDraftProduct.modified);
226
226
  });
227
227
 
228
- it('can revert the draft to Title 3', async () => {
228
+ it('can revert the draft to Title 3', async function() {
229
229
  testDraftProduct = await apos.product.revertDraftToPublished(apos.task.getReq({
230
230
  mode: 'draft'
231
231
  }), testDraftProduct);
@@ -234,7 +234,7 @@ describe('Draft / Published', function() {
234
234
  assert(testDraftProduct.title === 'Title 3');
235
235
  });
236
236
 
237
- it('can revert the published version to Test Product (previous publication)', async () => {
237
+ it('can revert the published version to Test Product (previous publication)', async function() {
238
238
  const req = apos.task.getReq({
239
239
  mode: 'published'
240
240
  });
@@ -257,7 +257,7 @@ describe('Draft / Published', function() {
257
257
  assert(testDraftProduct.modified);
258
258
  });
259
259
 
260
- it('cannot revert published to previous again', async () => {
260
+ it('cannot revert published to previous again', async function() {
261
261
  const req = apos.task.getReq({
262
262
  mode: 'published'
263
263
  });
@@ -276,7 +276,7 @@ describe('Draft / Published', function() {
276
276
 
277
277
  let parent;
278
278
 
279
- it('should be able to create and insert a draft page', async () => {
279
+ it('should be able to create and insert a draft page', async function() {
280
280
  parent = {
281
281
  type: 'test-page',
282
282
  title: 'Parent',
@@ -294,19 +294,19 @@ describe('Draft / Published', function() {
294
294
  assert(parent.modified);
295
295
  });
296
296
 
297
- it('published should not exist yet', async () => {
297
+ it('published should not exist yet again', async function() {
298
298
  assert(!await apos.doc.db.findOne({
299
299
  _id: parent._id.replace(':draft', ':published')
300
300
  }));
301
301
  });
302
302
 
303
- it('should be able to publish the page', async () => {
303
+ it('should be able to publish the page', async function() {
304
304
  await apos.page.publish(apos.task.getReq({
305
305
  mode: 'draft'
306
306
  }), parent);
307
307
  });
308
308
 
309
- it('published page should exist and be the same', async () => {
309
+ it('published page should exist and be the same', async function() {
310
310
  const publishedParent = await apos.page.find(apos.task.getReq({
311
311
  mode: 'published'
312
312
  }), {
@@ -318,7 +318,7 @@ describe('Draft / Published', function() {
318
318
  assert(publishedParent.title === parent.title);
319
319
  });
320
320
 
321
- it('original page should no longer be modified', async () => {
321
+ it('original page should no longer be modified', async function() {
322
322
  parent = await apos.page.find(apos.task.getReq({
323
323
  mode: 'draft'
324
324
  }), {
@@ -328,14 +328,14 @@ describe('Draft / Published', function() {
328
328
  assert(!parent.modified);
329
329
  });
330
330
 
331
- it('original page still shows as unmodified if we update it with no changes', async () => {
331
+ it('original page still shows as unmodified if we update it with no changes', async function() {
332
332
  parent = await apos.page.update(apos.task.getReq({
333
333
  mode: 'draft'
334
334
  }), parent);
335
335
  assert(!parent.modified);
336
336
  });
337
337
 
338
- it('original page shows as modified if we make a change to it', async () => {
338
+ it('original page shows as modified if we make a change to it', async function() {
339
339
  parent.title = 'Parent Title 2';
340
340
  parent = await apos.page.update(apos.task.getReq({
341
341
  mode: 'draft'
@@ -343,7 +343,7 @@ describe('Draft / Published', function() {
343
343
  assert(parent.modified);
344
344
  });
345
345
 
346
- it('can revert the page draft to published', async () => {
346
+ it('can revert the page draft to published', async function() {
347
347
  parent = await apos.page.revertDraftToPublished(apos.task.getReq({
348
348
  mode: 'draft'
349
349
  }), parent);
@@ -352,7 +352,7 @@ describe('Draft / Published', function() {
352
352
  assert(parent.title === 'Parent');
353
353
  });
354
354
 
355
- it('cannot revert the draft again', async () => {
355
+ it('cannot revert the draft again (2)', async function() {
356
356
  assert(!await apos.page.revertDraftToPublished(apos.task.getReq({
357
357
  mode: 'draft'
358
358
  }), parent));
@@ -361,7 +361,7 @@ describe('Draft / Published', function() {
361
361
  // TODO convert more tests, add tests involving the page tree more,
362
362
  // write another test file with REST tests, implement the RESTfulness
363
363
 
364
- it('original page shows as modified if we make another change to it', async () => {
364
+ it('original page shows as modified if we make another change to it', async function() {
365
365
  parent.title = 'Parent Title 3';
366
366
  parent = await apos.page.update(apos.task.getReq({
367
367
  mode: 'draft'
@@ -369,13 +369,13 @@ describe('Draft / Published', function() {
369
369
  assert(parent.modified);
370
370
  });
371
371
 
372
- it('should be able to publish the page', async () => {
372
+ it('should be able to publish the page again', async function() {
373
373
  await apos.page.publish(apos.task.getReq({
374
374
  mode: 'draft'
375
375
  }), parent);
376
376
  });
377
377
 
378
- it('original page shows as modified if we make a third change to it', async () => {
378
+ it('original page shows as modified if we make a third change to it', async function() {
379
379
  parent.title = 'Parent Title 4';
380
380
  parent = await apos.page.update(apos.task.getReq({
381
381
  mode: 'draft'
@@ -383,7 +383,7 @@ describe('Draft / Published', function() {
383
383
  assert(parent.modified);
384
384
  });
385
385
 
386
- it('can revert the draft to parent Title 3', async () => {
386
+ it('can revert the draft to parent Title 3', async function() {
387
387
  parent = await apos.page.revertDraftToPublished(apos.task.getReq({
388
388
  mode: 'draft'
389
389
  }), parent);
@@ -392,7 +392,7 @@ describe('Draft / Published', function() {
392
392
  assert(parent.title === 'Parent Title 3');
393
393
  });
394
394
 
395
- it('can revert the published version to previous', async () => {
395
+ it('can revert the published version to previous', async function() {
396
396
  const req = apos.task.getReq({
397
397
  mode: 'published'
398
398
  });
@@ -415,7 +415,7 @@ describe('Draft / Published', function() {
415
415
  assert(parent.modified);
416
416
  });
417
417
 
418
- it('cannot revert published to previous again', async () => {
418
+ it('cannot revert published to previous again (2)', async function() {
419
419
  const req = apos.task.getReq({
420
420
  mode: 'published'
421
421
  });
@@ -434,7 +434,7 @@ describe('Draft / Published', function() {
434
434
 
435
435
  let sibling;
436
436
 
437
- it('should be able to create and insert a sibling draft page', async () => {
437
+ it('should be able to create and insert a sibling draft page', async function() {
438
438
  sibling = {
439
439
  type: 'test-page',
440
440
  title: 'Sibling',
@@ -446,7 +446,7 @@ describe('Draft / Published', function() {
446
446
  assert(sibling.modified);
447
447
  });
448
448
 
449
- it('should be able to publish the sibling page', async () => {
449
+ it('should be able to publish the sibling page', async function() {
450
450
  await apos.page.publish(apos.task.getReq({
451
451
  mode: 'draft'
452
452
  }), sibling);
@@ -454,7 +454,7 @@ describe('Draft / Published', function() {
454
454
 
455
455
  let grandchild;
456
456
 
457
- it('should be able to create and insert a grandchild page', async () => {
457
+ it('should be able to create and insert a grandchild page', async function() {
458
458
  grandchild = {
459
459
  type: 'test-page',
460
460
  title: 'Grandchild',
@@ -469,7 +469,7 @@ describe('Draft / Published', function() {
469
469
  assert.strictEqual(grandchild.slug, '/parent/grandchild');
470
470
  });
471
471
 
472
- it('published grandchild should not exist yet', async () => {
472
+ it('published grandchild should not exist yet', async function() {
473
473
  assert(!await apos.page.find(apos.task.getReq({
474
474
  mode: 'published'
475
475
  }), {
@@ -477,7 +477,7 @@ describe('Draft / Published', function() {
477
477
  }).toObject());
478
478
  });
479
479
 
480
- it('should be able to publish the grandchild page', async () => {
480
+ it('should be able to publish the grandchild page', async function() {
481
481
  await apos.page.publish(apos.task.getReq({
482
482
  mode: 'draft'
483
483
  }), grandchild);
@@ -492,7 +492,7 @@ describe('Draft / Published', function() {
492
492
  assert.strictEqual(published.slug, '/parent/grandchild');
493
493
  });
494
494
 
495
- it('should be able to move the grandchild page beneath the sibling page', async () => {
495
+ it('should be able to move the grandchild page beneath the sibling page', async function() {
496
496
  grandchild = await apos.page.find(apos.task.getReq({
497
497
  mode: 'draft'
498
498
  }), {
@@ -518,7 +518,7 @@ describe('Draft / Published', function() {
518
518
  assert(!grandchild.modified);
519
519
  });
520
520
 
521
- it('published grandchild page should now also be beneath the sibling page', async () => {
521
+ it('published grandchild page should now also be beneath the sibling page', async function() {
522
522
  sibling = await apos.page.find(apos.task.getReq({
523
523
  mode: 'published'
524
524
  }), {
@@ -527,13 +527,13 @@ describe('Draft / Published', function() {
527
527
  assert(sibling && sibling._children && sibling._children[0] && sibling._children[0].aposDocId === grandchild.aposDocId);
528
528
  });
529
529
 
530
- it('should be able to publish the grandchild page again to re-execute the move in the published locale', async () => {
530
+ it('should be able to publish the grandchild page again to re-execute the move in the published locale', async function() {
531
531
  await apos.page.publish(apos.task.getReq({
532
532
  mode: 'draft'
533
533
  }), grandchild);
534
534
  });
535
535
 
536
- it('published grandchild page should now be beneath sibling page', async () => {
536
+ it('published grandchild page should now be beneath sibling page', async function() {
537
537
  const siblingPublished = await apos.page.find(apos.task.getReq({
538
538
  mode: 'published'
539
539
  }), {
package/test/express.js CHANGED
@@ -105,7 +105,7 @@ describe('Express', function() {
105
105
  assert(apos.app !== apos.baseApp);
106
106
  });
107
107
 
108
- it('should successfully make a GET request to establish CSRF', async function() {
108
+ it('should successfully make a GET request to establish CSRF (prefix)', async function() {
109
109
  jar = apos.http.jar();
110
110
  const body = await apos.http.get('/prefix/tests/welcome', {
111
111
  jar
package/test/http.js CHANGED
@@ -32,7 +32,7 @@ describe('Http', function() {
32
32
  jar = apos.http.jar();
33
33
  });
34
34
 
35
- it('should be able to make an http request', async () => {
35
+ it('should be able to make an http request', async function() {
36
36
  const result = await apos.http.get('/', {
37
37
  jar
38
38
  });
@@ -40,7 +40,7 @@ describe('Http', function() {
40
40
  assert(result.match(/logged out/));
41
41
  });
42
42
 
43
- it('should be able to make an http POST request with csrf header via default csrf convenience of http.post', async () => {
43
+ it('should be able to make an http POST request with csrf header via default csrf convenience of http.post', async function() {
44
44
  const response = await apos.http.post('/csrf-test', {
45
45
  jar,
46
46
  body: {}