Commit graph

141 commits

Author SHA1 Message Date
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
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
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
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
mgold1234
7cb3f2d0b6 Wizard: add description field to Details steps 2023-07-28 12:24:25 +02:00
mgold1234
ca2f2f7ba3 Wizard: change the image name
fixes #1196
this commit update the wording on image name step
when user create new image.
2023-07-17 17:05:03 +02:00
regexowl
c4f616763d Wizard: Image name validation
This adds validation of an image name based on a pattern, which was chosen as an intersection of the naming constrains of hyperscalers.

The pattern is based on the one for naming GCP images as those naming guidelines are the most restrictive. With added minimal length restriction of AWS.
2023-07-11 10:39:32 +02:00
Sanne Raymaekers
f20686df4d CreateImageWizard: Add support for vsphere-ova imagetype
The OVA type is also the default when checking VMWare now.
2023-07-05 13:02:39 +02:00
lucasgarfield
0fd07f1f74 RTKQ: Add typing to RTKQ hooks in apiSlice
This commit adds typing to the RTK Query hooks. The hooks have been
refactored to be simpler and all custom query functions have been
removed.
2023-06-20 16:36:39 +02:00
regexowl
8f021105b4 test: Move mock json blobs to fixtures
This moves all mock json blobs from the Mock Service Worker handlers and component tests into one central location under `/fixtures`.
2023-05-30 10:41:51 +02:00
Sanne Raymaekers
fc63aec015 CreateImageWizard: turn off gpg check explicitly
gpgcheck is on by default, and if no gpgkey is specified dnf complains.
2023-05-12 23:07:42 +02:00
Sanne Raymaekers
d0024a8d48 src/test/CreateImageWizard: increase timeout 2023-05-09 20:12:13 +02:00
lucasgarfield
f1f544daec Wizard: Make AWS sources select scrollable in modal
There is a bug in Patternfly that causes 'pop out' selects (those that
use the menuAppendTo="parent" prop) to be rendered underneat the wizard
footer.

Until this is patched in Patternfly, we will have to live with
suboptimal select menus that scroll inside the modal.
2023-05-04 16:34:43 +02:00
lucasgarfield
383f2a6855 Wizard: Add filtering to repositories
This commit adds filtering based on architecture and version to the
repositories table in the wizard.

Apart from filtering, this commit now shows *all* repositories,
regardless of their status. Previously, invalid repositories were not
displayed. A future PR will add a status column and edge case handling
(how to handle an invalid repo, etc...). For now, invalid repos are
displayed and can be selected.

RTK Query is now used to manage the state of the repositories.
Previously, the repositories were fetched in a useEffect hook upon
opening the wizard.

MSW is now used instead of jest mocking for the tests involving
repositories. The repositories test fixture now contains a function that
mimics the content sources API.
2023-05-04 14:13:17 +02:00
Sanne Raymaekers
23d58d563d CreateImageWizard/Repositories: set custom-repositories
Embed the payload repositories into the image.
2023-05-02 14:33:53 +02:00
lucasgarfield
7bca4c7438 LandingPage/ImagesTable/Wizard: Remove all insights global calls
This commit replaces all calls to the insights.chrome global with calls
to the useChrome() hook (or the useGetEnvironment() custom hook that
wraps useChrome()).
2023-04-28 17:07:31 +02:00
lucasgarfield
b2e6e3cf04 Wizard: Use useChrome hook to set beta feature flag
The use of chrome.isBeta is deprecated, the useChrome hook should be
used instead to obtain an isBeta() function. Using the deprecrated
chrome.isBeta pollutes the browser console with warning messages.

This commit replaces the isBeta() helper function with a new custom
hook, useGetEnvironment().

We still sometimes need to know which environment is running outside of
React components, where we cannot call the useChrome() or
useGetEnvironment() hooks. For instance, in the json used to define a
wizard step. Therefore a new isBeta variable has been added to the
form's initialState for use in these cases.
2023-04-28 17:07:31 +02:00
lucasgarfield
bc1435994d Router: Modify /share and /imagewizard routing
Insights offers 'quickstarts', which can be used to provide
mini-tutorials in a sidebar.

Unfortunately, these quickstarts change our URL... they add an optional
query parameter related to the quickstart. The process of doing so
destroys our router's `location`, setting it to undefined.

We have been using the location state to store the GUID of the image,
needed when opening the wizard via the `Recreate image` action or when
opening the share modal.

