@centreon/js-config 25.6.4 → 25.9.0
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/cypress/e2e/commands.ts +7 -0
- package/cypress/e2e/tasks.ts +18 -2
- package/package.json +1 -1
package/cypress/e2e/commands.ts
CHANGED
|
@@ -166,6 +166,12 @@ Cypress.Commands.add('getContainersLogs', () => {
|
|
|
166
166
|
return cy.task('getContainersLogs');
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
+
Cypress.Commands.add('getContainerMappedPort', (containerName: string, containerPort: number) => {
|
|
170
|
+
cy.log(`Getting mapped port ${containerPort} of container ${containerName}`);
|
|
171
|
+
|
|
172
|
+
return cy.task('getContainerMappedPort', { containerName, containerPort });
|
|
173
|
+
});
|
|
174
|
+
|
|
169
175
|
interface CopyFromContainerProps {
|
|
170
176
|
destination: string;
|
|
171
177
|
name?: string;
|
|
@@ -916,6 +922,7 @@ declare global {
|
|
|
916
922
|
getContainerId: (containerName: string) => Cypress.Chainable;
|
|
917
923
|
getContainerIpAddress: (containerName: string) => Cypress.Chainable;
|
|
918
924
|
getContainersLogs: () => Cypress.Chainable;
|
|
925
|
+
getContainerMappedPort: (containerName: string, containerPort: number) => Cypress.Chainable;
|
|
919
926
|
getIframeBody: () => Cypress.Chainable;
|
|
920
927
|
getLogDirectory: () => Cypress.Chainable;
|
|
921
928
|
getTimeFromHeader: () => Cypress.Chainable;
|
package/cypress/e2e/tasks.ts
CHANGED
|
@@ -19,6 +19,13 @@ interface Containers {
|
|
|
19
19
|
[key: string]: StartedTestContainer;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
class NotFoundContainerError extends Error {
|
|
23
|
+
constructor(message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = 'NotFoundContainerError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
22
29
|
export default (on: Cypress.PluginEvents): void => {
|
|
23
30
|
let dockerEnvironment: StartedDockerComposeEnvironment | null = null;
|
|
24
31
|
const containers: Containers = {};
|
|
@@ -31,7 +38,7 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
31
38
|
} else if (containers[containerName]) {
|
|
32
39
|
container = containers[containerName];
|
|
33
40
|
} else {
|
|
34
|
-
throw new
|
|
41
|
+
throw new NotFoundContainerError(`Cannot get container ${containerName}`);
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
return container;
|
|
@@ -68,7 +75,11 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
68
75
|
});
|
|
69
76
|
});
|
|
70
77
|
} catch (error) {
|
|
71
|
-
|
|
78
|
+
if (error instanceof NotFoundContainerError) {
|
|
79
|
+
console.log(`Cannot get ${source} from container ${serviceName} because it doesn't exist.`);
|
|
80
|
+
} else {
|
|
81
|
+
console.error(error);
|
|
82
|
+
}
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
return null;
|
|
@@ -139,6 +150,11 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
139
150
|
return null;
|
|
140
151
|
}
|
|
141
152
|
},
|
|
153
|
+
getContainerMappedPort: async ({ containerName, containerPort }) => {
|
|
154
|
+
const container = getContainer(containerName);
|
|
155
|
+
|
|
156
|
+
return container.getMappedPort(containerPort);
|
|
157
|
+
},
|
|
142
158
|
requestOnDatabase: async ({ database, query }) => {
|
|
143
159
|
let container: StartedTestContainer | null = null;
|
|
144
160
|
|
package/package.json
CHANGED