@squiz/component-cli-lib 1.50.1-alpha.2 → 1.50.1-alpha.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/component-cli-lib",
3
- "version": "1.50.1-alpha.2",
3
+ "version": "1.50.1-alpha.4",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -13,12 +13,12 @@
13
13
  "author": "",
14
14
  "license": "ISC",
15
15
  "devDependencies": {
16
- "@squiz/component-lib": "1.50.1-alpha.2",
17
- "@squiz/component-web-api-lib": "1.50.1-alpha.2",
18
- "@squiz/dx-common-lib": "1.50.1-alpha.2",
19
- "@squiz/dx-json-schema-lib": "1.50.1-alpha.2",
20
- "@squiz/dx-logger-lib": "1.50.1-alpha.2",
21
- "@squiz/virus-scanner-lib": "1.50.1-alpha.2",
16
+ "@squiz/component-lib": "1.50.1-alpha.4",
17
+ "@squiz/component-web-api-lib": "1.50.1-alpha.4",
18
+ "@squiz/dx-common-lib": "1.50.1-alpha.4",
19
+ "@squiz/dx-json-schema-lib": "1.50.1-alpha.4",
20
+ "@squiz/dx-logger-lib": "1.50.1-alpha.4",
21
+ "@squiz/virus-scanner-lib": "1.50.1-alpha.4",
22
22
  "@types/cli-color": "2.0.2",
23
23
  "@types/express": "4.17.17",
24
24
  "@types/jest": "28.1.8",
@@ -32,12 +32,12 @@
32
32
  "typescript": "4.9.4"
33
33
  },
34
34
  "dependencies": {
35
- "@squiz/render-runtime-lib": "1.50.1-alpha.2",
35
+ "@squiz/render-runtime-lib": "1.50.1-alpha.4",
36
36
  "archiver": "5.3.1",
37
37
  "axios": "1.3.2",
38
38
  "cli-color": "^2.0.2",
39
39
  "open": "^8.4.0",
40
40
  "supertest": "^6.2.3"
41
41
  },
42
- "gitHead": "ec81b03b1f03a1f3cc4127ee68a4da221cb9dbcf"
42
+ "gitHead": "6ee39e06e101416bd0474de4585a172a8e5568b9"
43
43
  }
@@ -111,9 +111,116 @@ describe('PageRenderController- Integration', () => {
111
111
  PAGE_CONTENT_ID = response.data.id!;
112
112
  expect(response.status).toBe(201);
113
113
 
114
- const page = await pageRenderService.get(`p/${PAGE_CONTENT_ID}`);
114
+ const mockJwtPayload = {
115
+ segments: ['is-authenticated'],
116
+ customerId: 'test-id-123',
117
+ };
118
+ const mockSession = Buffer.from(JSON.stringify(mockJwtPayload)).toString('base64');
119
+ const page = await pageRenderService.get(`p/${PAGE_CONTENT_ID}`, {
120
+ headers: { 'x-dxp-customer-session': mockSession },
121
+ });
115
122
  expect(page.data).toEqual(
116
123
  `<div class="container"><h1>Hello World!</h1><esi:include src="/__dxp/au/components-render/${process.env.TENANT_ID}/r/unit-test-components/test-page-render/1.0.0/main?_componentSet=${COMPONENT_SET_WEB_PATH}&_contentItemId=${COMPONENT_CONTENT_ID}"/><p>Bottom text</p></div>`,
117
124
  );
118
125
  });
126
+
127
+ describe('it should render', () => {
128
+ beforeAll(async () => {
129
+ const pageVariant: PageContentsCreate = {
130
+ name: 'page-contents-test-2',
131
+ layouts: [
132
+ {
133
+ name: 'single-column',
134
+ content: {
135
+ main: [
136
+ {
137
+ type: 'variation',
138
+ default: {
139
+ node: {
140
+ type: 'tag',
141
+ tag: 'h1',
142
+ children: [
143
+ {
144
+ type: 'text',
145
+ value: 'Hello World!',
146
+ },
147
+ ],
148
+ },
149
+ },
150
+ variants: [
151
+ {
152
+ node: {
153
+ type: 'tag',
154
+ tag: 'h1',
155
+ children: [
156
+ {
157
+ type: 'text',
158
+ value: 'Hello Authenticated User!',
159
+ },
160
+ ],
161
+ },
162
+ conditions: {
163
+ segment: { code: 'is-authenticated' },
164
+ },
165
+ },
166
+ {
167
+ node: {
168
+ type: 'tag',
169
+ tag: 'h1',
170
+ children: [
171
+ {
172
+ type: 'text',
173
+ value: 'Hello Unauthenticated User!',
174
+ },
175
+ ],
176
+ },
177
+ conditions: {
178
+ segment: { code: 'is-unauthenticated' },
179
+ },
180
+ },
181
+ ],
182
+ },
183
+ ],
184
+ },
185
+ },
186
+ ],
187
+ };
188
+ const response = await contentService.post('page-contents', pageVariant);
189
+ PAGE_CONTENT_ID = response.data.id!;
190
+ });
191
+
192
+ it('a valid page variation', async () => {
193
+ const mockJwtPayload = {
194
+ segments: ['is-authenticated'],
195
+ customerId: 'test-id-123',
196
+ };
197
+ const mockSession = Buffer.from(JSON.stringify(mockJwtPayload)).toString('base64');
198
+ const page = await pageRenderService.get(`p/${PAGE_CONTENT_ID}`, {
199
+ headers: { 'x-dxp-customer-session': mockSession },
200
+ });
201
+ expect(page.data).toEqual('<div class="container"><h1>Hello Authenticated User!</h1></div>');
202
+ });
203
+ it('another valid page variation', async () => {
204
+ const mockJwtPayload = {
205
+ segments: ['is-unauthenticated'],
206
+ customerId: 'test-id-123',
207
+ };
208
+ const mockSession = Buffer.from(JSON.stringify(mockJwtPayload)).toString('base64');
209
+ const page = await pageRenderService.get(`p/${PAGE_CONTENT_ID}`, {
210
+ headers: { 'x-dxp-customer-session': mockSession },
211
+ });
212
+ expect(page.data).toEqual('<div class="container"><h1>Hello Unauthenticated User!</h1></div>');
213
+ });
214
+ it('the default node if there is not a valid page variation', async () => {
215
+ const mockJwtPayload = {
216
+ segments: ['not-valid'],
217
+ customerId: 'test-id-123',
218
+ };
219
+ const mockSession = Buffer.from(JSON.stringify(mockJwtPayload)).toString('base64');
220
+ const page = await pageRenderService.get(`p/${PAGE_CONTENT_ID}`, {
221
+ headers: { 'x-dxp-customer-session': mockSession },
222
+ });
223
+ expect(page.data).toEqual('<div class="container"><h1>Hello World!</h1></div>');
224
+ });
225
+ });
119
226
  });