Commit graph

3 commits

Author SHA1 Message Date
lucasgarfield
d4c9534ecc V2Wizard/Details: Add request assertion tests
Adds tests to verify requets for images with names and descriptions are
formulated correctly.

Test functions shared/common to multiple steps were extracted to the
test utilities.
2024-02-15 13:10:34 +01:00
lucasgarfield
ef7582a8ff V2Wizard/Tests: Add new helper function interceptBlueprintRequest
The logic for spying on an API request has been extracted into a new
reusable helper function to make writing tests that need to perform
request assertions easier.
2024-02-15 13:10:34 +01:00
lucasgarfield
8c31e6f54f V2Wizard/Registration: Add request assertion tests
We need to start using `undefined` as the default state for when a value
has not been defined. Previously we had used things like `’’` for string
typed values. But this causes problems later when generating the request
we send to image-builder. Using `undefined` is explicit and will make
generating the requests much easier (as we don’t need to check for `’’`,
determine the intent, and convert it to undefined if necessary).
Explicit is better than implicit.

With that in mind, tests have been added to ensure that the correct
request is sent to the API for every option on the Registration step.
This is facilitated using a new `spyOnRequest()` function. In the
future, we will have similar tests for the rest of the steps.

A few other minor things:

1. We need to get the `store` using `useStore()`
for when we later call `store.getState()` because the tests use a different
store that is configured in the renderer than the one we were importing.

2. In the wizardSlice, a new type RegistrationType is added that provides
additional type safety instead of using `string`.
2024-02-14 17:01:52 +01:00