Commit graph

208 commits

Author SHA1 Message Date
lucasgarfield
d7bfb8efef Tests: Fix flake in recreate image tests
The getBy selector in this test caused tests to flake in CI, changing to
findBy should prevent flakes.
2023-11-16 16:25:52 +01:00
Sanne Raymaekers
f1141ec698 src: add RHEL 8.9 2023-11-16 14:44:21 +01:00
Thomas Lavocat
c7ffde49ae wizard/tests: add integration and unit tests
Add integration and unit tests for the wizard. The integration testing
is making sure that the wizard holds up together, is navigable and has
at least a happy path tested.
The unit test of the ImageOuput tests more combinations of clicks on the
interface and make sure the inner logic is sound.

The intersection of the two tests brings us confidence that the UX will
work according to spec.
2023-11-14 09:33:36 +01:00
mgold1234
303e557f07 fix linting warnings
this commit fix some linting warnings that user get when running npm run lint:js:fix command,
some worning comes after big changes to TypeScript
2023-11-13 16:00:01 +01:00
regexowl
d3eaccc636 test: Fix "Unnecessary escape character" error
This fixes an error triggered by the no-useless-escape rule.
2023-11-08 14:15:17 +01:00
regexowl
7b0b9a8ddc test: Fix await-async-events error
After cleaning up the ESLint plugins a new error for eslint-plugin-testing-library popped up. This PR solves all of the occurences of `Promise returned from async event method `user` must be handled` and removes the `"testing-library/await-async-events": "off"` switch which was temporary put in place.
2023-11-08 14:15:17 +01:00
Thomas Lavocat
7a22d623e8 tests: add a unit test for the targetEnv
This new test is complementing the integration testing found in
src/test/Components/CreateImageWizars.*.test.js.

This new test makes sure that the logic within the component itself is
sound without taking care of interacting with other parts of the wizard.
It allows to test more combinations without worrying about combinatory
effects.

Refs HMS-1135
2023-10-26 20:07:54 +02:00
Thomas Lavocat
e2c3ea98b3 tests: there's now two option-menu to select from
Adding a new select into the images output step had for effet to
mechanically add a new option menu. In order to select the release
menu we have to take now the first option menu of all possibilities.

Refs HMS-1135
2023-10-26 20:07:54 +02:00
Thomas Lavocat
826882d1ef tests: adapt to target appearing dynamically
There is now a delay between when the user clicks on the architecture
button (or just goes onto the step) and when the targets are being
displayed. This is due to the fact that the data to filter which targets
needs to be displayed has to be fetched from the backend. And during the
meantime a loading spinner is shown.

To adapt to this the code simply waits for the fields to be accessible.

Refs HMS-1135
2023-10-26 20:07:54 +02:00
jkozol
4e3e154f08 test: add awaits to user click in table's error test 2023-10-25 09:02:47 +02:00
jkozol
cf1d477544 ShareImageModal: update the typeahead selector to pf5
This dropdown needed to be update as part of the overall pf5 upgrade.
Each of the components in the select now need to be declared and
handled. Also, some of the Select and SelectOption props come from the
Menu props since Select inherits Menu.
2023-10-25 09:02:47 +02:00
jkozol
a5b1b1f775 package.json: upgrade patternfly to version 5
This upgrade requires multiple package updates. There are many style
updates to reflect pf5's syntax and structure changes
2023-10-25 09:02:47 +02:00
lucasgarfield
c4d411efa4 Wizard: Improve in-page wizard cosmetically
This commit:
1. Removes the header from the Data Driven Forms wizard
2. Adds padding around the in-page wizard so it is visually consistent
   with the images table
3. Refactors the images table header into a re-usable component that is
   now used in both the images table and the wizard
4. Allows the repositories table to fill the available vertical space in
   the wizard
5. Adjusts the package dual list selectors so that they fill the
   available horizontal space in the wizard
2023-10-20 15:51:03 +02:00
Thomas Lavocat
1c1290f7ed oscap: a policy isn't a profile
There was a mixup on our side between what is a profile and what is a
policy. Long story short, a policy a super set of rules including a
profile. For now the wizard is only able to apply profiles and no
policies on images. So let's fix the terminology there.
2023-10-20 10:46:02 +02:00
Thomas Lavocat
d60c6cb74b oscap: lock the wizard step behind a feature flag
The oscap feature have been quite eagerly pushed forward and it seems we
went a bit fast with it. To take more time and make sure all the
stakeholders agree on the way forward the decision was taken to put this
functionality behind a feature flag.

