@squiz/component-cli-lib 1.2.10 → 1.2.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"upload-component-folder.js","sourceRoot":"","sources":["../src/upload-component-folder.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAkE;AAElE,wDAAoD;AACpD,wDAAuE;AACvE,2DAA8B;AAC9B,gDAAwB;AACxB,kDAAwE;AACxE,0DAA8B;AAC9B,wDAAyD;AAE5C,QAAA,MAAM,GAAW,IAAA,yBAAS,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AAEhF,KAAK,UAAU,qBAAqB,CACzC,UAAkB,EAClB,6BAAqC,EACrC,yBAAiC,EACjC,cAAsB,EAAE;IAExB,MAAM,MAAM,GAAG,MAAM,kBAAG,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;IAE1E,IAAI;QACF,MAAM,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;YACjC,OAAO,EAAE,6BAA6B;YACtC,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,MAAM,eAAe,CAAC,UAAU,EAAE,yBAAyB,CAAC,CAAC;QAC7D,cAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAChC,MAAM,GAAG,GAAG,MAAM,IAAA,4BAAY,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAEnD,MAAM,aAAa,GAAG,MAAM,cAAc,CAAM,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAExF,cAAM,CAAC,IAAI,CAAC,kBAAkB,aAAa,CAAC,EAAE,uBAAuB,CAAC,CAAC;QACvE,MAAM,IAAA,8BAAU,EAAC,aAAa,EAAE,GAAG,CAAC,CAAC;QAErC,MAAM,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,CAAC,MAAM,cAAc,OAAO,EAAE,CAAC,CAAC;KACtF;SAAM;QACL,OAAO,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;KAClE;AACH,CAAC;AAED,SAAS,YAAY,CAAC,KAAU;IAC9B,OAAO,KAAK,IAAI,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC;AAC9C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/component-cli-lib",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -24,19 +24,20 @@
24
24
  "ts-jest": "28.0.8",
25
25
  "ts-loader": "9.3.1",
26
26
  "ts-node": "10.9.1",
27
- "typescript": "4.7.4"
27
+ "typescript": "4.9.3"
28
28
  },
29
29
  "dependencies": {
30
- "@squiz/component-lib": "1.2.10",
31
- "@squiz/component-web-api-lib": "1.2.10",
32
- "@squiz/dx-common-lib": "1.2.10",
33
- "@squiz/dx-logger-lib": "1.2.10",
34
- "@squiz/render-runtime-lib": "1.2.10",
35
- "@squiz/virus-scanner-lib": "^1.2.2",
30
+ "@squiz/component-lib": "1.2.12",
31
+ "@squiz/component-web-api-lib": "1.2.12",
32
+ "@squiz/dx-common-lib": "1.2.12",
33
+ "@squiz/dx-logger-lib": "1.2.12",
34
+ "@squiz/render-runtime-lib": "1.2.12",
35
+ "@squiz/virus-scanner-lib": "1.2.12",
36
36
  "archiver": "5.3.1",
37
37
  "axios": "0.27.2",
38
38
  "cli-color": "^2.0.2",
39
+ "open": "^8.4.0",
39
40
  "supertest": "^6.2.3"
40
41
  },
41
- "gitHead": "a245165ef36e9b72faece39b0ad8f2182fa310b3"
42
+ "gitHead": "dfecde850fcd8f456c07d11446d49d5e7c7aa0f9"
42
43
  }
@@ -13,7 +13,7 @@ describe('component-dev', () => {
13
13
  let server: Server;
14
14
  let request: supertest.SuperTest<supertest.Test>;
15
15
  beforeAll(async () => {
16
- server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0 });
16
+ server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0, noBrowser: true });
17
17
  request = supertest(server);
18
18
  });
19
19
 
@@ -45,7 +45,7 @@ describe('component-dev', () => {
45
45
  fixtureDirectory = createdFixtureDirectory;
46
46
  componentName = createdName;
47
47
 
48
- server = startDevelopmentRender(fixtureDirectory, { port: 0 });
48
+ server = startDevelopmentRender(fixtureDirectory, { port: 0, noBrowser: true });
49
49
  request = supertest(server);
50
50
  });
