@squiz/component-cli-lib 1.2.1-alpha.106 → 1.2.1-alpha.107
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/.gitlab-ci.yml +18 -21
- package/CHANGELOG.md +8 -0
- package/jest.config.ts +3 -0
- package/lib/component-dev-folder-structures.spec.d.ts +1 -0
- package/lib/component-dev-folder-structures.spec.js +58 -0
- package/lib/component-dev-folder-structures.spec.js.map +1 -0
- package/lib/component-dev.d.ts +4 -1
- package/lib/component-dev.js +27 -18
- package/lib/component-dev.js.map +1 -1
- package/lib/component-dev.spec.js +28 -65
- package/lib/component-dev.spec.js.map +1 -1
- package/lib/integration-tests/__components__/big-package/manifest.json +3 -0
- package/lib/integration-tests/__components__/cmp-static-file-test/manifest.json +3 -0
- package/lib/integration-tests/__components__/invalid-manifest/manifest.json +3 -0
- package/lib/integration-tests/helper.d.ts +1 -0
- package/lib/integration-tests/helper.js +4 -1
- package/lib/integration-tests/helper.js.map +1 -1
- package/lib/integration-tests/service-deployment.spec.js +21 -1
- package/lib/integration-tests/service-deployment.spec.js.map +1 -1
- package/lib/integration-tests/upload-and-render-component.spec.js +24 -19
- package/lib/integration-tests/upload-and-render-component.spec.js.map +1 -1
- package/lib/upload-component-folder.d.ts +1 -1
- package/lib/upload-component-folder.js +9 -6
- package/lib/upload-component-folder.js.map +1 -1
- package/package.json +9 -9
- package/src/component-dev-folder-structures.spec.ts +69 -0
- package/src/component-dev.spec.ts +31 -83
- package/src/component-dev.ts +44 -18
- package/src/integration-tests/__components__/big-package/manifest.json +3 -0
- package/src/integration-tests/__components__/cmp-static-file-test/manifest.json +3 -1
- package/src/integration-tests/__components__/invalid-manifest/manifest.json +3 -0
- package/src/integration-tests/helper.ts +4 -0
- package/src/integration-tests/service-deployment.spec.ts +26 -2
- package/src/integration-tests/upload-and-render-component.spec.ts +51 -19
- package/src/upload-component-folder.ts +15 -7
- package/tsconfig.tsbuildinfo +1 -1
package/.gitlab-ci.yml
CHANGED
|
@@ -4,25 +4,21 @@
|
|
|
4
4
|
rules:
|
|
5
5
|
- if: $CI_DEPLOY_TO_PROD && $CI_COMMIT_REF_NAME == $TARGET_BRANCH_PRODUCTION
|
|
6
6
|
when: on_success
|
|
7
|
-
- when: never
|
|
8
7
|
|
|
9
8
|
.rules:when-uat:
|
|
10
9
|
rules:
|
|
11
10
|
- if: $CI_COMMIT_REF_NAME == $TARGET_BRANCH_UAT && $CI_DEPLOY_TO_PROD == null
|
|
12
11
|
when: on_success
|
|
13
|
-
- when: never
|
|
14
12
|
|
|
15
13
|
.rules:when-development:
|
|
16
14
|
rules:
|
|
17
15
|
- if: $CI_COMMIT_REF_NAME == $TARGET_BRANCH_DEVELOPMENT && $CI_DEPLOY_TO_PROD == null
|
|
18
16
|
when: on_success
|
|
19
|
-
- when: never
|
|
20
17
|
|
|
21
18
|
.rules:when-other-branch:
|
|
22
19
|
rules:
|
|
23
20
|
- if: $CI_COMMIT_REF_NAME != $TARGET_BRANCH_DEVELOPMENT && $CI_COMMIT_REF_NAME != $TARGET_BRANCH_UAT && $CI_COMMIT_REF_NAME != $TARGET_BRANCH_PRODUCTION && $CI_DEPLOY_TO_PROD == null
|
|
24
21
|
when: on_success
|
|
25
|
-
- when: never
|
|
26
22
|
|
|
27
23
|
.get-service-urls:
|
|
28
24
|
stage: smoke-test-setup
|
|
@@ -63,7 +59,7 @@
|
|
|
63
59
|
reports:
|
|
64
60
|
dotenv: dot.env
|
|
65
61
|
|
|
66
|
-
smoke-test:
|
|
62
|
+
.smoke-test:
|
|
67
63
|
stage: smoke-test
|
|
68
64
|
tags:
|
|
69
65
|
- size/l
|
|
@@ -83,13 +79,24 @@ smoke-test:
|
|
|
83
79
|
- runner_system_failure
|
|
84
80
|
- stuck_or_timeout_failure
|
|
85
81
|
|
|
86
|
-
|
|
82
|
+
smoke-test:development:
|
|
87
83
|
extends:
|
|
88
|
-
- .
|
|
89
|
-
- .
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
- .smoke-test
|
|
85
|
+
- .rules:when-development
|
|
86
|
+
|
|
87
|
+
smoke-test:uat:
|
|
88
|
+
extends:
|
|
89
|
+
- .smoke-test
|
|
90
|
+
- .rules:when-uat
|
|
91
|
+
|
|
92
|
+
# TODO: Do we need this running for feature branches?
|
|
93
|
+
# get-branch-service-urls:
|
|
94
|
+
# extends:
|
|
95
|
+
# - .rules:when-other-branch
|
|
96
|
+
# - .get-service-urls
|
|
97
|
+
# environment:
|
|
98
|
+
# name: non-production-development
|
|
99
|
+
# url: components.dev.dx.squiz.cloud
|
|
93
100
|
|
|
94
101
|
get-development-service-urls:
|
|
95
102
|
extends:
|
|
@@ -106,13 +113,3 @@ get-uat-service-urls:
|
|
|
106
113
|
environment:
|
|
107
114
|
name: non-production-development
|
|
108
115
|
url: components.dev.dx.squiz.cloud
|
|
109
|
-
|
|
110
|
-
get-production-service-urls:
|
|
111
|
-
extends:
|
|
112
|
-
- .rules:when-production
|
|
113
|
-
- .get-service-urls
|
|
114
|
-
environment:
|
|
115
|
-
name: production
|
|
116
|
-
url: components.prod.dx.squiz.cloud
|
|
117
|
-
tags:
|
|
118
|
-
- access/aws-dx-prod
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.2.1-alpha.107](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.107) (2022-09-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [1.2.1-alpha.106](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.106) (2022-09-02)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @squiz/component-cli-lib
|
package/jest.config.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const supertest_1 = __importDefault(require("supertest"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const render_runtime_lib_1 = require("@squiz/render-runtime-lib");
|
|
10
|
+
const component_dev_1 = require("./component-dev");
|
|
11
|
+
jest.setTimeout(20000);
|
|
12
|
+
describe('component-dev', () => {
|
|
13
|
+
describe('production style folder structure', () => {
|
|
14
|
+
let server;
|
|
15
|
+
let request;
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
server = (0, component_dev_1.startDevelopmentRender)(render_runtime_lib_1.TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
18
|
+
request = (0, supertest_1.default)(server);
|
|
19
|
+
});
|
|
20
|
+
afterAll(async () => {
|
|
21
|
+
server.close();
|
|
22
|
+
});
|
|
23
|
+
it('should find the component', async () => {
|
|
24
|
+
const response = await request.get(`/r/set/unit-test-components/test-component/1.0.0?something=hello`);
|
|
25
|
+
expect(response.text).toEqual('<h1>hello</h1>');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe('local developer style folders', () => {
|
|
29
|
+
let version;
|
|
30
|
+
let componentName;
|
|
31
|
+
let fixtureDirectory;
|
|
32
|
+
let server;
|
|
33
|
+
let request;
|
|
34
|
+
beforeAll(async () => {
|
|
35
|
+
const { fixtureDirectory: createdFixtureDirectory, version: createdVersion, componentName: createdName, } = await render_runtime_lib_1.TestHelpers.ComponentFixture.setupFullComponentDirectory('<h1>Hello World</h1>');
|
|
36
|
+
version = createdVersion;
|
|
37
|
+
fixtureDirectory = createdFixtureDirectory;
|
|
38
|
+
componentName = createdName;
|
|
39
|
+
server = (0, component_dev_1.startDevelopmentRender)(fixtureDirectory, { port: 0 });
|
|
40
|
+
request = (0, supertest_1.default)(server);
|
|
41
|
+
});
|
|
42
|
+
afterAll(async () => {
|
|
43
|
+
server.close();
|
|
44
|
+
});
|
|
45
|
+
afterAll(async () => {
|
|
46
|
+
await promises_1.default.rm(path_1.default.join(fixtureDirectory, componentName), { force: true, recursive: true });
|
|
47
|
+
});
|
|
48
|
+
it('should handle recursing folders to find the component', async () => {
|
|
49
|
+
const response = await request.get(`/r/set/some-namespace/${componentName}/${version}/`);
|
|
50
|
+
expect(response.text).toEqual('<h1>Hello World</h1>');
|
|
51
|
+
});
|
|
52
|
+
it('should handle serving static files from single component directory', async () => {
|
|
53
|
+
const response = await request.get(`/s/some-namespace/${componentName}/${version}/static.txt`);
|
|
54
|
+
expect(response.text).toEqual('hello');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=component-dev-folder-structures.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-dev-folder-structures.spec.js","sourceRoot":"","sources":["../src/component-dev-folder-structures.spec.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAClC,gDAAwB;AACxB,2DAA8B;AAE9B,kEAAwD;AACxD,mDAAyD;AAGzD,IAAI,CAAC,UAAU,CAAC,KAAM,CAAC,CAAC;AAExB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;QACjD,IAAI,MAAc,CAAC;QACnB,IAAI,OAA4C,CAAC;QACjD,SAAS,CAAC,KAAK,IAAI,EAAE;YACnB,MAAM,GAAG,IAAA,sCAAsB,EAAC,gCAAW,CAAC,sBAAsB,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,C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AE;YAClB,MAAM,kBAAG,CAAC,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7F,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;YACrE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,yBAAyB,aAAa,IAAI,OAAO,GAAG,CAAC,CAAC;YACzF,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oEAAoE,EAAE,KAAK,IAAI,EAAE;YAClF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,qBAAqB,aAAa,IAAI,OAAO,aAAa,CAAC,CAAC;YAC/F,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/component-dev.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { LoggerOptions } from '@squiz/dx-logger-lib';
|
|
1
3
|
/**
|
|
2
4
|
* startDevelopmentRender starts a dev-mode render stack for any
|
|
3
5
|
* local directory. This should start an express server on a random unused port
|
|
@@ -10,4 +12,5 @@
|
|
|
10
12
|
export declare function startDevelopmentRender(componentPath: string, options: {
|
|
11
13
|
port: number;
|
|
12
14
|
previewFile?: string;
|
|
13
|
-
|
|
15
|
+
loggingFormat?: LoggerOptions['format'];
|
|
16
|
+
}): import("http").Server;
|
package/lib/component-dev.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.startDevelopmentRender = void 0;
|
|
|
7
7
|
const render_runtime_lib_1 = require("@squiz/render-runtime-lib");
|
|
8
8
|
const dx_logger_lib_1 = require("@squiz/dx-logger-lib");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const component_lib_1 = require("@squiz/component-lib");
|
|
10
11
|
/**
|
|
11
12
|
* startDevelopmentRender starts a dev-mode render stack for any
|
|
12
13
|
* local directory. This should start an express server on a random unused port
|
|
@@ -16,25 +17,33 @@ const path_1 = __importDefault(require("path"));
|
|
|
16
17
|
* @param {object} options - Additional configuration for the dev stack
|
|
17
18
|
* @returns a function to stop the render stack
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
const logger = (0, dx_logger_lib_1.getLogger)({ name: 'component-dev', format: 'human' });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
function startDevelopmentRender(componentPath, options) {
|
|
21
|
+
const logger = (0, dx_logger_lib_1.getLogger)({ name: 'component-dev', format: options.loggingFormat || 'human' });
|
|
22
|
+
const rootUrl = `http://localhost:${options.port}`;
|
|
23
|
+
const dataMountPoint = path_1.default.resolve(process.cwd(), componentPath);
|
|
24
|
+
const componentRunnerService = new render_runtime_lib_1.ComponentRunnerServiceWithWorkers({
|
|
25
|
+
dataMountPoint,
|
|
26
|
+
shouldCacheResponses: false,
|
|
27
|
+
workerTimeout: 5000,
|
|
28
|
+
}, logger);
|
|
29
|
+
const webServer = (0, render_runtime_lib_1.setupRenderRuntimeServer)({
|
|
30
|
+
logger,
|
|
31
|
+
componentRunnerService,
|
|
32
|
+
componentSetService: new component_lib_1.ComponentSetServiceForLocalDev(logger),
|
|
33
|
+
componentFunctionService: new component_lib_1.ComponentFunctionService(rootUrl),
|
|
34
|
+
componentPreviewService: new render_runtime_lib_1.ComponentPreviewService(options.previewFile),
|
|
35
|
+
manifestService: new component_lib_1.ManifestServiceForDev(dataMountPoint, logger),
|
|
36
|
+
}, { rootUrl });
|
|
37
|
+
const server = webServer.listen(options.port, () => {
|
|
38
|
+
logger.info(`Component development webserver started on port ${options.port}`);
|
|
36
39
|
});
|
|
37
|
-
|
|
40
|
+
server.on('close', async () => {
|
|
41
|
+
await componentRunnerService.stop();
|
|
42
|
+
});
|
|
43
|
+
process.on('SIGINT', () => {
|
|
44
|
+
server.close();
|
|
45
|
+
});
|
|
46
|
+
return server;
|
|
38
47
|
}
|
|
39
48
|
exports.startDevelopmentRender = startDevelopmentRender;
|
|
40
49
|
//# sourceMappingURL=component-dev.js.map
|
package/lib/component-dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-dev.js","sourceRoot":"","sources":["../src/component-dev.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"component-dev.js","sourceRoot":"","sources":["../src/component-dev.ts"],"names":[],"mappings":";;;;;;AAAA,kEAImC;AACnC,wDAAgE;AAChE,gDAAwB;AACxB,wDAAuH;AAEvH;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,aAAqB,EACrB,OAAwF;IAExF,MAAM,MAAM,GAAG,IAAA,yBAAS,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,EAAE,CAAC,CAAC;IAC9F,MAAM,OAAO,GAAG,oBAAoB,OAAO,CAAC,IAAI,EAAE,CAAC;IACnD,MAAM,cAAc,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAElE,MAAM,sBAAsB,GAAG,IAAI,sDAAiC,CAClE;QACE,cAAc;QACd,oBAAoB,EAAE,KAAK;QAC3B,aAAa,EAAE,IAAK;KACrB,EACD,MAAM,CACP,CAAC;IACF,MAAM,SAAS,GAAG,IAAA,6CAAwB,EACxC;QACE,MAAM;QACN,sBAAsB;QACtB,mBAAmB,EAAE,IAAI,8CAA8B,CAAC,MAAM,CAAC;QAC/D,wBAAwB,EAAE,IAAI,wCAAwB,CAAC,OAAO,CAAC;QAC/D,uBAAuB,EAAE,IAAI,4CAAuB,CAAC,OAAO,CAAC,WAAW,CAAC;QACzE,eAAe,EAAE,IAAI,qCAAqB,CAAC,cAAc,EAAE,MAAM,CAAC;KACnE,EACD,EAAE,OAAO,EAAE,CACZ,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE;QACjD,MAAM,CAAC,IAAI,CAAC,mDAAmD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;QAC5B,MAAM,sBAAsB,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACxB,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAzCD,wDAyCC"}
|
|
@@ -3,87 +3,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
6
|
const render_runtime_lib_1 = require("@squiz/render-runtime-lib");
|
|
9
7
|
const component_dev_1 = require("./component-dev");
|
|
10
8
|
const supertest_1 = __importDefault(require("supertest"));
|
|
11
9
|
jest.setTimeout(20000);
|
|
12
10
|
describe('component-dev', () => {
|
|
13
|
-
describe('
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
doStopStack = await (0, component_dev_1.startDevelopmentRender)(path_1.default.join(__dirname, '../../../test-components'), { port: 0 });
|
|
17
|
-
});
|
|
18
|
-
afterAll(async () => {
|
|
19
|
-
await doStopStack();
|
|
20
|
-
});
|
|
21
|
-
it('should find the component', async () => {
|
|
22
|
-
const testServer = render_runtime_lib_1.TestHelpers.getTestServer();
|
|
23
|
-
const response = await testServer.get(`/r/set/test-component/1.0.0?something=hello`);
|
|
24
|
-
expect(response.text).toEqual('<h1>hello</h1>');
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe('local developer style folders', () => {
|
|
28
|
-
let doStopStack;
|
|
29
|
-
let version;
|
|
30
|
-
let componentName;
|
|
31
|
-
let fixtureDirectory;
|
|
11
|
+
describe('accessing local dev routes', () => {
|
|
12
|
+
let server;
|
|
13
|
+
let request;
|
|
32
14
|
beforeAll(async () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
fixtureDirectory = ceratedFixtureDirectory;
|
|
36
|
-
componentName = createdName;
|
|
37
|
-
doStopStack = await (0, component_dev_1.startDevelopmentRender)(fixtureDirectory, { port: 0 });
|
|
15
|
+
server = (0, component_dev_1.startDevelopmentRender)(render_runtime_lib_1.TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
16
|
+
request = (0, supertest_1.default)(server);
|
|
38
17
|
});
|
|
39
18
|
afterAll(async () => {
|
|
40
|
-
|
|
41
|
-
await promises_1.default.rm(path_1.default.join(fixtureDirectory, componentName), { force: true, recursive: true });
|
|
42
|
-
});
|
|
43
|
-
it('should handle recursing folders to find the component', async () => {
|
|
44
|
-
const testServer = render_runtime_lib_1.TestHelpers.getTestServer();
|
|
45
|
-
const response = await testServer.get(`/r/set/${componentName}/${version}/`);
|
|
46
|
-
expect(response.text).toEqual('<h1>Hello World</h1>');
|
|
47
|
-
});
|
|
48
|
-
it('should handle serving static files from single component directory', async () => {
|
|
49
|
-
const testServer = render_runtime_lib_1.TestHelpers.getTestServer();
|
|
50
|
-
const response = await testServer.get(`/s/${componentName}/${version}/static.txt`);
|
|
51
|
-
expect(response.text).toEqual('hello');
|
|
19
|
+
server.close();
|
|
52
20
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const url = `http://localhost:${port}`;
|
|
58
|
-
const request = (0, supertest_1.default)(url);
|
|
59
|
-
beforeAll(async () => {
|
|
60
|
-
const compDir = path_1.default.join(__dirname, '../', '../../test-components');
|
|
61
|
-
stopServer = await (0, component_dev_1.startDevelopmentRender)(compDir, {
|
|
62
|
-
port: port,
|
|
21
|
+
it('should fail validation when requesting a function with a missing entry file', async () => {
|
|
22
|
+
const response = await request.get('/r/set/unit-test-components/test-component/1.0.3/non-existent-entry-file?something=not-used');
|
|
23
|
+
expect(response.body).toEqual({
|
|
24
|
+
message: '"main\'s" entry file "missing-entry-file.js" is inaccessible',
|
|
63
25
|
});
|
|
64
|
-
|
|
65
|
-
afterAll(async () => {
|
|
66
|
-
await stopServer();
|
|
26
|
+
expect(response.statusCode).toEqual(500);
|
|
67
27
|
});
|
|
68
28
|
describe('definition routes', () => {
|
|
69
|
-
render_runtime_lib_1.
|
|
29
|
+
const server = (0, component_dev_1.startDevelopmentRender)(render_runtime_lib_1.TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
30
|
+
const request = () => (0, supertest_1.default)(server);
|
|
31
|
+
render_runtime_lib_1.routeTests.definition(request, 'http://localhost:0');
|
|
32
|
+
afterAll(() => {
|
|
33
|
+
server.close();
|
|
34
|
+
});
|
|
70
35
|
});
|
|
71
36
|
describe('static routes', () => {
|
|
72
|
-
render_runtime_lib_1.
|
|
37
|
+
const server = (0, component_dev_1.startDevelopmentRender)(render_runtime_lib_1.TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
38
|
+
const request = () => (0, supertest_1.default)(server);
|
|
39
|
+
render_runtime_lib_1.routeTests.static(request);
|
|
40
|
+
afterAll(() => {
|
|
41
|
+
server.close();
|
|
42
|
+
});
|
|
73
43
|
});
|
|
74
44
|
describe('render routes', () => {
|
|
75
|
-
render_runtime_lib_1.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// this is should 500 in prod and 404 locally
|
|
81
|
-
it('should fail validation if trying to render a component with an invalid schema', async () => {
|
|
82
|
-
const response = await request.get('/r/set/test-component/1.0.1?something=not-used');
|
|
83
|
-
expect(response.statusCode).toEqual(404);
|
|
84
|
-
expect(response.body).toEqual({
|
|
85
|
-
message: 'manifest could not be found',
|
|
86
|
-
});
|
|
45
|
+
const server = (0, component_dev_1.startDevelopmentRender)(render_runtime_lib_1.TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
46
|
+
const request = () => (0, supertest_1.default)(server);
|
|
47
|
+
render_runtime_lib_1.routeTests.render(request, 'http://localhost:0');
|
|
48
|
+
afterAll(() => {
|
|
49
|
+
server.close();
|
|
87
50
|
});
|
|
88
51
|
});
|
|
89
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-dev.spec.js","sourceRoot":"","sources":["../src/component-dev.spec.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"component-dev.spec.js","sourceRoot":"","sources":["../src/component-dev.spec.ts"],"names":[],"mappings":";;;;;AAAA,kEAAoE;AACpE,mDAAyD;AACzD,0DAAkC;AAGlC,IAAI,CAAC,UAAU,CAAC,KAAM,CAAC,CAAC;AAExB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,IAAI,MAAc,CAAC;QACnB,IAAI,OAA4C,CAAC;QACjD,SAAS,CAAC,KAAK,IAAI,EAAE;YACnB,MAAM,GAAG,IAAA,sCAAsB,EAAC,gCAAW,CAAC,sBAAsB,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YACnF,OAAO,GAAG,IAAA,mBAAS,EAAC,MAAM,CA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AAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;YAC7B,MAAM,MAAM,GAAG,IAAA,sCAAsB,EAAC,gCAAW,CAAC,sBAAsB,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YACzF,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAA,mBAAS,EAAC,MAAM,CAAC,CAAC;YACxC,+BAAU,CAAC,MAAM,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;YACjD,QAAQ,CAAC,GAAG,EAAE;gBACZ,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -8,6 +8,7 @@ interface Config {
|
|
|
8
8
|
declare const configObj: Config;
|
|
9
9
|
export default configObj;
|
|
10
10
|
export declare const managementService: import("axios").AxiosInstance;
|
|
11
|
+
export declare const managementServiceRoot: import("axios").AxiosInstance;
|
|
11
12
|
export declare const renderService: import("axios").AxiosInstance;
|
|
12
13
|
export declare const ci_buildVersion: string;
|
|
13
14
|
export declare const ci_buildBranch: string;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.addComponentSet = exports.deleteComponentSet = exports.removeFile = exports.createFile = exports.getTestComponents = exports.ci_buildBranch = exports.ci_buildVersion = exports.renderService = exports.managementService = void 0;
|
|
6
|
+
exports.addComponentSet = exports.deleteComponentSet = exports.removeFile = exports.createFile = exports.getTestComponents = exports.ci_buildBranch = exports.ci_buildVersion = exports.renderService = exports.managementServiceRoot = exports.managementService = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -20,6 +20,9 @@ const configObj = {
|
|
|
20
20
|
};
|
|
21
21
|
exports.default = configObj;
|
|
22
22
|
exports.managementService = axios_1.default.create({
|
|
23
|
+
baseURL: configObj.managementServiceUrl + '/v1',
|
|
24
|
+
});
|
|
25
|
+
exports.managementServiceRoot = axios_1.default.create({
|
|
23
26
|
baseURL: configObj.managementServiceUrl,
|
|
24
27
|
});
|
|
25
28
|
exports.renderService = axios_1.default.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/integration-tests/helper.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AAExB,2DAA8B;AAC9B,mCAAqC;AAErC,wDAAyD;AACzD,mCAAgC;AAEhC,IAAA,eAAM,GAAE,CAAC;AAST,MAAM,SAAS,GAAW;IACxB,oBAAoB,EAAE,IAAA,iCAAiB,EAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IAC/F,gBAAgB,EAAE,IAAA,iCAAiB,EAAC,8BAA8B,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IACvF,eAAe,EAAE,IAAA,iCAAiB,EAAC,qBAAqB,CAAC;IACzD,cAAc,EAAE,IAAA,iCAAiB,EAAC,oBAAoB,CAAC;CACxD,CAAC;AAEF,kBAAe,SAAS,CAAC;AAEZ,QAAA,iBAAiB,GAAG,eAAK,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,SAAS,CAAC,oBAAoB;CACxC,CAAC,CAAC;AAEU,QAAA,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,SAAS,CAAC,gBAAgB;CACpC,CAAC,CAAC;AAEU,QAAA,eAAe,GAAG,SAAS,CAAC,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defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const helper_1 = require("./helper");
|
|
4
4
|
describe('Verify latest services deployments', () => {
|
|
5
5
|
it('Should have latest Management API service', async () => {
|
|
6
|
-
const response = (await helper_1.
|
|
6
|
+
const response = (await helper_1.managementServiceRoot.get('/health')).data;
|
|
7
7
|
expect(response.buildVersion).toBe(helper_1.ci_buildVersion);
|
|
8
8
|
expect(response.buildBranch).toBe(helper_1.ci_buildBranch);
|
|
9
9
|
});
|
|
10
|
+
it('Should return 200 for Management API docs', async () => {
|
|
11
|
+
const req = await helper_1.managementService.get('/docs');
|
|
12
|
+
expect(req.status).toBe(200);
|
|
13
|
+
expect(req.headers['content-type']).toEqual('text/html; charset=utf-8');
|
|
14
|
+
});
|
|
15
|
+
it('Should return 200 for Management API docs.json', async () => {
|
|
16
|
+
const req = await helper_1.managementService.get('/docs.json');
|
|
17
|
+
expect(req.status).toBe(200);
|
|
18
|
+
expect(req.headers['content-type']).toEqual('application/json; charset=UTF-8');
|
|
19
|
+
});
|
|
10
20
|
it('Should have latest Render Runtime service', async () => {
|
|
11
21
|
const response = (await helper_1.renderService.get('/health')).data;
|
|
12
22
|
expect(response.buildVersion).toBe(helper_1.ci_buildVersion);
|
|
13
23
|
expect(response.buildBranch).toBe(helper_1.ci_buildBranch);
|
|
14
24
|
});
|
|
25
|
+
it('Should return 200 for Render Runtime API docs', async () => {
|
|
26
|
+
const req = await helper_1.renderService.get('/docs');
|
|
27
|
+
expect(req.status).toBe(200);
|
|
28
|
+
expect(req.headers['content-type']).toEqual('text/html; charset=utf-8');
|
|
29
|
+
});
|
|
30
|
+
it('Should return 200 for Render Runtime API docs.json', async () => {
|
|
31
|
+
const req = await helper_1.renderService.get('/docs.json');
|
|
32
|
+
expect(req.status).toBe(200);
|
|
33
|
+
expect(req.headers['content-type']).toEqual('application/json; charset=UTF-8');
|
|
34
|
+
});
|
|
15
35
|
});
|
|
16
36
|
//# sourceMappingURL=service-deployment.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-deployment.spec.js","sourceRoot":"","sources":["../../src/integration-tests/service-deployment.spec.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"service-deployment.spec.js","sourceRoot":"","sources":["../../src/integration-tests/service-deployment.spec.ts"],"names":[],"mappings":";;AAAA,qCAAoH;AAQpH,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAClD,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,QAAQ,GAAe,CAAC,MAAM,8BAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/E,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,wBAAe,CAAC,CAAC;QACpD,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,uBAAc,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,GAAG,GAAG,MAAM,0BAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;QAC9D,MAAM,GAAG,GAAG,MAAM,0BAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,QAAQ,GAAe,CAAC,MAAM,sBAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QACvE,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,wBAAe,CAAC,CAAC;QACpD,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,uBAAc,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC7D,MAAM,GAAG,GAAG,MAAM,sBAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7C,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,GAAG,GAAG,MAAM,sBAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -32,21 +32,29 @@ const cli_color_1 = __importDefault(require("cli-color"));
|
|
|
32
32
|
const path_1 = __importDefault(require("path"));
|
|
33
33
|
const supertest_1 = __importDefault(require("supertest"));
|
|
34
34
|
const upload_component_folder_1 = require("../upload-component-folder");
|
|
35
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
35
36
|
const mockConsoleError = jest.fn();
|
|
36
37
|
const mockConsoleLog = jest.fn();
|
|
37
38
|
const orgConsoleError = console.error;
|
|
38
39
|
const webPath = 'set';
|
|
40
|
+
const testFilesDir = path_1.default.resolve(__dirname, 'test-files');
|
|
41
|
+
beforeAll(async () => {
|
|
42
|
+
await promises_1.default.rm(testFilesDir, { force: true, recursive: true });
|
|
43
|
+
await promises_1.default.mkdir(testFilesDir);
|
|
44
|
+
});
|
|
39
45
|
afterAll(async () => {
|
|
40
46
|
// clean up the component added by the test
|
|
41
47
|
await (0, helper_1.deleteComponentSet)(webPath);
|
|
42
48
|
for (const componentName of (0, helper_1.getTestComponents)()) {
|
|
43
49
|
try {
|
|
44
|
-
await helper_1.managementService.delete(`/component/${componentName}`);
|
|
50
|
+
await helper_1.managementService.delete(`/component/smoke-test-components/${componentName}`);
|
|
45
51
|
}
|
|
46
52
|
catch {
|
|
47
53
|
// no op
|
|
48
54
|
}
|
|
49
55
|
}
|
|
56
|
+
// clean up the test componnet files
|
|
57
|
+
await promises_1.default.rm(testFilesDir, { force: true, recursive: true });
|
|
50
58
|
});
|
|
51
59
|
describe('Test isolated test cases', () => {
|
|
52
60
|
beforeEach(() => {
|
|
@@ -56,21 +64,21 @@ describe('Test isolated test cases', () => {
|
|
|
56
64
|
it('Should fail uploading a component without manifest.json', async () => {
|
|
57
65
|
mockConsoleError.mockClear();
|
|
58
66
|
const componentPath = path_1.default.join(__dirname, '/__components__/invalid-upload');
|
|
59
|
-
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl, helper_1.default.renderServiceUrl);
|
|
67
|
+
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl + '/v1', helper_1.default.renderServiceUrl, testFilesDir);
|
|
60
68
|
expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red('manifest could not be found'));
|
|
61
69
|
});
|
|
62
70
|
it('Should fail uploading a component that has invalid manifest.json', async () => {
|
|
63
71
|
mockConsoleError.mockClear();
|
|
64
72
|
const componentPath = path_1.default.join(__dirname, '/__components__/invalid-manifest');
|
|
65
|
-
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl, helper_1.default.renderServiceUrl);
|
|
66
|
-
expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red('/name
|
|
73
|
+
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl + '/v1', helper_1.default.renderServiceUrl, testFilesDir);
|
|
74
|
+
expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red('failed validation: /name pattern must match pattern "^[a-zA-Z0-9_\\-]+$"'));
|
|
67
75
|
});
|
|
68
76
|
it('Should fail uploading the component that has size more than 100MB', async () => {
|
|
69
77
|
mockConsoleError.mockClear();
|
|
70
78
|
const componentPath = path_1.default.join(__dirname, '/__components__/big-package');
|
|
71
79
|
const filePath = `${componentPath}/105mb-file`;
|
|
72
80
|
await (0, helper_1.createFile)(filePath, 105); // Higher limit has been used because compression reduces the size if you use closer to 100MB
|
|
73
|
-
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl, helper_1.default.renderServiceUrl);
|
|
81
|
+
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl + '/v1', helper_1.default.renderServiceUrl, testFilesDir);
|
|
74
82
|
expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red(['File size exceeds the maximum limit of 100MB'].join('')));
|
|
75
83
|
(0, helper_1.removeFile)(filePath);
|
|
76
84
|
});
|
|
@@ -97,20 +105,17 @@ describe('Deploy basic component having a static file', () => {
|
|
|
97
105
|
console.error = orgConsoleError;
|
|
98
106
|
});
|
|
99
107
|
it('Should upload the component and return a valid url to preview', async () => {
|
|
100
|
-
var _a
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
await (0,
|
|
104
|
-
const url = ((_a = /uploaded location: (.*)/.exec(mockConsoleLog.mock.lastCall)) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
|
105
|
-
const uploadedComponent = '<a href="/r/set/cmp-static-file-test/1.0.0">1.0.0</a>';
|
|
106
|
-
const get = await (0, supertest_1.default)(url).get('/');
|
|
108
|
+
var _a;
|
|
109
|
+
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl + '/v1', helper_1.default.renderServiceUrl, testFilesDir);
|
|
110
|
+
const uploadedComponent = '<a href="/r/set/smoke-test-components/cmp-static-file-test/1.0.0">1.0.0</a>';
|
|
111
|
+
const get = await (0, supertest_1.default)(helper_1.default.renderServiceUrl).get('/');
|
|
107
112
|
expect(get.status).toEqual(200);
|
|
108
|
-
expect((
|
|
113
|
+
expect((_a = get === null || get === void 0 ? void 0 : get.res) === null || _a === void 0 ? void 0 : _a.text).toContain(uploadedComponent);
|
|
109
114
|
});
|
|
110
115
|
it('Should fail upload the component with same version', async () => {
|
|
111
116
|
mockConsoleError.mockClear();
|
|
112
|
-
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl, helper_1.default.renderServiceUrl);
|
|
113
|
-
expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red('Cannot upload component version, cmp-static-file-test 1.0.0 already exists'));
|
|
117
|
+
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl + '/v1', helper_1.default.renderServiceUrl, testFilesDir);
|
|
118
|
+
expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red('Cannot upload component version, smoke-test-components/cmp-static-file-test 1.0.0 already exists'));
|
|
114
119
|
});
|
|
115
120
|
it('Should render component', async () => {
|
|
116
121
|
const componentSet = {
|
|
@@ -120,16 +125,16 @@ describe('Deploy basic component having a static file', () => {
|
|
|
120
125
|
headers: {},
|
|
121
126
|
envVars: {},
|
|
122
127
|
components: {
|
|
123
|
-
'cmp-static-file-test': [{ envVars: {}, version: '1.0.0' }],
|
|
128
|
+
'smoke-test-components/cmp-static-file-test': [{ envVars: {}, version: '1.0.0' }],
|
|
124
129
|
},
|
|
125
130
|
};
|
|
126
131
|
await (0, helper_1.addComponentSet)(componentSet);
|
|
127
|
-
const response = await helper_1.renderService.get('/r/set/cmp-static-file-test/1.0.0/?something=hello');
|
|
132
|
+
const response = await helper_1.renderService.get('/r/set/smoke-test-components/cmp-static-file-test/1.0.0/?something=hello');
|
|
128
133
|
expect(response.status).toEqual(200);
|
|
129
134
|
expect(response.data).toEqual([
|
|
130
135
|
'<div>Input: hello</div>',
|
|
131
|
-
'<div>cmp-static-file-test 1.0.0 ',
|
|
132
|
-
`${helper_1.default.renderServiceUrl}/s/cmp-static-file-test/1.0.0/birthday-cake.png</div>`,
|
|
136
|
+
'<div>smoke-test-components/cmp-static-file-test 1.0.0 ',
|
|
137
|
+
`${helper_1.default.renderServiceUrl}/s/smoke-test-components/cmp-static-file-test/1.0.0/birthday-cake.png</div>`,
|
|
133
138
|
].join(''));
|
|
134
139
|
});
|
|
135
140
|
});
|