@centreon/js-config 24.4.1-fixAuthentificationTests.3 → 24.4.1-fixE2ETestsOn2404.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.
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable @typescript-eslint/no-var-requires */
2
- const { devServer } = require('cypress-rspack-dev-server');
3
2
  const { defineConfig } = require('cypress');
4
3
  const {
5
4
  addMatchImageSnapshotPlugin
@@ -7,22 +6,22 @@ const {
7
6
  const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
8
7
 
9
8
  module.exports = ({
10
- rspackConfig,
9
+ webpackConfig,
11
10
  cypressFolder,
12
11
  specPattern,
13
12
  env,
13
+ useVite = false,
14
14
  excludeSpecPattern
15
15
  }) => {
16
16
  const mainCypressFolder = cypressFolder || 'cypress';
17
17
 
18
18
  return defineConfig({
19
19
  component: {
20
- devServer: (devServerConfig) =>
21
- devServer({
22
- ...devServerConfig,
23
- framework: 'react',
24
- rspackConfig
25
- }),
20
+ devServer: {
21
+ bundler: useVite ? 'vite' : 'webpack',
22
+ framework: 'react',
23
+ webpackConfig
24
+ },
26
25
  excludeSpecPattern,
27
26
  setupNodeEvents: (on, config) => {
28
27
  addMatchImageSnapshotPlugin(on, config);
@@ -260,6 +260,7 @@ Cypress.Commands.add(
260
260
  return cy.get('.MuiAlert-message').then(($snackbar) => {
261
261
  if ($snackbar.text().includes('Login succeeded')) {
262
262
  cy.wait('@getNavigationList');
263
+ cy.get('.MuiAlert-message').should('not.be.visible');
263
264
  }
264
265
  });
265
266
  }
@@ -279,7 +280,7 @@ Cypress.Commands.add('logout', (): void => {
279
280
  cy.wait('@logout').its('response.statusCode').should('eq', 302);
280
281
 
281
282
  // https://github.com/cypress-io/cypress/issues/25841
282
- // cy.clearAllCookies();
283
+ cy.clearAllCookies();
283
284
  });
284
285
 
285
286
  Cypress.Commands.add('logoutViaAPI', (): Cypress.Chainable => {
@@ -518,10 +519,6 @@ Cypress.Commands.add('stopContainers', (): Cypress.Chainable => {
518
519
  .createDirectory(logDirectory)
519
520
  .getContainersLogs()
520
521
  .then((containersLogs: Array<Array<string>>) => {
521
- if (!containersLogs) {
522
- return;
523
- }
524
-
525
522
  Object.entries(containersLogs).forEach(([containerName, logs]) => {
526
523
  cy.writeFile(
527
524
  `results/logs/${Cypress.spec.name.replace(
@@ -802,7 +799,7 @@ declare global {
802
799
  patch: PatchDashboardBody
803
800
  ) => Cypress.Chainable;
804
801
  loginAsAdminViaApiV2: () => Cypress.Chainable;
805
- loginByTypeOfUser: ({
802
+ <loginByTypeOfUser>: ({
806
803
  jsonName,
807
804
  loginViaApi
808
805
  }: LoginByTypeOfUserProps) => Cypress.Chainable;
@@ -38,7 +38,7 @@ export default ({
38
38
 
39
39
  return defineConfig({
40
40
  chromeWebSecurity: false,
41
- defaultCommandTimeout: 20000,
41
+ defaultCommandTimeout: 6000,
42
42
  downloadsFolder: `${resultsFolder}/downloads`,
43
43
  e2e: {
44
44
  excludeSpecPattern: ['*.js', '*.ts', '*.md'],
@@ -66,7 +66,7 @@ export default ({
66
66
  WEB_IMAGE_VERSION: webImageVersion
67
67
  },
68
68
  execTimeout: 60000,
69
- requestTimeout: 20000,
69
+ requestTimeout: 10000,
70
70
  retries: 0,
71
71
  screenshotsFolder: `${resultsFolder}/screenshots`,
72
72
  video: isDevelopment,
@@ -28,6 +28,7 @@ export default (
28
28
  // force screen to be non-retina and just use our given resolution
29
29
  launchOptions.args.push('--force-device-scale-factor=1');
30
30
  }
31
+ launchOptions.args.push(`--window-size=${width},${height}`);
31
32
 
32
33
  return launchOptions;
33
34
  });
@@ -252,21 +252,6 @@ export default (on: Cypress.PluginEvents): void => {
252
252
  waitOn: async (url: string) => {
253
253
  execSync(`npx wait-on ${url}`);
254
254
 
255
- return null;
256
- },
257
- modifyCookieFlags:async() =>{
258
- const puppeteer = require('puppeteer');
259
- const browser = await puppeteer.launch();
260
- const page = await browser.newPage();
261
- await page.goto('chrome://settings/cookies');
262
- await page.waitForSelector('settings-ui');
263
- await page.type('settings-ui', 'SameSite by default cookies');
264
- await page.waitForSelector('settings-ui .name');
265
- await page.click('settings-ui .switch');
266
- await page.type('settings-ui', 'Cookies without SameSite must be secure');
267
- await page.waitForSelector('settings-ui .name');
268
- await page.click('settings-ui .switch');
269
- await browser.close();
270
255
  return null;
271
256
  }
272
257
  });
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": "24.4.1-fixAuthentificationTests.3",
4
+ "version": "24.4.1-fixE2ETestsOn2404.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"
@@ -16,6 +16,13 @@
16
16
  "url": "https://github.com/centreon/centreon-frontend/issues"
17
17
  },
18
18
  "homepage": "https://github.com/centreon/centreon-frontend#readme",
19
+ "files": [
20
+ "eslint",
21
+ "jest",
22
+ "tsconfig",
23
+ "webpack",
24
+ "cypress"
25
+ ],
19
26
  "peerDependencies": {
20
27
  "eslint": "^8.53.0",
21
28
  "prettier": "^3.0.0"
@@ -1,71 +1,76 @@
1
- const isDev = process.env.NODE_ENV !== 'production';
2
-
3
- const excludeNodeModulesExceptCentreonUi =
4
- /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon|file\+packages\+ui-context))/;
5
-
6
- module.exports = {
7
- cache: false,
8
- excludeNodeModulesExceptCentreonUi,
9
- getModuleConfiguration: (enableCoverage) => ({
10
- rules: [
11
- {
12
- exclude: [excludeNodeModulesExceptCentreonUi],
13
- test: /\.[jt]sx?$/,
14
- use: {
15
- loader: 'swc-loader',
16
- options: {
17
- jsc: {
18
- experimental: {
19
- plugins: [
20
- enableCoverage && ['swc-plugin-coverage-instrument', {}]
21
- ].filter(Boolean)
22
- },
23
- parser: {
24
- syntax: 'typescript',
25
- tsx: true
26
- },
27
- transform: {
28
- react: {
29
- development: isDev,
30
- refresh: isDev
31
- }
32
- }
33
- }
34
- }
35
- }
36
- },
37
- {
38
- test: /\.icon.svg$/,
39
- use: ['@svgr/webpack']
40
- },
41
- {
42
- exclude: excludeNodeModulesExceptCentreonUi,
43
- test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
44
- type: 'asset/inline'
45
- },
46
- {
47
- generator: {
48
- filename: '[name][ext]'
49
- },
50
- test: /\.(woff|woff2|eot|ttf|otf)$/i,
51
- type: 'asset/resource'
52
- },
53
- {
54
- test: /\.css$/i,
55
- use: ['style-loader', 'css-loader']
56
- }
57
- ]
58
- }),
59
- optimization: {
60
- splitChunks: {
61
- chunks: 'all',
62
- maxSize: 400 * 1024
63
- }
64
- },
65
- output: {
66
- chunkFilename: '[name].[chunkhash:8].chunk.js',
67
- filename: '[name].[chunkhash:8].js',
68
- libraryTarget: 'umd',
69
- umdNamedDefine: true
70
- }
71
- };
1
+ const excludeNodeModulesExceptCentreonUi =
2
+ /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon|file\+packages\+ui-context))/;
3
+
4
+ module.exports = {
5
+ cache: false,
6
+ excludeNodeModulesExceptCentreonUi,
7
+ getModuleConfiguration: (jscTransformConfiguration, enableCoverage) => ({
8
+ rules: [
9
+ {
10
+ parser: { system: false },
11
+ test: /\.[cm]?(j|t)sx?$/
12
+ },
13
+ {
14
+ exclude: [excludeNodeModulesExceptCentreonUi],
15
+ test: /\.[jt]sx?$/,
16
+ use: {
17
+ loader: 'swc-loader',
18
+ options: {
19
+ jsc: {
20
+ experimental: {
21
+ plugins: [
22
+ enableCoverage && ['swc-plugin-coverage-instrument', {}]
23
+ ].filter(Boolean)
24
+ },
25
+ parser: {
26
+ syntax: 'typescript',
27
+ tsx: true
28
+ },
29
+ transform: jscTransformConfiguration
30
+ }
31
+ }
32
+ }
33
+ },
34
+ {
35
+ test: /\.icon.svg$/,
36
+ use: ['@svgr/webpack']
37
+ },
38
+ {
39
+ exclude: excludeNodeModulesExceptCentreonUi,
40
+ test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
41
+ use: [
42
+ {
43
+ loader: 'url-loader',
44
+ options: {
45
+ limit: 10000,
46
+ name: '[name].[hash:8].[ext]'
47
+ }
48
+ }
49
+ ]
50
+ },
51
+ {
52
+ generator: {
53
+ filename: '[name][ext]'
54
+ },
55
+ test: /\.(woff|woff2|eot|ttf|otf)$/i,
56
+ type: 'asset/resource'
57
+ },
58
+ {
59
+ test: /\.css$/i,
60
+ use: ['style-loader', 'css-loader']
61
+ }
62
+ ]
63
+ }),
64
+ optimization: {
65
+ splitChunks: {
66
+ chunks: 'all',
67
+ maxSize: 400 * 1024
68
+ }
69
+ },
70
+ output: {
71
+ chunkFilename: '[name].[chunkhash:8].chunk.js',
72
+ filename: '[name].[chunkhash:8].js',
73
+ libraryTarget: 'umd',
74
+ umdNamedDefine: true
75
+ }
76
+ };
@@ -1,6 +1,7 @@
1
1
  const path = require('path');
2
2
 
3
- const rspack = require('@rspack/core');
3
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
4
+ const { ModuleFederationPlugin } = require('webpack').container;
4
5
 
5
6
  const {
6
7
  getModuleConfiguration,
@@ -12,27 +13,28 @@ const {
12
13
  const getBaseConfiguration = ({
13
14
  moduleName,
14
15
  moduleFederationConfig,
16
+ jscTransformConfiguration,
15
17
  enableCoverage
16
18
  }) => ({
17
19
  cache,
18
- module: getModuleConfiguration(enableCoverage),
20
+ module: getModuleConfiguration(jscTransformConfiguration, enableCoverage),
19
21
  optimization,
20
22
  output: {
21
23
  ...output,
22
- clean: true,
23
24
  library: moduleName,
24
25
  uniqueName: moduleName
25
26
  },
26
27
  plugins: [
28
+ new CleanWebpackPlugin(),
27
29
  moduleName &&
28
- new rspack.container.ModuleFederationPlugin({
30
+ new ModuleFederationPlugin({
29
31
  filename: 'remoteEntry.[chunkhash:8].js',
30
32
  library: { name: moduleName, type: 'umd' },
31
33
  name: moduleName,
32
34
  shared: [
33
35
  {
34
36
  '@centreon/ui-context': {
35
- requiredVersion: '1.x',
37
+ requiredVersion: '24.x',
36
38
  singleton: true
37
39
  }
38
40
  },
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ devJscTransformConfiguration: {
3
+ react: {
4
+ development: true,
5
+ refresh: false,
6
+ },
7
+ },
8
+ devRefreshJscTransformConfiguration: {
9
+ react: {
10
+ development: true,
11
+ refresh: true,
12
+ },
13
+ },
14
+ getDevConfiguration: () => ({
15
+ cache: true,
16
+ devtool: 'eval-cheap-module-source-map',
17
+ optimization: {
18
+ splitChunks: false,
19
+ },
20
+ output: {
21
+ filename: '[name].js',
22
+ },
23
+ }),
24
+ };
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const ReactRefreshPlugin = require('@rspack/plugin-react-refresh');
3
+ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
4
4
 
5
5
  const devServerPort = 9090;
6
6
 
@@ -19,9 +19,10 @@ const devServerAddress = externalInterface
19
19
 
20
20
  const publicPath = `http://${devServerAddress}:${devServerPort}/static/`;
21
21
 
22
- const isDevelopmentMode = process.env.NODE_ENV !== 'production';
22
+ const isServeMode = process.env.WEBPACK_ENV === 'serve';
23
+ const isDevelopmentMode = process.env.WEBPACK_ENV === 'development';
23
24
 
24
- const devServerPlugins = isDevelopmentMode ? [new ReactRefreshPlugin()] : [];
25
+ const devServerPlugins = isServeMode ? [new ReactRefreshWebpackPlugin()] : [];
25
26
 
26
27
  module.exports = {
27
28
  devServer: {
@@ -31,5 +32,6 @@ module.exports = {
31
32
  },
32
33
  devServerPlugins,
33
34
  isDevelopmentMode,
35
+ isServeMode,
34
36
  publicPath
35
37
  };
@@ -0,0 +1,46 @@
1
+ const fs = require('fs');
2
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
3
+
4
+ class CentreonModulePlugin {
5
+ constructor(federatedComponentConfiguration) {
6
+ this.federatedComponentConfiguration = federatedComponentConfiguration;
7
+ }
8
+
9
+ apply(compiler) {
10
+ compiler.hooks.done.tap('CentreonModulePlugin', (stats) => {
11
+ const newFederatedComponentConfiguration = {
12
+ ...this.federatedComponentConfiguration,
13
+ remoteEntry: Object.keys(stats.compilation.assets).find((assetName) =>
14
+ assetName.match(/(^remoteEntry)\S+.js$/),
15
+ ),
16
+ };
17
+
18
+ if (!fs.existsSync(compiler.options.output.path)) {
19
+ fs.mkdirSync(compiler.options.output.path, { recursive: true });
20
+ }
21
+
22
+ fs.writeFileSync(
23
+ `${compiler.options.output.path}/moduleFederation.json`,
24
+ JSON.stringify(newFederatedComponentConfiguration, null, 2),
25
+ );
26
+ });
27
+ }
28
+ }
29
+
30
+ module.exports = ({
31
+ outputPath,
32
+ federatedComponentConfiguration,
33
+ }) => ({
34
+ output: {
35
+ library: '[chunkhash:8]',
36
+ path: outputPath,
37
+ },
38
+ plugins: [
39
+ new CleanWebpackPlugin({
40
+ cleanOnceBeforeBuildPatterns: [`${outputPath}/**/*.js`],
41
+ dangerouslyAllowCleanPatternsOutsideProject: true,
42
+ dry: false,
43
+ }),
44
+ new CentreonModulePlugin(federatedComponentConfiguration),
45
+ ],
46
+ });
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- getDevConfiguration: () => ({
3
- cache: true,
4
- devtool: 'eval-cheap-module-source-map',
5
- optimization: {
6
- splitChunks: false
7
- },
8
- output: {
9
- filename: '[name].js'
10
- }
11
- })
12
- };
@@ -1,13 +0,0 @@
1
- const WriteRemoteEntryNameToModuleFederation = require('../plugins/WriteRemoteEntryNameToModuleFederation');
2
- const TransformPreloadScript = require('../plugins/TransformPreloadScript');
3
-
4
- module.exports = ({ outputPath, federatedComponentConfiguration }) => ({
5
- output: {
6
- library: '[chunkhash:8]',
7
- path: outputPath
8
- },
9
- plugins: [
10
- new WriteRemoteEntryNameToModuleFederation(federatedComponentConfiguration),
11
- new TransformPreloadScript(federatedComponentConfiguration)
12
- ]
13
- });
@@ -1,37 +0,0 @@
1
- const fs = require('fs');
2
-
3
- const swc = require('@swc/core');
4
-
5
- module.exports = class TransformPreloadScript {
6
- constructor(federatedComponentConfiguration) {
7
- this.federatedComponentConfiguration = federatedComponentConfiguration;
8
- }
9
-
10
- apply(compiler) {
11
- compiler.hooks.done.tap('TransformPreloadScript', () => {
12
- if (!fs.existsSync(compiler.options.output.path)) {
13
- fs.mkdirSync(compiler.options.output.path, { recursive: true });
14
- }
15
-
16
- if (this.federatedComponentConfiguration.preloadScript) {
17
- const { code } = swc.transformFileSync(
18
- `./${this.federatedComponentConfiguration.preloadScript}.ts`,
19
- {
20
- filename: `${this.federatedComponentConfiguration.preloadScript}.ts`,
21
- jsc: {
22
- parser: {
23
- syntax: 'typescript'
24
- }
25
- },
26
- minify: true
27
- }
28
- );
29
-
30
- fs.writeFileSync(
31
- `${compiler.options.output.path}/${this.federatedComponentConfiguration.preloadScript}.js`,
32
- code
33
- );
34
- }
35
- });
36
- }
37
- };
@@ -1,30 +0,0 @@
1
- const fs = require('fs');
2
-
3
- module.exports = class WriteRemoteEntryNameToModuleFederation {
4
- constructor(federatedComponentConfiguration) {
5
- this.federatedComponentConfiguration = federatedComponentConfiguration;
6
- }
7
-
8
- apply(compiler) {
9
- compiler.hooks.done.tap(
10
- 'WriteRemoteEntryNameToModuleFederation',
11
- (stats) => {
12
- const newFederatedComponentConfiguration = {
13
- ...this.federatedComponentConfiguration,
14
- remoteEntry: Object.keys(stats.compilation.assets).find((assetName) =>
15
- assetName.match(/(^remoteEntry)\S+.js$/)
16
- )
17
- };
18
-
19
- if (!fs.existsSync(compiler.options.output.path)) {
20
- fs.mkdirSync(compiler.options.output.path, { recursive: true });
21
- }
22
-
23
- fs.writeFileSync(
24
- `${compiler.options.output.path}/moduleFederation.json`,
25
- JSON.stringify(newFederatedComponentConfiguration, null, 2)
26
- );
27
- }
28
- );
29
- }
30
- };
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "extends": "./tsconfig/index.json",
3
- "compilerOptions": {
4
- "baseUrl": "./",
5
- "outDir": "./dist",
6
- "declaration": true,
7
- "skipLibCheck": true,
8
- "pretty": true,
9
- "emitDeclarationOnly": true,
10
- "types": ["cypress", "cypress-wait-until"],
11
- "esModuleInterop": true,
12
- "paths": {
13
- "@badeball/cypress-cucumber-preprocessor/*": ["./node_modules/@badeball/cypress-cucumber-preprocessor/dist/subpath-entrypoints/*"]
14
- }
15
- },
16
- "exclude": [
17
- "./node_modules",
18
- "./dist",
19
- "../../node_modules"
20
- ],
21
- }