The two feature flags for both stage and prod are there:
* https://insights-stage.unleash.devshift.net/projects/default/features/image-builder.wizard.oscap.enabled (enabled on stage so we can test the feature)
* https://insights.unleash.devshift.net/projects/default/features/image-builder.wizard.oscap.enabled (disabled on prod)
2023-10-19 10:00:44 +02:00
Sanne Raymaekers
d706a7e5e2 ImagesTable: show error popover on s3 images
The error popover should be shown in case there's a reason for the
error. This is already the case for the other image types.
2023-10-12 15:24:55 +02:00
regexowl
51ad859747 test: Improve stability of the ImagesTable tests
This should help with tests flaking on the `act()` error.
2023-10-10 15:30:39 +02:00
Thomas Lavocat
cbe710e75e wizard: don't show the form as a modal
When the user clicks on the "create an image" button, the image wizard
shows up replacing the landing page. This allows to keep the quickstart
guides to the right of the wizard while the user is interacting with it.
2023-10-09 11:40:40 +02:00
Thomas Lavocat
382b0195da test: new set of tests for the compliance step
The compliance step is now tested with two new tests:
- One to test that upon creation, if a user selects a profile, then the
  customizations are applied to the file system and package steps
- One to test that upon recreation, the file system and packages
  customizations are still present.