51
51
  afterAll(async () => {
@@ -66,4 +66,20 @@ describe('component-dev', () => {
66
66
  expect(response.text).toEqual('hello');
67
67
  });
68
68
  });
69
+
70
+ describe('It should pass a simple test and not launch the browser if the -nb flag is present', () => {
71
+ let server: Server;
72
+ let request: supertest.SuperTest<supertest.Test>;
73
+ beforeAll(async () => {
74
+ server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0, noBrowser: true });
75
+ request = supertest(server);
76
+ });
77
+ afterAll(async () => {
78
+ server.close();
79
+ });
80
+ it('should find the component', async () => {
81
+ const response = await request.get(`/r/set/unit-test-components/test-component/1.0.0?something=hello`);
82
+ expect(response.text).toEqual('<div>hello - {"something":"hello"}</div>');
83
+ });
84
+ });
69
85
  });
@@ -9,8 +9,9 @@ describe('component-dev', () => {
9
9
  describe('accessing local dev routes', () => {
10
10
  let server: Server;
11
11
  let request: supertest.SuperTest<supertest.Test>;
12
+
12
13
  beforeAll(async () => {
13
- server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0 });
14
+ server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0, noBrowser: true });
14
15
  request = supertest(server);
15
16
  });
16
17
 
@@ -30,7 +31,7 @@ describe('component-dev', () => {
30
31
  });
31
32
 
32
33
  describe('definition routes', () => {
33
- const server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0 });
34
+ const server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0, noBrowser: true });
34
35
  const request = () => supertest(server);
35
36
  routeTests.definition(request, 'http://localhost:0');
36
37
  afterAll(() => {
@@ -39,7 +40,7 @@ describe('component-dev', () => {
39
40
  });
40
41
 
41
42
  describe('static routes', () => {
42
- const server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0 });
43
+ const server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0, noBrowser: true });
43
44
  const request = () => supertest(server);
44
45
  routeTests.static(request);
45
46
  afterAll(() => {
@@ -48,7 +49,7 @@ describe('component-dev', () => {
48
49
  });
49
50
 
50
51
  describe('render routes', () => {
51
- const server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0 });
52
+ const server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0, noBrowser: true });
52
53
  const request = () => supertest(server);
53
54
  routeTests.render(request, 'http://localhost:0');
