@centreon/js-config 23.10.1-remove-video-compression.1 → 23.10.1-stabilization-panel-edit-23-10.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.
@@ -11,6 +11,8 @@ import { ThemeProvider } from '@centreon/ui';
11
11
  import '@testing-library/cypress/add-commands';
12
12
  import 'cypress-msw-interceptor';
13
13
 
14
+ import disableMotion from './disableCssTransitions';
15
+
14
16
  interface MountProps {
15
17
  Component: React.ReactNode;
16
18
  options?: object;
@@ -132,9 +134,16 @@ Cypress.Commands.add('makeSnapshot', (title?: string) => {
132
134
  cy.matchImageSnapshot(title);
133
135
  });
134
136
 
137
+ Cypress.Commands.add('cssDisableMotion', (): void => {
138
+ Cypress.on('window:before:load', (cyWindow) => {
139
+ disableMotion(cyWindow);
140
+ });
141
+ });
142
+
135
143
  declare global {
136
144
  namespace Cypress {
137
145
  interface Chainable {
146
+ cssDisableMotion: () => Cypress.Chainable;
138
147
  interceptAPIRequest: <T extends object>(
139
148
  props: InterceptAPIRequestProps<T>
140
149
  ) => Cypress.Chainable;
@@ -24,6 +24,14 @@ module.exports = ({
24
24
  excludeSpecPattern,
25
25
  setupNodeEvents: (on, config) => {
26
26
  addMatchImageSnapshotPlugin(on, config);
27
+
28
+ on('before:browser:launch', (browser, launchOptions) => {
29
+ if (browser.name === 'chrome' && browser.isHeadless) {
30
+ launchOptions.args.push('--headless=new');
31
+ }
32
+
33
+ return launchOptions;
34
+ });
27
35
  },
28
36
  specPattern,
29
37
  supportFile: `${mainCypressFolder}/support/component.tsx`
@@ -0,0 +1,19 @@
1
+ const disableMotion = (win): void => {
2
+ const injectedStyleEl = win.document.getElementById('__cy_disable_motion__');
3
+ if (injectedStyleEl) {
4
+ return;
5
+ }
6
+ win.document.head.insertAdjacentHTML(
7
+ 'beforeend',
8
+ `
9
+ <style id="__cy_disable_motion__">
10
+ /* Disable CSS transitions. */
11
+ *, *::before, *::after { -webkit-transition: none !important; -moz-transition: none !important; -o-transition: none !important; -ms-transition: none !important; transition: none !important; }
12
+ /* Disable CSS animations. */
13
+ *, *::before, *::after { -webkit-animation: none !important; -moz-animation: none !important; -o-animation: none !important; -ms-animation: none !important; animation: none !important; }
14
+ </style>
15
+ `.trim()
16
+ );
17
+ };
18
+
19
+ export default disableMotion;
@@ -3,6 +3,10 @@
3
3
  import './commands/configuration';
4
4
  import './commands/monitoring';
5
5
 
6
+ import installLogsCollector from 'cypress-terminal-report/src/installLogsCollector';
7
+
8
+ installLogsCollector();
9
+
6
10
  const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
7
11
 
8
12
  const artifactIllegalCharactersMatcher = /[,\s/|<>*?:"]/g;
@@ -207,7 +211,20 @@ interface ExecInContainerProps {
207
211
  Cypress.Commands.add(
208
212
  'execInContainer',
209
213
  ({ command, name }: ExecInContainerProps): Cypress.Chainable => {
210
- return cy.exec(`docker exec -i ${name} ${command}`);
214
+ return cy
215
+ .exec(`docker exec -i ${name} ${command}`, { failOnNonZeroExit: false })
216
+ .then((result) => {
217
+ if (result.code) {
218
+ // output will not be truncated
219
+ throw new Error(`
220
+ Execution of "${command}" failed
221
+ Exit code: ${result.code}
222
+ Stdout:\n${result.stdout}
223
+ Stderr:\n${result.stderr}`);
224
+ }
225
+
226
+ return cy.wrap(result);
227
+ });
211
228
  }
212
229
  );
213
230
 
@@ -225,7 +242,18 @@ interface StartContainerProps {
225
242
  Cypress.Commands.add(
226
243
  'startContainer',
227
244
  ({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
228
- return cy.task('startContainer', { image, name, portBindings });
245
+ return cy.task(
246
+ 'startContainer',
247
+ { image, name, portBindings },
248
+ { timeout: 600000 } // 10 minutes because docker pull can be very slow
249
+ );
250
+ }
251
+ );
252
+
253
+ Cypress.Commands.add(
254
+ 'createDirectory',
255
+ (directoryPath: string): Cypress.Chainable => {
256
+ return cy.task('createDirectory', directoryPath);
229
257
  }
230
258
  );
231
259
 
@@ -288,7 +316,7 @@ Cypress.Commands.add(
288
316
 
289
317
  return cy
290
318
  .visitEmptyPage()
291
- .exec(`mkdir -p "${logDirectory}"`)
319
+ .createDirectory(logDirectory)
292
320
  .copyFromContainer({
293
321
  destination: `${logDirectory}/broker`,
294
322
  name,
@@ -459,6 +487,7 @@ declare global {
459
487
  props: CopyToContainerProps,
460
488
  options?: Partial<Cypress.ExecOptions>
461
489
  ) => Cypress.Chainable;
490
+ createDirectory: (directoryPath: string) => Cypress.Chainable;
462
491
  execInContainer: ({
463
492
  command,
464
493
  name
@@ -4,6 +4,7 @@
4
4
  import { execSync } from 'child_process';
5
5
 
6
6
  import { defineConfig } from 'cypress';
7
+ import installLogsPrinter from 'cypress-terminal-report/src/installLogsPrinter';
7
8
 
8
9
  import esbuildPreprocessor from './esbuild-preprocessor';
9
10
  import plugins from './plugins';
@@ -24,7 +25,7 @@ export default ({
24
25
  dockerName,
25
26
  env
26
27
  }: ConfigurationOptions): Cypress.ConfigOptions => {
27
- const resultsFolder = `${cypressFolder || 'cypress'}/results`;
28
+ const resultsFolder = `${cypressFolder || '.'}/results`;
28
29
 
29
30
  const webImageVersion = execSync('git rev-parse --abbrev-ref HEAD')
30
31
  .toString('utf8')
@@ -35,13 +36,20 @@ export default ({
35
36
  defaultCommandTimeout: 6000,
36
37
  e2e: {
37
38
  excludeSpecPattern: ['*.js', '*.ts', '*.md'],
39
+ fixturesFolder: 'fixtures',
40
+ reporter: require.resolve('cypress-multi-reporters'),
41
+ reporterOptions: {
42
+ configFile: `${__dirname}/reporter-config.js`
43
+ },
38
44
  setupNodeEvents: async (on, config) => {
45
+ installLogsPrinter(on);
39
46
  await esbuildPreprocessor(on, config);
40
47
  tasks(on);
41
48
 
42
49
  return plugins(on, config);
43
50
  },
44
- specPattern
51
+ specPattern,
52
+ supportFile: 'support/e2e.{js,jsx,ts,tsx}'
45
53
  },
46
54
  env: {
47
55
  ...env,
@@ -51,14 +59,6 @@ export default ({
51
59
  dockerName: dockerName || 'centreon-dev'
52
60
  },
53
61
  execTimeout: 60000,
54
- reporter: 'mochawesome',
55
- reporterOptions: {
56
- html: false,
57
- json: true,
58
- overwrite: true,
59
- reportDir: `${resultsFolder}/reports`,
60
- reportFilename: '[name]-report.json'
61
- },
62
62
  requestTimeout: 10000,
63
63
  retries: 0,
64
64
  screenshotsFolder: `${resultsFolder}/screenshots`,
@@ -11,16 +11,20 @@ export default (
11
11
  const width = 1920;
12
12
  const height = 1080;
13
13
 
14
- if ((browser as { name }).name === 'chrome') {
14
+ if (browser.name === 'chrome') {
15
+ if (browser.isHeadless) {
16
+ launchOptions.args.push('--headless=new');
17
+ }
18
+
15
19
  // flags description : https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md
16
20
  launchOptions.args.push('--disable-gpu');
17
21
  launchOptions.args.push('--auto-open-devtools-for-tabs');
18
22
  launchOptions.args.push('--disable-extensions');
19
23
  launchOptions.args.push('--hide-scrollbars');
20
24
  launchOptions.args.push('--mute-audio');
21
- launchOptions.args.push('--hide-scrollbars');
22
25
 
23
26
  launchOptions.args.push(`--window-size=${width},${height}`);
27
+
24
28
  // force screen to be non-retina and just use our given resolution
25
29
  launchOptions.args.push('--force-device-scale-factor=1');
26
30
  }
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ mochawesomeReporterOptions: {
3
+ consoleReporter: 'none',
4
+ html: false,
5
+ json: true,
6
+ overwrite: true,
7
+ reportDir: 'results/reports',
8
+ reportFilename: '[name]-report.json'
9
+ },
10
+ reporterEnabled: `mochawesome,${require.resolve(
11
+ '@badeball/cypress-cucumber-preprocessor/pretty-reporter'
12
+ )}`
13
+ };
@@ -1,4 +1,5 @@
1
1
  import { execSync } from 'child_process';
2
+ import { existsSync, mkdirSync } from 'fs';
2
3
 
3
4
  import Docker from 'dockerode';
4
5
 
@@ -21,6 +22,13 @@ export default (on: Cypress.PluginEvents): void => {
21
22
  }
22
23
 
23
24
  on('task', {
25
+ createDirectory: async (directoryPath: string) => {
26
+ if (!existsSync(directoryPath)) {
27
+ mkdirSync(directoryPath, { recursive: true });
28
+ }
29
+
30
+ return null;
31
+ },
24
32
  startContainer: async ({
25
33
  image,
26
34
  name,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@centreon/js-config",
3
3
  "description": "Centreon Frontend shared build configuration",
4
- "version": "23.10.1-remove-video-compression.1",
4
+ "version": "23.10.1-stabilization-panel-edit-23-10.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"
@@ -16,15 +16,7 @@
16
16
  "url": "https://github.com/centreon/centreon-frontend/issues"
17
17
  },
18
18
  "devDependencies": {
19
- "@badeball/cypress-cucumber-preprocessor": "^18.0.5",
20
- "@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
21
- "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
22
- "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
23
19
  "@tsconfig/node16": "^16.1.1",
24
- "@types/cypress-cucumber-preprocessor": "^4.0.2",
25
- "@types/dockerode": "^3.3.19",
26
- "dockerode": "^3.3.5",
27
- "esbuild": "^0.19.3",
28
20
  "eslint": "^8.17.0",
29
21
  "eslint-config-airbnb": "19.0.4",
30
22
  "eslint-config-prettier": "^8.5.0",
@@ -50,5 +42,18 @@
50
42
  "tsconfig",
51
43
  "webpack",
52
44
  "cypress"
53
- ]
45
+ ],
46
+ "dependencies": {
47
+ "@badeball/cypress-cucumber-preprocessor": "^18.0.6",
48
+ "@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
49
+ "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
50
+ "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
51
+ "@types/cypress-cucumber-preprocessor": "^4.0.2",
52
+ "@types/dockerode": "^3.3.19",
53
+ "cypress-multi-reporters": "^1.6.3",
54
+ "cypress-terminal-report": "^5.3.6",
55
+ "dockerode": "^3.3.5",
56
+ "esbuild": "^0.19.3",
57
+ "mochawesome": "^7.1.3"
58
+ }
54
59
  }