HMS-2077
2023-10-06 16:26:09 +02:00
Adi Abramovich
a890dc5666 wizard: add GCP image sharing options
Adding GCP image sharing option according to the discussion on slack(https://redhat-internal.slack.com/archives/C03AZ0264LW/p1692789579814619) and mocks(https://issues.redhat.com/browse/HMS-2352).

In summary, within our GCP sources, we store the project ID. Images cannot be shared directly with a project ID, but they can be shared with a service account or a Google account. Consequently, to launch instances in GCP, users are not required to provide their Google account; instead, the images should be shared with the provisioning service account. This ensures that the provisioning team has access to the necessary images, as sharing them with individual users would not allow that.

After a thorough discussion, we have collectively decided to introduce an option. This option allows users to exclusively utilize the Launch service without the need to share the image with a Google account.
2023-09-27 13:53:36 +02:00
Thomas Lavocat
543d4e95d3 edge: setup an unleash toggle for the image table
The edge images table is going to be integrated in the frontend code
base in the coming weeks. To help smooth that development process there
is need for a feature flag that would keep the current behavior running
on stage and prod while the new image table is being developed.

For now dummy code is returned for when the flag is on, and legacy
behavior keeps on going when the flag is off.

The stage flag can be seen there:
- https://insights-stage.unleash.devshift.net/projects/default/features/image-builder.edge.local-image-table

The prod flag can be seen there:
- https://insights.unleash.devshift.net/projects/default/features/image-builder.edge.local-image-table

The commit brings in some documentation in the Readme. Any member of
the team should be able to follow these steps to add in new feature
flags and use them in the code base.

The commit also brings in two new testing files for the future
components to come. For now these tests only check that the mocking
value for the unleash flag is properly set.
2023-09-18 13:35:37 +02:00
lucasgarfield
7b9e726151 ImagesTable: Convert ImagesTable to Typescript & RTK Query
This commit converts the Images Table to Typescript and converts all API
calls to image-builder to use RTK Query hooks.

This should increase the performance of the app significantly.
Previously our calls to the image-builder API were made in series. They
are now made in parallel. We may want to investigate the possibility of
hitting rate limiting now that we will be issuing requests in much more
rapid succession.

In the tests, moving to RTK Query hooks has allowed us to remove
virtually all Jest mocking. However, this means that some of our
previous tests which tested against implementation details were broken.
Most notably, we no longer check the Redux store to verify that clones
have been added correctly and we no longer check that compose requests
were issued successfully. Test coverage will be restored in a follow-up
PR where the dev-dependency @msw/data is added. Adding a persistent data
layer to the tests using @msw/data will allow us to verify that our POST
requests (creating composes and cloning them) are working by testing
that the Images Table has been updated.
2023-09-18 10:35:04 +02:00
regexowl
9f5a0af826 Wizard: Update the Repositories step
This updates the Repositories and Review step as per [mocks](https://www.sketch.com/s/d7aa6d29-fca0-4283-a846-09cc5fd10612/a/MyEbDz7).

Repositories with the unavailable or invalid status have a popover that allows for further inspection. The time of the last introspection and the counter of failed attempts was added to the popover, together with the "Go to Repositories" button.

On Recreate the payload repositories are checked against "freshly" fetched list of repositories. In case any of the previously checked repositories is no longer available in content sources an Alert is rendered on both Repositories and Review steps. The unavailable repository is checked, but the checkbox is disabled and the information is dashed out. Since the information about the repository is stored in the Repository type, the only information available to be rendered is the baseurl.

Create image button is also disabled when recreating an image with unavailable repositories.
2023-09-11 10:30:04 +02:00
regexowl
ff0eb304bf test: Safeguard first setUp() in .test and .azure against early exit
The "Step Image output - clicking Next loads Upload to AWS" and "Step Upload to Azure - clicking Next loads Registration" were sometimes returning the "Warning: An update to <element> inside a test was not wrapped in act(...)" error.

This seems to have been caused by an early exit in the `setUp()` function in the first `describe` block.
Safeguards were put in place to fix this behaviour.

As this error didn't occur every time, testing the updates was not easy. This current fix passed the threshold of ten successful runs of `npm run test`.
2023-08-30 16:01:02 +02:00
regexowl
38e2852734 test: Fix problem with mocked server.use calls
Test `component renders error state correctly` was outputting errors for both AWS and Azure tests.
This was caused by calling `server.use()` after the wizard was already rendered.

Fixed by moving the one time server mock response to the very beginning of the unit test. Also added `server.resetHandlers()` to be run after each of the unit tests.

Thanks to this fix, azure tests could be merged again. Which means no more splitting into `CreateImageWizard.azure.test.js` and `CreateImageWizard.azure.2.test.js`
2023-08-30 16:01:02 +02:00
regexowl
e71d98da08 test: Update CreateImageWizard tests
This updates following test suites after bumping react and testing-library:
- CreateImageWizard.azure.test.js
- CreateImageWizard.azure.2.test.js
- CreateImageWizard.content.test.js
- CreateImageWizard.test.js
2023-08-30 16:01:02 +02:00
regexowl
31859822e9 test: Update ImagesTable tests
This updates ImagesTable.test.js after bumping react and testing-library.
2023-08-30 16:01:02 +02:00
regexowl
ecb33431c4 test: Update ShareImageModal tests
This updates ShareImageModal.test.js after bumping react and testing-library.
2023-08-30 16:01:02 +02:00
regexowl
90a012d49b HMS-1492: Change rhc to non-capitalized
Fixes HMS-1492

This changes all occurences of "rhc" and "remote host configuration" from capitalized to lowercase.
In cases where the sentence started with "rhc" this was changed to "remote host configuration" to avoid
starting the sentence with "Rhc".
2023-08-29 12:36:38 +02:00
Ondrej Ezr
8b796ef431 Switch to Content Sources search
Enable searching for RH packages through Content Sources service.
Gates the search by Content Sources feature flag, to keep the easy kill switch.
2023-08-24 14:41:16 +02:00
Ondrej Ezr
b486f44dcb Custom Repositories gate by Feature flag 2023-08-23 15:38:25 +02:00
regexowl
77ff00d107 lint: Fix the "Expected a default case" warning
This fixes the "Expected a default case" warning
2023-08-23 14:54:23 +02:00
Ondrej Ezr
2a8e5a10df Launch button in stable environments
This moves Beta only features to stable environment:
- Sharing Images through Sources
- Launch button

This tries to avoid any refactoring, just moving components from Beta to stable with minimal changes.
2023-08-23 09:27:25 +02:00
Thomas Lavocat
8ab31edbe9 eslint/expect: uneffective tests
Correct the tests that were not testing the result. And set the values
to a functioning one.
2023-08-17 17:18:55 +02:00
Thomas Lavocat
3b8afeaf7d eslint/excpect: should not be called conditionally
This commit fixes the error but not really the pattern. We should
consider refactoring the tests following these guidelines:
https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-conditional-expect.md
2023-08-17 17:18:55 +02:00
regexowl
8fbad0d99b test/fixtures: Migrate some fixtures to TypeScript
This migrates following fixtures to TypeScript:
- architectures
- customizations
- sources

Typing and explicit returns were added.

The extensions of `composes` and `packages` fixtures were also updated from .tsx to .ts
2023-08-16 13:39:16 +02:00
Thomas Lavocat
697d0af4b5 test/wizard/azure: avoid scalprum errors
Avoid having to deal with scalprum errors by not rendering the
LandingPage.
2023-08-09 16:03:00 +02:00
Thomas Lavocat
baefa79bb8 tests/wizard/azure: separate tests
A weird error occurs because when the tests are executing together. To
avoid that, as a temporary measure, separate the last test in a separate
file to ensure insolation from its peers.
2023-08-09 16:03:00 +02:00
Thomas Lavocat
6b1ae7d1d8 test/wizard/beta: avoid scalprum errors
Avoid having to deal with scalprum errors by not rendering the
LandingPage.
2023-08-09 16:03:00 +02:00
Thomas Lavocat
71126b1d26 test/wizard/beta: fix act errors
Brute force approach to fix the act errors in the Wizard tests. It's not
ideal but allows to move on toward activating strict mode on the test
suite ASAP
2023-08-09 16:03:00 +02:00
Thomas Lavocat
62bca76627 test/wizard: avoid scalprum errors
Avoid having to deal with scalprum errors by not rendering the
LandingPage.
2023-08-09 16:03:00 +02:00
Thomas Lavocat
dd54af2c7b test/wizard: fix act errors
Brute force approach to fix the act errors in the Wizard tests. It's not
ideal but allows to move on toward activating strict mode on the test
suite ASAP.
2023-08-09 16:03:00 +02:00
Thomas Lavocat
2b051823bf test/ShareImageModal: use act when accessing the UI
Errors were fired upon while testing the ShareImageModal because some
clicks on the UI were not encapsulated in an act block. This is now
patched up.
2023-08-09 16:03:00 +02:00
Thomas Lavocat
8144aaa76d test/ShareImageModal: only render the modal
Before, the LandingPage was not properly rendering because
EdgeImagesTable has a dependency to Scalprum. Scalprum is a service that
is provided by Insight that enables up to access shared components.
However scalprum wasn't getting initialized properly during the
execution of the unit tests making the entire LandingPage not rendering.

There are ways to mock scalprum but this commit takes another decision
to fix the issue. Instead of having a test environment rendering the
LandingPage and the Wizard to test the ShareImageModal, the rendering is
tailored to ShareImageModal needs, which only contains the rendering of
that said module + static routes to avoid 404 on final redirections.

This makes the scalprum errors go without hurting the coverage of the
tests.
2023-08-09 16:03:00 +02:00
regexowl
5b516a5270 test/fixtures: Update timestamps of mock composes
The format of the timestamps of mock composes was causing an error in msw browser after merging https://github.com/RedHatInsights/image-builder-frontend/pull/1137

This updates the mock timestamps to the format of the actual ones fetched from the API.
2023-08-07 14:36:19 +02:00
regexowl
608ca157eb test/fixtures: Update compose fixture and migrate it to TypeScript
This adds `request` to a reponse from the `composes/{composeId}` endpoint and `meta` to a response from the `/composes/{composeId}/clones` endpoint as per API documentation.

The incomplete responses were causing problems when fetching data from the endpoints mentioned above.

The fixture was also migrated to TypeScript.
2023-08-07 10:20:44 +02:00
regexowl
e2ffc1705c test/fixtures: Migrate the packages fixture to TypeScript
This migrates the `packages` fixture to TypeScript and adds needed types to `index.ts`
2023-08-07 10:01:40 +02:00
regexowl
857257591c Wizard: Disable non-valid repositories and add a Status column
This disables adding of repositories that do not have 'Valid' status.

Status column was also added to the Repositories table to make the reason why the checkbox is disabled visible.
2023-08-02 15:40:57 +02:00
regexowl
1456861e63 test: Move button clicking functions to testUtils
This moves the `clickBack`, `clickCancel`, `clickNext`, `getNextButton` and `verifyCancelButton` functions from the tests to `testUtils`.
2023-08-01 13:32:20 +02:00
lucasgarfield
702b667dc5 API: Add programatically generated Provisioning API slice definitions
These definitions were generated using the RTKQ code generation tool and
will replace the existing definitions.
2023-07-28 15:05:08 +02:00