As a workaround, we can simply accept that the quickstarts will change
our URL and destroy our router's location. Instead, we now put the image
id (its UUID) in the route itself. We can access it in the components as
necessary via the useParams hook.
2023-04-20 14:59:12 +02:00
Sanne Raymaekers
38dda9da67
CreateImageWizard: support verifying repository metadata (#1076) 2023-04-18 13:45:23 +02:00
regexowl
e5a9f0eaf9 Wizard: Add "refine search" warning to Packages step
Fixes #913.

This adds status bars to the `DualListSelectorPane` on the Packages step. The status bar indicates how many packages were found and how many of those have been selected.

Warning for too many returned results was also added. When an exact match is found during a search with over 100 results, it is shown together with the warning.
2023-04-14 18:27:10 +02:00
regexowl
5f99bc79cf Wizard: Migrate activation keys calls to RTK Query
This migrates calls to RHSM endpoints `activation_keys` and `/activation_keys/{name}` to RTK Query.

Tests were also updated to use Mock Service Worker instead of previous Jest mock function.
2023-04-14 16:52:47 +02:00
Ondrej Ezr
481c8759b7 test: Increase azure test timeout
The Jenkins job takes too long to execute the Azure tests.

This is a hotfix, we should rather speed up the tests.
2023-04-14 10:46:43 +02:00
Ondrej Ezr
065900c0f8 Add sources selection for Azure
Fixes HMS-1511
2023-04-13 13:32:23 +02:00
lucasgarfield
4c2a410dd7 Wizard: Expose beta features in qa environment
The QE team has requested that all beta features be exposed in the
ephemeral environment (insights.chrome.getEnvironment() === 'qa').
2023-03-28 09:26:13 +02:00
regexowl
254ba7afac Wizard: Update the Review step to have expandable sections
Fixes #919.

This updates the Review step as per proposed mocks.

The tabs were replaced by expandable sections containing all the information relevant to a specific step.
2023-03-27 10:35:17 +02:00
regexowl
f92cae1fc2 DevDeps: Bump @testing-library/user-event from 13.5.0 to 14.4.3
This bumps user-event library by a major release and resolves the breaking changes.

Direct invocation of `userEvent` APIs (such as `userEvent.click()`and `userEvent.type()`) was replaced by calling the methods returned by `userEvent.setup()` as described here:
https://testing-library.com/docs/user-event/intro
2023-03-24 15:09:51 +01:00
Sanne Raymaekers
9e6d951641 CreateImageWizard: rhc support 2023-03-08 16:45:31 +01:00
regexowl
753afa197d Wizard: Get distribution repositories from an api endpoint
Previously the base repository links for each distribution were read from `repos.js` file. This gets the needed information
from a call to api endpoint `architectures/{distribution}`. The data is fetched via RTK Query and is then filtered by an
architecture. For now the x86_64 architecture is hardcoded, this will change when multiple architectures get available.
2023-03-07 08:34:03 +01:00
lucasgarfield
5bd9756a45 Tests/Wizard: Add tests for AWS sources
This commit adds tests for the new AWS sources feature.
2023-03-01 11:25:28 +01:00
lucasgarfield
3ff80a7398 Tests/Wizard: Fix tests broken by AWS sources
This commit fixes the tests broken by adding the AWS sources feature. No
new tests have been added in this commit.
2023-03-01 11:25:28 +01:00
lucasgarfield
4000b8d5e5 ESLint: Add prefer-const rule
Require const declarations for variables that are never reassigned after
being declared. If a variable is never reassigned, using the const
declaration is better. const declaration tells readers, “this variable
is never reassigned,” reducing cognitive load and improving
maintainability.
2023-02-10 11:37:06 +01:00
Sanne Raymaekers
1fa0466676 src/test: use stage tests for prod-beta tests
Content sources is now available in prod-beta, so let's test simulating
the production env, but split on beta/non-beta.
2023-01-25 16:15:51 +01:00
regexowl
cbd6b1e4cb Wizard: Update the File system step
Fixes #911. Fixes #912.

This updates the File system step. The changes are:
- changed the toggle group for selecting the mode of partitioning to radio select and updated information for each radio button as mentioned in #911
- added information to the "automatic" option of the file system configuration as mentioned in #912
- updated information for the "manual" option of the configuration as mentioned in mocks
2023-01-19 16:07:58 +01:00