apostrophe 3.13.0 → 3.14.2-alpha.20220401

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.
@@ -34,6 +34,24 @@ describe('Pieces Pages', function() {
34
34
  perPage: 10
35
35
  }
36
36
  },
37
+ home: {
38
+ extend: '@apostrophecms/piece-type',
39
+ options: {
40
+ name: 'home',
41
+ label: 'Home',
42
+ alias: 'home',
43
+ sort: { title: 1 }
44
+ }
45
+ },
46
+ 'home-page': {
47
+ extend: '@apostrophecms/piece-page-type',
48
+ options: {
49
+ name: 'homePiecePage',
50
+ label: 'Home Piece Page',
51
+ alias: 'homePiecePage',
52
+ perPage: 10
53
+ }
54
+ },
37
55
  '@apostrophecms/page': {
38
56
  options: {
39
57
  park: [
@@ -42,6 +60,12 @@ describe('Pieces Pages', function() {
42
60
  type: 'eventPage',
43
61
  slug: '/events',
44
62
  parkedId: 'events'
63
+ },
64
+ {
65
+ title: 'Home piece page',
66
+ type: 'homePiecePage',
67
+ slug: '/',
68
+ parkedId: 'home'
45
69
  }
46
70
  ]
47
71
  }
@@ -81,6 +105,36 @@ describe('Pieces Pages', function() {
81
105
  return apos.doc.db.insertMany(testItems);
82
106
  });
83
107
 
108
+ it('should be able to use db to insert test "home" pieces', async function() {
109
+ assert(apos.modules.home);
110
+ const testItems = [];
111
+ const total = 100;
112
+ for (let i = 1; (i <= total); i++) {
113
+ const paddedInt = apos.launder.padInteger(i, 3);
114
+
115
+ testItems.push({
116
+ _id: 'home' + paddedInt,
117
+ slug: 'home-' + paddedInt,
118
+ visibility: 'public',
119
+ type: 'home',
120
+ title: 'Home ' + paddedInt,
121
+ titleSortified: 'home ' + paddedInt,
122
+ body: {
123
+ metaType: 'area',
124
+ _id: apos.util.generateId(),
125
+ items: [
126
+ {
127
+ metaType: 'widget',
128
+ type: '@apostrophecms/rich-text',
129
+ content: '<p>This is some content.</p>'
130
+ }
131
+ ]
132
+ }
133
+ });
134
+ }
135
+
136
+ return apos.doc.db.insertMany(testItems);
137
+ });
84
138
  it('should populate the ._url property of pieces in any docs query', async function() {
85
139
  const piece = await apos.doc.find(apos.task.getAnonReq(), {
86
140
  type: 'event',
@@ -104,6 +158,15 @@ describe('Pieces Pages', function() {
104
158
  assert((!piece._url) || (piece._url.match(/undefined/)));
105
159
  });
106
160
 
161
+ it('should not create a double-slashed _url on a piece-page-type set as the homepage', async function() {
162
+ const piece = await apos.doc.find(apos.task.getAnonReq(), {
163
+ type: 'home',
164
+ title: 'Home 001'
165
+ }).toObject();
166
+ assert(piece);
167
+ assert(piece._url === '/home-001');
168
+ });
169
+
107
170
  it('should correctly populate the ._url property of pieces in a docs query if _url itself is "projected"', async function() {
108
171
  const piece = await apos.doc.find(apos.task.getAnonReq(), {
109
172
  type: 'event',
package/test/package.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "name": "test",
3
- "dependencies": {
4
- "apostrophe": "^3.0.0",
5
- "improve-global": "1.0.0",
6
- "improve-piece-type": "1.0.0"
7
- },
8
- "devDependencies": {
9
- "test-bundle": "1.0.0"
10
- }
11
- }