@centreon/js-config 23.4.21-MON-fix-image-snapshot.4 → 23.4.21

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.
@@ -2,11 +2,13 @@
2
2
  import React from 'react';
3
3
 
4
4
  import { mount } from 'cypress/react18';
5
+ import { equals, isNil } from 'ramda';
5
6
 
6
7
  import { Box } from '@mui/material';
7
8
 
8
9
  import { ThemeProvider } from '@centreon/ui';
9
10
 
11
+ import '@testing-library/cypress/add-commands';
10
12
  import 'cypress-msw-interceptor';
11
13
 
12
14
  interface MountProps {
@@ -29,7 +31,6 @@ Cypress.Commands.add('mount', ({ Component, options }) => {
29
31
  sx={{
30
32
  backgroundColor: 'background.paper',
31
33
  height: '100%',
32
- overflow: 'hidden',
33
34
  width: '100%'
34
35
  }}
35
36
  >
@@ -43,10 +44,16 @@ Cypress.Commands.add('mount', ({ Component, options }) => {
43
44
  return mount(wrapped, options);
44
45
  });
45
46
 
47
+ interface Query {
48
+ name: string;
49
+ value: string;
50
+ }
51
+
46
52
  export interface InterceptAPIRequestProps<T> {
47
53
  alias: string;
48
54
  method: Method;
49
55
  path: string;
56
+ query?: Query;
50
57
  response?: T | Array<T>;
51
58
  statusCode?: number;
52
59
  }
@@ -58,13 +65,30 @@ Cypress.Commands.add(
58
65
  path,
59
66
  response,
60
67
  alias,
68
+ query,
61
69
  statusCode = 200
62
70
  }: InterceptAPIRequestProps<T>): void => {
63
71
  cy.interceptRequest(
64
72
  method,
65
73
  path.replace('./', '**'),
66
74
  (req, res, ctx) => {
67
- return res(ctx.delay(500), ctx.json(response), ctx.status(statusCode));
75
+ const getQuery = req?.url?.searchParams?.get(query?.name);
76
+ if (query && equals(query.value, getQuery)) {
77
+ return res(
78
+ ctx.delay(500),
79
+ ctx.json(response),
80
+ ctx.status(statusCode)
81
+ );
82
+ }
83
+ if (!getQuery && isNil(query)) {
84
+ return res(
85
+ ctx.delay(500),
86
+ ctx.json(response),
87
+ ctx.status(statusCode)
88
+ );
89
+ }
90
+
91
+ return null;
68
92
  },
69
93
  alias
70
94
  );
@@ -2,7 +2,7 @@
2
2
  const { defineConfig } = require('cypress');
3
3
  const {
4
4
  addMatchImageSnapshotPlugin
5
- } = require('@simonsmith/cypress-image-snapshot/plugin');
5
+ } = require('cypress-image-snapshot/plugin');
6
6
 
7
7
  module.exports = ({ webpackConfig, cypressFolder, specPattern, env }) => {
8
8
  const mainCypressFolder = cypressFolder || 'cypress';
@@ -1,4 +1,4 @@
1
- import { addMatchImageSnapshotCommand } from '@simonsmith/cypress-image-snapshot/command';
1
+ import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
2
2
 
3
3
  const enableVisualTesting = (cypressFolder = 'cypress'): void => {
4
4
  if (Cypress.config('isInteractive')) {
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.4.21-MON-fix-image-snapshot.4",
4
+ "version": "23.4.21",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"