54
55
  afterAll(() => {
@@ -6,6 +6,7 @@ import {
6
6
  import { getLogger, LoggerOptions } from '@squiz/dx-logger-lib';
7
7
  import path from 'path';
8
8
  import { ComponentFunctionService, ComponentSetServiceForLocalDev, ManifestServiceForDev } from '@squiz/component-lib';
9
+ import open from 'open';
9
10
 
10
11
  /**
11
12
  * startDevelopmentRender starts a dev-mode render stack for any
@@ -18,7 +19,7 @@ import { ComponentFunctionService, ComponentSetServiceForLocalDev, ManifestServi
18
19
  */
19
20
  export function startDevelopmentRender(
20
21
  componentPath: string,
21
- options: { port: number; loggingFormat?: LoggerOptions['format'] },
22
+ options: { port: number; loggingFormat?: LoggerOptions['format']; noBrowser?: boolean },
22
23
  ) {
23
24
  const logger = getLogger({ name: 'component-dev', format: options.loggingFormat || 'human' });
24
25
  const rootUrl = `http://localhost:${options.port}`;
@@ -51,6 +52,10 @@ export function startDevelopmentRender(
51
52
  logger.info(`Component development webserver started on port ${options.port}`);
52
53
  });
53
54
 
55
+ if (options?.noBrowser !== true) {
56
+ open(rootUrl);
57
+ }
58
+
54
59
  server.on('close', async () => {
55
60
  await componentRunnerService.stop();
56
61
  });
@@ -4,7 +4,7 @@ import path from 'path';
4
4
 
5
5
  import fsp from 'fs/promises';
6
6
  import { randomBytes } from 'crypto';
7
- import { ComponentSetWebModel } from '@squiz/component-lib';
7
+ import { ComponentSetWebModelForCreate } from '@squiz/component-lib';
8
8
  import { parseEnvVarForVar } from '@squiz/dx-common-lib';
9
9
  import { ContentApi } from '@squiz/component-web-api-lib';
10
10
  import { config } from 'dotenv';
@@ -77,7 +77,7 @@ export async function deleteComponentSet(webPath: string) {
77
77
  }
78
78
  }
79
79
 
80
- export async function addComponentSet(componentSet: ComponentSetWebModel) {
80
+ export async function addComponentSet(componentSet: ComponentSetWebModelForCreate) {
81
81
  try {
82
82
  await managementService.post(`/component-set`, componentSet);
83
83
  } catch (error) {
@@ -9,12 +9,13 @@ import configObj, {
9
9
  deleteComponentSet,
10
10
  addContentItem,
11
11
  deleteContentItem,
12
+ managementServiceRoot,
12
13
  } from './helper';
13
14
  import color from 'cli-color';
14
15
  import path from 'path';
15
16
  import supertest from 'supertest';
16
17
  import { logger } from '../upload-component-folder';
17
- import { ComponentSetWebModel } from '@squiz/component-lib';
18
+ import { ComponentSetWebModelForCreate } from '@squiz/component-lib';
18
19
  import fsp from 'fs/promises';
19
20
  import { randomUUID } from 'crypto';
20
21
 
@@ -22,195 +23,203 @@ const mockConsoleError = jest.fn();
22
23
  const mockConsoleLog = jest.fn();
23
24
 
24
25
  const orgConsoleError = console.error;
25
- const webPath = 'set';
26
+ const webPath = 'set-' + randomUUID();
26
27
  const contentItemId = randomUUID();
27
28
  const testFilesDir = path.resolve(__dirname, 'test-files');
28
29
 
29
- beforeAll(async () => {
30
- await fsp.rm(testFilesDir, { force: true, recursive: true });
31
- await fsp.mkdir(testFilesDir);
32
- });
33
-
34
- afterAll(async () => {
35
- // clean up the component added by the test
36
- await deleteComponentSet(webPath);
37
- await deleteContentItem(contentItemId);
38
-
39
- for (const componentName of getTestComponents()) {
40
- try {
41
- await managementService.delete(`/component/smoke-test-components/${componentName}`);
42
- } catch {
43
- // no op
44
- }
45
- }
46
-
47
- // clean up the test componnet files
48
- await fsp.rm(testFilesDir, { force: true, recursive: true });
49
- });
50
-
51
- describe('Test isolated test cases', () => {
52
- beforeEach(() => {
53
- jest.spyOn(logger, 'error').mockImplementation(mockConsoleError);
54
- jest.spyOn(logger, 'info').mockImplementation(mockConsoleLog);
55
- });
56
-
57
- it('Should fail uploading a component without manifest.json', async () => {
58
- mockConsoleError.mockClear();
59
- const componentPath = path.join(__dirname, '/__components__/invalid-upload');
60
- await uploadComponentFolder(
61
- componentPath,
62
- configObj.managementServiceUrl + '/v1',
63
- configObj.renderServiceUrl,
64
- testFilesDir,
65
- );
66
- expect(mockConsoleError.mock.calls[0][0]).toEqual(color.red('manifest could not be found'));
67
- });
68
-
69
- it('Should fail uploading a component that has invalid manifest.json', async () => {
70
- mockConsoleError.mockClear();
71
- const componentPath = path.join(__dirname, '/__components__/invalid-manifest');
72
- await uploadComponentFolder(
73
- componentPath,
74
- configObj.managementServiceUrl + '/v1',
75
- configObj.renderServiceUrl,
76
- testFilesDir,
77
- );
78
- expect(mockConsoleError.mock.calls[0][0]).toEqual(
79
- color.red('failed validation: /name pattern must match pattern "^[a-zA-Z0-9_\\-]+$"'),
80
- );
81
- });
82
-
83
- it('Should fail uploading the component that has size more than 100MB', async () => {
84
- mockConsoleError.mockClear();
85
- const componentPath = path.join(__dirname, '/__components__/big-package');
86
- const filePath = `${componentPath}/105mb-file`;
87
- await createFile(filePath, 105); // Higher limit has been used because compression reduces the size if you use closer to 100MB
88
- await uploadComponentFolder(
89
- componentPath,
90
- configObj.managementServiceUrl + '/v1',
91
- configObj.renderServiceUrl,
92
- testFilesDir,
93
- );
94
- expect(mockConsoleError.mock.calls[0][0]).toEqual(
95
- color.red(['File size exceeds the maximum limit of 100MB'].join('')),
96
- );
97
- removeFile(filePath);
30
+ describe('uploading a component', () => {
31
+ beforeAll(async () => {
32
+ await fsp.rm(testFilesDir, { force: true, recursive: true });
33
+ await fsp.mkdir(testFilesDir);
98
34
  });
99
- });
100
35
 
101
- describe('Deploy basic component having a static file', () => {
102
- // component to deploy for this test
103
- const componentPath = path.join(__dirname, '/__components__/cmp-static-file-test');
104
-
105
- beforeAll(async () => {
36
+ afterAll(async () => {
37
+ // clean up the component added by the test
106
38
  await deleteComponentSet(webPath);
107
39
  await deleteContentItem(contentItemId);
40
+
108
41
  for (const componentName of getTestComponents()) {
109
42
  try {
110
- await managementService.delete(`/component/${componentName}`);
43
+ await managementService.delete(`/component/smoke-test-components/${componentName}`);
111
44
  } catch {
112
45
  // no op
113
46
  }
114
47
  }
115
- });
116
48
 
117
- beforeEach(() => {
118
- console.error = mockConsoleError;
119
- console.log = mockConsoleLog;
49
+ // clean up the test componnet files
50
+ await fsp.rm(testFilesDir, { force: true, recursive: true });
120
51
  });
121
52
 
122
- afterEach(() => {
123
- console.error = orgConsoleError;
124
- });
53
+ describe('Test isolated test cases', () => {
54
+ beforeEach(() => {
55
+ jest.spyOn(logger, 'error').mockImplementation(mockConsoleError);
56
+ jest.spyOn(logger, 'info').mockImplementation(mockConsoleLog);
57
+ });
125
58
 
126
- it('Should upload the component and return a valid url to preview', async () => {
127
- await uploadComponentFolder(
128
- componentPath,
129
- configObj.managementServiceUrl + '/v1',
130
- configObj.renderServiceUrl,
131
- testFilesDir,
132
- );
133
-
134
- const uploadedComponent = '<a href="/preview/smoke-test-components/cmp-static-file-test/1.0.0">1.0.0</a>';
135
- const get = await supertest(configObj.renderServiceUrl).get('/');
136
- expect(get.status).toEqual(200);
137
- expect((get as any)?.res?.text).toContain(uploadedComponent);
138
- });
59
+ it('Should fail uploading a component without manifest.json', async () => {
60
+ mockConsoleError.mockClear();
61
+ const componentPath = path.join(__dirname, '/__components__/invalid-upload');
62
+ await uploadComponentFolder(managementServiceRoot, configObj.managementServiceUrl, componentPath, testFilesDir);
63
+ expect(mockConsoleError.mock.calls[0][0]).toEqual(color.red('manifest could not be found'));
64
+ });
139
65
 
140
- it('Should fail upload the component with same version', async () => {
141
- mockConsoleError.mockClear();
142
- await uploadComponentFolder(
143
- componentPath,
144
- configObj.managementServiceUrl + '/v1',
145
- configObj.renderServiceUrl,
146
- testFilesDir,
147
- );
148
- expect(mockConsoleError.mock.calls[0][0]).toEqual(
149
- color.red('Cannot upload component version, smoke-test-components/cmp-static-file-test 1.0.0 already exists'),
150
- );
151
- });
66
+ it('Should fail uploading a component that has invalid manifest.json', async () => {
67
+ mockConsoleError.mockClear();
68
+ const componentPath = path.join(__dirname, '/__components__/invalid-manifest');
69
+ await uploadComponentFolder(
70
+ managementServiceRoot,
71
+ configObj.managementServiceUrl,
72
+ componentPath,
73
+
74
+ testFilesDir,
75
+ );
76
+ expect(mockConsoleError.mock.calls[0][0]).toEqual(
77
+ color.red('failed validation: /name pattern must match pattern "^[a-zA-Z0-9_\\-]+$"'),
78
+ );
79
+ });
152
80
 
153
- it('Should render component', async () => {
154
- const componentSet: ComponentSetWebModel = {
155
- webPath,
156
- displayName: 'Set',
157
- description: 'Set description',
158
- headers: {},
159
- environmentVariables: {},
160
- components: {
161
- 'smoke-test-components/cmp-static-file-test': [{ environmentVariables: {}, version: '1.0.0' }],
162
- },
163
- componentVersionRules: {},
164
- };
165
-
166
- await addComponentSet(componentSet);
167
-
168
- const response = await renderService.get(
169
- '/r/set/smoke-test-components/cmp-static-file-test/1.0.0/?something=hello',
170
- );
171
- expect(response.status).toEqual(200);
172
- expect(response.data).toEqual(
173
- [
174
- '<div>Input: hello</div>',
175
- '<div>smoke-test-components/cmp-static-file-test 1.0.0 ',
176
- `${configObj.renderServiceUrl}/s/set/smoke-test-components/cmp-static-file-test/1.0.0/birthday-cake.png</div>`,
177
- ].join(''),
178
- );
81
+ it('Should fail uploading the component that has size more than 100MB', async () => {
82
+ mockConsoleError.mockClear();
83
+ const componentPath = path.join(__dirname, '/__components__/big-package');
84
+ const filePath = `${componentPath}/105mb-file`;
85
+ await createFile(filePath, 105); // Higher limit has been used because compression reduces the size if you use closer to 100MB
86
+ await uploadComponentFolder(
87
+ managementServiceRoot,
88
+ configObj.managementServiceUrl,
89
+ componentPath,
90
+
91
+ testFilesDir,
92
+ );
93
+ expect(mockConsoleError.mock.calls[0][0]).toEqual(
94
+ color.red(['File size exceeds the maximum limit of 100MB'].join('')),
95
+ );
96
+ removeFile(filePath);
97
+ });
179
98
  });
180
99
 
181
- it('Should render component with content item ID input', async () => {
182
- const componentSet: ComponentSetWebModel = {
183
- webPath,
184
- displayName: 'Set',
185
- description: 'Set description',
186
- headers: {},
187
- environmentVariables: {},
188
- components: {
189
- 'smoke-test-components/cmp-static-file-test': [{ environmentVariables: {}, version: '1.0.0' }],
190
- },
191
- componentVersionRules: {},
192
- };
193
- await addComponentSet(componentSet);
194
-
195
- // add a component item for the test
196
- await addContentItem({
197
- id: contentItemId,
198
- schemaName: 'smoke-test-components/cmp-static-file-test/1.0.0/main',
199
- content: {
200
- something: 'from-content-item-service',
201
- },
100
+ describe('Deploy basic component having a static file', () => {
101
+ // component to deploy for this test
102
+ const componentPath = path.join(__dirname, '/__components__/cmp-static-file-test');
103
+
104
+ beforeAll(async () => {
105
+ await deleteComponentSet(webPath);
106
+ await deleteContentItem(contentItemId);
107
+ for (const componentName of getTestComponents()) {
108
+ try {
109
+ await managementService.delete(`/component/${componentName}`);
110
+ } catch {
111
+ // no op
112
+ }
113
+ }
114
+ });
115
+
116
+ beforeEach(() => {
117
+ console.error = mockConsoleError;
118
+ console.log = mockConsoleLog;
119
+ });
120
+
121
+ afterEach(() => {
122
+ console.error = orgConsoleError;
123
+ });
124
+
125
+ it('Should upload the component and return a valid url to preview', async () => {
126
+ await uploadComponentFolder(
127
+ managementServiceRoot,
128
+ configObj.managementServiceUrl,
129
+ componentPath,
130
+
131
+ testFilesDir,
132
+ );
133
+
134
+ const uploadedComponent = '<a href="/preview/smoke-test-components/cmp-static-file-test/1.0.0">1.0.0</a>';
135
+ const get = await supertest(configObj.renderServiceUrl).get('/');
136
+ expect(get.status).toEqual(200);
137
+ expect((get as any)?.res?.text).toContain(uploadedComponent);
202
138
  });
203
139
 
204
- const response = await renderService.get(
205
- '/r/set/smoke-test-components/cmp-static-file-test/1.0.0/?_contentItemId=' + contentItemId,
206
- );
207
- expect(response.status).toEqual(200);
208
- expect(response.data).toEqual(
209
- [
210
- '<div>Input: from-content-item-service</div>',
211
- '<div>smoke-test-components/cmp-static-file-test 1.0.0 ',
212
- `${configObj.renderServiceUrl}/s/set/smoke-test-components/cmp-static-file-test/1.0.0/birthday-cake.png</div>`,
213
- ].join(''),
214
- );
140
+ it('Should fail upload the component with same version', async () => {
141
+ mockConsoleError.mockClear();
142
+ await uploadComponentFolder(
143
+ managementServiceRoot,
144
+ configObj.managementServiceUrl,
145
+ componentPath,
146
+
147
+ testFilesDir,
148
+ );
149
+ expect(mockConsoleError.mock.calls[0][0]).toEqual(
150
+ color.red('Cannot upload component version, smoke-test-components/cmp-static-file-test 1.0.0 already exists'),
151
+ );
152
+ });
153
+
154
+ it('Should render component', async () => {
155
+ const componentSet: ComponentSetWebModelForCreate = {
156
+ webPath,
157
+ displayName: 'some-display-name',
158
+ description: 'Set description',
159
+ headers: {},
160
+ environmentVariables: {},
161
+ components: {
162
+ 'smoke-test-components/cmp-static-file-test': [
163
+ {
164
+ environmentVariables: {},
165
+ version: '1.0.0',
166
+ },
167
+ ],
168
+ },
169
+ componentVersionRules: {},
170
+ };
171
+
172
+ await addComponentSet(componentSet);
173
+
174
+ const response = await renderService.get(
175
+ `/r/${webPath}/smoke-test-components/cmp-static-file-test/1.0.0/?something=hello`,
176
+ );
177
+ expect(response.status).toEqual(200);
178
+ expect(response.data).toEqual(
179
+ [
180
+ '<div>Input: hello</div>',
181
+ '<div>smoke-test-components/cmp-static-file-test 1.0.0 ',
182
+ `${configObj.renderServiceUrl}/s/${webPath}/smoke-test-components/cmp-static-file-test/1.0.0/birthday-cake.png</div>`,
183
+ ].join(''),
184
+ );
185
+ });
186
+
187
+ it('Should render component with content item ID input', async () => {
188
+ const componentSet: ComponentSetWebModelForCreate = {
189
+ webPath,
190
+ displayName: 'some-display-name',
191
+ description: 'Set description',
192
+ headers: {},
193
+ environmentVariables: {},
194
+ components: {
195
+ 'smoke-test-components/cmp-static-file-test': [{ environmentVariables: {}, version: '1.0.0' }],
196
+ },
197
+ componentVersionRules: {},
198
+ };
199
+ await addComponentSet(componentSet);
200
+
201
+ // add a component item for the test
202
+ await addContentItem({
203
+ id: contentItemId,
204
+ schemaName: 'smoke-test-components/cmp-static-file-test/1.0.0/main',
205
+ content: {
206
+ something: 'from-content-item-service',
207
+ },
208
+ });
209
+
210
+ console.log(`/r/${webPath}/smoke-test-components/cmp-static-file-test/1.0.0/?_contentItemId=` + contentItemId);
211
+
212
+ const response = await renderService.get(
213
+ `/r/${webPath}/smoke-test-components/cmp-static-file-test/1.0.0/?_contentItemId=` + contentItemId,
214
+ );
215
+ expect(response.status).toEqual(200);
216
+ expect(response.data).toEqual(
217
+ [
218
+ '<div>Input: from-content-item-service</div>',
219
+ '<div>smoke-test-components/cmp-static-file-test 1.0.0 ',
220
+ `${configObj.renderServiceUrl}/s/${webPath}/smoke-test-components/cmp-static-file-test/1.0.0/birthday-cake.png</div>`,
221
+ ].join(''),
222
+ );
223
+ });
215
224
  });
216
225
  });