From 086e32aa09f4a322974d68f61f6227c9e64a4e93 Mon Sep 17 00:00:00 2001 From: Quentin Pavy Date: Fri, 13 Dec 2024 15:07:18 +0100 Subject: [PATCH] feat(vrack-services): confirm create vs it ref: MANAGER-16104 Signed-off-by: Quentin Pavy --- .../apps/vrack-services/mocks/vrack/index.ts | 10 +-- .../vrack-services/create/Messages_fr_FR.json | 2 +- .../create-vs/CreateVrackServices.spec.tsx | 70 +++++++++++++++++-- 3 files changed, 69 insertions(+), 13 deletions(-) diff --git a/packages/manager/apps/vrack-services/mocks/vrack/index.ts b/packages/manager/apps/vrack-services/mocks/vrack/index.ts index 2162546164c1..4f1460f8855d 100644 --- a/packages/manager/apps/vrack-services/mocks/vrack/index.ts +++ b/packages/manager/apps/vrack-services/mocks/vrack/index.ts @@ -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', }, { @@ -35,7 +35,7 @@ export const getVrackMocks = ({ function: '', id: 123456, }, - status: dissociateKo ? 500 : 200, + status: dissociateKo ? 400 : 200, api: 'v6', method: 'delete', }, @@ -47,7 +47,7 @@ export const getVrackMocks = ({ } : getAllowedServicesResponse(nbEligibleVrackServices), api: 'v6', - status: getVrackEligibleServicesKo ? 500 : 200, + status: getVrackEligibleServicesKo ? 400 : 200, }, { url: '/vrack/:id/vrackServices', @@ -60,7 +60,7 @@ export const getVrackMocks = ({ id: 123456, }, method: 'post', - status: associationKo ? 500 : 200, + status: associationKo ? 400 : 200, api: 'v6', }, { @@ -76,6 +76,6 @@ export const getVrackMocks = ({ } : vrackList.slice(0, nbVrack), api: 'v6', - status: getVrackKo ? 500 : 200, + status: getVrackKo ? 400 : 200, }, ]; diff --git a/packages/manager/apps/vrack-services/public/translations/vrack-services/create/Messages_fr_FR.json b/packages/manager/apps/vrack-services/public/translations/vrack-services/create/Messages_fr_FR.json index 3ec4fc198556..77cc898f7ced 100644 --- a/packages/manager/apps/vrack-services/public/translations/vrack-services/create/Messages_fr_FR.json +++ b/packages/manager/apps/vrack-services/public/translations/vrack-services/create/Messages_fr_FR.json @@ -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", diff --git a/packages/manager/apps/vrack-services/src/pages/create-vs/CreateVrackServices.spec.tsx b/packages/manager/apps/vrack-services/src/pages/create-vs/CreateVrackServices.spec.tsx index 4cce8966b91d..6d5530a28529 100644 --- a/packages/manager/apps/vrack-services/src/pages/create-vs/CreateVrackServices.spec.tsx +++ b/packages/manager/apps/vrack-services/src/pages/create-vs/CreateVrackServices.spec.tsx @@ -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 () => { @@ -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'); @@ -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 () => { @@ -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, + }); + }); });