From 005f580e14a0e745bf75adf74743552dc7e0d0e9 Mon Sep 17 00:00:00 2001 From: MariaAga Date: Wed, 30 Oct 2024 16:54:01 +0000 Subject: [PATCH] Refs #37882 - update tests to npm8 --- .github/workflows/foreman.yml | 2 ++ .github/workflows/js_tests.yml | 2 ++ .github/workflows/plugins_react_tests.yml | 2 ++ package.json | 9 ++++----- .../javascripts/react_app/common/urlHelpers.test.js | 2 +- webpack/core_test_setup.js | 11 +++++++++++ 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/foreman.yml b/.github/workflows/foreman.yml index 7a5c845604d..07862bb1d39 100644 --- a/.github/workflows/foreman.yml +++ b/.github/workflows/foreman.yml @@ -93,6 +93,8 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} + - name: use npm 8 + run: npm i -g npm@8 --registry=https://registry.npmjs.org - name: Setup NPM Cache uses: actions/cache@v4 with: diff --git a/.github/workflows/js_tests.yml b/.github/workflows/js_tests.yml index cddfe11b63e..5d8980fd24f 100644 --- a/.github/workflows/js_tests.yml +++ b/.github/workflows/js_tests.yml @@ -46,6 +46,8 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} + - name: use npm 8 + run: npm i -g npm@8 --registry=https://registry.npmjs.org - name: Generate npm dependencies package-lock run: npm install --package-lock-only --no-audit - name: Install npm dependencies diff --git a/.github/workflows/plugins_react_tests.yml b/.github/workflows/plugins_react_tests.yml index 551b3e9c710..ce1d1baeb42 100644 --- a/.github/workflows/plugins_react_tests.yml +++ b/.github/workflows/plugins_react_tests.yml @@ -48,6 +48,8 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} + - name: use npm 8 + run: npm i -g npm@8 --registry=https://registry.npmjs.org - name: "Set up Ruby ${{ matrix.ruby }}" uses: ruby/setup-ruby@v1 with: diff --git a/package.json b/package.json index 693a5fc4eec..0de2a5bfbe4 100644 --- a/package.json +++ b/package.json @@ -138,8 +138,7 @@ "prettier": "^1.19.1", "pretty-format": "26.6.2", "react-dnd-test-backend": "^9.4.0", - "react-redux-test-utils": "^0.2.0", - "react-test-renderer": "^17.0.1", + "react-test-renderer": "^16.9.0", "mini-css-extract-plugin": "^2.9.1", "redux-mock-store": "^1.2.2", "sass": "~1.60.0", @@ -148,9 +147,9 @@ "stylelint": "^9.3.0", "stylelint-config-standard": "^18.0.0", "tabbable": "~5.2.0", - "victory-core": "~36.8.6", - "victory-legend": "~36.8.6", - "victory-pie": "~36.8.6", + "victory-core": "36.8.6", + "victory-legend": "36.8.6", + "victory-pie": "36.8.6", "webpack": "^5.75.0", "webpack-bundle-analyzer": "^4.5.0", "webpack-cli": "^5.0.1", diff --git a/webpack/assets/javascripts/react_app/common/urlHelpers.test.js b/webpack/assets/javascripts/react_app/common/urlHelpers.test.js index efd5e446164..34ffab09bcb 100644 --- a/webpack/assets/javascripts/react_app/common/urlHelpers.test.js +++ b/webpack/assets/javascripts/react_app/common/urlHelpers.test.js @@ -1,5 +1,5 @@ import { mockWindowLocation } from './testHelpers'; -import { visit } from '../../foreman_navigation'; +import { visit } from './helpers'; import { urlBuilder, urlWithSearch, diff --git a/webpack/core_test_setup.js b/webpack/core_test_setup.js index d22b70ab381..6940d453554 100644 --- a/webpack/core_test_setup.js +++ b/webpack/core_test_setup.js @@ -26,3 +26,14 @@ jest.mock('./assets/javascripts/foreman_tools', () => ({ foremanUrl: url => url, })); jest.mock('./assets/javascripts/foreman_navigation'); + +jest.mock('./assets/javascripts/react_app/common/helpers', () => { + const helpers = jest.requireActual( + './assets/javascripts/react_app/common/helpers' + ); + return { + ...helpers, + visit: jest.fn(), + reloadPage: jest.fn(), + }; +});