Skip to content

Commit

Permalink
feat(vrack-services): confirm create vs it
Browse files Browse the repository at this point in the history
ref: MANAGER-16104

Signed-off-by: Quentin Pavy <[email protected]>
  • Loading branch information
Quentin Pavy committed Dec 13, 2024
1 parent 4872b4f commit 086e32a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 13 deletions.
10 changes: 5 additions & 5 deletions packages/manager/apps/vrack-services/mocks/vrack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const getVrackMocks = ({
{
url: '/vrack/:id/task/:taskId',
response: vrackTaskKo ? { message: 'Task error' } : {},
status: vrackTaskKo ? 500 : 404,
status: vrackTaskKo ? 400 : 404,
api: 'v6',
},
{
Expand All @@ -35,7 +35,7 @@ export const getVrackMocks = ({
function: '',
id: 123456,
},
status: dissociateKo ? 500 : 200,
status: dissociateKo ? 400 : 200,
api: 'v6',
method: 'delete',
},
Expand All @@ -47,7 +47,7 @@ export const getVrackMocks = ({
}
: getAllowedServicesResponse(nbEligibleVrackServices),
api: 'v6',
status: getVrackEligibleServicesKo ? 500 : 200,
status: getVrackEligibleServicesKo ? 400 : 200,
},
{
url: '/vrack/:id/vrackServices',
Expand All @@ -60,7 +60,7 @@ export const getVrackMocks = ({
id: 123456,
},
method: 'post',
status: associationKo ? 500 : 200,
status: associationKo ? 400 : 200,
api: 'v6',
},
{
Expand All @@ -76,6 +76,6 @@ export const getVrackMocks = ({
}
: vrackList.slice(0, nbVrack),
api: 'v6',
status: getVrackKo ? 500 : 200,
status: getVrackKo ? 400 : 200,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"modalDescriptionLine1": "Pour activer vRack Services, vous devez créer un vRack.",
"modalDescriptionLine2": "Souhaitez vous commander un vRack en parallèle de l'activation de vRack Services ?",
"modalDescriptionLine4": "Vous avez demandé la création d'un vRack lors de l'activation de vRack Services.",
"modalDescriptionLine5": "Pour finaliser l'activation de vRack Services, merci d'accepter les termes et conditions suivantes.",
"modalDescriptionLine5": "Pour finaliser l'activation de vRack Services, merci d'accepter les termes et conditions suivantes.",
"modalDescriptionLine3": "Prix du vRack : 0€",
"modalCancelButtonLabel": "Annuler",
"modalConfirmVrackButtonLabel": "Oui",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {
assertTextVisibility,
getButtonByLabel,
} from '@ovh-ux/manager-core-test-utils';
import { screen, waitFor, act } from '@testing-library/react';
import { screen, waitFor, act, fireEvent } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { labels, renderTest } from '../../test-utils';
import { assertModalTitle, labels, renderTest } from '../../test-utils';
import { urls } from '@/routes/routes.constants';

describe('Vrack Services create page test suite', () => {
it('should display the create form with regions', async () => {
Expand All @@ -35,9 +36,7 @@ describe('Vrack Services create page test suite', () => {
return regionRadioInput;
});

await act(() => {
user.click(regionRadio);
});
await waitFor(() => user.click(regionRadio));

await waitFor(() => {
expect(regionRadio.closest('osds-radio')).toHaveAttribute('checked');
Expand All @@ -53,8 +52,8 @@ describe('Vrack Services create page test suite', () => {
user.click(submitButton);
});

assertModalVisibility({ container, isVisible: true });
assertModalText({ container, text: labels.create.modalHeadline });
await assertModalVisibility({ container, isVisible: true });
await assertModalTitle({ container, title: labels.create.modalHeadline });
});

it('should redirect to listing page if user has no right to order vrs', async () => {
Expand All @@ -71,4 +70,61 @@ describe('Vrack Services create page test suite', () => {

await assertTextVisibility(labels.listing.listingDescription);
});

it('should display create with vRack', async () => {
const { container } = await renderTest({
initialRoute: urls.createConfirm.replace(':region', 'eu-west-rbx'),
nbVs: 1,
});

const createvrackButton = await getButtonByLabel({
container,
label: labels.create.modalConfirmVrackButtonLabel,
});

await waitFor(() => fireEvent.click(createvrackButton));

await assertModalText({
container,
text: labels.create.modalDescriptionLine4,
});
await assertModalText({
container,
text: labels.create.modalDescriptionLine5,
});

const cancelButton = await getButtonByLabel({
container,
label: labels.create.modalCancelButtonLabel,
});

await waitFor(() => fireEvent.click(cancelButton));

await assertModalVisibility({ container, isVisible: false });
});

it('should display create without vRack', async () => {
const { container } = await renderTest({
initialRoute: urls.createConfirm.replace(':region', 'eu-west-rbx'),
nbVs: 1,
});

const createWithoutVrackButton = await getButtonByLabel({
container,
label: labels.create.modalNoVrackButtonLabel,
});

await waitFor(() => fireEvent.click(createWithoutVrackButton));

await waitFor(() => {
expect(
screen.queryByText(labels.create.modalDescriptionLine4),
).toBeNull();
});

await assertModalText({
container,
text: labels.create.modalDescriptionLine5,
});
});
});

0 comments on commit 086e32a

Please sign in to comment.