From 08d0e6b549ffa3715342f76b31defa857df5b898 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Wed, 10 Apr 2024 17:18:50 -0400 Subject: [PATCH 01/33] Introduce workflow for codecov upload --- .github/workflows/ci.yml | 56 ++++++++++++++++++++++++++++++ .github/workflows/pull_request.yml | 22 +++--------- 2 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..9cc11ecad --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: Code Coverage + +on: + pull_request: + branches: [ main, prod-beta, prod-stable, stage-beta, stage-stable ] + push: + branches: [ main ] + +env: + BRANCH: ${{ github.base_ref }} + +jobs: + build: + name: koku-ui codecov + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache node modules + id: cache-npm + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install dependencies + run: npm install + + - name: Test + run: npm test -- --collect-coverage --max-workers=4 + + - name: Upload coverage report + if: ${{ success() }} + uses: codecov/codecov-action@v4.2.0 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + directory: coverage + plugin: pycoverage # Only run one plugin so that all do not run. There is no way to disable plugins entirely. + diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 8c96d2d2f..82c171702 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,13 +1,9 @@ name: Pull request + on: pull_request: - branches: - - main - - master - - prod-beta - - prod-stable - - stage-beta - - stage-stable + branches: [ main, prod-beta, prod-stable, stage-beta, stage-stable ] + env: BRANCH: ${{ github.base_ref }} @@ -53,14 +49,4 @@ jobs: - name: Test if: ${{ success() }} - run: npm test -- --collect-coverage --max-workers=4 - - - name: Upload coverage report - if: ${{ success() }} - uses: codecov/codecov-action@v4.2.0 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - with: - directory: coverage - plugin: pycoverage # Only run one plugin so that all do not run. There is no way to disable plugins entirely. - + run: npm test From af8b3c66bfe632e7a5f0ab4599bdc869629fc205 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Wed, 10 Apr 2024 18:06:36 -0400 Subject: [PATCH 02/33] Add branches for codecov upload --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cc11ecad..e8e4acbfc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: pull_request: branches: [ main, prod-beta, prod-stable, stage-beta, stage-stable ] push: - branches: [ main ] + branches: [ main, prod-beta, prod-stable, stage-beta, stage-stable ] env: BRANCH: ${{ github.base_ref }} From fcb13f7b65e5ad129dabe30f3ba6865f127f0589 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Wed, 10 Apr 2024 18:38:23 -0400 Subject: [PATCH 03/33] Clean up README --- .github/workflows/pull_request.yml | 2 ++ README.md | 34 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 82c171702..3d1f61e0f 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,3 +1,5 @@ +# Run this workflow for PRs only to confirm container build is working properly + name: Pull request on: diff --git a/README.md b/README.md index ea663f30e..f1b50829e 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ Follow the prompts that follow. 2. Open the following URL ``` - http://localhost:8002/beta/openshift/cost-management +http://localhost:8002/beta/openshift/cost-management ``` #### Koku API @@ -134,23 +134,23 @@ Refer to the project [README][koku-readme] for prerequisites 1. Setup & run Koku API (see project [README][koku-readme] for more details) ``` -> git clone git@github.com:project-koku/koku.git -> cd [KOKU_GIT_REPO] -> pipenv install --dev -> pipenv shell "pre-commit install" -> make docker-up-min or make docker-up-min-trino -> make create-test-customer -> make load-test-customer-data (use with docker-up-min-trino) +git clone git@github.com:project-koku/koku.git +cd [KOKU_GIT_REPO] +pipenv install --dev +pipenv shell "pre-commit install" +make docker-up-min or make docker-up-min-trino +make create-test-customer +make load-test-customer-data (use with docker-up-min-trino) ``` 2. Check to see if containers are running (optional) ``` -> docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Ports}}\t{{.Status}}" +docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Ports}}\t{{.Status}}" ``` 3. Watch the Koku API logs in another terminal (optional) ``` -> docker-compose logs -f koku-server koku-worker +docker-compose logs -f koku-server koku-worker ``` 4. Clean up (optional) @@ -168,21 +168,21 @@ Follow the [steps](#koku-api) to run a local Koku API instance 1. Clone the Settings Frontend repository and install dependencies ``` -> git clone https://github.com/RedHatInsights/settings-frontend.git -> cd [SETTINGS_FRONTEND_GIT_REPO] -> npm install +git clone https://github.com/RedHatInsights/settings-frontend.git +cd [SETTINGS_FRONTEND_GIT_REPO] +npm install ``` 2. Set the following variables in your environment ``` -> export API_PORT=8000 -> export LOCAL_API="/api/cost-management/v1/" -> export KEYCLOAK_PORT=4020 +export API_PORT=8000 +export LOCAL_API="/api/cost-management/v1/" +export KEYCLOAK_PORT=4020 ``` 3. Start development server ``` -> npm run start:standalone:beta +npm run start:standalone:beta ``` 4. Open the following URL From f1dd93b2c7934ca35f960899000beec26982c185 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Wed, 10 Apr 2024 21:51:24 -0400 Subject: [PATCH 04/33] Update README --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f1b50829e..7ffc5cb75 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ https://stage.foo.redhat.com:1337/beta/openshift/cost-management ### Running Koku UI with local Cloud Services Backend -See https://github.com/RedHatInsights/chrome-service-backend/blob/main/docs/cloud-services-config.md#serving-files-locally +Refer to the [serving files locally][serving-files-locally] section of cloud services config for more details 1. Serve files locally from Cloud Services Backend repo ``` @@ -78,7 +78,7 @@ npm start:csb ### Running Koku UI with local Koku microfrontend (MFE) -See https://github.com/project-koku/koku-ui-mfe +Refer to the [koku-ui-mfe README][koku-ui-mfe-readme] for more details 1. Start development server in Koku MFE repo ``` @@ -92,8 +92,7 @@ npm start:mfe ### Running Koku UI with local Koku microfrontend (MFE) and Cloud Services Backend -See https://github.com/RedHatInsights/chrome-service-backend/blob/main/docs/cloud-services-config.md#serving-files-locally -and https://github.com/project-koku/koku-ui-mfe +Refer to the [serving files locally][serving-files-locally] section of cloud services config and the [koku-ui README][koku-ui-mfe-readme] for more details 1. Serve files locally from Cloud Services Backend repo ``` @@ -130,9 +129,10 @@ http://localhost:8002/beta/openshift/cost-management ``` #### Koku API -Refer to the project [README][koku-readme] for prerequisites -1. Setup & run Koku API (see project [README][koku-readme] for more details) +Refer to the [koku README][koku-readme] for more details + +1. Setup & run Koku API ``` git clone git@github.com:project-koku/koku.git cd [KOKU_GIT_REPO] @@ -164,7 +164,7 @@ exit ## Running local instances of Settings Frontend & Koku API -Follow the [steps](#koku-api) to run a local Koku API instance +Follow the koku API [steps](#koku-api) to run a local Koku API instance 1. Clone the Settings Frontend repository and install dependencies ``` @@ -195,13 +195,14 @@ http://localhost:1337/beta/settings/applications/cost-management This [RELEASE][release-doc] doc describes how to release Koku UI to each staging environment. [build-badge]: https://github.com/project-koku/koku-ui/actions/workflows/tag_release.yml/badge.svg -[license-badge]: https://img.shields.io/github/license/project-koku/koku-ui.svg?longCache=true [codecov-badge]: https://codecov.io/gh/project-koku/koku-ui/graph/badge.svg?token=1hjFIy1cRe - +[Jira]: https://issues.redhat.com/projects/COST/ [koku-readme]: https://github.com/project-koku/koku#readme +[koku-ui-mfe-readme]: https://github.com/project-koku/koku-ui-mfe#readme +[license-badge]: https://img.shields.io/github/license/project-koku/koku-ui.svg?longCache=true [nodejs]: https://nodejs.org/en/ +[npm]: https://www.npmjs.com/ [patch-etc-hosts]: https://github.com/RedHatInsights/insights-proxy/blob/master/scripts/patch-etc-hosts.sh [Patternfly]: https://www.patternfly.org/ [release-doc]: https://github.com/project-koku/koku-ui/blob/main/RELEASE.md -[npm]: https://www.npmjs.com/ -[Jira]: https://issues.redhat.com/projects/COST/ +[serving-files-locally]: https://github.com/RedHatInsights/chrome-service-backend/blob/main/docs/cloud-services-config.md#serving-files-locally From 56dc9ed447aade1a11320bdfe9863c3840a0b008 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Wed, 10 Apr 2024 22:02:51 -0400 Subject: [PATCH 05/33] Fix README typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ffc5cb75..0d51088f8 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ npm start:mfe ### Running Koku UI with local Koku microfrontend (MFE) and Cloud Services Backend -Refer to the [serving files locally][serving-files-locally] section of cloud services config and the [koku-ui README][koku-ui-mfe-readme] for more details +Refer to the [serving files locally][serving-files-locally] section of cloud services config and the [koku-ui-mfe README][koku-ui-mfe-readme] for more details 1. Serve files locally from Cloud Services Backend repo ``` From 027f969ab4df4dcf694656c9e8b10742be8bad00 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Wed, 10 Apr 2024 22:33:57 -0400 Subject: [PATCH 06/33] Format README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0d51088f8..e9e4fba7f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ User interface is based on [Patternfly]. Submit issues in [Jira]. ## Requirements + * [NodeJS v18.15+][nodejs] * [npm v9.5+][npm] @@ -28,6 +29,7 @@ sudo bash scripts/patch-etc-hosts.sh ``` ## Getting Started + 1. Install requirements listed above. 2. Setup `/etc/hosts` entries listed above. 3. Clone the repository, and open a terminal in the base of this project. @@ -44,6 +46,7 @@ npm test ``` ## Running Koku UI against a hosted Koku API, using webpack proxy + Note that this approach currently supports the Insights stage-beta, stage-stable, prod-beta, and prod-stable environments. 1. Start development server From 01d34d9f7747fff28738116437f8fecb60d6498b Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 11 Apr 2024 10:45:07 -0400 Subject: [PATCH 07/33] Update README - Update badge to show CI status for main branch - Link to job run --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e9e4fba7f..b1d8790a1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Koku UI [![Apache 2.0][license-badge]](https://github.com/project-koku/koku-ui/blob/main/LICENSE) -[![CI Status][build-badge]](https://github.com/project-koku/koku-ui/actions/workflows/tag_release.yml) +[![CI Status][build-badge]](https://github.com/project-koku/koku-ui/actions/workflows/ci.yml?query=branch%3Amain) [![codecov][codecov-badge]](https://codecov.io/gh/project-koku/koku-ui) React.js app for Cost Management. @@ -153,7 +153,7 @@ docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Ports}}\t{{.Status}}" 3. Watch the Koku API logs in another terminal (optional) ``` -docker-compose logs -f koku-server koku-worker +docker compose logs -f koku-server koku-worker ``` 4. Clean up (optional) @@ -197,7 +197,7 @@ http://localhost:1337/beta/settings/applications/cost-management This [RELEASE][release-doc] doc describes how to release Koku UI to each staging environment. -[build-badge]: https://github.com/project-koku/koku-ui/actions/workflows/tag_release.yml/badge.svg +[build-badge]: https://github.com/project-koku/koku-ui/actions/workflows/ci.yml/badge.svg?branch=main [codecov-badge]: https://codecov.io/gh/project-koku/koku-ui/graph/badge.svg?token=1hjFIy1cRe [Jira]: https://issues.redhat.com/projects/COST/ [koku-readme]: https://github.com/project-koku/koku#readme From 0ca0a9825eb6b5e36ef7113ddc748319d339b436 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 11 Apr 2024 11:51:48 -0400 Subject: [PATCH 08/33] Consolidate CI workflows - Create a separate workflow for setup that is reusable - Do not run build on PRs - Run lint and build jobs concurrently --- .github/workflows/ci.yml | 73 ++++++++++++------- .../workflows/{pull_request.yml => setup.yml} | 36 +++------ 2 files changed, 55 insertions(+), 54 deletions(-) rename .github/workflows/{pull_request.yml => setup.yml} (53%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8e4acbfc..e919c3a05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Code Coverage +name: CI on: pull_request: @@ -10,38 +10,19 @@ env: BRANCH: ${{ github.base_ref }} jobs: - build: - name: koku-ui codecov + unit: + name: Units - Node.js ${{ strategy.matrix.node-version }} runs-on: ubuntu-latest + + uses: ./.github/workflows/setup.yml + with: + node-version: ${{ matrix.node-version }} + strategy: matrix: node-version: [18] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - - name: Cache node modules - id: cache-npm - uses: actions/cache@v4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Install dependencies - run: npm install + steps: - name: Test run: npm test -- --collect-coverage --max-workers=4 @@ -54,3 +35,39 @@ jobs: directory: coverage plugin: pycoverage # Only run one plugin so that all do not run. There is no way to disable plugins entirely. + build: + name: Build - Node.js ${{ strategy.matrix.node-version }} + runs-on: ubuntu-latest + + uses: ./.github/workflows/setup.yml + with: + node-version: ${{ matrix.node-version }} + + if: ${{ github.event_name == 'push' }} + strategy: + matrix: + node-version: [18] + + steps: + - name: Build + run: npm run build + + lint: + name: Lint - Node.js ${{ strategy.matrix.node-version }} + runs-on: ubuntu-latest + + uses: ./.github/workflows/setup.yml + with: + node-version: ${{ matrix.node-version }} + + strategy: + matrix: + node-version: [18] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + + - name: Lint + run: npm run lint diff --git a/.github/workflows/pull_request.yml b/.github/workflows/setup.yml similarity index 53% rename from .github/workflows/pull_request.yml rename to .github/workflows/setup.yml index 3d1f61e0f..b3d01f674 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/setup.yml @@ -1,29 +1,24 @@ -# Run this workflow for PRs only to confirm container build is working properly - -name: Pull request +name: Setup on: - pull_request: - branches: [ main, prod-beta, prod-stable, stage-beta, stage-stable ] - -env: - BRANCH: ${{ github.base_ref }} + workflow_call: + inputs: + node-version: + required: true + type: string jobs: - build: - name: koku-ui build + setup: + name: Setup runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18] steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js ${{ matrix.node-version }} + - name: Setup Node.js ${{ inputs.node-version }} uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} + node-version: ${{ inputs.node-version }} - name: Cache node modules id: cache-npm @@ -41,14 +36,3 @@ jobs: - name: Install dependencies run: npm install - - - name: Build - run: npm run build - - - name: Lint - if: ${{ success() }} - run: npm run lint - - - name: Test - if: ${{ success() }} - run: npm test From 601321f1500545f95d4f89b0d4106a601821583f Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 11 Apr 2024 12:11:33 -0400 Subject: [PATCH 09/33] =?UTF-8?q?Reusable=20workflow=20won=E2=80=99t=20wor?= =?UTF-8?q?k=20how=20I=20thought?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A composite workflow is most likely what is needed. The setup tasks are redudant but required for test concurrency. --- .github/workflows/ci.yml | 85 +++++++++++++++++++++++++++++++------ .github/workflows/setup.yml | 38 ----------------- 2 files changed, 72 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/setup.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e919c3a05..27d377adb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,15 +14,36 @@ jobs: name: Units - Node.js ${{ strategy.matrix.node-version }} runs-on: ubuntu-latest - uses: ./.github/workflows/setup.yml - with: - node-version: ${{ matrix.node-version }} - strategy: matrix: node-version: [18] steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ inputs.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - name: Cache node modules + id: cache-npm + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install dependencies + run: npm install + - name: Test run: npm test -- --collect-coverage --max-workers=4 @@ -39,16 +60,36 @@ jobs: name: Build - Node.js ${{ strategy.matrix.node-version }} runs-on: ubuntu-latest - uses: ./.github/workflows/setup.yml - with: - node-version: ${{ matrix.node-version }} - - if: ${{ github.event_name == 'push' }} strategy: matrix: node-version: [18] steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ inputs.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - name: Cache node modules + id: cache-npm + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install dependencies + run: npm install + - name: Build run: npm run build @@ -56,10 +97,6 @@ jobs: name: Lint - Node.js ${{ strategy.matrix.node-version }} runs-on: ubuntu-latest - uses: ./.github/workflows/setup.yml - with: - node-version: ${{ matrix.node-version }} - strategy: matrix: node-version: [18] @@ -68,6 +105,28 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Setup Node.js ${{ inputs.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - name: Cache node modules + id: cache-npm + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install dependencies + run: npm install - name: Lint run: npm run lint + diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml deleted file mode 100644 index b3d01f674..000000000 --- a/.github/workflows/setup.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Setup - -on: - workflow_call: - inputs: - node-version: - required: true - type: string - -jobs: - setup: - name: Setup - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Node.js ${{ inputs.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ inputs.node-version }} - - - name: Cache node modules - id: cache-npm - uses: actions/cache@v4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Install dependencies - run: npm install From 5798432fb17ac3f84782988500a1891990e58b20 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 11 Apr 2024 12:15:21 -0400 Subject: [PATCH 10/33] Correct variable names --- .github/workflows/ci.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27d377adb..475392d4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ env: jobs: unit: - name: Units - Node.js ${{ strategy.matrix.node-version }} + name: Units - Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: @@ -22,10 +22,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js ${{ inputs.node-version }} + - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: - node-version: ${{ inputs.node-version }} + node-version: ${{ matrix.node-version }} - name: Cache node modules id: cache-npm @@ -57,7 +57,7 @@ jobs: plugin: pycoverage # Only run one plugin so that all do not run. There is no way to disable plugins entirely. build: - name: Build - Node.js ${{ strategy.matrix.node-version }} + name: Build - Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: @@ -68,10 +68,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js ${{ inputs.node-version }} + - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: - node-version: ${{ inputs.node-version }} + node-version: ${{ matrix.node-version }} - name: Cache node modules id: cache-npm @@ -94,7 +94,7 @@ jobs: run: npm run build lint: - name: Lint - Node.js ${{ strategy.matrix.node-version }} + name: Lint - Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: @@ -105,10 +105,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js ${{ inputs.node-version }} + - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: - node-version: ${{ inputs.node-version }} + node-version: ${{ matrix.node-version }} - name: Cache node modules id: cache-npm From 1d337458bb41789fd4544e535175da772d6896c9 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 11 Apr 2024 12:22:33 -0400 Subject: [PATCH 11/33] Do not use a test matrix We only need to test with the latest LTS version of Node.js --- .github/workflows/ci.yml | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 475392d4f..1f0af6305 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,24 +8,21 @@ on: env: BRANCH: ${{ github.base_ref }} + NODEJS_VERSION: '18' jobs: unit: - name: Units - Node.js ${{ matrix.node-version }} + name: Units runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18] - steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js ${{ matrix.node-version }} + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} + node-version: ${{ env.NODEJS_VERSION }} - name: Cache node modules id: cache-npm @@ -57,21 +54,17 @@ jobs: plugin: pycoverage # Only run one plugin so that all do not run. There is no way to disable plugins entirely. build: - name: Build - Node.js ${{ matrix.node-version }} + name: Build runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18] - steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js ${{ matrix.node-version }} + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} + node-version: ${{ env.NODEJS_VERSION }} - name: Cache node modules id: cache-npm @@ -94,21 +87,17 @@ jobs: run: npm run build lint: - name: Lint - Node.js ${{ matrix.node-version }} + name: Lint runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18] - steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js ${{ matrix.node-version }} + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} + node-version: ${{ env.NODEJS_VERSION }} - name: Cache node modules id: cache-npm From 0c6f0826eec01ab49b32bd350f4183a989bfab30 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 11 Apr 2024 12:39:38 -0400 Subject: [PATCH 12/33] Make coverage report upload a separate job --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f0af6305..633608c77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ env: NODEJS_VERSION: '18' jobs: - unit: + units: name: Units runs-on: ubuntu-latest @@ -42,16 +42,17 @@ jobs: run: npm install - name: Test + id: test_run run: npm test -- --collect-coverage --max-workers=4 - - name: Upload coverage report - if: ${{ success() }} - uses: codecov/codecov-action@v4.2.0 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - uses: actions/upload-artifact@v3 + if: ${{ steps.test_run.outcome == 'success' }} + name: Save coverage report with: - directory: coverage - plugin: pycoverage # Only run one plugin so that all do not run. There is no way to disable plugins entirely. + name: coverage_report + path: coverage/ + retention-days: 10 + build: name: Build @@ -119,3 +120,28 @@ jobs: - name: Lint run: npm run lint + + + coverage: + name: Coverage + needs: [units] + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download coverage report + uses: actions/download-artifact@v3 + with: + name: coverage_report + path: coverage + + - name: Upload coverage report + if: ${{ success() }} + uses: codecov/codecov-action@v4.2.0 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + directory: coverage + plugin: pycoverage # Only run one plugin so that all do not run. There is no way to disable plugins entirely. From 5d54cfe1fafae35c40bc97561f5fed5b8120902c Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 11 Apr 2024 13:19:37 -0400 Subject: [PATCH 13/33] Try v4 upload/download-artifact --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 633608c77..781ea2bb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: id: test_run run: npm test -- --collect-coverage --max-workers=4 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: ${{ steps.test_run.outcome == 'success' }} name: Save coverage report with: @@ -132,7 +132,7 @@ jobs: uses: actions/checkout@v4 - name: Download coverage report - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: coverage_report path: coverage From 8ae597b4d53fecc09aec93c87a33859534e258ee Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 11 Apr 2024 13:33:15 -0400 Subject: [PATCH 14/33] Only run build and lint jobs for PRs --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 781ea2bb9..74c6f73c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,7 @@ jobs: build: + if: ${{ github.event_name == 'pull_request' }} name: Build runs-on: ubuntu-latest @@ -88,6 +89,7 @@ jobs: run: npm run build lint: + if: ${{ github.event_name == 'pull_request' }} name: Lint runs-on: ubuntu-latest @@ -120,8 +122,6 @@ jobs: - name: Lint run: npm run lint - - coverage: name: Coverage needs: [units] From 6265f35d5902844a178dcb3bf56a28fd77ae3031 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 11 Apr 2024 13:47:41 -0400 Subject: [PATCH 15/33] Consolidate build and lint jobs into one sanity job --- .github/workflows/ci.yml | 41 +++++----------------------------------- 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74c6f73c9..4ee33811a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,43 +54,9 @@ jobs: retention-days: 10 - build: + sanity: if: ${{ github.event_name == 'pull_request' }} - name: Build - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODEJS_VERSION }} - - - name: Cache node modules - id: cache-npm - uses: actions/cache@v4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Install dependencies - run: npm install - - - name: Build - run: npm run build - - lint: - if: ${{ github.event_name == 'pull_request' }} - name: Lint + name: Sanity runs-on: ubuntu-latest steps: @@ -122,6 +88,9 @@ jobs: - name: Lint run: npm run lint + - name: Build + run: npm run build + coverage: name: Coverage needs: [units] From a1979dbf55b0f3dfd85f36c925a53e6e8ded422e Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Thu, 11 Apr 2024 14:28:10 -0400 Subject: [PATCH 16/33] Update order of jobs and add comment --- .github/workflows/ci.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ee33811a..da8322a0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,8 +11,10 @@ env: NODEJS_VERSION: '18' jobs: - units: - name: Units + build: + # This job is run for PRs only, as a sanity check, to confirm ci.ext.devshift.net is working properly + if: ${{ github.event_name == 'pull_request' }} + name: Build runs-on: ubuntu-latest steps: @@ -41,22 +43,14 @@ jobs: - name: Install dependencies run: npm install - - name: Test - id: test_run - run: npm test -- --collect-coverage --max-workers=4 - - - uses: actions/upload-artifact@v4 - if: ${{ steps.test_run.outcome == 'success' }} - name: Save coverage report - with: - name: coverage_report - path: coverage/ - retention-days: 10 + - name: Build + run: npm run build + - name: Lint + run: npm run lint - sanity: - if: ${{ github.event_name == 'pull_request' }} - name: Sanity + units: + name: Units runs-on: ubuntu-latest steps: @@ -85,11 +79,17 @@ jobs: - name: Install dependencies run: npm install - - name: Lint - run: npm run lint + - name: Test + id: test_run + run: npm test -- --collect-coverage --max-workers=4 - - name: Build - run: npm run build + - uses: actions/upload-artifact@v4 + if: ${{ steps.test_run.outcome == 'success' }} + name: Save coverage report + with: + name: coverage_report + path: coverage/ + retention-days: 10 coverage: name: Coverage From 737045156d2e743f6b3fa1cc30f14aeb221fdf30 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Fri, 12 Apr 2024 12:12:36 -0400 Subject: [PATCH 17/33] Silent PatternFly Th aria-label warning --- src/routes/settings/costModels/costModelsDetails/table.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/settings/costModels/costModelsDetails/table.tsx b/src/routes/settings/costModels/costModelsDetails/table.tsx index 6ac314c42..9d630f72d 100644 --- a/src/routes/settings/costModels/costModelsDetails/table.tsx +++ b/src/routes/settings/costModels/costModelsDetails/table.tsx @@ -115,14 +115,14 @@ class CostModelsTableBase extends React.Component {cells.map((c, cellIndex) => ( {c.title} ))} - + From e8c3131da1d1a68f29927cb975fe56592c75be93 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Fri, 12 Apr 2024 12:13:00 -0400 Subject: [PATCH 18/33] Add settings api test --- src/api/settings.test.ts | 33 +++++++++++++++++++++++++++++++++ src/api/settings.ts | 3 ++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/api/settings.test.ts diff --git a/src/api/settings.test.ts b/src/api/settings.test.ts new file mode 100644 index 000000000..a42289645 --- /dev/null +++ b/src/api/settings.test.ts @@ -0,0 +1,33 @@ +import { axiosInstance } from 'api'; + +import { fetchSettings, SettingsType } from './settings'; + +test('api get cost category keys', () => { + fetchSettings(SettingsType.costCategories, ''); + expect(axiosInstance.get).toBeCalledWith('settings/aws_category_keys/'); +}); + +test('api get platform projects', () => { + fetchSettings(SettingsType.platformProjects, ''); + expect(axiosInstance.get).toBeCalledWith('settings/cost-groups/'); +}); + +test('api get child tag mappings', () => { + fetchSettings(SettingsType.tagsMappingsChild, ''); + expect(axiosInstance.get).toBeCalledWith('settings/tags/mappings/child'); +}); + +test('api get parent tag mappings', () => { + fetchSettings(SettingsType.tagsMappingsParent, ''); + expect(axiosInstance.get).toBeCalledWith('settings/tags/mappings/parent'); +}); + +test('api get tag mappings', () => { + fetchSettings(SettingsType.tagsMappings, ''); + expect(axiosInstance.get).toBeCalledWith('settings/tags/mappings'); +}); + +test('api get tags', () => { + fetchSettings(SettingsType.tags, ''); + expect(axiosInstance.get).toBeCalledWith('settings/tags'); +}); diff --git a/src/api/settings.ts b/src/api/settings.ts index edaf1fb62..39c8ac023 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -71,7 +71,8 @@ export const SettingsTypePaths: Partial> = { export function fetchSettings(settingsType: SettingsType, query: string) { const path = SettingsTypePaths[settingsType]; - return axiosInstance.get(`${path}?${query}`); + const queryString = query ? `?${query}` : ''; + return axiosInstance.get(`${path}${queryString}`); } export function updateSettings(settingsType: SettingsType, payload: SettingsPayload) { From 45306d8135cb4c7aadf63986c457f3ea3067d627 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Fri, 12 Apr 2024 12:32:24 -0400 Subject: [PATCH 19/33] Replace screenReaderText with aria-label --- src/routes/settings/costModels/costModelsDetails/table.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/settings/costModels/costModelsDetails/table.tsx b/src/routes/settings/costModels/costModelsDetails/table.tsx index 9d630f72d..153985077 100644 --- a/src/routes/settings/costModels/costModelsDetails/table.tsx +++ b/src/routes/settings/costModels/costModelsDetails/table.tsx @@ -122,7 +122,7 @@ class CostModelsTableBase extends React.Component ))} - + From f8afbe0f49f51985da1d6dd8e493ec9ae9fd988b Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Fri, 12 Apr 2024 15:38:31 -0400 Subject: [PATCH 20/33] Add query tests --- src/api/orgs/orgUtils.test.ts | 10 +++++ src/api/queries/awsQuery.test.ts | 22 ++++++++++ src/api/queries/azureQuery.test.ts | 22 ++++++++++ src/api/queries/gcpQuery.test.ts | 22 ++++++++++ src/api/queries/ibmQuery.test.ts | 22 ++++++++++ src/api/queries/ociQuery.test.ts | 22 ++++++++++ src/api/queries/ocpCloudQuery.test.ts | 22 ++++++++++ src/api/queries/ocpQuery.test.ts | 22 ++++++++++ src/api/queries/overviewQuery.test.ts | 22 ++++++++++ src/api/queries/providers.test.ts | 13 ++++++ src/api/queries/query.test.ts | 57 +++++++++++++++++++++++++ src/api/queries/query.ts | 4 +- src/api/queries/rhelQuery.test.ts | 22 ++++++++++ src/api/queries/userAccessQuery.test.ts | 13 ++++++ 14 files changed, 293 insertions(+), 2 deletions(-) create mode 100644 src/api/orgs/orgUtils.test.ts create mode 100644 src/api/queries/awsQuery.test.ts create mode 100644 src/api/queries/azureQuery.test.ts create mode 100644 src/api/queries/gcpQuery.test.ts create mode 100644 src/api/queries/ibmQuery.test.ts create mode 100644 src/api/queries/ociQuery.test.ts create mode 100644 src/api/queries/ocpCloudQuery.test.ts create mode 100644 src/api/queries/ocpQuery.test.ts create mode 100644 src/api/queries/overviewQuery.test.ts create mode 100644 src/api/queries/providers.test.ts create mode 100644 src/api/queries/query.test.ts create mode 100644 src/api/queries/rhelQuery.test.ts create mode 100644 src/api/queries/userAccessQuery.test.ts diff --git a/src/api/orgs/orgUtils.test.ts b/src/api/orgs/orgUtils.test.ts new file mode 100644 index 000000000..6a451b41f --- /dev/null +++ b/src/api/orgs/orgUtils.test.ts @@ -0,0 +1,10 @@ +import { axiosInstance } from 'api'; + +import { OrgPathsType, OrgType } from './org'; +import { runOrg } from './orgUtils'; + +test('api run reports calls axios get', () => { + const query = 'filter[resolution]=daily'; + runOrg(OrgPathsType.aws, OrgType.org, query); + expect(axiosInstance.get).toBeCalledWith(`organizations/aws/?${query}`); +}); diff --git a/src/api/queries/awsQuery.test.ts b/src/api/queries/awsQuery.test.ts new file mode 100644 index 000000000..f16491888 --- /dev/null +++ b/src/api/queries/awsQuery.test.ts @@ -0,0 +1,22 @@ +import { getQuery, getQueryRoute, parseQuery } from './awsQuery'; + +const query = { + filter_by: { + account: 'test', + }, + order_by: { + account: 'asc', + }, +}; + +test('getQuery filter_by props are converted', () => { + expect(getQuery(query)).toEqual('filter[account]=test&order_by[account]=asc'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(getQueryRoute(query)).toEqual('filter_by[account]=test&order_by[account]=asc'); +}); + +test('parseQuery to convert query string to JSON', () => { + expect(parseQuery('filter_by[account]=test&order_by[account]=asc')).toEqual(query); +}); diff --git a/src/api/queries/azureQuery.test.ts b/src/api/queries/azureQuery.test.ts new file mode 100644 index 000000000..3135545f2 --- /dev/null +++ b/src/api/queries/azureQuery.test.ts @@ -0,0 +1,22 @@ +import { getQuery, getQueryRoute, parseQuery } from './azureQuery'; + +const query = { + filter_by: { + subscription_guid: 'test', + }, + order_by: { + subscription_guid: 'asc', + }, +}; + +test('getQuery filter_by props are converted', () => { + expect(getQuery(query)).toEqual('filter[subscription_guid]=test&order_by[subscription_guid]=asc'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(getQueryRoute(query)).toEqual('filter_by[subscription_guid]=test&order_by[subscription_guid]=asc'); +}); + +test('parseQuery to convert query string to JSON', () => { + expect(parseQuery('filter_by[subscription_guid]=test&order_by[subscription_guid]=asc')).toEqual(query); +}); diff --git a/src/api/queries/gcpQuery.test.ts b/src/api/queries/gcpQuery.test.ts new file mode 100644 index 000000000..29802ec20 --- /dev/null +++ b/src/api/queries/gcpQuery.test.ts @@ -0,0 +1,22 @@ +import { getQuery, getQueryRoute, parseQuery } from './gcpQuery'; + +const query = { + filter_by: { + account: 'test', + }, + order_by: { + account: 'asc', + }, +}; + +test('getQuery filter_by props are converted', () => { + expect(getQuery(query)).toEqual('filter[account]=test&order_by[account]=asc'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(getQueryRoute(query)).toEqual('filter_by[account]=test&order_by[account]=asc'); +}); + +test('parseQuery to convert query string to JSON', () => { + expect(parseQuery('filter_by[account]=test&order_by[account]=asc')).toEqual(query); +}); diff --git a/src/api/queries/ibmQuery.test.ts b/src/api/queries/ibmQuery.test.ts new file mode 100644 index 000000000..921ac71fc --- /dev/null +++ b/src/api/queries/ibmQuery.test.ts @@ -0,0 +1,22 @@ +import { getQuery, getQueryRoute, parseQuery } from './ibmQuery'; + +const query = { + filter_by: { + account: 'test', + }, + order_by: { + account: 'asc', + }, +}; + +test('getQuery filter_by props are converted', () => { + expect(getQuery(query)).toEqual('filter[account]=test&order_by[account]=asc'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(getQueryRoute(query)).toEqual('filter_by[account]=test&order_by[account]=asc'); +}); + +test('parseQuery to convert query string to JSON', () => { + expect(parseQuery('filter_by[account]=test&order_by[account]=asc')).toEqual(query); +}); diff --git a/src/api/queries/ociQuery.test.ts b/src/api/queries/ociQuery.test.ts new file mode 100644 index 000000000..78a91646c --- /dev/null +++ b/src/api/queries/ociQuery.test.ts @@ -0,0 +1,22 @@ +import { getQuery, getQueryRoute, parseQuery } from './ociQuery'; + +const query = { + filter_by: { + payer_tenant_id: 'test', + }, + order_by: { + payer_tenant_id: 'asc', + }, +}; + +test('getQuery filter_by props are converted', () => { + expect(getQuery(query)).toEqual('filter[payer_tenant_id]=test&order_by[payer_tenant_id]=asc'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(getQueryRoute(query)).toEqual('filter_by[payer_tenant_id]=test&order_by[payer_tenant_id]=asc'); +}); + +test('parseQuery to convert query string to JSON', () => { + expect(parseQuery('filter_by[payer_tenant_id]=test&order_by[payer_tenant_id]=asc')).toEqual(query); +}); diff --git a/src/api/queries/ocpCloudQuery.test.ts b/src/api/queries/ocpCloudQuery.test.ts new file mode 100644 index 000000000..cbce8699c --- /dev/null +++ b/src/api/queries/ocpCloudQuery.test.ts @@ -0,0 +1,22 @@ +import { getQuery, getQueryRoute, parseQuery } from './ocpCloudQuery'; + +const query = { + filter_by: { + project: 'test', + }, + order_by: { + project: 'asc', + }, +}; + +test('getQuery filter_by props are converted', () => { + expect(getQuery(query)).toEqual('filter[project]=test&order_by[project]=asc'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(getQueryRoute(query)).toEqual('filter_by[project]=test&order_by[project]=asc'); +}); + +test('parseQuery to convert query string to JSON', () => { + expect(parseQuery('filter_by[project]=test&order_by[project]=asc')).toEqual(query); +}); diff --git a/src/api/queries/ocpQuery.test.ts b/src/api/queries/ocpQuery.test.ts new file mode 100644 index 000000000..448b6f71d --- /dev/null +++ b/src/api/queries/ocpQuery.test.ts @@ -0,0 +1,22 @@ +import { getQuery, getQueryRoute, parseQuery } from './ocpQuery'; + +const query = { + filter_by: { + project: 'test', + }, + order_by: { + project: 'asc', + }, +}; + +test('getQuery filter_by props are converted', () => { + expect(getQuery(query)).toEqual('filter[project]=test&order_by[project]=asc'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(getQueryRoute(query)).toEqual('filter_by[project]=test&order_by[project]=asc'); +}); + +test('parseQuery to convert query string to JSON', () => { + expect(parseQuery('filter_by[project]=test&order_by[project]=asc')).toEqual(query); +}); diff --git a/src/api/queries/overviewQuery.test.ts b/src/api/queries/overviewQuery.test.ts new file mode 100644 index 000000000..4c605fbba --- /dev/null +++ b/src/api/queries/overviewQuery.test.ts @@ -0,0 +1,22 @@ +import { getQuery, getQueryRoute, parseQuery } from './overviewQuery'; + +const query = { + filter_by: { + ocpPerspective: 'test', + }, + order_by: { + ocpPerspective: 'asc', + }, +}; + +test('getQuery filter_by props are converted', () => { + expect(getQuery(query)).toEqual('filter[ocpPerspective]=test&order_by[ocpPerspective]=asc'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(getQueryRoute(query)).toEqual('filter_by[ocpPerspective]=test&order_by[ocpPerspective]=asc'); +}); + +test('parseQuery to convert query string to JSON', () => { + expect(parseQuery('filter_by[ocpPerspective]=test&order_by[ocpPerspective]=asc')).toEqual(query); +}); diff --git a/src/api/queries/providers.test.ts b/src/api/queries/providers.test.ts new file mode 100644 index 000000000..95513701e --- /dev/null +++ b/src/api/queries/providers.test.ts @@ -0,0 +1,13 @@ +import { getProvidersQuery, parseProvidersQuery } from './providersQuery'; + +const query = { + type: 'AWS' as any, +}; + +test('getUserAccessQuery filter_by props are converted', () => { + expect(getProvidersQuery(query)).toEqual('type=AWS'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(parseProvidersQuery('type=AWS')).toEqual(query); +}); diff --git a/src/api/queries/query.test.ts b/src/api/queries/query.test.ts new file mode 100644 index 000000000..d6d3c0289 --- /dev/null +++ b/src/api/queries/query.test.ts @@ -0,0 +1,57 @@ +import { logicalAndPrefix, logicalOrPrefix } from 'utils/props'; + +import { convertFilterBy, getQuery, getQueryRoute, parseFilterByPrefix, parseGroupByPrefix, parseQuery } from './query'; + +const query = { + filter_by: { + [`${logicalAndPrefix}project`]: 'test', + [`${logicalOrPrefix}node`]: 'test', + }, + group_by: { + [`${logicalAndPrefix}project`]: 'test', + [`${logicalOrPrefix}node`]: 'test', + }, +}; + +test('getQuery filter_by props are converted', () => { + expect(getQuery(query)).toEqual( + 'filter[and:project]=test&filter[or:node]=test&group_by[and:project]=test&group_by[or:node]=test' + ); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(getQueryRoute(query)).toEqual( + 'filter_by[and:project]=test&filter_by[or:node]=test&group_by[and:project]=test&group_by[or:node]=test' + ); +}); + +test('parseQuery to convert query string to JSON', () => { + expect( + parseQuery('filter_by[and:project]=test&filter_by[or:node]=test&group_by[and:project]=test&group_by[or:node]=test') + ).toEqual({ + filter_by: { project: 'test', node: 'test' }, + group_by: { project: 'test', node: 'test' }, + }); +}); + +test('Convert filter_by props to filter props', () => { + expect(convertFilterBy(query)).toEqual({ + filter: { 'and:project': 'test', 'or:node': 'test' }, + filter_by: undefined, + group_by: { 'and:project': 'test', 'or:node': 'test' }, + }); +}); + +test('Return query without AND/OR prefix for filter_by', () => { + expect(parseFilterByPrefix(query)).toEqual({ + filter_by: { node: 'test', project: 'test' }, + group_by: { 'or:node': 'test', 'and:project': 'test' }, + }); +}); + +test('Return query without AND/OR prefix for group_by', () => { + expect(parseGroupByPrefix(query)).toEqual({ + filter_by: { 'or:node': 'test', 'and:project': 'test' }, + group_by: { node: 'test', project: 'test' }, + }); +}); diff --git a/src/api/queries/query.ts b/src/api/queries/query.ts index f2dc72930..157887010 100644 --- a/src/api/queries/query.ts +++ b/src/api/queries/query.ts @@ -95,7 +95,7 @@ function parseKey(val: string) { return key; } -// Returns query without filter_by prefix +// Returns query without AND/OR prefix for filter_by export function parseFilterByPrefix(query: Query) { if (!query?.filter_by) { return query; @@ -111,7 +111,7 @@ export function parseFilterByPrefix(query: Query) { return newQuery; } -// Returns query without group_by prefix -- https://github.com/project-koku/koku-ui/issues/704 +// Returns query without AND/OR prefix for group_by -- https://github.com/project-koku/koku-ui/issues/704 export function parseGroupByPrefix(query: Query) { if (!query?.group_by) { return query; diff --git a/src/api/queries/rhelQuery.test.ts b/src/api/queries/rhelQuery.test.ts new file mode 100644 index 000000000..29ac5ffb1 --- /dev/null +++ b/src/api/queries/rhelQuery.test.ts @@ -0,0 +1,22 @@ +import { getQuery, getQueryRoute, parseQuery } from './rhelQuery'; + +const query = { + filter_by: { + project: 'test', + }, + order_by: { + project: 'asc', + }, +}; + +test('getQuery filter_by props are converted', () => { + expect(getQuery(query)).toEqual('filter[project]=test&order_by[project]=asc'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(getQueryRoute(query)).toEqual('filter_by[project]=test&order_by[project]=asc'); +}); + +test('parseQuery to convert query string to JSON', () => { + expect(parseQuery('filter_by[project]=test&order_by[project]=asc')).toEqual(query); +}); diff --git a/src/api/queries/userAccessQuery.test.ts b/src/api/queries/userAccessQuery.test.ts new file mode 100644 index 000000000..0614c79fc --- /dev/null +++ b/src/api/queries/userAccessQuery.test.ts @@ -0,0 +1,13 @@ +import { getUserAccessQuery, parseUserAccessQuery } from './userAccessQuery'; + +const query = { + type: 'AWS' as any, +}; + +test('getUserAccessQuery filter_by props are converted', () => { + expect(getUserAccessQuery(query)).toEqual('type=AWS'); +}); + +test('getQueryRoute filter_by props are not converted', () => { + expect(parseUserAccessQuery('type=AWS')).toEqual(query); +}); From b47e04d9a9750ba758ca01d5113878543ae2bce9 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Fri, 12 Apr 2024 17:56:58 -0400 Subject: [PATCH 21/33] Add export API tests --- src/api/accountSettings.test.ts | 13 ++++++++++++ src/api/export/awsExport.test.ts | 9 ++++++++ src/api/export/awsOcpExport.test.ts | 11 ++++++++++ src/api/export/azureExport.test.ts | 11 ++++++++++ src/api/export/azureOcpExport.test.ts | 11 ++++++++++ src/api/export/exportUtils.test.ts | 11 ++++++++++ src/api/export/gcpExport.test.ts | 11 ++++++++++ src/api/export/gcpOcpExport.test.ts | 11 ++++++++++ src/api/export/ibmExport.test.ts | 11 ++++++++++ src/api/export/ociExport.test.ts | 11 ++++++++++ src/api/export/ocpCloudExport.test.ts | 11 ++++++++++ src/api/export/ocpExport.test.ts | 11 ++++++++++ src/api/export/rhelExport.test.ts | 11 ++++++++++ src/api/settings.test.ts | 30 +++++---------------------- 14 files changed, 148 insertions(+), 25 deletions(-) create mode 100644 src/api/accountSettings.test.ts create mode 100644 src/api/export/awsExport.test.ts create mode 100644 src/api/export/awsOcpExport.test.ts create mode 100644 src/api/export/azureExport.test.ts create mode 100644 src/api/export/azureOcpExport.test.ts create mode 100644 src/api/export/exportUtils.test.ts create mode 100644 src/api/export/gcpExport.test.ts create mode 100644 src/api/export/gcpOcpExport.test.ts create mode 100644 src/api/export/ibmExport.test.ts create mode 100644 src/api/export/ociExport.test.ts create mode 100644 src/api/export/ocpCloudExport.test.ts create mode 100644 src/api/export/ocpExport.test.ts create mode 100644 src/api/export/rhelExport.test.ts diff --git a/src/api/accountSettings.test.ts b/src/api/accountSettings.test.ts new file mode 100644 index 000000000..6688eaf1c --- /dev/null +++ b/src/api/accountSettings.test.ts @@ -0,0 +1,13 @@ +import { axiosInstance } from 'api'; + +import { AccountSettingsType, fetchAccountSettings, updateAccountSettings } from './accountSettings'; + +test('fetchSettings API request for account settings', () => { + fetchAccountSettings(AccountSettingsType.settings); + expect(axiosInstance.get).toBeCalledWith('account-settings/'); +}); + +test('updateAccountSettings API request to update currency', () => { + updateAccountSettings(AccountSettingsType.currency, { currency: 'EUR' }); + expect(axiosInstance.put).toBeCalledWith('account-settings/currency/', { currency: 'EUR' }); +}); diff --git a/src/api/export/awsExport.test.ts b/src/api/export/awsExport.test.ts new file mode 100644 index 000000000..fd0549dba --- /dev/null +++ b/src/api/export/awsExport.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './awsExport'; + +test('runExport API request for AWS export', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/aws/costs/?', { headers: { Accept: 'text/csv' } }); +}); diff --git a/src/api/export/awsOcpExport.test.ts b/src/api/export/awsOcpExport.test.ts new file mode 100644 index 000000000..a21c5c0ab --- /dev/null +++ b/src/api/export/awsOcpExport.test.ts @@ -0,0 +1,11 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './awsOcpExport'; + +test('runExport API request for OCP on AWS export', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/openshift/infrastructures/aws/costs/?', { + headers: { Accept: 'text/csv' }, + }); +}); diff --git a/src/api/export/azureExport.test.ts b/src/api/export/azureExport.test.ts new file mode 100644 index 000000000..6210fb9bc --- /dev/null +++ b/src/api/export/azureExport.test.ts @@ -0,0 +1,11 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './azureExport'; + +test('runExport API request for Azure export', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/azure/costs/?', { + headers: { Accept: 'text/csv' }, + }); +}); diff --git a/src/api/export/azureOcpExport.test.ts b/src/api/export/azureOcpExport.test.ts new file mode 100644 index 000000000..7af4ed963 --- /dev/null +++ b/src/api/export/azureOcpExport.test.ts @@ -0,0 +1,11 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './azureOcpExport'; + +test('runExport API request for OCP on Azure export', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/openshift/infrastructures/azure/costs/?', { + headers: { Accept: 'text/csv' }, + }); +}); diff --git a/src/api/export/exportUtils.test.ts b/src/api/export/exportUtils.test.ts new file mode 100644 index 000000000..16093a0a3 --- /dev/null +++ b/src/api/export/exportUtils.test.ts @@ -0,0 +1,11 @@ +import { waitFor } from '@testing-library/react'; +import { ReportPathsType, ReportType } from 'api/reports/report'; + +import * as exportUtils from './exportUtils'; + +jest.spyOn(exportUtils, 'runExport'); + +test('runExport API request', async () => { + exportUtils.runExport(ReportPathsType.ocp, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); +}); diff --git a/src/api/export/gcpExport.test.ts b/src/api/export/gcpExport.test.ts new file mode 100644 index 000000000..26da4bf11 --- /dev/null +++ b/src/api/export/gcpExport.test.ts @@ -0,0 +1,11 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './gcpExport'; + +test('runExport API request for GCP export', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/gcp/costs/?', { + headers: { Accept: 'text/csv' }, + }); +}); diff --git a/src/api/export/gcpOcpExport.test.ts b/src/api/export/gcpOcpExport.test.ts new file mode 100644 index 000000000..e368275a6 --- /dev/null +++ b/src/api/export/gcpOcpExport.test.ts @@ -0,0 +1,11 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './gcpOcpExport'; + +test('runExport API request for GCP on OCP export', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/openshift/infrastructures/gcp/costs/?', { + headers: { Accept: 'text/csv' }, + }); +}); diff --git a/src/api/export/ibmExport.test.ts b/src/api/export/ibmExport.test.ts new file mode 100644 index 000000000..9b041b679 --- /dev/null +++ b/src/api/export/ibmExport.test.ts @@ -0,0 +1,11 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './ibmExport'; + +test('runExport API request for IBM export', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/gcp/costs/?', { + headers: { Accept: 'text/csv' }, + }); +}); diff --git a/src/api/export/ociExport.test.ts b/src/api/export/ociExport.test.ts new file mode 100644 index 000000000..bad9b8456 --- /dev/null +++ b/src/api/export/ociExport.test.ts @@ -0,0 +1,11 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './ociExport'; + +test('runExport API request for OCI export', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/oci/costs/?', { + headers: { Accept: 'text/csv' }, + }); +}); diff --git a/src/api/export/ocpCloudExport.test.ts b/src/api/export/ocpCloudExport.test.ts new file mode 100644 index 000000000..f4cd7918e --- /dev/null +++ b/src/api/export/ocpCloudExport.test.ts @@ -0,0 +1,11 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './ocpCloudExport'; + +test('runExport API request for all cloud filtered by OCP', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/openshift/infrastructures/all/costs/?', { + headers: { Accept: 'text/csv' }, + }); +}); diff --git a/src/api/export/ocpExport.test.ts b/src/api/export/ocpExport.test.ts new file mode 100644 index 000000000..b5e6b56f8 --- /dev/null +++ b/src/api/export/ocpExport.test.ts @@ -0,0 +1,11 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './ocpExport'; + +test('runExport API request for OCP export', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/openshift/costs/?', { + headers: { Accept: 'text/csv' }, + }); +}); diff --git a/src/api/export/rhelExport.test.ts b/src/api/export/rhelExport.test.ts new file mode 100644 index 000000000..f63ece2a3 --- /dev/null +++ b/src/api/export/rhelExport.test.ts @@ -0,0 +1,11 @@ +import { axiosInstance } from 'api'; +import { ReportType } from 'api/reports/report'; + +import { runExport } from './rhelExport'; + +test('runExport API request for RHEL export', () => { + runExport(ReportType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('reports/openshift/costs/?', { + headers: { Accept: 'text/csv' }, + }); +}); diff --git a/src/api/settings.test.ts b/src/api/settings.test.ts index a42289645..0352496ba 100644 --- a/src/api/settings.test.ts +++ b/src/api/settings.test.ts @@ -1,33 +1,13 @@ import { axiosInstance } from 'api'; -import { fetchSettings, SettingsType } from './settings'; +import { fetchSettings, SettingsType, updateSettings } from './settings'; -test('api get cost category keys', () => { +test('fetchSettings API request for cost categories', () => { fetchSettings(SettingsType.costCategories, ''); expect(axiosInstance.get).toBeCalledWith('settings/aws_category_keys/'); }); -test('api get platform projects', () => { - fetchSettings(SettingsType.platformProjects, ''); - expect(axiosInstance.get).toBeCalledWith('settings/cost-groups/'); -}); - -test('api get child tag mappings', () => { - fetchSettings(SettingsType.tagsMappingsChild, ''); - expect(axiosInstance.get).toBeCalledWith('settings/tags/mappings/child'); -}); - -test('api get parent tag mappings', () => { - fetchSettings(SettingsType.tagsMappingsParent, ''); - expect(axiosInstance.get).toBeCalledWith('settings/tags/mappings/parent'); -}); - -test('api get tag mappings', () => { - fetchSettings(SettingsType.tagsMappings, ''); - expect(axiosInstance.get).toBeCalledWith('settings/tags/mappings'); -}); - -test('api get tags', () => { - fetchSettings(SettingsType.tags, ''); - expect(axiosInstance.get).toBeCalledWith('settings/tags'); +test('updateSettings API request to enable cost categories', () => { + updateSettings(SettingsType.costCategoriesEnable, { ids: ['test'] }); + expect(axiosInstance.put).toBeCalledWith('settings/aws_category_keys/enable/', { ids: ['test'] }); }); From 88733c02435215803eeda9038d71aa96640f71b9 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Fri, 12 Apr 2024 23:02:07 -0400 Subject: [PATCH 22/33] Added more API tests --- src/api/export/awsExport.test.ts | 2 +- src/api/export/awsOcpExport.test.ts | 2 +- src/api/export/azureExport.test.ts | 2 +- src/api/export/azureOcpExport.test.ts | 2 +- src/api/export/exportUtils.test.ts | 82 ++++++++++++++++++++-- src/api/export/gcpExport.test.ts | 2 +- src/api/export/gcpOcpExport.test.ts | 2 +- src/api/export/ibmExport.test.ts | 2 +- src/api/export/ociExport.test.ts | 2 +- src/api/export/ocpExport.test.ts | 2 +- src/api/export/rhelExport.test.ts | 2 +- src/api/forecasts/awsForcast.test.ts | 9 +++ src/api/forecasts/awsOcpForcast.test.ts | 9 +++ src/api/forecasts/azureForcast.test.ts | 9 +++ src/api/forecasts/azureOcpForcast.test.ts | 9 +++ src/api/forecasts/forecastUtils.test.ts | 81 +++++++++++++++++++++ src/api/forecasts/gcpForcast.test.ts | 9 +++ src/api/forecasts/gcpOcpForcast.test.ts | 9 +++ src/api/forecasts/ociForcast.test.ts | 9 +++ src/api/forecasts/ocpCloudForcast.test.ts | 9 +++ src/api/forecasts/ocpForcast.test.ts | 9 +++ src/api/forecasts/rhelForcast.test.ts | 9 +++ src/api/reports/reportUtils.test.ts | 81 +++++++++++++++++++++ src/api/reports/rhelReports.test.ts | 2 +- src/api/resources/awsOcpResource.test.ts | 9 +++ src/api/resources/awsOcpResource.ts | 4 +- src/api/resources/awsResource.test.ts | 9 +++ src/api/resources/awsResource.ts | 4 +- src/api/resources/azureOcpResource.test.ts | 9 +++ src/api/resources/azureResource.test.ts | 9 +++ src/api/resources/gcpOcpResource.test.ts | 9 +++ src/api/resources/gcpResource.test.ts | 9 +++ src/api/resources/ibmResource.test.ts | 9 +++ src/api/resources/ociResource.test.ts | 9 +++ src/api/resources/ocpResource.test.ts | 9 +++ src/api/resources/resourceUtils.test.ts | 74 +++++++++++++++++++ src/api/resources/rhelResource.test.ts | 9 +++ src/api/tags/awsOcpTags.test.ts | 9 +++ src/api/tags/awsTags.test.ts | 2 +- src/api/tags/azureOcpTags.test.ts | 9 +++ src/api/tags/azureTags.test.ts | 2 +- src/api/tags/gcpOcpTags.test.ts | 2 +- src/api/tags/gcpTags.test.ts | 2 +- src/api/tags/ibmTags.test.ts | 2 +- src/api/tags/ociTags.test.ts | 2 +- src/api/tags/ocpCloudTags.test.ts | 9 +++ src/api/tags/ocpTags.test.ts | 2 +- src/api/tags/rhelTags.test.ts | 9 +++ src/api/tags/tagUtils.test.ts | 81 +++++++++++++++++++++ 49 files changed, 631 insertions(+), 28 deletions(-) create mode 100644 src/api/forecasts/awsForcast.test.ts create mode 100644 src/api/forecasts/awsOcpForcast.test.ts create mode 100644 src/api/forecasts/azureForcast.test.ts create mode 100644 src/api/forecasts/azureOcpForcast.test.ts create mode 100644 src/api/forecasts/forecastUtils.test.ts create mode 100644 src/api/forecasts/gcpForcast.test.ts create mode 100644 src/api/forecasts/gcpOcpForcast.test.ts create mode 100644 src/api/forecasts/ociForcast.test.ts create mode 100644 src/api/forecasts/ocpCloudForcast.test.ts create mode 100644 src/api/forecasts/ocpForcast.test.ts create mode 100644 src/api/forecasts/rhelForcast.test.ts create mode 100644 src/api/reports/reportUtils.test.ts create mode 100644 src/api/resources/awsOcpResource.test.ts create mode 100644 src/api/resources/awsResource.test.ts create mode 100644 src/api/resources/azureOcpResource.test.ts create mode 100644 src/api/resources/azureResource.test.ts create mode 100644 src/api/resources/gcpOcpResource.test.ts create mode 100644 src/api/resources/gcpResource.test.ts create mode 100644 src/api/resources/ibmResource.test.ts create mode 100644 src/api/resources/ociResource.test.ts create mode 100644 src/api/resources/ocpResource.test.ts create mode 100644 src/api/resources/resourceUtils.test.ts create mode 100644 src/api/resources/rhelResource.test.ts create mode 100644 src/api/tags/awsOcpTags.test.ts create mode 100644 src/api/tags/azureOcpTags.test.ts create mode 100644 src/api/tags/ocpCloudTags.test.ts create mode 100644 src/api/tags/rhelTags.test.ts create mode 100644 src/api/tags/tagUtils.test.ts diff --git a/src/api/export/awsExport.test.ts b/src/api/export/awsExport.test.ts index fd0549dba..473f49bbc 100644 --- a/src/api/export/awsExport.test.ts +++ b/src/api/export/awsExport.test.ts @@ -3,7 +3,7 @@ import { ReportType } from 'api/reports/report'; import { runExport } from './awsExport'; -test('runExport API request for AWS export', () => { +test('runExport API request for AWS', () => { runExport(ReportType.cost, ''); expect(axiosInstance.get).toBeCalledWith('reports/aws/costs/?', { headers: { Accept: 'text/csv' } }); }); diff --git a/src/api/export/awsOcpExport.test.ts b/src/api/export/awsOcpExport.test.ts index a21c5c0ab..3bd147a34 100644 --- a/src/api/export/awsOcpExport.test.ts +++ b/src/api/export/awsOcpExport.test.ts @@ -3,7 +3,7 @@ import { ReportType } from 'api/reports/report'; import { runExport } from './awsOcpExport'; -test('runExport API request for OCP on AWS export', () => { +test('runExport API request for OCP on AWS', () => { runExport(ReportType.cost, ''); expect(axiosInstance.get).toBeCalledWith('reports/openshift/infrastructures/aws/costs/?', { headers: { Accept: 'text/csv' }, diff --git a/src/api/export/azureExport.test.ts b/src/api/export/azureExport.test.ts index 6210fb9bc..952d6f86f 100644 --- a/src/api/export/azureExport.test.ts +++ b/src/api/export/azureExport.test.ts @@ -3,7 +3,7 @@ import { ReportType } from 'api/reports/report'; import { runExport } from './azureExport'; -test('runExport API request for Azure export', () => { +test('runExport API request for Azure', () => { runExport(ReportType.cost, ''); expect(axiosInstance.get).toBeCalledWith('reports/azure/costs/?', { headers: { Accept: 'text/csv' }, diff --git a/src/api/export/azureOcpExport.test.ts b/src/api/export/azureOcpExport.test.ts index 7af4ed963..ba6ad4481 100644 --- a/src/api/export/azureOcpExport.test.ts +++ b/src/api/export/azureOcpExport.test.ts @@ -3,7 +3,7 @@ import { ReportType } from 'api/reports/report'; import { runExport } from './azureOcpExport'; -test('runExport API request for OCP on Azure export', () => { +test('runExport API request for OCP on Azure', () => { runExport(ReportType.cost, ''); expect(axiosInstance.get).toBeCalledWith('reports/openshift/infrastructures/azure/costs/?', { headers: { Accept: 'text/csv' }, diff --git a/src/api/export/exportUtils.test.ts b/src/api/export/exportUtils.test.ts index 16093a0a3..9a10f6ee0 100644 --- a/src/api/export/exportUtils.test.ts +++ b/src/api/export/exportUtils.test.ts @@ -1,11 +1,81 @@ import { waitFor } from '@testing-library/react'; -import { ReportPathsType, ReportType } from 'api/reports/report'; +import { ReportPathsType } from 'api/reports/report'; -import * as exportUtils from './exportUtils'; +import * as awsExport from './awsExport'; +import * as awsOcpExport from './awsOcpExport'; +import * as azureExport from './azureExport'; +import * as azureOcpExport from './azureOcpExport'; +import * as gcpExport from './gcpExport'; +import * as gcpOcpExport from './gcpOcpExport'; +import * as ibmExport from './ibmExport'; +import * as ociExport from './ociExport'; +import * as ocpCloudExport from './ocpCloudExport'; +import * as ocpExport from './ocpExport'; +import * as rhelExport from './rhelExport'; -jest.spyOn(exportUtils, 'runExport'); +jest.spyOn(awsExport, 'runExport'); +jest.spyOn(awsOcpExport, 'runExport'); +jest.spyOn(azureExport, 'runExport'); +jest.spyOn(azureOcpExport, 'runExport'); +jest.spyOn(gcpExport, 'runExport'); +jest.spyOn(gcpOcpExport, 'runExport'); +jest.spyOn(ibmExport, 'runExport'); +jest.spyOn(ociExport, 'runExport'); +jest.spyOn(ocpCloudExport, 'runExport'); +jest.spyOn(ocpExport, 'runExport'); +jest.spyOn(rhelExport, 'runExport'); -test('runExport API request', async () => { - exportUtils.runExport(ReportPathsType.ocp, ReportType.cost, ''); - await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); +test('runExport API request for AWS', async () => { + awsExport.runExport(ReportPathsType.aws, ''); + await waitFor(() => expect(awsExport.runExport).toHaveBeenCalled()); +}); + +test('runExport API request for OCP on AWS', async () => { + awsOcpExport.runExport(ReportPathsType.awsOcp, ''); + await waitFor(() => expect(awsOcpExport.runExport).toHaveBeenCalled()); +}); + +test('runExport API request for Azure', async () => { + azureExport.runExport(ReportPathsType.azure, ''); + await waitFor(() => expect(azureExport.runExport).toHaveBeenCalled()); +}); + +test('runExport API request for OCP on Azure', async () => { + azureOcpExport.runExport(ReportPathsType.azureOcp, ''); + await waitFor(() => expect(azureOcpExport.runExport).toHaveBeenCalled()); +}); + +test('runExport API request for GCP', async () => { + gcpExport.runExport(ReportPathsType.gcp, ''); + await waitFor(() => expect(gcpExport.runExport).toHaveBeenCalled()); +}); + +test('runExport API request for OCP on GCP', async () => { + gcpOcpExport.runExport(ReportPathsType.gcpOcp, ''); + await waitFor(() => expect(gcpOcpExport.runExport).toHaveBeenCalled()); +}); + +test('runExport API request for IBM', async () => { + ibmExport.runExport(ReportPathsType.ibm, ''); + await waitFor(() => expect(ibmExport.runExport).toHaveBeenCalled()); +}); + +test('runExport API request for OCI', async () => { + ociExport.runExport(ReportPathsType.oci, ''); + await waitFor(() => expect(ociExport.runExport).toHaveBeenCalled()); +}); + +test('runExport API request for all cloud filtered by OCP', async () => { + ocpCloudExport.runExport(ReportPathsType.ocpCloud, ''); + await waitFor(() => expect(ocpCloudExport.runExport).toHaveBeenCalled()); +}); + +test('runExport API request for OCP', async () => { + ocpExport.runExport(ReportPathsType.ocp, ''); + await waitFor(() => expect(ocpExport.runExport).toHaveBeenCalled()); +}); + +test('runExport API request for RHEL', async () => { + rhelExport.runExport(ReportPathsType.rhel, ''); + await waitFor(() => expect(rhelExport.runExport).toHaveBeenCalled()); }); diff --git a/src/api/export/gcpExport.test.ts b/src/api/export/gcpExport.test.ts index 26da4bf11..9119adefd 100644 --- a/src/api/export/gcpExport.test.ts +++ b/src/api/export/gcpExport.test.ts @@ -3,7 +3,7 @@ import { ReportType } from 'api/reports/report'; import { runExport } from './gcpExport'; -test('runExport API request for GCP export', () => { +test('runExport API request for GCP', () => { runExport(ReportType.cost, ''); expect(axiosInstance.get).toBeCalledWith('reports/gcp/costs/?', { headers: { Accept: 'text/csv' }, diff --git a/src/api/export/gcpOcpExport.test.ts b/src/api/export/gcpOcpExport.test.ts index e368275a6..e836067a6 100644 --- a/src/api/export/gcpOcpExport.test.ts +++ b/src/api/export/gcpOcpExport.test.ts @@ -3,7 +3,7 @@ import { ReportType } from 'api/reports/report'; import { runExport } from './gcpOcpExport'; -test('runExport API request for GCP on OCP export', () => { +test('runExport API request for GCP on OCP', () => { runExport(ReportType.cost, ''); expect(axiosInstance.get).toBeCalledWith('reports/openshift/infrastructures/gcp/costs/?', { headers: { Accept: 'text/csv' }, diff --git a/src/api/export/ibmExport.test.ts b/src/api/export/ibmExport.test.ts index 9b041b679..0085fab05 100644 --- a/src/api/export/ibmExport.test.ts +++ b/src/api/export/ibmExport.test.ts @@ -3,7 +3,7 @@ import { ReportType } from 'api/reports/report'; import { runExport } from './ibmExport'; -test('runExport API request for IBM export', () => { +test('runExport API request for IBM', () => { runExport(ReportType.cost, ''); expect(axiosInstance.get).toBeCalledWith('reports/gcp/costs/?', { headers: { Accept: 'text/csv' }, diff --git a/src/api/export/ociExport.test.ts b/src/api/export/ociExport.test.ts index bad9b8456..eccd7ba64 100644 --- a/src/api/export/ociExport.test.ts +++ b/src/api/export/ociExport.test.ts @@ -3,7 +3,7 @@ import { ReportType } from 'api/reports/report'; import { runExport } from './ociExport'; -test('runExport API request for OCI export', () => { +test('runExport API request for OCI', () => { runExport(ReportType.cost, ''); expect(axiosInstance.get).toBeCalledWith('reports/oci/costs/?', { headers: { Accept: 'text/csv' }, diff --git a/src/api/export/ocpExport.test.ts b/src/api/export/ocpExport.test.ts index b5e6b56f8..23c82074d 100644 --- a/src/api/export/ocpExport.test.ts +++ b/src/api/export/ocpExport.test.ts @@ -3,7 +3,7 @@ import { ReportType } from 'api/reports/report'; import { runExport } from './ocpExport'; -test('runExport API request for OCP export', () => { +test('runExport API request for OCP', () => { runExport(ReportType.cost, ''); expect(axiosInstance.get).toBeCalledWith('reports/openshift/costs/?', { headers: { Accept: 'text/csv' }, diff --git a/src/api/export/rhelExport.test.ts b/src/api/export/rhelExport.test.ts index f63ece2a3..94a281a74 100644 --- a/src/api/export/rhelExport.test.ts +++ b/src/api/export/rhelExport.test.ts @@ -3,7 +3,7 @@ import { ReportType } from 'api/reports/report'; import { runExport } from './rhelExport'; -test('runExport API request for RHEL export', () => { +test('runExport API request for RHEL', () => { runExport(ReportType.cost, ''); expect(axiosInstance.get).toBeCalledWith('reports/openshift/costs/?', { headers: { Accept: 'text/csv' }, diff --git a/src/api/forecasts/awsForcast.test.ts b/src/api/forecasts/awsForcast.test.ts new file mode 100644 index 000000000..f1731b763 --- /dev/null +++ b/src/api/forecasts/awsForcast.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runForecast } from './awsForecast'; +import { ForecastType } from './forecast'; + +test('runForecast API request for AWS', () => { + runForecast(ForecastType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('forecasts/aws/costs/?'); +}); diff --git a/src/api/forecasts/awsOcpForcast.test.ts b/src/api/forecasts/awsOcpForcast.test.ts new file mode 100644 index 000000000..6844fa585 --- /dev/null +++ b/src/api/forecasts/awsOcpForcast.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runForecast } from './awsOcpForecast'; +import { ForecastType } from './forecast'; + +test('runForecast API request for OCP on AWS', () => { + runForecast(ForecastType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('forecasts/openshift/infrastructures/aws/costs/?'); +}); diff --git a/src/api/forecasts/azureForcast.test.ts b/src/api/forecasts/azureForcast.test.ts new file mode 100644 index 000000000..449ef7fe6 --- /dev/null +++ b/src/api/forecasts/azureForcast.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runForecast } from './azureForecast'; +import { ForecastType } from './forecast'; + +test('runForecast API request for Azure', () => { + runForecast(ForecastType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('forecasts/azure/costs/?'); +}); diff --git a/src/api/forecasts/azureOcpForcast.test.ts b/src/api/forecasts/azureOcpForcast.test.ts new file mode 100644 index 000000000..b49a8032e --- /dev/null +++ b/src/api/forecasts/azureOcpForcast.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runForecast } from './azureOcpForecast'; +import { ForecastType } from './forecast'; + +test('runForecast API request for OCP on Azure', () => { + runForecast(ForecastType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('forecasts/openshift/infrastructures/azure/costs/?'); +}); diff --git a/src/api/forecasts/forecastUtils.test.ts b/src/api/forecasts/forecastUtils.test.ts new file mode 100644 index 000000000..072421995 --- /dev/null +++ b/src/api/forecasts/forecastUtils.test.ts @@ -0,0 +1,81 @@ +import { waitFor } from '@testing-library/react'; + +import * as awsForecast from './awsForecast'; +import * as awsOcpForecast from './awsOcpForecast'; +import * as azureForecast from './azureForecast'; +import * as azureOcpForecast from './azureOcpForecast'; +import { ForecastType } from './forecast'; +import * as gcpForecast from './gcpForecast'; +import * as gcpOcpForecast from './gcpOcpForecast'; +import * as ibmForecast from './ibmForecast'; +import * as ociForecast from './ociForecast'; +import * as ocpCloudForecast from './ocpCloudForecast'; +import * as ocpForecast from './ocpForecast'; +import * as rhelForecast from './rhelForecast'; + +jest.spyOn(awsForecast, 'runForecast'); +jest.spyOn(awsOcpForecast, 'runForecast'); +jest.spyOn(azureForecast, 'runForecast'); +jest.spyOn(azureOcpForecast, 'runForecast'); +jest.spyOn(gcpForecast, 'runForecast'); +jest.spyOn(gcpOcpForecast, 'runForecast'); +jest.spyOn(ibmForecast, 'runForecast'); +jest.spyOn(ociForecast, 'runForecast'); +jest.spyOn(ocpCloudForecast, 'runForecast'); +jest.spyOn(ocpForecast, 'runForecast'); +jest.spyOn(rhelForecast, 'runForecast'); + +test('runForecast API request for AWS', async () => { + awsForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(awsForecast.runForecast).toHaveBeenCalled()); +}); + +test('runForecast API request for OCP on AWS', async () => { + awsOcpForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(awsOcpForecast.runForecast).toHaveBeenCalled()); +}); + +test('runForecast API request for Azure', async () => { + azureForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(azureForecast.runForecast).toHaveBeenCalled()); +}); + +test('runForecast API request for OCP on Azure', async () => { + azureOcpForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(azureOcpForecast.runForecast).toHaveBeenCalled()); +}); + +test('runForecast API request for GCP', async () => { + gcpForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(gcpForecast.runForecast).toHaveBeenCalled()); +}); + +test('runForecast API request for OCP on GCP', async () => { + gcpOcpForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(gcpOcpForecast.runForecast).toHaveBeenCalled()); +}); + +test('runForecast API request for IBM', async () => { + ibmForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(ibmForecast.runForecast).toHaveBeenCalled()); +}); + +test('runForecast API request for OCI', async () => { + ociForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(ociForecast.runForecast).toHaveBeenCalled()); +}); + +test('runForecast API request for all cloud filtered by OCP', async () => { + ocpCloudForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(ocpCloudForecast.runForecast).toHaveBeenCalled()); +}); + +test('runForecast API request for OCP', async () => { + ocpForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(ocpForecast.runForecast).toHaveBeenCalled()); +}); + +test('runForecast API request for RHEL', async () => { + rhelForecast.runForecast(ForecastType.cost, ''); + await waitFor(() => expect(rhelForecast.runForecast).toHaveBeenCalled()); +}); diff --git a/src/api/forecasts/gcpForcast.test.ts b/src/api/forecasts/gcpForcast.test.ts new file mode 100644 index 000000000..e7acd9d2d --- /dev/null +++ b/src/api/forecasts/gcpForcast.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { ForecastType } from './forecast'; +import { runForecast } from './gcpForecast'; + +test('runForecast API request for GCP', () => { + runForecast(ForecastType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('forecasts/gcp/costs/?'); +}); diff --git a/src/api/forecasts/gcpOcpForcast.test.ts b/src/api/forecasts/gcpOcpForcast.test.ts new file mode 100644 index 000000000..6a04faec8 --- /dev/null +++ b/src/api/forecasts/gcpOcpForcast.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { ForecastType } from './forecast'; +import { runForecast } from './gcpOcpForecast'; + +test('runForecast API request for OCP on GCP', () => { + runForecast(ForecastType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('forecasts/openshift/infrastructures/gcp/costs/?'); +}); diff --git a/src/api/forecasts/ociForcast.test.ts b/src/api/forecasts/ociForcast.test.ts new file mode 100644 index 000000000..c29a27701 --- /dev/null +++ b/src/api/forecasts/ociForcast.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { ForecastType } from './forecast'; +import { runForecast } from './ociForecast'; + +test('runForecast API request for OCI', () => { + runForecast(ForecastType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('forecasts/oci/costs/?'); +}); diff --git a/src/api/forecasts/ocpCloudForcast.test.ts b/src/api/forecasts/ocpCloudForcast.test.ts new file mode 100644 index 000000000..14b915919 --- /dev/null +++ b/src/api/forecasts/ocpCloudForcast.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { ForecastType } from './forecast'; +import { runForecast } from './ocpCloudForecast'; + +test('runForecast API request for all cloud filtered by OCP', () => { + runForecast(ForecastType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('forecasts/openshift/infrastructures/all/costs/?'); +}); diff --git a/src/api/forecasts/ocpForcast.test.ts b/src/api/forecasts/ocpForcast.test.ts new file mode 100644 index 000000000..da9344709 --- /dev/null +++ b/src/api/forecasts/ocpForcast.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { ForecastType } from './forecast'; +import { runForecast } from './ocpForecast'; + +test('runForecast API request for OCP', () => { + runForecast(ForecastType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('forecasts/openshift/costs/?'); +}); diff --git a/src/api/forecasts/rhelForcast.test.ts b/src/api/forecasts/rhelForcast.test.ts new file mode 100644 index 000000000..338bf5587 --- /dev/null +++ b/src/api/forecasts/rhelForcast.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { ForecastType } from './forecast'; +import { runForecast } from './rhelForecast'; + +test('runForecast API request for RHEL', () => { + runForecast(ForecastType.cost, ''); + expect(axiosInstance.get).toBeCalledWith('forecasts/openshift/costs/?'); +}); diff --git a/src/api/reports/reportUtils.test.ts b/src/api/reports/reportUtils.test.ts new file mode 100644 index 000000000..e2c5502f1 --- /dev/null +++ b/src/api/reports/reportUtils.test.ts @@ -0,0 +1,81 @@ +import { waitFor } from '@testing-library/react'; + +import * as awsOcpReports from './awsOcpReports'; +import * as awsReports from './awsReports'; +import * as azureOcpReports from './azureOcpReports'; +import * as azureReports from './azureReports'; +import * as gcpOcpReports from './gcpOcpReports'; +import * as gcpReports from './gcpReports'; +import * as ibmReports from './ibmReports'; +import * as ociReports from './ociReports'; +import * as ocpCloudReports from './ocpCloudReports'; +import * as ocpReports from './ocpReports'; +import { ReportType } from './report'; +import * as rhelReports from './rhelReports'; + +jest.spyOn(awsReports, 'runReport'); +jest.spyOn(awsOcpReports, 'runReport'); +jest.spyOn(azureReports, 'runReport'); +jest.spyOn(azureOcpReports, 'runReport'); +jest.spyOn(gcpReports, 'runReport'); +jest.spyOn(gcpOcpReports, 'runReport'); +jest.spyOn(ibmReports, 'runReport'); +jest.spyOn(ociReports, 'runReport'); +jest.spyOn(ocpCloudReports, 'runReport'); +jest.spyOn(ocpReports, 'runReport'); +jest.spyOn(rhelReports, 'runReport'); + +test('runReport API request for AWS', async () => { + awsReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(awsReports.runReport).toHaveBeenCalled()); +}); + +test('runReport API request for OCP on AWS', async () => { + awsOcpReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(awsOcpReports.runReport).toHaveBeenCalled()); +}); + +test('runReport API request for Azure', async () => { + azureReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(azureReports.runReport).toHaveBeenCalled()); +}); + +test('runReport API request for OCP on Azure', async () => { + azureOcpReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(azureOcpReports.runReport).toHaveBeenCalled()); +}); + +test('runReport API request for GCP', async () => { + gcpReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(gcpReports.runReport).toHaveBeenCalled()); +}); + +test('runReport API request for OCP on GCP', async () => { + gcpOcpReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(gcpOcpReports.runReport).toHaveBeenCalled()); +}); + +test('runReport API request for IBM', async () => { + ibmReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(ibmReports.runReport).toHaveBeenCalled()); +}); + +test('runReport API request for OCI', async () => { + ociReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(ociReports.runReport).toHaveBeenCalled()); +}); + +test('runReport API request for all cloud filtered by OCP', async () => { + ocpCloudReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(ocpCloudReports.runReport).toHaveBeenCalled()); +}); + +test('runReport API request for OCP', async () => { + ocpReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(ocpReports.runReport).toHaveBeenCalled()); +}); + +test('runReport API request for RHEL', async () => { + rhelReports.runReport(ReportType.cost, ''); + await waitFor(() => expect(rhelReports.runReport).toHaveBeenCalled()); +}); diff --git a/src/api/reports/rhelReports.test.ts b/src/api/reports/rhelReports.test.ts index e3ca9c29f..20184efb1 100644 --- a/src/api/reports/rhelReports.test.ts +++ b/src/api/reports/rhelReports.test.ts @@ -1,7 +1,7 @@ import { axiosInstance } from 'api'; import { ReportType } from 'api/reports/report'; -import { runReport } from './ocpReports'; +import { runReport } from './rhelReports'; test('api run reports calls axios get', () => { const query = 'filter[resolution]=daily'; diff --git a/src/api/resources/awsOcpResource.test.ts b/src/api/resources/awsOcpResource.test.ts new file mode 100644 index 000000000..512d1c169 --- /dev/null +++ b/src/api/resources/awsOcpResource.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runResource } from './awsOcpResource'; +import { ResourceType } from './resource'; + +test('runExport API request for OCP on AWS', () => { + runResource(ResourceType.account, ''); + expect(axiosInstance.get).toBeCalledWith('resource-types/aws-accounts/'); +}); diff --git a/src/api/resources/awsOcpResource.ts b/src/api/resources/awsOcpResource.ts index 695da2c94..b955c84fe 100644 --- a/src/api/resources/awsOcpResource.ts +++ b/src/api/resources/awsOcpResource.ts @@ -5,7 +5,7 @@ import { ResourceType } from './resource'; export const ResourceTypePaths: Partial> = { [ResourceType.account]: 'resource-types/aws-accounts/', - [ResourceType.aws_category]: 'resource-types/aws-categories', + [ResourceType.aws_category]: 'resource-types/aws-categories/', [ResourceType.region]: 'resource-types/aws-regions/', [ResourceType.service]: 'resource-types/aws-services/', }; @@ -13,5 +13,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; const queryString = query ? `?${query}` : ''; - return axiosInstance.get(`${path}/${queryString}`); + return axiosInstance.get(`${path}${queryString}`); } diff --git a/src/api/resources/awsResource.test.ts b/src/api/resources/awsResource.test.ts new file mode 100644 index 000000000..f220460cd --- /dev/null +++ b/src/api/resources/awsResource.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runResource } from './awsResource'; +import { ResourceType } from './resource'; + +test('runExport API request for AWS', () => { + runResource(ResourceType.account, ''); + expect(axiosInstance.get).toBeCalledWith('resource-types/aws-accounts/'); +}); diff --git a/src/api/resources/awsResource.ts b/src/api/resources/awsResource.ts index 695da2c94..b955c84fe 100644 --- a/src/api/resources/awsResource.ts +++ b/src/api/resources/awsResource.ts @@ -5,7 +5,7 @@ import { ResourceType } from './resource'; export const ResourceTypePaths: Partial> = { [ResourceType.account]: 'resource-types/aws-accounts/', - [ResourceType.aws_category]: 'resource-types/aws-categories', + [ResourceType.aws_category]: 'resource-types/aws-categories/', [ResourceType.region]: 'resource-types/aws-regions/', [ResourceType.service]: 'resource-types/aws-services/', }; @@ -13,5 +13,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; const queryString = query ? `?${query}` : ''; - return axiosInstance.get(`${path}/${queryString}`); + return axiosInstance.get(`${path}${queryString}`); } diff --git a/src/api/resources/azureOcpResource.test.ts b/src/api/resources/azureOcpResource.test.ts new file mode 100644 index 000000000..93b56b9ed --- /dev/null +++ b/src/api/resources/azureOcpResource.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runResource } from './azureOcpResource'; +import { ResourceType } from './resource'; + +test('runExport API request for OCP on Azure', () => { + runResource(ResourceType.subscriptionGuid, ''); + expect(axiosInstance.get).toBeCalledWith('resource-types/azure-subscription-guids/?'); +}); diff --git a/src/api/resources/azureResource.test.ts b/src/api/resources/azureResource.test.ts new file mode 100644 index 000000000..e42664a63 --- /dev/null +++ b/src/api/resources/azureResource.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runResource } from './azureResource'; +import { ResourceType } from './resource'; + +test('runExport API request for Azure', () => { + runResource(ResourceType.subscriptionGuid, ''); + expect(axiosInstance.get).toBeCalledWith('resource-types/azure-subscription-guids/?'); +}); diff --git a/src/api/resources/gcpOcpResource.test.ts b/src/api/resources/gcpOcpResource.test.ts new file mode 100644 index 000000000..816efdc61 --- /dev/null +++ b/src/api/resources/gcpOcpResource.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runResource } from './gcpOcpResource'; +import { ResourceType } from './resource'; + +test('runExport API request for OCP on GCP', () => { + runResource(ResourceType.account, ''); + expect(axiosInstance.get).toBeCalledWith('resource-types/gcp-accounts/?'); +}); diff --git a/src/api/resources/gcpResource.test.ts b/src/api/resources/gcpResource.test.ts new file mode 100644 index 000000000..61cf4b3b8 --- /dev/null +++ b/src/api/resources/gcpResource.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runResource } from './gcpResource'; +import { ResourceType } from './resource'; + +test('runExport API request for GCP', () => { + runResource(ResourceType.account, ''); + expect(axiosInstance.get).toBeCalledWith('resource-types/gcp-accounts/?'); +}); diff --git a/src/api/resources/ibmResource.test.ts b/src/api/resources/ibmResource.test.ts new file mode 100644 index 000000000..1749196ee --- /dev/null +++ b/src/api/resources/ibmResource.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runResource } from './ibmResource'; +import { ResourceType } from './resource'; + +test('runExport API request for IBM', () => { + runResource(ResourceType.account, ''); + expect(axiosInstance.get).toBeCalledWith('resource-types/gcp-accounts/?'); +}); diff --git a/src/api/resources/ociResource.test.ts b/src/api/resources/ociResource.test.ts new file mode 100644 index 000000000..bfd589073 --- /dev/null +++ b/src/api/resources/ociResource.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runResource } from './ociResource'; +import { ResourceType } from './resource'; + +test('runExport API request for OCI', () => { + runResource(ResourceType.payerTenantId, ''); + expect(axiosInstance.get).toBeCalledWith('resource-types/oci-payer-tenant-ids/?'); +}); diff --git a/src/api/resources/ocpResource.test.ts b/src/api/resources/ocpResource.test.ts new file mode 100644 index 000000000..f06b089bb --- /dev/null +++ b/src/api/resources/ocpResource.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runResource } from './ocpResource'; +import { ResourceType } from './resource'; + +test('runExport API request for OCP', () => { + runResource(ResourceType.project, ''); + expect(axiosInstance.get).toBeCalledWith('resource-types/openshift-projects/?'); +}); diff --git a/src/api/resources/resourceUtils.test.ts b/src/api/resources/resourceUtils.test.ts new file mode 100644 index 000000000..5f1b5ee4e --- /dev/null +++ b/src/api/resources/resourceUtils.test.ts @@ -0,0 +1,74 @@ +import { waitFor } from '@testing-library/react'; + +import * as awsOcpResource from './awsOcpResource'; +import * as awsResource from './awsResource'; +import * as azureOcpResource from './azureOcpResource'; +import * as azureResource from './azureResource'; +import * as gcpOcpResource from './gcpOcpResource'; +import * as gcpResource from './gcpResource'; +import * as ibmResource from './ibmResource'; +import * as ociResource from './ociResource'; +import * as ocpResource from './ocpResource'; +import { ResourceType } from './resource'; +import * as rhelResource from './rhelResource'; + +jest.spyOn(awsResource, 'runResource'); +jest.spyOn(awsOcpResource, 'runResource'); +jest.spyOn(azureResource, 'runResource'); +jest.spyOn(azureOcpResource, 'runResource'); +jest.spyOn(gcpResource, 'runResource'); +jest.spyOn(gcpOcpResource, 'runResource'); +jest.spyOn(ibmResource, 'runResource'); +jest.spyOn(ociResource, 'runResource'); +jest.spyOn(ocpResource, 'runResource'); +jest.spyOn(rhelResource, 'runResource'); + +test('runResource API request for AWS', async () => { + awsResource.runResource(ResourceType.account, ''); + await waitFor(() => expect(awsResource.runResource).toHaveBeenCalled()); +}); + +test('runResource API request for OCP on AWS', async () => { + awsOcpResource.runResource(ResourceType.account, ''); + await waitFor(() => expect(awsOcpResource.runResource).toHaveBeenCalled()); +}); + +test('runResource API request for Azure', async () => { + azureResource.runResource(ResourceType.payerTenantId, ''); + await waitFor(() => expect(azureResource.runResource).toHaveBeenCalled()); +}); + +test('runResource API request for OCP on Azure', async () => { + azureOcpResource.runResource(ResourceType.payerTenantId, ''); + await waitFor(() => expect(azureOcpResource.runResource).toHaveBeenCalled()); +}); + +test('runResource API request for GCP', async () => { + gcpResource.runResource(ResourceType.account, ''); + await waitFor(() => expect(gcpResource.runResource).toHaveBeenCalled()); +}); + +test('runResource API request for OCP on GCP', async () => { + gcpOcpResource.runResource(ResourceType.project, ''); + await waitFor(() => expect(gcpOcpResource.runResource).toHaveBeenCalled()); +}); + +test('runResource API request for IBM', async () => { + ibmResource.runResource(ResourceType.project, ''); + await waitFor(() => expect(ibmResource.runResource).toHaveBeenCalled()); +}); + +test('runResource API request for OCI', async () => { + ociResource.runResource(ResourceType.payerTenantId, ''); + await waitFor(() => expect(ociResource.runResource).toHaveBeenCalled()); +}); + +test('runResource API request for OCP', async () => { + ocpResource.runResource(ResourceType.project, ''); + await waitFor(() => expect(ocpResource.runResource).toHaveBeenCalled()); +}); + +test('runResource API request for RHEL', async () => { + rhelResource.runResource(ResourceType.project, ''); + await waitFor(() => expect(rhelResource.runResource).toHaveBeenCalled()); +}); diff --git a/src/api/resources/rhelResource.test.ts b/src/api/resources/rhelResource.test.ts new file mode 100644 index 000000000..ab71fe660 --- /dev/null +++ b/src/api/resources/rhelResource.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { ResourceType } from './resource'; +import { runResource } from './rhelResource'; + +test('runExport API request for RHEL', () => { + runResource(ResourceType.project, ''); + expect(axiosInstance.get).toBeCalledWith('resource-types/openshift-projects/?'); +}); diff --git a/src/api/tags/awsOcpTags.test.ts b/src/api/tags/awsOcpTags.test.ts new file mode 100644 index 000000000..b957bf566 --- /dev/null +++ b/src/api/tags/awsOcpTags.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runTag } from './awsOcpTags'; +import { TagType } from './tag'; + +test('runForecast API request for OCP on AWS', () => { + runTag(TagType.tag, ''); + expect(axiosInstance.get).toBeCalledWith('tags/openshift/infrastructures/aws/?'); +}); diff --git a/src/api/tags/awsTags.test.ts b/src/api/tags/awsTags.test.ts index f122a96df..0feb3a1a5 100644 --- a/src/api/tags/awsTags.test.ts +++ b/src/api/tags/awsTags.test.ts @@ -3,7 +3,7 @@ import { axiosInstance } from 'api'; import { runTag } from './awsTags'; import { TagType } from './tag'; -test('api run reports calls axios get', () => { +test('runTag API request for AWS', () => { const query = 'filter[resolution]=daily'; runTag(TagType.tag, query); expect(axiosInstance.get).toBeCalledWith(`tags/aws/?${query}`); diff --git a/src/api/tags/azureOcpTags.test.ts b/src/api/tags/azureOcpTags.test.ts new file mode 100644 index 000000000..a06f8cf1f --- /dev/null +++ b/src/api/tags/azureOcpTags.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runTag } from './azureOcpTags'; +import { TagType } from './tag'; + +test('runForecast API request for OCP on Azure', () => { + runTag(TagType.tag, ''); + expect(axiosInstance.get).toBeCalledWith('tags/openshift/infrastructures/azure/?'); +}); diff --git a/src/api/tags/azureTags.test.ts b/src/api/tags/azureTags.test.ts index 6378fddc5..efdc70d4c 100644 --- a/src/api/tags/azureTags.test.ts +++ b/src/api/tags/azureTags.test.ts @@ -3,7 +3,7 @@ import { axiosInstance } from 'api'; import { runTag } from './azureTags'; import { TagType } from './tag'; -test('api run reports calls axios get', () => { +test('runTag API request for Azure', () => { const query = 'filter[resolution]=daily'; runTag(TagType.tag, query); expect(axiosInstance.get).toBeCalledWith(`tags/azure/?${query}`); diff --git a/src/api/tags/gcpOcpTags.test.ts b/src/api/tags/gcpOcpTags.test.ts index 0dacade3a..62b0c999c 100644 --- a/src/api/tags/gcpOcpTags.test.ts +++ b/src/api/tags/gcpOcpTags.test.ts @@ -3,7 +3,7 @@ import { axiosInstance } from 'api'; import { runTag } from './gcpOcpTags'; import { TagType } from './tag'; -test('api run reports calls axios get', () => { +test('runTag API request for OCP on GCP', () => { const query = 'filter[resolution]=daily'; runTag(TagType.tag, query); expect(axiosInstance.get).toBeCalledWith(`tags/openshift/infrastructures/gcp/?${query}`); diff --git a/src/api/tags/gcpTags.test.ts b/src/api/tags/gcpTags.test.ts index d2430dfac..ecabb89c5 100644 --- a/src/api/tags/gcpTags.test.ts +++ b/src/api/tags/gcpTags.test.ts @@ -3,7 +3,7 @@ import { axiosInstance } from 'api'; import { runTag } from './gcpTags'; import { TagType } from './tag'; -test('api run reports calls axios get', () => { +test('runTag API request for GCP', () => { const query = 'filter[resolution]=daily'; runTag(TagType.tag, query); expect(axiosInstance.get).toBeCalledWith(`tags/gcp/?${query}`); diff --git a/src/api/tags/ibmTags.test.ts b/src/api/tags/ibmTags.test.ts index 9b4e4424b..187f7294a 100644 --- a/src/api/tags/ibmTags.test.ts +++ b/src/api/tags/ibmTags.test.ts @@ -3,7 +3,7 @@ import { axiosInstance } from 'api'; import { runTag } from './ibmTags'; import { TagType } from './tag'; -test('api run reports calls axios get', () => { +test('runTag API request for IBM', () => { const query = 'filter[resolution]=daily'; runTag(TagType.tag, query); expect(axiosInstance.get).toBeCalledWith(`tags/gcp/?${query}`); // Todo: Update when APIs are available diff --git a/src/api/tags/ociTags.test.ts b/src/api/tags/ociTags.test.ts index 4177a12d1..a54113305 100644 --- a/src/api/tags/ociTags.test.ts +++ b/src/api/tags/ociTags.test.ts @@ -3,7 +3,7 @@ import { axiosInstance } from 'api'; import { runTag } from './ociTags'; import { TagType } from './tag'; -test('api run reports calls axios get', () => { +test('runTag API request for OCI', () => { const query = 'filter[resolution]=daily'; runTag(TagType.tag, query); expect(axiosInstance.get).toBeCalledWith(`tags/oci/?${query}`); diff --git a/src/api/tags/ocpCloudTags.test.ts b/src/api/tags/ocpCloudTags.test.ts new file mode 100644 index 000000000..8500454ed --- /dev/null +++ b/src/api/tags/ocpCloudTags.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runTag } from './ocpCloudTags'; +import { TagType } from './tag'; + +test('runForecast API request for all cloud filtered by OCP', () => { + runTag(TagType.tag, ''); + expect(axiosInstance.get).toBeCalledWith('tags/openshift/infrastructures/all/?'); +}); diff --git a/src/api/tags/ocpTags.test.ts b/src/api/tags/ocpTags.test.ts index 54888a13e..6bc8ad71f 100644 --- a/src/api/tags/ocpTags.test.ts +++ b/src/api/tags/ocpTags.test.ts @@ -3,7 +3,7 @@ import { axiosInstance } from 'api'; import { runTag } from './ocpTags'; import { TagType } from './tag'; -test('api run reports calls axios get', () => { +test('runTag API request for OCP', () => { const query = 'filter[resolution]=daily'; runTag(TagType.tag, query); expect(axiosInstance.get).toBeCalledWith(`tags/openshift/?${query}`); diff --git a/src/api/tags/rhelTags.test.ts b/src/api/tags/rhelTags.test.ts new file mode 100644 index 000000000..438165c30 --- /dev/null +++ b/src/api/tags/rhelTags.test.ts @@ -0,0 +1,9 @@ +import { axiosInstance } from 'api'; + +import { runTag } from './rhelTags'; +import { TagType } from './tag'; + +test('runTag API request for RHEL', () => { + runTag(TagType.tag, ''); + expect(axiosInstance.get).toBeCalledWith('tags/openshift/?'); +}); diff --git a/src/api/tags/tagUtils.test.ts b/src/api/tags/tagUtils.test.ts new file mode 100644 index 000000000..9b095a136 --- /dev/null +++ b/src/api/tags/tagUtils.test.ts @@ -0,0 +1,81 @@ +import { waitFor } from '@testing-library/react'; + +import * as awsOcpTags from './awsOcpTags'; +import * as awsTags from './awsTags'; +import * as azureOcpTags from './azureOcpTags'; +import * as azureTags from './azureTags'; +import * as gcpOcpTags from './gcpOcpTags'; +import * as gcpTags from './gcpTags'; +import * as ibmTags from './ibmTags'; +import * as ociTags from './ociTags'; +import * as ocpCloudTags from './ocpCloudTags'; +import * as ocpTags from './ocpTags'; +import * as rhelTags from './rhelTags'; +import { TagType } from './tag'; + +jest.spyOn(awsTags, 'runTag'); +jest.spyOn(awsOcpTags, 'runTag'); +jest.spyOn(azureTags, 'runTag'); +jest.spyOn(azureOcpTags, 'runTag'); +jest.spyOn(gcpTags, 'runTag'); +jest.spyOn(gcpOcpTags, 'runTag'); +jest.spyOn(ibmTags, 'runTag'); +jest.spyOn(ociTags, 'runTag'); +jest.spyOn(ocpCloudTags, 'runTag'); +jest.spyOn(ocpTags, 'runTag'); +jest.spyOn(rhelTags, 'runTag'); + +test('runTag API request for AWS', async () => { + awsTags.runTag(TagType.tag, ''); + await waitFor(() => expect(awsTags.runTag).toHaveBeenCalled()); +}); + +test('runTag API request for OCP on AWS', async () => { + awsOcpTags.runTag(TagType.tag, ''); + await waitFor(() => expect(awsOcpTags.runTag).toHaveBeenCalled()); +}); + +test('runTag API request for Azure', async () => { + azureTags.runTag(TagType.tag, ''); + await waitFor(() => expect(azureTags.runTag).toHaveBeenCalled()); +}); + +test('runTag API request for OCP on Azure', async () => { + azureOcpTags.runTag(TagType.tag, ''); + await waitFor(() => expect(azureOcpTags.runTag).toHaveBeenCalled()); +}); + +test('runTag API request for GCP', async () => { + gcpTags.runTag(TagType.tag, ''); + await waitFor(() => expect(gcpTags.runTag).toHaveBeenCalled()); +}); + +test('runTag API request for OCP on GCP', async () => { + gcpOcpTags.runTag(TagType.tag, ''); + await waitFor(() => expect(gcpOcpTags.runTag).toHaveBeenCalled()); +}); + +test('runTag API request for IBM', async () => { + ibmTags.runTag(TagType.tag, ''); + await waitFor(() => expect(ibmTags.runTag).toHaveBeenCalled()); +}); + +test('runTag API request for OCI', async () => { + ociTags.runTag(TagType.tag, ''); + await waitFor(() => expect(ociTags.runTag).toHaveBeenCalled()); +}); + +test('runTag API request for all cloud filtered by OCP', async () => { + ocpCloudTags.runTag(TagType.tag, ''); + await waitFor(() => expect(ocpCloudTags.runTag).toHaveBeenCalled()); +}); + +test('runTag API request for OCP', async () => { + ocpTags.runTag(TagType.tag, ''); + await waitFor(() => expect(ocpTags.runTag).toHaveBeenCalled()); +}); + +test('runTag API request for RHEL', async () => { + rhelTags.runTag(TagType.tag, ''); + await waitFor(() => expect(rhelTags.runTag).toHaveBeenCalled()); +}); From fd44773a906b3590542d2036c1093b4a04d77d7b Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Fri, 12 Apr 2024 23:39:29 -0400 Subject: [PATCH 23/33] Refactor utils tests --- src/api/export/exportUtils.test.ts | 70 +++++++++---------------- src/api/forecasts/forecastUtils.test.ts | 70 +++++++++---------------- src/api/reports/reportUtils.test.ts | 70 +++++++++---------------- src/api/resources/resourceUtils.test.ts | 65 +++++++++-------------- src/api/tags/tagUtils.test.ts | 70 +++++++++---------------- 5 files changed, 124 insertions(+), 221 deletions(-) diff --git a/src/api/export/exportUtils.test.ts b/src/api/export/exportUtils.test.ts index 9a10f6ee0..4b9f41109 100644 --- a/src/api/export/exportUtils.test.ts +++ b/src/api/export/exportUtils.test.ts @@ -1,81 +1,61 @@ import { waitFor } from '@testing-library/react'; -import { ReportPathsType } from 'api/reports/report'; +import { ReportPathsType, ReportType } from 'api/reports/report'; -import * as awsExport from './awsExport'; -import * as awsOcpExport from './awsOcpExport'; -import * as azureExport from './azureExport'; -import * as azureOcpExport from './azureOcpExport'; -import * as gcpExport from './gcpExport'; -import * as gcpOcpExport from './gcpOcpExport'; -import * as ibmExport from './ibmExport'; -import * as ociExport from './ociExport'; -import * as ocpCloudExport from './ocpCloudExport'; -import * as ocpExport from './ocpExport'; -import * as rhelExport from './rhelExport'; +import * as exportUtils from './exportUtils'; -jest.spyOn(awsExport, 'runExport'); -jest.spyOn(awsOcpExport, 'runExport'); -jest.spyOn(azureExport, 'runExport'); -jest.spyOn(azureOcpExport, 'runExport'); -jest.spyOn(gcpExport, 'runExport'); -jest.spyOn(gcpOcpExport, 'runExport'); -jest.spyOn(ibmExport, 'runExport'); -jest.spyOn(ociExport, 'runExport'); -jest.spyOn(ocpCloudExport, 'runExport'); -jest.spyOn(ocpExport, 'runExport'); -jest.spyOn(rhelExport, 'runExport'); +jest.spyOn(exportUtils, 'runExport'); test('runExport API request for AWS', async () => { - awsExport.runExport(ReportPathsType.aws, ''); - await waitFor(() => expect(awsExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.aws, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); test('runExport API request for OCP on AWS', async () => { - awsOcpExport.runExport(ReportPathsType.awsOcp, ''); - await waitFor(() => expect(awsOcpExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.awsOcp, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); test('runExport API request for Azure', async () => { - azureExport.runExport(ReportPathsType.azure, ''); - await waitFor(() => expect(azureExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.azure, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); test('runExport API request for OCP on Azure', async () => { - azureOcpExport.runExport(ReportPathsType.azureOcp, ''); - await waitFor(() => expect(azureOcpExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.azureOcp, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); test('runExport API request for GCP', async () => { - gcpExport.runExport(ReportPathsType.gcp, ''); - await waitFor(() => expect(gcpExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.gcp, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); test('runExport API request for OCP on GCP', async () => { - gcpOcpExport.runExport(ReportPathsType.gcpOcp, ''); - await waitFor(() => expect(gcpOcpExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.gcpOcp, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); test('runExport API request for IBM', async () => { - ibmExport.runExport(ReportPathsType.ibm, ''); - await waitFor(() => expect(ibmExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.ibm, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); test('runExport API request for OCI', async () => { - ociExport.runExport(ReportPathsType.oci, ''); - await waitFor(() => expect(ociExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.oci, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); test('runExport API request for all cloud filtered by OCP', async () => { - ocpCloudExport.runExport(ReportPathsType.ocpCloud, ''); - await waitFor(() => expect(ocpCloudExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.ocpCloud, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); test('runExport API request for OCP', async () => { - ocpExport.runExport(ReportPathsType.ocp, ''); - await waitFor(() => expect(ocpExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.ocp, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); test('runExport API request for RHEL', async () => { - rhelExport.runExport(ReportPathsType.rhel, ''); - await waitFor(() => expect(rhelExport.runExport).toHaveBeenCalled()); + exportUtils.runExport(ReportPathsType.rhel, ReportType.cost, ''); + await waitFor(() => expect(exportUtils.runExport).toHaveBeenCalled()); }); diff --git a/src/api/forecasts/forecastUtils.test.ts b/src/api/forecasts/forecastUtils.test.ts index 072421995..c11694fc4 100644 --- a/src/api/forecasts/forecastUtils.test.ts +++ b/src/api/forecasts/forecastUtils.test.ts @@ -1,81 +1,61 @@ import { waitFor } from '@testing-library/react'; -import * as awsForecast from './awsForecast'; -import * as awsOcpForecast from './awsOcpForecast'; -import * as azureForecast from './azureForecast'; -import * as azureOcpForecast from './azureOcpForecast'; -import { ForecastType } from './forecast'; -import * as gcpForecast from './gcpForecast'; -import * as gcpOcpForecast from './gcpOcpForecast'; -import * as ibmForecast from './ibmForecast'; -import * as ociForecast from './ociForecast'; -import * as ocpCloudForecast from './ocpCloudForecast'; -import * as ocpForecast from './ocpForecast'; -import * as rhelForecast from './rhelForecast'; +import { ForecastPathsType, ForecastType } from './forecast'; +import * as forecastUtils from './forecastUtils'; -jest.spyOn(awsForecast, 'runForecast'); -jest.spyOn(awsOcpForecast, 'runForecast'); -jest.spyOn(azureForecast, 'runForecast'); -jest.spyOn(azureOcpForecast, 'runForecast'); -jest.spyOn(gcpForecast, 'runForecast'); -jest.spyOn(gcpOcpForecast, 'runForecast'); -jest.spyOn(ibmForecast, 'runForecast'); -jest.spyOn(ociForecast, 'runForecast'); -jest.spyOn(ocpCloudForecast, 'runForecast'); -jest.spyOn(ocpForecast, 'runForecast'); -jest.spyOn(rhelForecast, 'runForecast'); +jest.spyOn(forecastUtils, 'runForecast'); test('runForecast API request for AWS', async () => { - awsForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(awsForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.aws, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); test('runForecast API request for OCP on AWS', async () => { - awsOcpForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(awsOcpForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.awsOcp, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); test('runForecast API request for Azure', async () => { - azureForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(azureForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.azure, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); test('runForecast API request for OCP on Azure', async () => { - azureOcpForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(azureOcpForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.azureOcp, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); test('runForecast API request for GCP', async () => { - gcpForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(gcpForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.gcp, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); test('runForecast API request for OCP on GCP', async () => { - gcpOcpForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(gcpOcpForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.gcpOcp, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); test('runForecast API request for IBM', async () => { - ibmForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(ibmForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.ibm, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); test('runForecast API request for OCI', async () => { - ociForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(ociForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.oci, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); test('runForecast API request for all cloud filtered by OCP', async () => { - ocpCloudForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(ocpCloudForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.ocpCloud, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); test('runForecast API request for OCP', async () => { - ocpForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(ocpForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.ocp, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); test('runForecast API request for RHEL', async () => { - rhelForecast.runForecast(ForecastType.cost, ''); - await waitFor(() => expect(rhelForecast.runForecast).toHaveBeenCalled()); + forecastUtils.runForecast(ForecastPathsType.rhel, ForecastType.cost, ''); + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); }); diff --git a/src/api/reports/reportUtils.test.ts b/src/api/reports/reportUtils.test.ts index e2c5502f1..75b2423df 100644 --- a/src/api/reports/reportUtils.test.ts +++ b/src/api/reports/reportUtils.test.ts @@ -1,81 +1,61 @@ import { waitFor } from '@testing-library/react'; -import * as awsOcpReports from './awsOcpReports'; -import * as awsReports from './awsReports'; -import * as azureOcpReports from './azureOcpReports'; -import * as azureReports from './azureReports'; -import * as gcpOcpReports from './gcpOcpReports'; -import * as gcpReports from './gcpReports'; -import * as ibmReports from './ibmReports'; -import * as ociReports from './ociReports'; -import * as ocpCloudReports from './ocpCloudReports'; -import * as ocpReports from './ocpReports'; -import { ReportType } from './report'; -import * as rhelReports from './rhelReports'; +import { ReportPathsType, ReportType } from './report'; +import * as reportUtils from './reportUtils'; -jest.spyOn(awsReports, 'runReport'); -jest.spyOn(awsOcpReports, 'runReport'); -jest.spyOn(azureReports, 'runReport'); -jest.spyOn(azureOcpReports, 'runReport'); -jest.spyOn(gcpReports, 'runReport'); -jest.spyOn(gcpOcpReports, 'runReport'); -jest.spyOn(ibmReports, 'runReport'); -jest.spyOn(ociReports, 'runReport'); -jest.spyOn(ocpCloudReports, 'runReport'); -jest.spyOn(ocpReports, 'runReport'); -jest.spyOn(rhelReports, 'runReport'); +jest.spyOn(reportUtils, 'runReport'); test('runReport API request for AWS', async () => { - awsReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(awsReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.aws, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); test('runReport API request for OCP on AWS', async () => { - awsOcpReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(awsOcpReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.awsOcp, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); test('runReport API request for Azure', async () => { - azureReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(azureReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.azure, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); test('runReport API request for OCP on Azure', async () => { - azureOcpReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(azureOcpReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.azureOcp, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); test('runReport API request for GCP', async () => { - gcpReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(gcpReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.gcp, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); test('runReport API request for OCP on GCP', async () => { - gcpOcpReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(gcpOcpReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.gcpOcp, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); test('runReport API request for IBM', async () => { - ibmReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(ibmReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.ibm, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); test('runReport API request for OCI', async () => { - ociReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(ociReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.oci, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); test('runReport API request for all cloud filtered by OCP', async () => { - ocpCloudReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(ocpCloudReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.ocpCloud, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); test('runReport API request for OCP', async () => { - ocpReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(ocpReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.ocp, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); test('runReport API request for RHEL', async () => { - rhelReports.runReport(ReportType.cost, ''); - await waitFor(() => expect(rhelReports.runReport).toHaveBeenCalled()); + reportUtils.runReport(ReportPathsType.rhel, ReportType.cost, ''); + await waitFor(() => expect(reportUtils.runReport).toHaveBeenCalled()); }); diff --git a/src/api/resources/resourceUtils.test.ts b/src/api/resources/resourceUtils.test.ts index 5f1b5ee4e..9a4fdd5f8 100644 --- a/src/api/resources/resourceUtils.test.ts +++ b/src/api/resources/resourceUtils.test.ts @@ -1,74 +1,57 @@ import { waitFor } from '@testing-library/react'; +import { ReportType } from 'api/reports/report'; -import * as awsOcpResource from './awsOcpResource'; -import * as awsResource from './awsResource'; -import * as azureOcpResource from './azureOcpResource'; -import * as azureResource from './azureResource'; -import * as gcpOcpResource from './gcpOcpResource'; -import * as gcpResource from './gcpResource'; -import * as ibmResource from './ibmResource'; -import * as ociResource from './ociResource'; -import * as ocpResource from './ocpResource'; -import { ResourceType } from './resource'; -import * as rhelResource from './rhelResource'; +import { ResourcePathsType, ResourceType } from './resource'; +import * as resourceUtils from './resourceUtils'; -jest.spyOn(awsResource, 'runResource'); -jest.spyOn(awsOcpResource, 'runResource'); -jest.spyOn(azureResource, 'runResource'); -jest.spyOn(azureOcpResource, 'runResource'); -jest.spyOn(gcpResource, 'runResource'); -jest.spyOn(gcpOcpResource, 'runResource'); -jest.spyOn(ibmResource, 'runResource'); -jest.spyOn(ociResource, 'runResource'); -jest.spyOn(ocpResource, 'runResource'); -jest.spyOn(rhelResource, 'runResource'); +jest.spyOn(resourceUtils, 'runResource'); test('runResource API request for AWS', async () => { - awsResource.runResource(ResourceType.account, ''); - await waitFor(() => expect(awsResource.runResource).toHaveBeenCalled()); + resourceUtils.runResource(ResourcePathsType.aws, ResourceType.account, ReportType.cost); + await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); test('runResource API request for OCP on AWS', async () => { - awsOcpResource.runResource(ResourceType.account, ''); - await waitFor(() => expect(awsOcpResource.runResource).toHaveBeenCalled()); + resourceUtils.runResource(ResourcePathsType.awsOcp, ResourceType.account, ''); + await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); test('runResource API request for Azure', async () => { - azureResource.runResource(ResourceType.payerTenantId, ''); - await waitFor(() => expect(azureResource.runResource).toHaveBeenCalled()); + resourceUtils.runResource(ResourcePathsType.azure, ResourceType.payerTenantId, ''); + await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); test('runResource API request for OCP on Azure', async () => { - azureOcpResource.runResource(ResourceType.payerTenantId, ''); - await waitFor(() => expect(azureOcpResource.runResource).toHaveBeenCalled()); + resourceUtils.runResource(ResourcePathsType.azureOcp, ResourceType.payerTenantId, ''); + await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); test('runResource API request for GCP', async () => { - gcpResource.runResource(ResourceType.account, ''); - await waitFor(() => expect(gcpResource.runResource).toHaveBeenCalled()); + resourceUtils.runResource(ResourcePathsType.gcp, ResourceType.account, ''); + await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); test('runResource API request for OCP on GCP', async () => { - gcpOcpResource.runResource(ResourceType.project, ''); - await waitFor(() => expect(gcpOcpResource.runResource).toHaveBeenCalled()); + resourceUtils.runResource(ResourcePathsType.gcpOcp, ResourceType.project, ''); + await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); test('runResource API request for IBM', async () => { - ibmResource.runResource(ResourceType.project, ''); - await waitFor(() => expect(ibmResource.runResource).toHaveBeenCalled()); + resourceUtils.runResource(ResourcePathsType.ibm, ResourceType.project, ''); + await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); test('runResource API request for OCI', async () => { - ociResource.runResource(ResourceType.payerTenantId, ''); - await waitFor(() => expect(ociResource.runResource).toHaveBeenCalled()); + resourceUtils.runResource(ResourcePathsType.oci, ResourceType.payerTenantId, ''); + await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); test('runResource API request for OCP', async () => { - ocpResource.runResource(ResourceType.project, ''); - await waitFor(() => expect(ocpResource.runResource).toHaveBeenCalled()); + resourceUtils.runResource(ResourcePathsType.ocp, ResourceType.project, ''); + await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); test('runResource API request for RHEL', async () => { - rhelResource.runResource(ResourceType.project, ''); - await waitFor(() => expect(rhelResource.runResource).toHaveBeenCalled()); + resourceUtils.runResource(ResourcePathsType.rhel, ResourceType.project, ''); + await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); diff --git a/src/api/tags/tagUtils.test.ts b/src/api/tags/tagUtils.test.ts index 9b095a136..2246c5a50 100644 --- a/src/api/tags/tagUtils.test.ts +++ b/src/api/tags/tagUtils.test.ts @@ -1,81 +1,61 @@ import { waitFor } from '@testing-library/react'; -import * as awsOcpTags from './awsOcpTags'; -import * as awsTags from './awsTags'; -import * as azureOcpTags from './azureOcpTags'; -import * as azureTags from './azureTags'; -import * as gcpOcpTags from './gcpOcpTags'; -import * as gcpTags from './gcpTags'; -import * as ibmTags from './ibmTags'; -import * as ociTags from './ociTags'; -import * as ocpCloudTags from './ocpCloudTags'; -import * as ocpTags from './ocpTags'; -import * as rhelTags from './rhelTags'; -import { TagType } from './tag'; +import { TagPathsType, TagType } from './tag'; +import * as tagUtils from './tagUtils'; -jest.spyOn(awsTags, 'runTag'); -jest.spyOn(awsOcpTags, 'runTag'); -jest.spyOn(azureTags, 'runTag'); -jest.spyOn(azureOcpTags, 'runTag'); -jest.spyOn(gcpTags, 'runTag'); -jest.spyOn(gcpOcpTags, 'runTag'); -jest.spyOn(ibmTags, 'runTag'); -jest.spyOn(ociTags, 'runTag'); -jest.spyOn(ocpCloudTags, 'runTag'); -jest.spyOn(ocpTags, 'runTag'); -jest.spyOn(rhelTags, 'runTag'); +jest.spyOn(tagUtils, 'runTag'); test('runTag API request for AWS', async () => { - awsTags.runTag(TagType.tag, ''); - await waitFor(() => expect(awsTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.aws, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); test('runTag API request for OCP on AWS', async () => { - awsOcpTags.runTag(TagType.tag, ''); - await waitFor(() => expect(awsOcpTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.awsOcp, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); test('runTag API request for Azure', async () => { - azureTags.runTag(TagType.tag, ''); - await waitFor(() => expect(azureTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.azure, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); test('runTag API request for OCP on Azure', async () => { - azureOcpTags.runTag(TagType.tag, ''); - await waitFor(() => expect(azureOcpTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.azureOcp, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); test('runTag API request for GCP', async () => { - gcpTags.runTag(TagType.tag, ''); - await waitFor(() => expect(gcpTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.gcp, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); test('runTag API request for OCP on GCP', async () => { - gcpOcpTags.runTag(TagType.tag, ''); - await waitFor(() => expect(gcpOcpTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.gcpOcp, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); test('runTag API request for IBM', async () => { - ibmTags.runTag(TagType.tag, ''); - await waitFor(() => expect(ibmTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.ibm, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); test('runTag API request for OCI', async () => { - ociTags.runTag(TagType.tag, ''); - await waitFor(() => expect(ociTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.oci, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); test('runTag API request for all cloud filtered by OCP', async () => { - ocpCloudTags.runTag(TagType.tag, ''); - await waitFor(() => expect(ocpCloudTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.ocpCloud, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); test('runTag API request for OCP', async () => { - ocpTags.runTag(TagType.tag, ''); - await waitFor(() => expect(ocpTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.ocp, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); test('runTag API request for RHEL', async () => { - rhelTags.runTag(TagType.tag, ''); - await waitFor(() => expect(rhelTags.runTag).toHaveBeenCalled()); + tagUtils.runTag(TagPathsType.rhel, TagType.tag, ''); + await waitFor(() => expect(tagUtils.runTag).toHaveBeenCalled()); }); From fb6b51800d85a25f1571986b37529834a5edbb21 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Fri, 12 Apr 2024 23:57:43 -0400 Subject: [PATCH 24/33] Add isResourceTypeValid tests --- src/api/resources/resourceUtils.test.ts | 40 +++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/api/resources/resourceUtils.test.ts b/src/api/resources/resourceUtils.test.ts index 9a4fdd5f8..5606b703e 100644 --- a/src/api/resources/resourceUtils.test.ts +++ b/src/api/resources/resourceUtils.test.ts @@ -1,13 +1,13 @@ import { waitFor } from '@testing-library/react'; -import { ReportType } from 'api/reports/report'; import { ResourcePathsType, ResourceType } from './resource'; import * as resourceUtils from './resourceUtils'; +jest.spyOn(resourceUtils, 'isResourceTypeValid'); jest.spyOn(resourceUtils, 'runResource'); test('runResource API request for AWS', async () => { - resourceUtils.runResource(ResourcePathsType.aws, ResourceType.account, ReportType.cost); + resourceUtils.runResource(ResourcePathsType.aws, ResourceType.account, ''); await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); @@ -55,3 +55,39 @@ test('runResource API request for RHEL', async () => { resourceUtils.runResource(ResourcePathsType.rhel, ResourceType.project, ''); await waitFor(() => expect(resourceUtils.runResource).toHaveBeenCalled()); }); + +test('isResourceTypeValid for AWS', async () => { + expect(resourceUtils.isResourceTypeValid(ResourcePathsType.aws, ResourceType.account)).toEqual(true); +}); + +test('isResourceTypeValid for OCP on AWS', async () => { + expect(resourceUtils.isResourceTypeValid(ResourcePathsType.awsOcp, ResourceType.account)).toEqual(true); +}); + +test('isResourceTypeValid for Azure', async () => { + expect(resourceUtils.isResourceTypeValid(ResourcePathsType.azure, ResourceType.payerTenantId)).toEqual(true); +}); + +test('isResourceTypeValid for OCP on Azure', async () => { + expect(resourceUtils.isResourceTypeValid(ResourcePathsType.azureOcp, ResourceType.payerTenantId)).toEqual(true); +}); + +test('isResourceTypeValid for GCP', async () => { + expect(resourceUtils.isResourceTypeValid(ResourcePathsType.gcp, ResourceType.account)).toEqual(true); +}); + +test('isResourceTypeValid for OCP on GCP', async () => { + expect(resourceUtils.isResourceTypeValid(ResourcePathsType.gcpOcp, ResourceType.account)).toEqual(true); +}); + +test('isResourceTypeValid for IBM', async () => { + expect(resourceUtils.isResourceTypeValid(ResourcePathsType.ibm, ResourceType.project)).toEqual(true); +}); + +test('isResourceTypeValid for OCI', async () => { + expect(resourceUtils.isResourceTypeValid(ResourcePathsType.oci, ResourceType.payerTenantId)).toEqual(true); +}); + +test('isResourceTypeValid for OCP', async () => { + expect(resourceUtils.isResourceTypeValid(ResourcePathsType.ocp, ResourceType.project)).toEqual(true); +}); From 2d6cc5537f2c3afe5832186fdd33a3ccbeed60b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:57:16 +0000 Subject: [PATCH 25/33] (chore): Bump eslint-plugin-simple-import-sort Bumps the lint-dependencies group with 1 update: [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort). Updates `eslint-plugin-simple-import-sort` from 12.0.0 to 12.1.0 - [Changelog](https://github.com/lydell/eslint-plugin-simple-import-sort/blob/main/CHANGELOG.md) - [Commits](https://github.com/lydell/eslint-plugin-simple-import-sort/compare/v12.0.0...v12.1.0) --- updated-dependencies: - dependency-name: eslint-plugin-simple-import-sort dependency-type: direct:development update-type: version-update:semver-minor dependency-group: lint-dependencies ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04cca90d5..7c8f5e83d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,7 +70,7 @@ "eslint-plugin-patternfly-react": "^5.2.1", "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-react": "^7.34.1", - "eslint-plugin-simple-import-sort": "^12.0.0", + "eslint-plugin-simple-import-sort": "^12.1.0", "eslint-plugin-sort-keys-fix": "^1.1.2", "eslint-plugin-testing-library": "^6.2.0", "git-revision-webpack-plugin": "^5.0.0", @@ -9850,9 +9850,9 @@ } }, "node_modules/eslint-plugin-simple-import-sort": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-12.0.0.tgz", - "integrity": "sha512-8o0dVEdAkYap0Cn5kNeklaKcT1nUsa3LITWEuFk3nJifOoD+5JQGoyDUW2W/iPWwBsNBJpyJS9y4je/BgxLcyQ==", + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-12.1.0.tgz", + "integrity": "sha512-Y2fqAfC11TcG/WP3TrI1Gi3p3nc8XJyEOJYHyEPEGI/UAgNx6akxxlX74p7SbAQdLcgASKhj8M0GKvH3vq/+ig==", "dev": true, "peerDependencies": { "eslint": ">=5.0.0" diff --git a/package.json b/package.json index 19e6f84a8..959c8223e 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ "eslint-plugin-patternfly-react": "^5.2.1", "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-react": "^7.34.1", - "eslint-plugin-simple-import-sort": "^12.0.0", + "eslint-plugin-simple-import-sort": "^12.1.0", "eslint-plugin-sort-keys-fix": "^1.1.2", "eslint-plugin-testing-library": "^6.2.0", "git-revision-webpack-plugin": "^5.0.0", From 8a81fc30f0b56554a9f08a6d26a9a6bac9ce6a9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:58:37 +0000 Subject: [PATCH 26/33] (chore): Bump @testing-library/react in the test-dependencies group Bumps the test-dependencies group with 1 update: [@testing-library/react](https://github.com/testing-library/react-testing-library). Updates `@testing-library/react` from 14.3.0 to 15.0.2 - [Release notes](https://github.com/testing-library/react-testing-library/releases) - [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md) - [Commits](https://github.com/testing-library/react-testing-library/compare/v14.3.0...v15.0.2) --- updated-dependencies: - dependency-name: "@testing-library/react" dependency-type: direct:development update-type: version-update:semver-major dependency-group: test-dependencies ... Signed-off-by: dependabot[bot] --- package-lock.json | 119 +++++++++++++++++++++++++++++++++++++++++++--- package.json | 2 +- 2 files changed, 113 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04cca90d5..9e7a65076 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,7 @@ "@swc/core": "1.3.105", "@swc/jest": "^0.2.36", "@testing-library/jest-dom": "^6.4.2", - "@testing-library/react": "^14.3.0", + "@testing-library/react": "^15.0.2", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.12", "@types/qs": "^6.9.14", @@ -3432,6 +3432,7 @@ "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.4.tgz", "integrity": "sha512-FlS4ZWlp97iiNWig0Muq8p+3rVDjRiYE+YKGbAqXOu9nwJFFOdL00kFpz42M+4huzYi86vAK1sOOfyOG45muIQ==", "dev": true, + "peer": true, "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", @@ -3451,6 +3452,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -3466,6 +3468,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -3482,6 +3485,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -3493,13 +3497,15 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@testing-library/dom/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -3509,6 +3515,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -3635,23 +3642,121 @@ } }, "node_modules/@testing-library/react": { - "version": "14.3.0", - "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-14.3.0.tgz", - "integrity": "sha512-AYJGvNFMbCa5vt1UtDCa/dcaABrXq8gph6VN+cffIx0UeA0qiGqS+sT60+sb+Gjc8tGXdECWYQgaF0khf8b+Lg==", + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-15.0.2.tgz", + "integrity": "sha512-5mzIpuytB1ctpyywvyaY2TAAUQVCZIGqwiqFQf6u9lvj/SJQepGUzNV18Xpk+NLCaCE2j7CWrZE0tEf9xLZYiQ==", "dev": true, "dependencies": { "@babel/runtime": "^7.12.5", - "@testing-library/dom": "^9.0.0", + "@testing-library/dom": "^10.0.0", "@types/react-dom": "^18.0.0" }, "engines": { - "node": ">=14" + "node": ">=18" }, "peerDependencies": { "react": "^18.0.0", "react-dom": "^18.0.0" } }, + "node_modules/@testing-library/react/node_modules/@testing-library/dom": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.0.0.tgz", + "integrity": "sha512-PmJPnogldqoVFf+EwbHvbBJ98MmqASV8kLrBYgsDNxQcFMeIS7JFL48sfyXvuMtgmWO/wMhh25odr+8VhDmn4g==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.3.0", + "chalk": "^4.1.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@testing-library/react/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@testing-library/react/node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dev": true, + "dependencies": { + "dequal": "^2.0.3" + } + }, + "node_modules/@testing-library/react/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@testing-library/react/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@testing-library/react/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/@testing-library/react/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@testing-library/react/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@testing-library/user-event": { "version": "14.5.2", "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.5.2.tgz", diff --git a/package.json b/package.json index 19e6f84a8..d993a7509 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "@swc/core": "1.3.105", "@swc/jest": "^0.2.36", "@testing-library/jest-dom": "^6.4.2", - "@testing-library/react": "^14.3.0", + "@testing-library/react": "^15.0.2", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.12", "@types/qs": "^6.9.14", From cde9f91c92dc06ec0141b03ee0a2a5d38cecbbe6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:03:56 +0000 Subject: [PATCH 27/33] (chore): Bump the ci-dependencies group with 6 updates Bumps the ci-dependencies group with 6 updates: | Package | From | To | | --- | --- | --- | | [@redhat-cloud-services/frontend-components](https://github.com/RedHatInsights/frontend-components) | `4.2.5` | `4.2.6` | | [qs](https://github.com/ljharb/qs) | `6.12.0` | `6.12.1` | | [react-redux](https://github.com/reduxjs/react-redux) | `9.1.0` | `9.1.1` | | [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) | `18.2.24` | `18.2.25` | | [typescript](https://github.com/Microsoft/TypeScript) | `5.4.4` | `5.4.5` | | [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) | `4.10.1` | `4.10.2` | Updates `@redhat-cloud-services/frontend-components` from 4.2.5 to 4.2.6 - [Commits](https://github.com/RedHatInsights/frontend-components/commits) Updates `qs` from 6.12.0 to 6.12.1 - [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md) - [Commits](https://github.com/ljharb/qs/compare/v6.12.0...v6.12.1) Updates `react-redux` from 9.1.0 to 9.1.1 - [Release notes](https://github.com/reduxjs/react-redux/releases) - [Changelog](https://github.com/reduxjs/react-redux/blob/master/CHANGELOG.md) - [Commits](https://github.com/reduxjs/react-redux/compare/v9.1.0...v9.1.1) Updates `@types/react-dom` from 18.2.24 to 18.2.25 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-dom) Updates `typescript` from 5.4.4 to 5.4.5 - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml) - [Commits](https://github.com/Microsoft/TypeScript/compare/v5.4.4...v5.4.5) Updates `webpack-bundle-analyzer` from 4.10.1 to 4.10.2 - [Release notes](https://github.com/webpack-contrib/webpack-bundle-analyzer/releases) - [Changelog](https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/master/CHANGELOG.md) - [Commits](https://github.com/webpack-contrib/webpack-bundle-analyzer/compare/v4.10.1...v4.10.2) --- updated-dependencies: - dependency-name: "@redhat-cloud-services/frontend-components" dependency-type: direct:production update-type: version-update:semver-patch dependency-group: ci-dependencies - dependency-name: qs dependency-type: direct:production update-type: version-update:semver-patch dependency-group: ci-dependencies - dependency-name: react-redux dependency-type: direct:production update-type: version-update:semver-patch dependency-group: ci-dependencies - dependency-name: "@types/react-dom" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: ci-dependencies - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch dependency-group: ci-dependencies - dependency-name: webpack-bundle-analyzer dependency-type: direct:development update-type: version-update:semver-patch dependency-group: ci-dependencies ... Signed-off-by: dependabot[bot] --- package-lock.json | 49 +++++++++++++++++++++++------------------------ package.json | 12 ++++++------ 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04cca90d5..e58b38607 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@patternfly/react-icons": "5.2.0", "@patternfly/react-table": "5.2.0", "@patternfly/react-tokens": "5.2.0", - "@redhat-cloud-services/frontend-components": "^4.2.5", + "@redhat-cloud-services/frontend-components": "^4.2.6", "@redhat-cloud-services/frontend-components-notifications": "^4.1.0", "@redhat-cloud-services/frontend-components-translations": "^3.2.7", "@redhat-cloud-services/frontend-components-utilities": "^4.0.10", @@ -28,11 +28,11 @@ "date-fns": "^3.6.0", "js-file-download": "^0.4.12", "lodash": "^4.17.21", - "qs": "^6.12.0", + "qs": "^6.12.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-intl": "^6.6.5", - "react-redux": "^9.1.0", + "react-redux": "^9.1.1", "react-router-dom": "^6.22.3", "redux": "^5.0.1", "redux-thunk": "^3.1.0", @@ -55,7 +55,7 @@ "@types/jest": "^29.5.12", "@types/qs": "^6.9.14", "@types/react": "^18.2.75", - "@types/react-dom": "^18.2.24", + "@types/react-dom": "^18.2.25", "@types/react-redux": "^7.1.33", "@types/react-router-dom": "^5.3.3", "@typescript-eslint/eslint-plugin": "^7.6.0", @@ -86,8 +86,8 @@ "rimraf": "^5.0.5", "ts-jest": "^29.1.2", "ts-patch": "^3.1.2", - "typescript": "^5.4.4", - "webpack-bundle-analyzer": "^4.10.1" + "typescript": "^5.4.5", + "webpack-bundle-analyzer": "^4.10.2" }, "engines": { "node": ">=18.15.0", @@ -2472,9 +2472,9 @@ } }, "node_modules/@redhat-cloud-services/frontend-components": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/@redhat-cloud-services/frontend-components/-/frontend-components-4.2.5.tgz", - "integrity": "sha512-lTVew1R6LccTMqDoaevtk6WBbH0VoiNPspPMSuEYT+/JIQLjs5NgpBNWTGImyp/4/JFwMiQq0ewtimQLq0E3Ig==", + "version": "4.2.6", + "resolved": "https://registry.npmjs.org/@redhat-cloud-services/frontend-components/-/frontend-components-4.2.6.tgz", + "integrity": "sha512-ErM9sWQUQpKwdKBOQlDBFI6IHyi3mRzTZ3wYJ57pouTzQzOhPozsIpPsPgB2gN/88khenjFEy+7SYuIZDaH5TA==", "dependencies": { "@patternfly/react-component-groups": "^5.0.0", "@redhat-cloud-services/frontend-components-utilities": "^4.0.0", @@ -4101,9 +4101,9 @@ } }, "node_modules/@types/react-dom": { - "version": "18.2.24", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.24.tgz", - "integrity": "sha512-cN6upcKd8zkGy4HU9F1+/s98Hrp6D4MOcippK4PoE8OZRngohHZpbJn1GsaDLz87MqvHNoT13nHvNqM9ocRHZg==", + "version": "18.2.25", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.25.tgz", + "integrity": "sha512-o/V48vf4MQh7juIKZU2QGDfli6p1+OOi5oXx36Hffpc9adsHeXjVp8rHuPkjd8VT8sOJ2Zp05HR7CdpGTIUFUA==", "dev": true, "dependencies": { "@types/react": "*" @@ -17893,9 +17893,9 @@ ] }, "node_modules/qs": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.0.tgz", - "integrity": "sha512-trVZiI6RMOkO476zLGaBIzszOdFPnCCXHPG9kn0yuS1uz6xdVxPfZdB3vUig9pxPFDM9BRAgz/YUIVQ1/vuiUg==", + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.1.tgz", + "integrity": "sha512-zWmv4RSuB9r2mYQw3zxQuHWeU+42aKi1wWig/j4ele4ygELZ7PEO6MM7rim9oAQH2A5MWfsAVf/jPvTPgCbvUQ==", "dependencies": { "side-channel": "^1.0.6" }, @@ -18078,9 +18078,9 @@ } }, "node_modules/react-redux": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.0.tgz", - "integrity": "sha512-6qoDzIO+gbrza8h3hjMA9aq4nwVFCKFtY2iLxCtVT38Swyy2C/dJCGBXHeHLtx6qlg/8qzc2MrhOeduf5K32wQ==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.1.tgz", + "integrity": "sha512-5ynfGDzxxsoV73+4czQM56qF43vsmgJsO22rmAvU5tZT2z5Xow/A2uhhxwXuGTxgdReF3zcp7A80gma2onRs1A==", "dependencies": { "@types/use-sync-external-store": "^0.0.3", "use-sync-external-store": "^1.0.0" @@ -20569,9 +20569,9 @@ } }, "node_modules/typescript": { - "version": "5.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.4.tgz", - "integrity": "sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "devOptional": true, "bin": { "tsc": "bin/tsc", @@ -21574,9 +21574,9 @@ } }, "node_modules/webpack-bundle-analyzer": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.10.1.tgz", - "integrity": "sha512-s3P7pgexgT/HTUSYgxJyn28A+99mmLq4HsJepMPzu0R8ImJc52QNqaFYW1Z2z2uIb1/J3eYgaAWVpaC+v/1aAQ==", + "version": "4.10.2", + "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.10.2.tgz", + "integrity": "sha512-vJptkMm9pk5si4Bv922ZbKLV8UTT4zib4FPgXMhgzUny0bfDDkLXAVQs3ly3fS4/TN9ROFtb0NFrm04UXFE/Vw==", "dev": true, "dependencies": { "@discoveryjs/json-ext": "0.5.7", @@ -21587,7 +21587,6 @@ "escape-string-regexp": "^4.0.0", "gzip-size": "^6.0.0", "html-escaper": "^2.0.2", - "is-plain-object": "^5.0.0", "opener": "^1.5.2", "picocolors": "^1.0.0", "sirv": "^2.0.3", diff --git a/package.json b/package.json index 19e6f84a8..e3a863947 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@patternfly/react-icons": "5.2.0", "@patternfly/react-table": "5.2.0", "@patternfly/react-tokens": "5.2.0", - "@redhat-cloud-services/frontend-components": "^4.2.5", + "@redhat-cloud-services/frontend-components": "^4.2.6", "@redhat-cloud-services/frontend-components-notifications": "^4.1.0", "@redhat-cloud-services/frontend-components-translations": "^3.2.7", "@redhat-cloud-services/frontend-components-utilities": "^4.0.10", @@ -68,11 +68,11 @@ "date-fns": "^3.6.0", "js-file-download": "^0.4.12", "lodash": "^4.17.21", - "qs": "^6.12.0", + "qs": "^6.12.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-intl": "^6.6.5", - "react-redux": "^9.1.0", + "react-redux": "^9.1.1", "react-router-dom": "^6.22.3", "redux": "^5.0.1", "redux-thunk": "^3.1.0", @@ -95,7 +95,7 @@ "@types/jest": "^29.5.12", "@types/qs": "^6.9.14", "@types/react": "^18.2.75", - "@types/react-dom": "^18.2.24", + "@types/react-dom": "^18.2.25", "@types/react-redux": "^7.1.33", "@types/react-router-dom": "^5.3.3", "@typescript-eslint/eslint-plugin": "^7.6.0", @@ -126,8 +126,8 @@ "rimraf": "^5.0.5", "ts-jest": "^29.1.2", "ts-patch": "^3.1.2", - "typescript": "^5.4.4", - "webpack-bundle-analyzer": "^4.10.1" + "typescript": "^5.4.5", + "webpack-bundle-analyzer": "^4.10.2" }, "overrides": { "redux": "^5.0.1" From 4650df1663b81694d29c90ada5076a74c20570d3 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Mon, 15 Apr 2024 11:34:48 -0400 Subject: [PATCH 28/33] Add cost model links to cluster info https://issues.redhat.com/browse/COST-4925 --- locales/data.json | 6 ++++++ locales/translations.json | 1 + src/locales/messages.ts | 7 +++++-- .../clusterInfo/clusterInfoContent.tsx | 17 ++++++++++++----- .../components/cloudIntegration.tsx | 19 ++++++++++++++----- src/utils/paths.ts | 5 +++-- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/locales/data.json b/locales/data.json index c3feb5d21..d6f7e0a86 100644 --- a/locales/data.json +++ b/locales/data.json @@ -1156,6 +1156,12 @@ "value": "Cost Management" } ], + "costModel": [ + { + "type": 0, + "value": "Cost Model:" + } + ], "costModels": [ { "type": 0, diff --git a/locales/translations.json b/locales/translations.json index bb164a591..37747ff4b 100644 --- a/locales/translations.json +++ b/locales/translations.json @@ -81,6 +81,7 @@ "costDistributionTitle": "Overhead cost breakdown", "costDistributionType": "{value, select, distributed {Distribute through cost models} total {Don't distribute overhead costs} other {}}", "costManagement": "Cost Management", + "costModel": "Cost Model:", "costModels": "Cost Models", "costModelsActions": "Cost model actions", "costModelsAddTagValues": "Add more tag values", diff --git a/src/locales/messages.ts b/src/locales/messages.ts index 05220b13d..3d67d9700 100644 --- a/src/locales/messages.ts +++ b/src/locales/messages.ts @@ -461,6 +461,11 @@ export default defineMessages({ description: 'Cost Management', id: 'costManagement', }, + costModel: { + defaultMessage: 'Cost Model:', + description: 'Cost Model:', + id: 'costModel', + }, costModels: { defaultMessage: 'Cost Models', description: 'Cost Models', @@ -1030,13 +1035,11 @@ export default defineMessages({ description: 'Currency and calculations', id: 'currencyCalcuationsTitle', }, - currencyDesc: { defaultMessage: 'Select the preferred currency view for your organization', description: 'Select the preferred currency view for your organization', id: 'currencyDesc', }, - // See https://www.localeplanet.com/icu/currency.html currencyOptions: { defaultMessage: diff --git a/src/routes/details/ocpBreakdown/providerDetails/clusterInfo/clusterInfoContent.tsx b/src/routes/details/ocpBreakdown/providerDetails/clusterInfo/clusterInfoContent.tsx index b6bd7ce84..135b7b028 100644 --- a/src/routes/details/ocpBreakdown/providerDetails/clusterInfo/clusterInfoContent.tsx +++ b/src/routes/details/ocpBreakdown/providerDetails/clusterInfo/clusterInfoContent.tsx @@ -67,11 +67,6 @@ const ClusterInfoContent: React.FC = ({ clusterId }: Cl {clusterId} {intl.formatMessage(messages.ocpClusterDetails)} - {clusterProvider?.cost_models?.length === 0 && ( - - {intl.formatMessage(messages.assignCostModel)} - - )} {intl.formatMessage(messages.metricsOperatorVersion)} @@ -95,6 +90,18 @@ const ClusterInfoContent: React.FC = ({ clusterId }: Cl {intl.formatMessage(messages.source, { value: 'ocp' })} {clusterProvider.name} + + {clusterProvider?.cost_models?.length ? ( + clusterProvider.cost_models.map(cm => ( + <> + {intl.formatMessage(messages.costModel)} + {cm.name} + + )) + ) : ( + {intl.formatMessage(messages.assignCostModel)} + )} + {cloudProvider && } diff --git a/src/routes/details/ocpBreakdown/providerDetails/clusterInfo/components/cloudIntegration.tsx b/src/routes/details/ocpBreakdown/providerDetails/clusterInfo/components/cloudIntegration.tsx index 630f5646e..7a0a82db1 100644 --- a/src/routes/details/ocpBreakdown/providerDetails/clusterInfo/components/cloudIntegration.tsx +++ b/src/routes/details/ocpBreakdown/providerDetails/clusterInfo/components/cloudIntegration.tsx @@ -7,6 +7,8 @@ import { routes } from 'routes'; import { SourceLink } from 'routes/details/ocpBreakdown/providerDetails/components/sourceLink'; import { formatPath } from 'utils/paths'; +import { styles } from '../clusterInfo.styles'; + interface CloudIntegrationOwnProps { provider: Provider; } @@ -27,11 +29,18 @@ const CloudIntegration: React.FC = ({ provider }: CloudIn - {provider?.cost_models?.length === 0 && ( - - {intl.formatMessage(messages.assignCostModel)} - - )} + + {provider?.cost_models?.length ? ( + provider.cost_models.map(cm => ( + <> + {intl.formatMessage(messages.costModel)} + {cm.name} + + )) + ) : ( + {intl.formatMessage(messages.assignCostModel)} + )} + ); diff --git a/src/utils/paths.ts b/src/utils/paths.ts index afb9b6483..bdd08d3d4 100644 --- a/src/utils/paths.ts +++ b/src/utils/paths.ts @@ -5,9 +5,10 @@ import { routes } from 'routes'; // // Note the basename does not include a release prefix (/beta, /preview, etc.), unlike the getBaseName function from // @redhat-cloud-services/frontend-components-utilities/helpers -export const formatPath = path => { +export const formatPath = (path, isReleasePath = false) => { const basename = '/openshift/cost-management'; - return path === routes.overview.path ? basename : `${basename}${path}`; + const newPath = path === routes.overview.path ? basename : `${basename}${path}`; + return isReleasePath ? `${getReleasePath()}${newPath}` : newPath; }; export const getReleasePath = () => { From 65162828b8b0b1ada2911408ae7d04c09feb571a Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Mon, 15 Apr 2024 12:23:18 -0400 Subject: [PATCH 29/33] Dependency updates --- package-lock.json | 135 ++++++---------------------------------------- package.json | 6 +-- 2 files changed, 18 insertions(+), 123 deletions(-) diff --git a/package-lock.json b/package-lock.json index c56880e30..e13a603d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,11 +50,11 @@ "@swc/core": "1.3.105", "@swc/jest": "^0.2.36", "@testing-library/jest-dom": "^6.4.2", - "@testing-library/react": "^15.0.2", + "@testing-library/react": "^14.3.1", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.12", "@types/qs": "^6.9.14", - "@types/react": "^18.2.75", + "@types/react": "^18.2.78", "@types/react-dom": "^18.2.25", "@types/react-redux": "^7.1.33", "@types/react-router-dom": "^5.3.3", @@ -72,7 +72,7 @@ "eslint-plugin-react": "^7.34.1", "eslint-plugin-simple-import-sort": "^12.1.0", "eslint-plugin-sort-keys-fix": "^1.1.2", - "eslint-plugin-testing-library": "^6.2.0", + "eslint-plugin-testing-library": "^6.2.2", "git-revision-webpack-plugin": "^5.0.0", "identity-obj-proxy": "^3.0.0", "jest": "^29.7.0", @@ -3432,7 +3432,6 @@ "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.4.tgz", "integrity": "sha512-FlS4ZWlp97iiNWig0Muq8p+3rVDjRiYE+YKGbAqXOu9nwJFFOdL00kFpz42M+4huzYi86vAK1sOOfyOG45muIQ==", "dev": true, - "peer": true, "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", @@ -3452,7 +3451,6 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -3468,7 +3466,6 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -3485,7 +3482,6 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -3497,15 +3493,13 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "peer": true + "dev": true }, "node_modules/@testing-library/dom/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, - "peer": true, "engines": { "node": ">=8" } @@ -3515,7 +3509,6 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -3642,121 +3635,23 @@ } }, "node_modules/@testing-library/react": { - "version": "15.0.2", - "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-15.0.2.tgz", - "integrity": "sha512-5mzIpuytB1ctpyywvyaY2TAAUQVCZIGqwiqFQf6u9lvj/SJQepGUzNV18Xpk+NLCaCE2j7CWrZE0tEf9xLZYiQ==", + "version": "14.3.1", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-14.3.1.tgz", + "integrity": "sha512-H99XjUhWQw0lTgyMN05W3xQG1Nh4lq574D8keFf1dDoNTJgp66VbJozRaczoF+wsiaPJNt/TcnfpLGufGxSrZQ==", "dev": true, "dependencies": { "@babel/runtime": "^7.12.5", - "@testing-library/dom": "^10.0.0", + "@testing-library/dom": "^9.0.0", "@types/react-dom": "^18.0.0" }, "engines": { - "node": ">=18" + "node": ">=14" }, "peerDependencies": { "react": "^18.0.0", "react-dom": "^18.0.0" } }, - "node_modules/@testing-library/react/node_modules/@testing-library/dom": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.0.0.tgz", - "integrity": "sha512-PmJPnogldqoVFf+EwbHvbBJ98MmqASV8kLrBYgsDNxQcFMeIS7JFL48sfyXvuMtgmWO/wMhh25odr+8VhDmn4g==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.10.4", - "@babel/runtime": "^7.12.5", - "@types/aria-query": "^5.0.1", - "aria-query": "5.3.0", - "chalk": "^4.1.0", - "dom-accessibility-api": "^0.5.9", - "lz-string": "^1.5.0", - "pretty-format": "^27.0.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@testing-library/react/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@testing-library/react/node_modules/aria-query": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", - "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", - "dev": true, - "dependencies": { - "dequal": "^2.0.3" - } - }, - "node_modules/@testing-library/react/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@testing-library/react/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@testing-library/react/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/@testing-library/react/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/react/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@testing-library/user-event": { "version": "14.5.2", "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.5.2.tgz", @@ -4197,9 +4092,9 @@ "dev": true }, "node_modules/@types/react": { - "version": "18.2.75", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.75.tgz", - "integrity": "sha512-+DNnF7yc5y0bHkBTiLKqXFe+L4B3nvOphiMY3tuA5X10esmjqk7smyBZzbGTy2vsiy/Bnzj8yFIBL8xhRacoOg==", + "version": "18.2.78", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.78.tgz", + "integrity": "sha512-qOwdPnnitQY4xKlKayt42q5W5UQrSHjgoXNVEtxeqdITJ99k4VXJOP3vt8Rkm9HmgJpH50UNU+rlqfkfWOqp0A==", "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" @@ -10037,9 +9932,9 @@ } }, "node_modules/eslint-plugin-testing-library": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-testing-library/-/eslint-plugin-testing-library-6.2.0.tgz", - "integrity": "sha512-+LCYJU81WF2yQ+Xu4A135CgK8IszcFcyMF4sWkbiu6Oj+Nel0TrkZq/HvDw0/1WuO3dhDQsZA/OpEMGd0NfcUw==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-testing-library/-/eslint-plugin-testing-library-6.2.2.tgz", + "integrity": "sha512-1E94YOTUDnOjSLyvOwmbVDzQi/WkKm3WVrMXu6SmBr6DN95xTGZmI6HJ/eOkSXh/DlheRsxaPsJvZByDBhWLVQ==", "dev": true, "dependencies": { "@typescript-eslint/utils": "^5.58.0" diff --git a/package.json b/package.json index e876c2de5..6934ef542 100644 --- a/package.json +++ b/package.json @@ -90,11 +90,11 @@ "@swc/core": "1.3.105", "@swc/jest": "^0.2.36", "@testing-library/jest-dom": "^6.4.2", - "@testing-library/react": "^15.0.2", + "@testing-library/react": "^14.3.1", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.12", "@types/qs": "^6.9.14", - "@types/react": "^18.2.75", + "@types/react": "^18.2.78", "@types/react-dom": "^18.2.25", "@types/react-redux": "^7.1.33", "@types/react-router-dom": "^5.3.3", @@ -112,7 +112,7 @@ "eslint-plugin-react": "^7.34.1", "eslint-plugin-simple-import-sort": "^12.1.0", "eslint-plugin-sort-keys-fix": "^1.1.2", - "eslint-plugin-testing-library": "^6.2.0", + "eslint-plugin-testing-library": "^6.2.2", "git-revision-webpack-plugin": "^5.0.0", "identity-obj-proxy": "^3.0.0", "jest": "^29.7.0", From 575fce83b783d3cd916af215cda4d57e0595b815 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Mon, 15 Apr 2024 13:21:55 -0400 Subject: [PATCH 30/33] Upgrade @testing-library/react dependency --- package-lock.json | 207 +++++++++++++----- package.json | 6 +- .../dropdownWrapper/dropdownWrapper.test.tsx | 6 +- .../selectCheckboxWrapper.test.tsx | 6 +- .../selectWrapper/selectWrapper.test.tsx | 6 +- .../components/addPriceList.test.tsx | 118 +++++----- .../hoc/withPriceListSearch.test.tsx | 14 +- .../costModels/components/rateTable.test.tsx | 4 +- .../costModel/updateRateModel.test.tsx | 96 ++++---- .../costModelsDetails/dialog.test.tsx | 6 +- 10 files changed, 289 insertions(+), 180 deletions(-) diff --git a/package-lock.json b/package-lock.json index e13a603d3..e265dd3d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,7 @@ "@swc/core": "1.3.105", "@swc/jest": "^0.2.36", "@testing-library/jest-dom": "^6.4.2", - "@testing-library/react": "^14.3.1", + "@testing-library/react": "^15.0.2", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.12", "@types/qs": "^6.9.14", @@ -58,8 +58,8 @@ "@types/react-dom": "^18.2.25", "@types/react-redux": "^7.1.33", "@types/react-router-dom": "^5.3.3", - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.6.0", + "@typescript-eslint/eslint-plugin": "^7.7.0", + "@typescript-eslint/parser": "^7.7.0", "aphrodite": "^2.4.0", "copy-webpack-plugin": "^12.0.2", "eslint": "^8.57.0", @@ -3432,6 +3432,7 @@ "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.4.tgz", "integrity": "sha512-FlS4ZWlp97iiNWig0Muq8p+3rVDjRiYE+YKGbAqXOu9nwJFFOdL00kFpz42M+4huzYi86vAK1sOOfyOG45muIQ==", "dev": true, + "peer": true, "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", @@ -3451,6 +3452,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -3466,6 +3468,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -3482,6 +3485,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -3493,13 +3497,15 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@testing-library/dom/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -3509,6 +3515,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -3635,23 +3642,121 @@ } }, "node_modules/@testing-library/react": { - "version": "14.3.1", - "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-14.3.1.tgz", - "integrity": "sha512-H99XjUhWQw0lTgyMN05W3xQG1Nh4lq574D8keFf1dDoNTJgp66VbJozRaczoF+wsiaPJNt/TcnfpLGufGxSrZQ==", + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-15.0.2.tgz", + "integrity": "sha512-5mzIpuytB1ctpyywvyaY2TAAUQVCZIGqwiqFQf6u9lvj/SJQepGUzNV18Xpk+NLCaCE2j7CWrZE0tEf9xLZYiQ==", "dev": true, "dependencies": { "@babel/runtime": "^7.12.5", - "@testing-library/dom": "^9.0.0", + "@testing-library/dom": "^10.0.0", "@types/react-dom": "^18.0.0" }, "engines": { - "node": ">=14" + "node": ">=18" }, "peerDependencies": { "react": "^18.0.0", "react-dom": "^18.0.0" } }, + "node_modules/@testing-library/react/node_modules/@testing-library/dom": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.0.0.tgz", + "integrity": "sha512-PmJPnogldqoVFf+EwbHvbBJ98MmqASV8kLrBYgsDNxQcFMeIS7JFL48sfyXvuMtgmWO/wMhh25odr+8VhDmn4g==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.3.0", + "chalk": "^4.1.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@testing-library/react/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@testing-library/react/node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dev": true, + "dependencies": { + "dequal": "^2.0.3" + } + }, + "node_modules/@testing-library/react/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@testing-library/react/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@testing-library/react/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/@testing-library/react/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@testing-library/react/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@testing-library/user-event": { "version": "14.5.2", "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.5.2.tgz", @@ -4329,16 +4434,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.6.0.tgz", - "integrity": "sha512-gKmTNwZnblUdnTIJu3e9kmeRRzV2j1a/LUO27KNNAnIC5zjy1aSvXSRp4rVNlmAoHlQ7HzX42NbKpcSr4jF80A==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.7.0.tgz", + "integrity": "sha512-GJWR0YnfrKnsRoluVO3PRb9r5aMZriiMMM/RHj5nnTrBy1/wIgk76XCtCKcnXGjpZQJQRFtGV9/0JJ6n30uwpQ==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "7.6.0", - "@typescript-eslint/type-utils": "7.6.0", - "@typescript-eslint/utils": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0", + "@typescript-eslint/scope-manager": "7.7.0", + "@typescript-eslint/type-utils": "7.7.0", + "@typescript-eslint/utils": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.3.1", @@ -4397,15 +4502,15 @@ "dev": true }, "node_modules/@typescript-eslint/parser": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.6.0.tgz", - "integrity": "sha512-usPMPHcwX3ZoPWnBnhhorc14NJw9J4HpSXQX4urF2TPKG0au0XhJoZyX62fmvdHONUkmyUe74Hzm1//XA+BoYg==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.7.0.tgz", + "integrity": "sha512-fNcDm3wSwVM8QYL4HKVBggdIPAy9Q41vcvC/GtDobw3c4ndVT3K6cqudUmjHPw8EAp4ufax0o58/xvWaP2FmTg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.6.0", - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/typescript-estree": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0", + "@typescript-eslint/scope-manager": "7.7.0", + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/typescript-estree": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0", "debug": "^4.3.4" }, "engines": { @@ -4425,13 +4530,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.6.0.tgz", - "integrity": "sha512-ngttyfExA5PsHSx0rdFgnADMYQi+Zkeiv4/ZxGYUWd0nLs63Ha0ksmp8VMxAIC0wtCFxMos7Lt3PszJssG/E6w==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.7.0.tgz", + "integrity": "sha512-/8INDn0YLInbe9Wt7dK4cXLDYp0fNHP5xKLHvZl3mOT5X17rK/YShXaiNmorl+/U4VKCVIjJnx4Ri5b0y+HClw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0" + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -4442,13 +4547,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.6.0.tgz", - "integrity": "sha512-NxAfqAPNLG6LTmy7uZgpK8KcuiS2NZD/HlThPXQRGwz6u7MDBWRVliEEl1Gj6U7++kVJTpehkhZzCJLMK66Scw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.7.0.tgz", + "integrity": "sha512-bOp3ejoRYrhAlnT/bozNQi3nio9tIgv3U5C0mVDdZC7cpcQEDZXvq8inrHYghLVwuNABRqrMW5tzAv88Vy77Sg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.6.0", - "@typescript-eslint/utils": "7.6.0", + "@typescript-eslint/typescript-estree": "7.7.0", + "@typescript-eslint/utils": "7.7.0", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -4469,9 +4574,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.6.0.tgz", - "integrity": "sha512-h02rYQn8J+MureCvHVVzhl69/GAfQGPQZmOMjG1KfCl7o3HtMSlPaPUAPu6lLctXI5ySRGIYk94clD/AUMCUgQ==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.7.0.tgz", + "integrity": "sha512-G01YPZ1Bd2hn+KPpIbrAhEWOn5lQBrjxkzHkWvP6NucMXFtfXoevK82hzQdpfuQYuhkvFDeQYbzXCjR1z9Z03w==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -4482,13 +4587,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.6.0.tgz", - "integrity": "sha512-+7Y/GP9VuYibecrCQWSKgl3GvUM5cILRttpWtnAu8GNL9j11e4tbuGZmZjJ8ejnKYyBRb2ddGQ3rEFCq3QjMJw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.7.0.tgz", + "integrity": "sha512-8p71HQPE6CbxIBy2kWHqM1KGrC07pk6RJn40n0DSc6bMOBBREZxSDJ+BmRzc8B5OdaMh1ty3mkuWRg4sCFiDQQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0", + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -4558,17 +4663,17 @@ "dev": true }, "node_modules/@typescript-eslint/utils": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.6.0.tgz", - "integrity": "sha512-x54gaSsRRI+Nwz59TXpCsr6harB98qjXYzsRxGqvA5Ue3kQH+FxS7FYU81g/omn22ML2pZJkisy6Q+ElK8pBCA==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.7.0.tgz", + "integrity": "sha512-LKGAXMPQs8U/zMRFXDZOzmMKgFv3COlxUQ+2NMPhbqgVm6R1w+nU1i4836Pmxu9jZAuIeyySNrN/6Rc657ggig==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.15", "@types/semver": "^7.5.8", - "@typescript-eslint/scope-manager": "7.6.0", - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/typescript-estree": "7.6.0", + "@typescript-eslint/scope-manager": "7.7.0", + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/typescript-estree": "7.7.0", "semver": "^7.6.0" }, "engines": { @@ -4616,12 +4721,12 @@ "dev": true }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.6.0.tgz", - "integrity": "sha512-4eLB7t+LlNUmXzfOu1VAIAdkjbu5xNSerURS9X/S5TUKWFRpXRQZbmtPqgKmYx8bj3J0irtQXSiWAOY82v+cgw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.7.0.tgz", + "integrity": "sha512-h0WHOj8MhdhY8YWkzIF30R379y0NqyOHExI9N9KCzvmu05EgG4FumeYa3ccfKUSphyWkWQE1ybVrgz/Pbam6YA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.6.0", + "@typescript-eslint/types": "7.7.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { diff --git a/package.json b/package.json index 6934ef542..ddf294ae7 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "@swc/core": "1.3.105", "@swc/jest": "^0.2.36", "@testing-library/jest-dom": "^6.4.2", - "@testing-library/react": "^14.3.1", + "@testing-library/react": "^15.0.2", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.12", "@types/qs": "^6.9.14", @@ -98,8 +98,8 @@ "@types/react-dom": "^18.2.25", "@types/react-redux": "^7.1.33", "@types/react-router-dom": "^5.3.3", - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.6.0", + "@typescript-eslint/eslint-plugin": "^7.7.0", + "@typescript-eslint/parser": "^7.7.0", "aphrodite": "^2.4.0", "copy-webpack-plugin": "^12.0.2", "eslint": "^8.57.0", diff --git a/src/routes/components/dropdownWrapper/dropdownWrapper.test.tsx b/src/routes/components/dropdownWrapper/dropdownWrapper.test.tsx index 53f6e5acd..2f2338893 100644 --- a/src/routes/components/dropdownWrapper/dropdownWrapper.test.tsx +++ b/src/routes/components/dropdownWrapper/dropdownWrapper.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react'; +import { act, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; @@ -16,9 +16,9 @@ test('primary selector', async () => { expect(screen.queryAllByText('CPU').length).toBe(0); expect(screen.queryAllByText('Memory').length).toBe(0); const button = screen.getByRole('button'); - await user.click(button); + await act(async () => user.click(button)); const menuItems = screen.getAllByRole('menuitem'); expect(menuItems.length).toBe(3); - await user.click(menuItems[1]); + await act(async () => user.click(menuItems[1])); expect(handleOnClick.mock.calls).toEqual([['memory']]); }); diff --git a/src/routes/components/selectWrapper/selectCheckboxWrapper.test.tsx b/src/routes/components/selectWrapper/selectCheckboxWrapper.test.tsx index 034ed0b18..96dc48078 100644 --- a/src/routes/components/selectWrapper/selectCheckboxWrapper.test.tsx +++ b/src/routes/components/selectWrapper/selectCheckboxWrapper.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react'; +import { act, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; @@ -24,11 +24,11 @@ test('checkbox selector', async () => { expect(screen.queryAllByText('CPU').length).toBe(0); expect(screen.queryAllByText('Memory').length).toBe(0); expect(screen.queryAllByText('Storage').length).toBe(0); - await user.click(screen.getByRole('button')); + await act(async () => user.click(screen.getByRole('button'))); expect(screen.queryAllByText('CPU').length).toBe(1); expect(screen.queryAllByText('Memory').length).toBe(1); expect(screen.queryAllByText('Storage').length).toBe(1); expect(handleOnSelect.mock.calls.length).toBe(0); - await user.click(screen.getAllByRole('checkbox')[0]); + await act(async () => user.click(screen.getAllByRole('checkbox')[0])); expect(handleOnSelect.mock.calls).toEqual([['cpu']]); }); diff --git a/src/routes/components/selectWrapper/selectWrapper.test.tsx b/src/routes/components/selectWrapper/selectWrapper.test.tsx index afe4dd9ed..ff53f7f93 100644 --- a/src/routes/components/selectWrapper/selectWrapper.test.tsx +++ b/src/routes/components/selectWrapper/selectWrapper.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react'; +import { act, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; @@ -23,9 +23,9 @@ test('primary selector', async () => { expect(screen.queryAllByText('CPU').length).toBe(1); expect(screen.queryAllByText('Memory').length).toBe(0); const button = screen.getByRole('button'); - await user.click(button); + await act(async () => user.click(button)); const options = screen.getAllByRole('option'); expect(options.length).toBe(3); - await user.click(options[1]); + await act(async () => user.click(options[1])); expect(handleOnSelect.mock.calls).toEqual([['memory']]); }); diff --git a/src/routes/settings/costModels/components/addPriceList.test.tsx b/src/routes/settings/costModels/components/addPriceList.test.tsx index 7009d724a..9db627bc0 100644 --- a/src/routes/settings/costModels/components/addPriceList.test.tsx +++ b/src/routes/settings/costModels/components/addPriceList.test.tsx @@ -1,4 +1,4 @@ -import { configure, render, screen } from '@testing-library/react'; +import { act, configure, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import type { Rate } from 'api/rates'; import messages from 'locales/messages'; @@ -124,67 +124,67 @@ describe('add-a-new-rate', () => { let options = null; render(); - await user.type(screen.getByLabelText('Description'), 'regular rate test'); + await act(async () => user.type(screen.getByLabelText('Description'), 'regular rate test')); // select first option for metric - await user.click(screen.getByLabelText('Select Metric')); + await act(async () => user.click(screen.getByLabelText('Select Metric'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); // select first option for measurement - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); // make sure the default cost type is selected expect(screen.getByLabelText(qr.infraradio)).toHaveProperty('checked', true); // selecting a different measurement does not reset cost type to default - await user.click(screen.getByLabelText(qr.supplradio)); + await act(async () => user.click(screen.getByLabelText(qr.supplradio))); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[1]); + await act(async () => user.click(options[1])); expect(screen.getByLabelText(qr.supplradio)).toHaveProperty('checked', true); // selecting metric will reset both measurement and cost type - await user.click(screen.getByLabelText(qr.infraradio)); + await act(async () => user.click(screen.getByLabelText(qr.infraradio))); - await user.click(screen.getByLabelText('Select Metric')); + await act(async () => user.click(screen.getByLabelText('Select Metric'))); options = await screen.findAllByRole('option'); - await user.click(options[1]); + await act(async () => user.click(options[1])); expect(screen.getByText(regExp(messages.costModelsRequiredField))).not.toBeNull(); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); expect(screen.getByLabelText(qr.supplradio)).toHaveProperty('checked', true); - await user.click(screen.getByLabelText(qr.infraradio)); + await act(async () => user.click(screen.getByLabelText(qr.infraradio))); const rateInput = screen.getByLabelText('Assign rate'); // setting rate to anything but a number expect(screen.queryByText(regExp(messages.priceListNumberRate))).toBeNull(); - await user.type(rateInput, 'A'); + await act(async () => user.type(rateInput, 'A')); expect(screen.getByText(regExp(messages.priceListNumberRate))).not.toBeNull(); // setting rate to a negative number - validation is done on blur - await user.clear(rateInput); - await user.type(rateInput, '-12'); + await act(async () => user.clear(rateInput)); + await act(async () => user.type(rateInput, '-12')); expect(screen.getByText(regExp(messages.priceListPosNumberRate))).not.toBeNull(); // setting rate to a valid number - await user.clear(rateInput); - await user.type(rateInput, '0.2'); + await act(async () => user.clear(rateInput)); + await act(async () => user.type(rateInput, '0.2')); expect(screen.queryByText(regExp(messages.priceListNumberRate))).toBeNull(); // making sure button is enabled const createButton = screen.getByText(regExp(messages.createRate)); expect(createButton.getAttribute('aria-disabled')).toBe('false'); - await user.click(createButton); + await act(async () => user.click(createButton)); expect(submit).toHaveBeenCalled(); }); @@ -195,68 +195,68 @@ describe('add-a-new-rate', () => { let options = null; render(); - await user.type(screen.getByLabelText('Description'), 'tag rate test'); + await act(async () => user.type(screen.getByLabelText('Description'), 'tag rate test')); - await user.click(screen.getByLabelText('Select Metric')); + await act(async () => user.click(screen.getByLabelText('Select Metric'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); - await user.click(screen.getByLabelText(regExp(messages.costModelsEnterTagRate))); + await act(async () => user.click(screen.getByLabelText(regExp(messages.costModelsEnterTagRate)))); // tag key is required validation const tagKeyInput = screen.getByPlaceholderText(qr.tagKeyPlaceHolder); - await user.type(tagKeyInput, 'test'); + await act(async () => user.type(tagKeyInput, 'test')); expect(screen.queryByText(regExp(messages.costModelsRequiredField))).toBeNull(); - await user.clear(tagKeyInput); + await act(async () => user.clear(tagKeyInput)); expect(screen.getByText(regExp(messages.costModelsRequiredField))).not.toBeNull(); - await user.type(tagKeyInput, 'openshift'); + await act(async () => user.type(tagKeyInput, 'openshift')); expect(screen.queryByText(regExp(messages.costModelsRequiredField))).toBeNull(); // tag value is required validation const tagValueInput = screen.getByPlaceholderText('Enter a tag value'); - await user.type(tagValueInput, 'test'); + await act(async () => user.type(tagValueInput, 'test')); expect(screen.queryByText(regExp(messages.costModelsRequiredField))).toBeNull(); - await user.clear(tagValueInput); + await act(async () => user.clear(tagValueInput)); expect(screen.getByText(regExp(messages.costModelsRequiredField))).not.toBeNull(); - await user.type(tagValueInput, 'openshift'); + await act(async () => user.type(tagValueInput, 'openshift')); expect(screen.queryByText(regExp(messages.costModelsRequiredField))).toBeNull(); // rate must be a number const tagRateInput = screen.getByLabelText('Assign rate'); - await user.type(tagRateInput, 'test'); + await act(async () => user.type(tagRateInput, 'test')); expect(screen.getByText(regExp(messages.priceListNumberRate))).not.toBeNull(); // rate is required - await user.clear(tagRateInput); + await act(async () => user.clear(tagRateInput)); expect(screen.getByText(regExp(messages.costModelsRequiredField))).not.toBeNull(); // rate must be positive - await user.type(tagRateInput, '-0.23'); + await act(async () => user.type(tagRateInput, '-0.23')); expect(screen.getByText(regExp(messages.priceListPosNumberRate))).not.toBeNull(); // setting a valid rate - now form is valid and can be submitted const createButton = screen.getByText(regExp(messages.createRate)); expect(createButton.getAttribute('aria-disabled')).toBe('true'); - await user.clear(tagRateInput); + await act(async () => user.clear(tagRateInput)); - await user.type(tagRateInput, '0.23'); - await user.type(screen.getByPlaceholderText('Enter a tag description'), 'default worker'); + await act(async () => user.type(tagRateInput, '0.23')); + await act(async () => user.type(screen.getByPlaceholderText('Enter a tag description'), 'default worker')); expect(createButton.getAttribute('aria-disabled')).toBe('false'); // set tag to default - await user.click(screen.getByLabelText('Default')); + await act(async () => user.click(screen.getByLabelText('Default'))); // add a new rate disables the submit button - await user.click(screen.getByText(/add more tag values/i)); + await act(async () => user.click(screen.getByText(/add more tag values/i))); expect(createButton.getAttribute('aria-disabled')).toBe('true'); - await user.click(screen.getAllByRole('button', { name: /remove tag value/i })[1]); + await act(async () => user.click(screen.getAllByRole('button', { name: /remove tag value/i })[1])); expect(createButton.getAttribute('aria-disabled')).toBe('false'); - await user.click(createButton); + await act(async () => user.click(createButton)); expect(submit).toHaveBeenCalled(); }); @@ -267,37 +267,37 @@ describe('add-a-new-rate', () => { let options = null; render(); - await user.click(screen.getByLabelText('Select Metric')); + await act(async () => user.click(screen.getByLabelText('Select Metric'))); options = await screen.findAllByRole('option'); - await user.click(options[1]); + await act(async () => user.click(options[1])); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); - await user.click(screen.getByLabelText(regExp(messages.costModelsEnterTagRate))); + await act(async () => user.click(screen.getByLabelText(regExp(messages.costModelsEnterTagRate)))); // tag key is duplicated const tagKeyInput = screen.getByPlaceholderText(qr.tagKeyPlaceHolder); - await user.type(tagKeyInput, 'app'); + await act(async () => user.type(tagKeyInput, 'app')); expect(screen.getByText(regExp(messages.priceListDuplicate))).not.toBeNull(); - await user.type(tagKeyInput, '1'); + await act(async () => user.type(tagKeyInput, '1')); expect(screen.queryByText(regExp(messages.priceListDuplicate))).toBeNull(); // change measurement will set tag key as not duplicate - await user.type(tagKeyInput, '{backspace}'); + await act(async () => user.type(tagKeyInput, '{backspace}')); expect(screen.getByText(regExp(messages.priceListDuplicate))).not.toBeNull(); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[1]); + await act(async () => user.click(options[1])); expect(screen.queryByText(regExp(messages.priceListDuplicate))).toBeNull(); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); expect(screen.getByText(regExp(messages.priceListDuplicate))).not.toBeNull(); }); @@ -310,13 +310,13 @@ describe('add-a-new-rate', () => { await render(); - await user.click(screen.getByLabelText('Select Metric')); + await act(async () => user.click(screen.getByLabelText('Select Metric'))); options = await screen.findAllByRole('option'); - await user.click(options[2]); + await act(async () => user.click(options[2])); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); expect(screen.queryAllByLabelText(regExp(messages.costModelsEnterTagRate))).toHaveLength(0); }); }); diff --git a/src/routes/settings/costModels/components/hoc/withPriceListSearch.test.tsx b/src/routes/settings/costModels/components/hoc/withPriceListSearch.test.tsx index a5e614325..c2764b911 100644 --- a/src/routes/settings/costModels/components/hoc/withPriceListSearch.test.tsx +++ b/src/routes/settings/costModels/components/hoc/withPriceListSearch.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react'; +import { act, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; @@ -40,27 +40,27 @@ test('with price list search', async () => { expect(screen.getByRole('main').outerHTML).toEqual( `
Primary: metrics
Metrics: None
Measurements: None
` ); - await user.click(screen.getByText('Select CPU')); + await act(async () => user.click(screen.getByText('Select CPU'))); expect(screen.getByRole('main').outerHTML).toEqual( `
Primary: metrics
Metrics: CPU
Measurements: None
` ); - await user.click(screen.getByText('Remove CPU')); + await act(async () => user.click(screen.getByText('Remove CPU'))); expect(screen.getByRole('main').outerHTML).toEqual( `
Primary: metrics
Metrics: None
Measurements: None
` ); - await user.click(screen.getByText('Select request')); + await act(async () => user.click(screen.getByText('Select request'))); expect(screen.getByRole('main').outerHTML).toEqual( `
Primary: metrics
Metrics: None
Measurements: Request
` ); - await user.click(screen.getByText('Remove request')); + await act(async () => user.click(screen.getByText('Remove request'))); expect(screen.getByRole('main').outerHTML).toEqual( `
Primary: metrics
Metrics: None
Measurements: None
` ); - await user.click(screen.getByText('Set search')); + await act(async () => user.click(screen.getByText('Set search'))); expect(screen.getByRole('main').outerHTML).toEqual( `
Primary: measurements
Metrics: Memory
Measurements: Usage
` ); - await user.click(screen.getByText('Clear all')); + await act(async () => user.click(screen.getByText('Clear all'))); expect(screen.getByRole('main').outerHTML).toEqual( `
Primary: measurements
Metrics: None
Measurements: None
` ); diff --git a/src/routes/settings/costModels/components/rateTable.test.tsx b/src/routes/settings/costModels/components/rateTable.test.tsx index 1cadc0964..e053ef88e 100644 --- a/src/routes/settings/costModels/components/rateTable.test.tsx +++ b/src/routes/settings/costModels/components/rateTable.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react'; +import { act, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import type { Rate } from 'api/rates'; import React from 'react'; @@ -68,7 +68,7 @@ describe('rate-table', () => { expect(screen.getByText('rate 1')).toBeTruthy(); expect(screen.getByText('rate 2')).toBeTruthy(); expect(screen.queryByText('grafana')).toBeNull(); - await user.click(screen.getByRole('button', { name: 'Various' })); + await act(async () => user.click(screen.getByRole('button', { name: 'Various' }))); expect(screen.getByText('grafana')).toBeTruthy(); }); test('sort by metric & measurement', () => { diff --git a/src/routes/settings/costModels/costModel/updateRateModel.test.tsx b/src/routes/settings/costModels/costModel/updateRateModel.test.tsx index 2d8de84c9..ee561811e 100644 --- a/src/routes/settings/costModels/costModel/updateRateModel.test.tsx +++ b/src/routes/settings/costModels/costModel/updateRateModel.test.tsx @@ -259,10 +259,10 @@ describe('update-rate', () => { test('submit regular', async () => { const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime }); render(); - await user.type(screen.getByDisplayValue(/openshift-aws-node/i), 'a new description'); + await act(async () => user.type(screen.getByDisplayValue(/openshift-aws-node/i), 'a new description')); // eslint-disable-next-line testing-library/prefer-presence-queries expect(screen.getByText(regExp(messages.save)).getAttribute('disabled')).toBeNull(); - await user.click(screen.getByText(regExp(messages.save))); + await act(async () => user.click(screen.getByText(regExp(messages.save)))); }); test('regular', async () => { @@ -272,62 +272,62 @@ describe('update-rate', () => { const descInput = screen.getByDisplayValue('openshift-aws-node'); const saveButton = screen.getByText(regExp(messages.save)); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.clear(descInput); - await user.type(descInput, 'a new description'); + await act(async () => user.clear(descInput)); + await act(async () => user.type(descInput, 'a new description')); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.clear(descInput); - await user.type(descInput, 'openshift-aws-node'); + await act(async () => user.clear(descInput)); + await act(async () => user.type(descInput, 'openshift-aws-node')); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[1]); + await act(async () => user.click(options[1])); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.click(screen.getByLabelText('Select Metric')); + await act(async () => user.click(screen.getByLabelText('Select Metric'))); options = await screen.findAllByRole('option'); - await user.click(options[1]); + await act(async () => user.click(options[1])); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.click(screen.getByLabelText('Select Metric')); + await act(async () => user.click(screen.getByLabelText('Select Metric'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); - await user.click(screen.getByLabelText('Select Measurement')); + await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[0]); + await act(async () => user.click(options[0])); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.click(screen.getByLabelText(/infrastructure/i)); + await act(async () => user.click(screen.getByLabelText(/infrastructure/i))); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.click(screen.getByLabelText(/supplementary/i)); + await act(async () => user.click(screen.getByLabelText(/supplementary/i))); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.type(screen.getByDisplayValue(/55/i), '.3'); + await act(async () => user.type(screen.getByDisplayValue(/55/i), '.3')); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.type(screen.getByDisplayValue(/55.3/i), '{backspace}{backspace}'); + await act(async () => user.type(screen.getByDisplayValue(/55.3/i), '{backspace}{backspace}')); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.click(screen.getByLabelText(regExp(messages.costModelsEnterTagRate))); + await act(async () => user.click(screen.getByLabelText(regExp(messages.costModelsEnterTagRate)))); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.type(screen.getByLabelText(regExp(messages.costModelsFilterTagKey)), 'openshift'); - await user.type(screen.getByLabelText(regExp(messages.costModelsTagRateTableValue)), 'worker'); - await user.type(screen.getByLabelText(regExp(messages.rate)), '0.321'); + await act(async () => user.type(screen.getByLabelText(regExp(messages.costModelsFilterTagKey)), 'openshift')); + await act(async () => user.type(screen.getByLabelText(regExp(messages.costModelsTagRateTableValue)), 'worker')); + await act(async () => user.type(screen.getByLabelText(regExp(messages.rate)), '0.321')); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.click(saveButton); + await act(async () => user.click(saveButton)); }); test('tag', async () => { @@ -335,36 +335,38 @@ describe('update-rate', () => { render(); const saveButton = screen.getByText(regExp(messages.save)); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.type(screen.getByDisplayValue(/^container$/i), '1'); + await act(async () => user.type(screen.getByDisplayValue(/^container$/i), '1')); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.type(screen.getByDisplayValue(/^container1$/i), '{backspace}'); + await act(async () => user.type(screen.getByDisplayValue(/^container1$/i), '{backspace}')); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.type(screen.getByDisplayValue(/any container$/i), '1'); + await act(async () => user.type(screen.getByDisplayValue(/any container$/i), '1')); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.type(screen.getByDisplayValue(/any container1$/i), '{backspace}'); + await act(async () => user.type(screen.getByDisplayValue(/any container1$/i), '{backspace}')); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.type(screen.getByDisplayValue(/^0.4$/i), '3'); + await act(async () => user.type(screen.getByDisplayValue(/^0.4$/i), '3')); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.type(screen.getByDisplayValue(/^0.43$/i), '{backspace}'); + await act(async () => user.type(screen.getByDisplayValue(/^0.43$/i), '{backspace}')); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.click(screen.getAllByLabelText(regExp(messages.default))[1]); + await act(async () => user.click(screen.getAllByLabelText(regExp(messages.default))[1])); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.click(screen.getAllByLabelText(regExp(messages.default))[0]); + await act(async () => user.click(screen.getAllByLabelText(regExp(messages.default))[0])); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.click(screen.getByText(/Add more tag values/i)); - await user.type(screen.getAllByLabelText(regExp(messages.costModelsTagRateTableValue))[4], 'something random'); - await user.type(screen.getAllByLabelText(regExp(messages.rate))[4], '1.01'); + await act(async () => user.click(screen.getByText(/Add more tag values/i))); + await act(async () => + user.type(screen.getAllByLabelText(regExp(messages.costModelsTagRateTableValue))[4], 'something random') + ); + await act(async () => user.type(screen.getAllByLabelText(regExp(messages.rate))[4], '1.01')); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.click(screen.getAllByLabelText(regExp(messages.costModelsRemoveTagLabel))[4]); + await act(async () => user.click(screen.getAllByLabelText(regExp(messages.costModelsRemoveTagLabel))[4])); expect(saveButton.getAttribute('disabled')).not.toBeNull(); - await user.type(screen.getByDisplayValue(/openshift-region-1/i), '2'); + await act(async () => user.type(screen.getByDisplayValue(/openshift-region-1/i), '2')); expect(saveButton.getAttribute('disabled')).toBeNull(); - await user.type(screen.getByDisplayValue(/openshift-region-12/i), '{backspace}'); + await act(async () => user.type(screen.getByDisplayValue(/openshift-region-12/i), '{backspace}')); expect(saveButton.getAttribute('disabled')).not.toBeNull(); }); @@ -375,10 +377,12 @@ describe('update-rate', () => { await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); - await user.click(options[1]); + await act(async () => user.click(options[1])); - await user.click(screen.getByLabelText(regExp(messages.costModelsEnterTagRate))); - await user.type(screen.getByLabelText(regExp(messages.costModelsFilterTagKey)), 'openshift-region-1'); + await act(async () => user.click(screen.getByLabelText(regExp(messages.costModelsEnterTagRate)))); + await act(async () => + user.type(screen.getByLabelText(regExp(messages.costModelsFilterTagKey)), 'openshift-region-1') + ); expect(screen.getByText(regExp(messages.priceListDuplicate))).not.toBeNull(); }); @@ -386,8 +390,8 @@ describe('update-rate', () => { const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime }); render(); const filterTagInput = screen.getByLabelText(regExp(messages.costModelsFilterTagKey)); - await user.clear(filterTagInput); - await user.type(filterTagInput, 'openshift-region-1'); + await act(async () => user.clear(filterTagInput)); + await act(async () => user.type(filterTagInput, 'openshift-region-1')); expect(screen.getByText(regExp(messages.priceListDuplicate))).not.toBeNull(); }); }); diff --git a/src/routes/settings/costModels/costModelsDetails/dialog.test.tsx b/src/routes/settings/costModels/costModelsDetails/dialog.test.tsx index 6918981f4..15ce3eb02 100644 --- a/src/routes/settings/costModels/costModelsDetails/dialog.test.tsx +++ b/src/routes/settings/costModels/costModelsDetails/dialog.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react'; +import { act, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import messages from 'locales/messages'; import React from 'react'; @@ -77,7 +77,7 @@ test('delete dialog open', async () => { expect(screen.queryAllByText(regExp(messages.costModelsDelete))).toHaveLength(2); expect(screen.queryAllByText(/This action will delete/i)).toHaveLength(1); expect(screen.queryAllByText(/The following sources are assigned to/i)).toHaveLength(0); - await user.click(screen.getAllByText(regExp(messages.costModelsDelete))[1]); + await act(async () => user.click(screen.getAllByText(regExp(messages.costModelsDelete))[1])); expect(screen.getAllByText(regExp(messages.costModelsDelete))[1].getAttribute('disabled')).not.toBeNull(); }); @@ -114,6 +114,6 @@ test('delete dialog error', async () => { expect(screen.queryAllByText(regExp(messages.costModelsDelete))).toHaveLength(1); expect(screen.queryAllByText(/This action will delete/i)).toHaveLength(0); expect(screen.queryAllByText(/The following integrations are assigned to/i)).toHaveLength(1); - await user.click(screen.getByText(regExp(messages.cancel))); + await act(async () => user.click(screen.getByText(regExp(messages.cancel)))); expect(screen.queryAllByText(regExp(messages.costModelsDelete))).toHaveLength(0); }); From 6c9135009e1adc5f85b7430390880940b7f12952 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Mon, 15 Apr 2024 13:53:00 -0400 Subject: [PATCH 31/33] Reduce test size --- .../costModel/updateRateModel.test.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/routes/settings/costModels/costModel/updateRateModel.test.tsx b/src/routes/settings/costModels/costModel/updateRateModel.test.tsx index ee561811e..f0472967e 100644 --- a/src/routes/settings/costModels/costModel/updateRateModel.test.tsx +++ b/src/routes/settings/costModels/costModel/updateRateModel.test.tsx @@ -265,9 +265,8 @@ describe('update-rate', () => { await act(async () => user.click(screen.getByText(regExp(messages.save)))); }); - test('regular', async () => { + test('Description', async () => { const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime }); - let options = null; render(); const descInput = screen.getByDisplayValue('openshift-aws-node'); const saveButton = screen.getByText(regExp(messages.save)); @@ -278,6 +277,13 @@ describe('update-rate', () => { await act(async () => user.clear(descInput)); await act(async () => user.type(descInput, 'openshift-aws-node')); expect(saveButton.getAttribute('disabled')).not.toBeNull(); + }); + + test('Select Measurement', async () => { + const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime }); + let options = null; + render(); + const saveButton = screen.getByText(regExp(messages.save)); await act(async () => user.click(screen.getByLabelText('Select Measurement'))); options = await screen.findAllByRole('option'); @@ -310,6 +316,12 @@ describe('update-rate', () => { await act(async () => user.click(options[0])); expect(saveButton.getAttribute('disabled')).not.toBeNull(); + }); + + test('regular', async () => { + const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime }); + render(); + const saveButton = screen.getByText(regExp(messages.save)); await act(async () => user.click(screen.getByLabelText(/infrastructure/i))); expect(saveButton.getAttribute('disabled')).toBeNull(); From 78fa93f7c6c088143fc02c71b16aa8f90d558ea9 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Tue, 16 Apr 2024 12:47:45 -0400 Subject: [PATCH 32/33] Dependency updates --- package-lock.json | 16 ++++++++-------- package.json | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index e265dd3d6..fd21a9aac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,8 +53,8 @@ "@testing-library/react": "^15.0.2", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.12", - "@types/qs": "^6.9.14", - "@types/react": "^18.2.78", + "@types/qs": "^6.9.15", + "@types/react": "^18.2.79", "@types/react-dom": "^18.2.25", "@types/react-redux": "^7.1.33", "@types/react-router-dom": "^5.3.3", @@ -4185,9 +4185,9 @@ "integrity": "sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==" }, "node_modules/@types/qs": { - "version": "6.9.14", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.14.tgz", - "integrity": "sha512-5khscbd3SwWMhFqylJBLQ0zIu7c1K6Vz0uBIt915BI3zV0q1nfjRQD3RqSBcPaO6PHEF4ov/t9y89fSiyThlPA==", + "version": "6.9.15", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.15.tgz", + "integrity": "sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==", "dev": true }, "node_modules/@types/range-parser": { @@ -4197,9 +4197,9 @@ "dev": true }, "node_modules/@types/react": { - "version": "18.2.78", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.78.tgz", - "integrity": "sha512-qOwdPnnitQY4xKlKayt42q5W5UQrSHjgoXNVEtxeqdITJ99k4VXJOP3vt8Rkm9HmgJpH50UNU+rlqfkfWOqp0A==", + "version": "18.2.79", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.79.tgz", + "integrity": "sha512-RwGAGXPl9kSXwdNTafkOEuFrTBD5SA2B3iEB96xi8+xu5ddUa/cpvyVCSNn+asgLCTHkb5ZxN8gbuibYJi4s1w==", "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" diff --git a/package.json b/package.json index ddf294ae7..1ce3b0f7d 100644 --- a/package.json +++ b/package.json @@ -93,8 +93,8 @@ "@testing-library/react": "^15.0.2", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.12", - "@types/qs": "^6.9.14", - "@types/react": "^18.2.78", + "@types/qs": "^6.9.15", + "@types/react": "^18.2.79", "@types/react-dom": "^18.2.25", "@types/react-redux": "^7.1.33", "@types/react-router-dom": "^5.3.3", From 54118196d8ee2714c8d0d1674c231f34ec6a7468 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Tue, 16 Apr 2024 13:35:47 -0400 Subject: [PATCH 33/33] The jest-workaround plugin was renamed as swc_mut_cjs_exports --- jest.config.js | 2 +- package-lock.json | 112 +++++++++++++++++++++++----------------------- package.json | 4 +- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/jest.config.js b/jest.config.js index 2522c7929..5f3bf5314 100644 --- a/jest.config.js +++ b/jest.config.js @@ -30,7 +30,7 @@ module.exports = { $schema: 'http://json.schemastore.org/swcrc', jsc: { experimental: { - plugins: [['jest_workaround', {}]], + plugins: [['swc_mut_cjs_exports', {}]], }, parser: { jsx: true, diff --git a/package-lock.json b/package-lock.json index fd21a9aac..ce55ef877 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "@redhat-cloud-services/eslint-config-redhat-cloud-services": "^2.0.4", "@redhat-cloud-services/frontend-components-config": "^6.0.12", "@redhat-cloud-services/tsc-transform-imports": "^1.0.9", - "@swc/core": "1.3.105", + "@swc/core": "^1.4.14", "@swc/jest": "^0.2.36", "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^15.0.2", @@ -76,7 +76,6 @@ "git-revision-webpack-plugin": "^5.0.0", "identity-obj-proxy": "^3.0.0", "jest": "^29.7.0", - "jest_workaround": "^0.79.19", "jest-environment-jsdom": "^29.7.0", "jest-mock-axios": "^4.7.3", "jest-transform-stub": "^2.0.0", @@ -84,6 +83,7 @@ "npm-run-all": "^4.1.5", "prettier": "^3.2.5", "rimraf": "^5.0.5", + "swc_mut_cjs_exports": "^0.90.24", "ts-jest": "^29.1.2", "ts-patch": "^3.1.2", "typescript": "^5.4.5", @@ -3198,13 +3198,13 @@ } }, "node_modules/@swc/core": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.105.tgz", - "integrity": "sha512-me2VZyr3OjqRpFrYQJJYy7x/zbFSl9nt+MAGnIcBtjDsN00iTVqEaKxBjPBFQV9BDAgPz2SRWes/DhhVm5SmMw==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.4.14.tgz", + "integrity": "sha512-tHXg6OxboUsqa/L7DpsCcFnxhLkqN/ht5pCwav1HnvfthbiNIJypr86rNx4cUnQDJepETviSqBTIjxa7pSpGDQ==", "dev": true, "hasInstallScript": true, "dependencies": { - "@swc/counter": "^0.1.1", + "@swc/counter": "^0.1.2", "@swc/types": "^0.1.5" }, "engines": { @@ -3215,16 +3215,16 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.3.105", - "@swc/core-darwin-x64": "1.3.105", - "@swc/core-linux-arm-gnueabihf": "1.3.105", - "@swc/core-linux-arm64-gnu": "1.3.105", - "@swc/core-linux-arm64-musl": "1.3.105", - "@swc/core-linux-x64-gnu": "1.3.105", - "@swc/core-linux-x64-musl": "1.3.105", - "@swc/core-win32-arm64-msvc": "1.3.105", - "@swc/core-win32-ia32-msvc": "1.3.105", - "@swc/core-win32-x64-msvc": "1.3.105" + "@swc/core-darwin-arm64": "1.4.14", + "@swc/core-darwin-x64": "1.4.14", + "@swc/core-linux-arm-gnueabihf": "1.4.14", + "@swc/core-linux-arm64-gnu": "1.4.14", + "@swc/core-linux-arm64-musl": "1.4.14", + "@swc/core-linux-x64-gnu": "1.4.14", + "@swc/core-linux-x64-musl": "1.4.14", + "@swc/core-win32-arm64-msvc": "1.4.14", + "@swc/core-win32-ia32-msvc": "1.4.14", + "@swc/core-win32-x64-msvc": "1.4.14" }, "peerDependencies": { "@swc/helpers": "^0.5.0" @@ -3236,9 +3236,9 @@ } }, "node_modules/@swc/core-darwin-arm64": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.105.tgz", - "integrity": "sha512-buWeweLVDXXmcnfIemH4PGnpjwsDTUGitnPchdftb0u1FU8zSSP/lw/pUCBDG/XvWAp7c/aFxgN4CyG0j7eayA==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.4.14.tgz", + "integrity": "sha512-8iPfLhYNspBl836YYsfv6ErXwDUqJ7IMieddV3Ey/t/97JAEAdNDUdtTKDtbyP0j/Ebyqyn+fKcqwSq7rAof0g==", "cpu": [ "arm64" ], @@ -3252,9 +3252,9 @@ } }, "node_modules/@swc/core-darwin-x64": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.105.tgz", - "integrity": "sha512-hFmXPApqjA/8sy/9NpljHVaKi1OvL9QkJ2MbbTCCbJERuHMpMUeMBUWipHRfepGHFhU+9B9zkEup/qJaJR4XIg==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.4.14.tgz", + "integrity": "sha512-9CqSj8uRZ92cnlgAlVaWMaJJBdxtNvCzJxaGj5KuIseeG6Q0l1g+qk8JcU7h9dAsH9saHTNwNFBVGKQo0W0ujg==", "cpu": [ "x64" ], @@ -3268,9 +3268,9 @@ } }, "node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.105.tgz", - "integrity": "sha512-mwXyMC41oMKkKrPpL8uJpOxw7fyfQoVtIw3Y5p0Blabk+espNYqix0E8VymHdRKuLmM//z5wVmMsuHdGBHvZeg==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.4.14.tgz", + "integrity": "sha512-mfd5JArPITTzMjcezH4DwMw+BdjBV1y25Khp8itEIpdih9ei+fvxOOrDYTN08b466NuE2dF2XuhKtRLA7fXArQ==", "cpu": [ "arm" ], @@ -3284,9 +3284,9 @@ } }, "node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.105.tgz", - "integrity": "sha512-H7yEIVydnUtqBSUxwmO6vpIQn7j+Rr0DF6ZOORPyd/SFzQJK9cJRtmJQ3ZMzlJ1Bb+1gr3MvjgLEnmyCYEm2Hg==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.4.14.tgz", + "integrity": "sha512-3Lqlhlmy8MVRS9xTShMaPAp0oyUt0KFhDs4ixJsjdxKecE0NJSV/MInuDmrkij1C8/RQ2wySRlV9np5jK86oWw==", "cpu": [ "arm64" ], @@ -3300,9 +3300,9 @@ } }, "node_modules/@swc/core-linux-arm64-musl": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.105.tgz", - "integrity": "sha512-Jg7RTFT3pGFdGt5elPV6oDkinRy7q9cXpenjXnJnM2uvx3jOwnsAhexPyCDHom8SHL0j+9kaLLC66T3Gz1E4UA==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.4.14.tgz", + "integrity": "sha512-n0YoCa64TUcJrbcXIHIHDWQjdUPdaXeMHNEu7yyBtOpm01oMGTKP3frsUXIABLBmAVWtKvqit4/W1KVKn5gJzg==", "cpu": [ "arm64" ], @@ -3316,9 +3316,9 @@ } }, "node_modules/@swc/core-linux-x64-gnu": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.105.tgz", - "integrity": "sha512-DJghplpyusAmp1X5pW/y93MmS/u83Sx5GrpJxI6KLPa82+NItTgMcl8KBQmW5GYAJpVKZyaIvBanS5TdR8aN2w==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.4.14.tgz", + "integrity": "sha512-CGmlwLWbfG1dB4jZBJnp2IWlK5xBMNLjN7AR5kKA3sEpionoccEnChOEvfux1UdVJQjLRKuHNV9yGyqGBTpxfQ==", "cpu": [ "x64" ], @@ -3332,9 +3332,9 @@ } }, "node_modules/@swc/core-linux-x64-musl": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.105.tgz", - "integrity": "sha512-wD5jL2dZH/5nPNssBo6jhOvkI0lmWnVR4vnOXWjuXgjq1S0AJpO5jdre/6pYLmf26hft3M42bteDnjR4AAZ38w==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.4.14.tgz", + "integrity": "sha512-xq4npk8YKYmNwmr8fbvF2KP3kUVdZYfXZMQnW425gP3/sn+yFQO8Nd0bGH40vOVQn41kEesSe0Z5O/JDor2TgQ==", "cpu": [ "x64" ], @@ -3348,9 +3348,9 @@ } }, "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.105.tgz", - "integrity": "sha512-UqJtwILUHRw2+3UTPnRkZrzM/bGdQtbR4UFdp79mZQYfryeOUVNg7aJj/bWUTkKtLiZ3o+FBNrM/x2X1mJX5bA==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.4.14.tgz", + "integrity": "sha512-imq0X+gU9uUe6FqzOQot5gpKoaC00aCUiN58NOzwp0QXEupn8CDuZpdBN93HiZswfLruu5jA1tsc15x6v9p0Yg==", "cpu": [ "arm64" ], @@ -3364,9 +3364,9 @@ } }, "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.105.tgz", - "integrity": "sha512-Z95C6vZgBEJ1snidYyjVKnVWiy/ZpPiIFIXGWkDr4ZyBgL3eZX12M6LzZ+NApHKffrbO4enbFyFomueBQgS2oA==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.4.14.tgz", + "integrity": "sha512-cH6QpXMw5D3t+lpx6SkErHrxN0yFzmQ0lgNAJxoDRiaAdDbqA6Col8UqUJwUS++Ul6aCWgNhCdiEYehPaoyDPA==", "cpu": [ "ia32" ], @@ -3380,9 +3380,9 @@ } }, "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.3.105", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.105.tgz", - "integrity": "sha512-3J8fkyDPFsS3mszuYUY4Wfk7/B2oio9qXUwF3DzOs2MK+XgdyMLIptIxL7gdfitXJBH8k39uVjrIw1JGJDjyFA==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.4.14.tgz", + "integrity": "sha512-FmZ4Tby4wW65K/36BKzmuu7mlq7cW5XOxzvufaSNVvQ5PN4OodAlqPjToe029oma4Av+ykJiif64scMttyNAzg==", "cpu": [ "x64" ], @@ -13318,16 +13318,6 @@ } } }, - "node_modules/jest_workaround": { - "version": "0.79.19", - "resolved": "https://registry.npmjs.org/jest_workaround/-/jest_workaround-0.79.19.tgz", - "integrity": "sha512-g/MtKSwyb4Ohnd5GHeJaduTgznkyst81x+eUBGOSGK7f8doWuRMPpt6XM/13sM2jLB2QNzT/7Djj7o2PhsozIA==", - "dev": true, - "peerDependencies": { - "@swc/core": "^1.3.68", - "@swc/jest": "^0.2.26" - } - }, "node_modules/jest-changed-files": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.7.0.tgz", @@ -19757,6 +19747,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/swc_mut_cjs_exports": { + "version": "0.90.24", + "resolved": "https://registry.npmjs.org/swc_mut_cjs_exports/-/swc_mut_cjs_exports-0.90.24.tgz", + "integrity": "sha512-8OBb1kaouRrpB42XFD7q7KGEaGxnGsEqxIFaUiCFp9w4pCy4rzzrpntlX3nZDhdAKnk4bLL6K979DUKRaBaBRg==", + "dev": true, + "peerDependencies": { + "@swc/core": "^1.4.0", + "@swc/jest": "^0.2.36" + } + }, "node_modules/swc-loader": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/swc-loader/-/swc-loader-0.2.6.tgz", diff --git a/package.json b/package.json index 1ce3b0f7d..0c0bc932e 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "@redhat-cloud-services/eslint-config-redhat-cloud-services": "^2.0.4", "@redhat-cloud-services/frontend-components-config": "^6.0.12", "@redhat-cloud-services/tsc-transform-imports": "^1.0.9", - "@swc/core": "1.3.105", + "@swc/core": "^1.4.14", "@swc/jest": "^0.2.36", "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^15.0.2", @@ -117,13 +117,13 @@ "identity-obj-proxy": "^3.0.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", - "jest_workaround": "^0.79.19", "jest-mock-axios": "^4.7.3", "jest-transform-stub": "^2.0.0", "jws": "^4.0.0", "npm-run-all": "^4.1.5", "prettier": "^3.2.5", "rimraf": "^5.0.5", + "swc_mut_cjs_exports": "^0.90.24", "ts-jest": "^29.1.2", "ts-patch": "^3.1.2", "typescript": "^5.4.5",