@squiz/component-cli-lib 1.51.1-alpha.1 → 1.51.1-alpha.10

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.51.1-alpha.1",
3
+ "version": "1.51.1-alpha.10",
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.51.1-alpha.1",
17
- "@squiz/component-web-api-lib": "1.51.1-alpha.1",
18
- "@squiz/dx-common-lib": "1.51.1-alpha.1",
19
- "@squiz/dx-json-schema-lib": "1.51.1-alpha.1",
20
- "@squiz/dx-logger-lib": "1.51.1-alpha.1",
21
- "@squiz/virus-scanner-lib": "1.51.1-alpha.1",
16
+ "@squiz/component-lib": "1.51.1-alpha.10",
17
+ "@squiz/component-web-api-lib": "1.51.1-alpha.10",
18
+ "@squiz/dx-common-lib": "1.51.1-alpha.10",
19
+ "@squiz/dx-json-schema-lib": "1.51.1-alpha.10",
20
+ "@squiz/dx-logger-lib": "1.51.1-alpha.10",
21
+ "@squiz/virus-scanner-lib": "1.51.1-alpha.10",
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.51.1-alpha.1",
35
+ "@squiz/render-runtime-lib": "1.51.1-alpha.10",
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": "04214ade8ff6fe306b1ae01ad28dc76532a40ed7"
42
+ "gitHead": "5e60a13adca251262fe3127d8da61ef69013f051"
43
43
  }
@@ -75,6 +75,9 @@ const authToken =
75
75
  'COMPONENT_SET_ENVIRONMENT_WRITE',
76
76
  ],
77
77
  },
78
+ [DxpServiceId.segmentation]: {
79
+ privileges: ['SEGMENT_READ'],
80
+ },
78
81
  },
79
82
  });
80
83
 
@@ -107,7 +107,9 @@ describe('PageRenderController- Integration', () => {
107
107
  });
108
108
 
109
109
  it('should render a page', async () => {
110
- const response = await contentService.post('page-contents', pageContents);
110
+ const response = await contentService.post('page-contents', pageContents, {
111
+ headers: { 'x-api-key': 'MOCK_KEY' },
112
+ });
111
113
  PAGE_CONTENT_ID = response.data.id!;
112
114
  expect(response.status).toBe(201);
113
115
 
@@ -185,42 +187,50 @@ describe('PageRenderController- Integration', () => {
185
187
  },
186
188
  ],
187
189
  };
188
- const response = await contentService.post('page-contents', pageVariant);
190
+ const response = await contentService.post('page-contents', pageVariant, {
191
+ headers: { 'x-api-key': 'MOCK_KEY' },
192
+ });
189
193
  PAGE_CONTENT_ID = response.data.id!;
190
194
  });
191
195
 
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 },
196
+ describe('Variations', () => {
197
+ it('a valid page variation', async () => {
198
+ const mockJwtPayload = {
199
+ segments: ['is-authenticated'],
200
+ customerid: 'test-id-123',
201
+ };
202
+ const mockSession = Buffer.from(JSON.stringify(mockJwtPayload)).toString('base64');
203
+ try {
204
+ const page = await pageRenderService.get(`p/${PAGE_CONTENT_ID}`, {
205
+ headers: { 'x-dxp-customer-session': mockSession },
206
+ });
207
+ expect(page.data).toEqual('<div class="container"><h1>Hello Authenticated User!</h1></div>');
208
+ } catch (error) {
209
+ console.log(JSON.stringify(error, null));
210
+ }
200
211
  });
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 },
212
+ it('another valid page variation', async () => {
213
+ const mockJwtPayload = {
214
+ segments: ['is-unauthenticated'],
215
+ customerid: 'test-id-123',
216
+ };
217
+ const mockSession = Buffer.from(JSON.stringify(mockJwtPayload)).toString('base64');
218
+ const page = await pageRenderService.get(`p/${PAGE_CONTENT_ID}`, {
219
+ headers: { 'x-dxp-customer-session': mockSession },
220
+ });
221
+ expect(page.data).toEqual('<div class="container"><h1>Hello Unauthenticated User!</h1></div>');
211
222
  });
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 },
223
+ it('the default node if there is not a valid page variation', async () => {
224
+ const mockJwtPayload = {
225
+ segments: ['not-valid'],
226
+ customerid: 'test-id-123',
227
+ };
228
+ const mockSession = Buffer.from(JSON.stringify(mockJwtPayload)).toString('base64');
229
+ const page = await pageRenderService.get(`p/${PAGE_CONTENT_ID}`, {
230
+ headers: { 'x-dxp-customer-session': mockSession },
231
+ });
232
+ expect(page.data).toEqual('<div class="container"><h1>Hello World!</h1></div>');
222
233
  });
223
- expect(page.data).toEqual('<div class="container"><h1>Hello World!</h1></div>');
224
234
  });
225
235
  });
226
236
  });