From 2baae01b264cacd36cb9e15693e98bd5c70683fc Mon Sep 17 00:00:00 2001 From: Quentin Pavy Date: Tue, 17 Dec 2024 16:37:58 +0100 Subject: [PATCH] test(vrack-services): clean playwright files ref: MANAGER-16104 Signed-off-by: Quentin Pavy --- .../e2e/features/associate-another.feature | 38 -- .../e2e/features/associate.feature | 31 -- .../e2e/features/availability.feature | 13 - .../e2e/features/create.feature | 27 - .../e2e/features/dissociate.feature | 35 -- .../e2e/features/endpoints.feature | 57 --- .../e2e/features/listing.feature | 51 -- .../e2e/features/onboarding.feature | 19 - .../e2e/features/overview.feature | 28 -- .../e2e/features/subnet.feature | 78 --- .../e2e/step-definitions/api.step.ts | 108 ---- .../e2e/step-definitions/given.step.ts | 147 ------ .../e2e/step-definitions/navigation.step.ts | 66 --- .../e2e/step-definitions/then.step.ts | 468 ------------------ .../e2e/step-definitions/when.step.ts | 365 -------------- .../vrack-services/e2e/utils/action-menu.ts | 50 -- .../vrack-services/e2e/utils/constants.ts | 24 - .../apps/vrack-services/e2e/utils/index.tsx | 34 -- .../apps/vrack-services/e2e/utils/network.ts | 14 - .../apps/vrack-services/mocks/setup.ts | 18 - .../vrack-services/mocks/vrack/association.ts | 8 +- .../manager/apps/vrack-services/package.json | 7 +- .../apps/vrack-services/playwright.config.ts | 20 - .../manager/apps/vrack-services/src/main.tsx | 16 +- 24 files changed, 5 insertions(+), 1717 deletions(-) delete mode 100644 packages/manager/apps/vrack-services/e2e/features/associate-another.feature delete mode 100644 packages/manager/apps/vrack-services/e2e/features/associate.feature delete mode 100644 packages/manager/apps/vrack-services/e2e/features/availability.feature delete mode 100644 packages/manager/apps/vrack-services/e2e/features/create.feature delete mode 100644 packages/manager/apps/vrack-services/e2e/features/dissociate.feature delete mode 100644 packages/manager/apps/vrack-services/e2e/features/endpoints.feature delete mode 100644 packages/manager/apps/vrack-services/e2e/features/listing.feature delete mode 100644 packages/manager/apps/vrack-services/e2e/features/onboarding.feature delete mode 100644 packages/manager/apps/vrack-services/e2e/features/overview.feature delete mode 100644 packages/manager/apps/vrack-services/e2e/features/subnet.feature delete mode 100644 packages/manager/apps/vrack-services/e2e/step-definitions/api.step.ts delete mode 100644 packages/manager/apps/vrack-services/e2e/step-definitions/given.step.ts delete mode 100644 packages/manager/apps/vrack-services/e2e/step-definitions/navigation.step.ts delete mode 100644 packages/manager/apps/vrack-services/e2e/step-definitions/then.step.ts delete mode 100644 packages/manager/apps/vrack-services/e2e/step-definitions/when.step.ts delete mode 100644 packages/manager/apps/vrack-services/e2e/utils/action-menu.ts delete mode 100644 packages/manager/apps/vrack-services/e2e/utils/constants.ts delete mode 100644 packages/manager/apps/vrack-services/e2e/utils/index.tsx delete mode 100644 packages/manager/apps/vrack-services/e2e/utils/network.ts delete mode 100644 packages/manager/apps/vrack-services/mocks/setup.ts delete mode 100644 packages/manager/apps/vrack-services/playwright.config.ts diff --git a/packages/manager/apps/vrack-services/e2e/features/associate-another.feature b/packages/manager/apps/vrack-services/e2e/features/associate-another.feature deleted file mode 100644 index ba6a169985c9..000000000000 --- a/packages/manager/apps/vrack-services/e2e/features/associate-another.feature +++ /dev/null @@ -1,38 +0,0 @@ -Feature: Associate to another from overview page - - Scenario Outline: User click on action menu of private network - Given User has 20 vRack Services - Given User "" a vRack Services associated to a vRack - When User navigates to vRack Services Overview page - Then User "" the action menu with button dissociate - When User click on the private network action menu button - Then User sees button associate another - - Examples: - | hasVrack | seeActionMenu | - | has | see | - | doesn't have | doesn't see | - - Scenario Outline: User associate a vRack Services to another vRack - Given User has 20 vRack Services - Given User "has" a vRack Services associated to a vRack - Given The webservice to dissociate a vRack is - Given The service to associate a vRack Services is - Given The vRack task service is - When User navigates to vRack Services Overview page - Then User "see" the action menu with button dissociate - When User click on the private network action menu button - Then User sees button associate another - When User click on associate another in action menu of private network - Then A modal appears to associate the vRack Services to another vRack - When User select the first vRack on the associate another vRack list and confirm - Then User "" on the Overview page from associate another modal - Then User sees error message - Then User sees success message - - Examples: - | dissociateOkOrKo | associateOkOrKo | taskOkOrKo | returnOverview | anyErrorMessage | anySuccessMessage | - | ok | OK | ok | returns | no | an | - | ko | OK | ok | doesn't returns | an | no | - | ok | OK | ko | doesn't returns | an | no | - | ok | KO | ok | doesn't returns | an | no | diff --git a/packages/manager/apps/vrack-services/e2e/features/associate.feature b/packages/manager/apps/vrack-services/e2e/features/associate.feature deleted file mode 100644 index 2996be81904d..000000000000 --- a/packages/manager/apps/vrack-services/e2e/features/associate.feature +++ /dev/null @@ -1,31 +0,0 @@ -Feature: Associate a vRack to a vRack Services - - Scenario: User associate a vRack Services with eligible vRacks - Given User has 19 vRack Services - Given User has a vRack Services in DRAFT state - When User clicks on the link to associate a vRack - Then User sees a modal to select an eligible vRack - - Scenario: User has an error when associating a vRack Services - Given User has 5 vRack Services - Given User has an eligible vRacks to be associated to his vRack Services - Given The service to associate a vRack Services is KO - When User clicks on the link to associate a vRack - Then User sees a modal to select an eligible vRack - When User selects a vRack in the association list and submits the form - Then User sees an error message - - Scenario Outline: User associate a vRack Services with no eligible vRack - Given User has 19 vRack Services - Given User has a vRack Services in DRAFT state - Given User has no eligible vRacks to be associated to his vRack Services - Given User has a vRack order - When User clicks on the link to associate a vRack - Then User sees a modal to create a new vRack - Then User sees information message about the order status of his vRack - Then The button to create a vRack is - - Examples: - | orderStatus | anyInformationMessage | buttonState | - | delivering | an | disabled | - | delivered | no | enabled | diff --git a/packages/manager/apps/vrack-services/e2e/features/availability.feature b/packages/manager/apps/vrack-services/e2e/features/availability.feature deleted file mode 100644 index 9c2bd665dee3..000000000000 --- a/packages/manager/apps/vrack-services/e2e/features/availability.feature +++ /dev/null @@ -1,13 +0,0 @@ -Feature: vRack Services feature availability - - Scenario Outline: User gets redirected if vRack Services feature is not available - Given Feature availability service is - Given vRack Services feature is - When User navigates to vRack Services Listing page - Then User "" redirected to HUB - - Examples: - | apiOk | availability | isRedirected | - | ok | available | is not | - | ko | available | is | - | ok | unavailable | is | diff --git a/packages/manager/apps/vrack-services/e2e/features/create.feature b/packages/manager/apps/vrack-services/e2e/features/create.feature deleted file mode 100644 index 5d9bc99b4c41..000000000000 --- a/packages/manager/apps/vrack-services/e2e/features/create.feature +++ /dev/null @@ -1,27 +0,0 @@ -Feature: Configuration page - - Scenario Outline: User can create a vRack Services - Given User has vRack Services - When User navigates to vRack Services Listing page - Then User sees the create a vRack Services button - - Examples: - | nbVrack | buttonState | - | 0 | enabled | - | 1 | enabled | - | 5 | enabled | - | 20 | disabled | - - Scenario Outline: User wants to create a new vRack Services - Given User has 5 vRack Services - Given User wants to create a vRack Services with region - When User fills the configuration form and clicks the submit button - Then A modal appear to ask if the user wants to create a new vRack - When User - Then User "" on the Listing page - - Examples: - | region | acceptOrDenyOrCancel | returnListing | - | RBX | accepts | returns | - | BHS | denies | returns | - | LIM | cancel | doesn't return | diff --git a/packages/manager/apps/vrack-services/e2e/features/dissociate.feature b/packages/manager/apps/vrack-services/e2e/features/dissociate.feature deleted file mode 100644 index d6bee74ab2f0..000000000000 --- a/packages/manager/apps/vrack-services/e2e/features/dissociate.feature +++ /dev/null @@ -1,35 +0,0 @@ -Feature: Dissociate from overview page - - Scenario Outline: User click on action menu of private network - Given User has 20 vRack Services - Given User "" a vRack Services associated to a vRack - When User navigates to vRack Services Overview page - Then User "" the action menu with button dissociate - When User click on the private network action menu button - Then User sees button dissociate - - Examples: - | hasVrack | seeActionMenu | - | has | see | - | doesn't have | doesn't see | - - Scenario Outline: User dissociate a vRack Services from a vRack - Given User has 20 vRack Services - Given User "has" a vRack Services associated to a vRack - Given The webservice to dissociate a vRack is - When User navigates to vRack Services Overview page - Then User "see" the action menu with button dissociate - When User click on the private network action menu button - Then User sees button dissociate - When User click on dissociate in action menu of private network - Then A modal appears to ask if the user wants to dissociate the vRack - When User dissociate modal - Then User "" on the Overview page from dissociation modal - Then User sees error message - - Examples: - | okOrKo | acceptOrCancel | returnOverview | anyErrorMessage | - | ok | accept | returns | no | - | ko | accept | doesn't returns | an | - | ok | cancel | returns | no | - | ko | cancel | returns | no | diff --git a/packages/manager/apps/vrack-services/e2e/features/endpoints.feature b/packages/manager/apps/vrack-services/e2e/features/endpoints.feature deleted file mode 100644 index 5284ea792efd..000000000000 --- a/packages/manager/apps/vrack-services/e2e/features/endpoints.feature +++ /dev/null @@ -1,57 +0,0 @@ -Feature: Service Endpoints page - - Scenario Outline: User wants to see the service endpoints of a vRack Services - Given User has 21 vRack Services - Given User has a vRack Services that "" a subnet and "" an endpoint and a status READY - When User navigates to endpoints page - Then User sees the endpoints page - - Examples: - | hasSubnet | hasEndpoint | page | - | has | has | Listing | - | has | doesn't have | Onboarding | - | doesn't have | doesn't have | Onboarding | - - Scenario Outline: User can create a service endpoint - Given User has 21 vRack Services - Given User has a vRack Services that "" a subnet and "" an endpoint and a status - When User navigates to endpoints page - Then User sees the create a endpoint button - - Examples: - | hasSubnet | hasEndpoint | resourceStatus | buttonState | - | has | has | UPDATING | disabled | - | has | has | DELETING | disabled | - | has | has | ERROR | disabled | - | doesn't have | doesn't have | READY | disabled | - | has | has | READY | enabled | - | has | doesn't have | READY | enabled | - - Scenario Outline: User wants to creates a new service endpoint for his vRack Services - Given User has 21 vRack Services - Given User has a vRack Services that "has" a subnet and a status READY - Given The service to create a endpoint is - Given User is on endpoints Creation page - When User fills the endpoints form and clicks the submit button - Then User "" on the Endpoints Listing page - Then User sees error message - - Examples: - | apiOk | returnListing | anyErrorMessage | - | OK | returns | no | - | KO | doesn't return | an | - - Scenario Outline: User wants to delete an existing service endpoint - Given User has 21 vRack Services - Given User has a vRack Services that "has" a subnet and "has" an endpoint and a status READY - Given The service to delete a endpoint is - When User navigates to endpoints page - And User opens endpoints delete modal - When User fills the endpoints delete form - Then User sees error message - Then User sees success message - - Examples: - | apiOk | anyErrorMessage | anySuccessMessage | - | OK | no | an | - | KO | an | no | diff --git a/packages/manager/apps/vrack-services/e2e/features/listing.feature b/packages/manager/apps/vrack-services/e2e/features/listing.feature deleted file mode 100644 index 8d7579e6ee13..000000000000 --- a/packages/manager/apps/vrack-services/e2e/features/listing.feature +++ /dev/null @@ -1,51 +0,0 @@ -Feature: Listing page - - Scenario: User sees an empty vRack Services listing - Given User has 0 vRack Services - Given User has a vRack Services order delivering - When User navigates to vRack Services Listing page - Then User sees an information message about the order status of his vRack Services - Then User sees an empty listing page - - Scenario: User has a vRack Services and an order - Given User has 19 vRack Services - Given User has a vRack Services in DRAFT state - Given User has a vRack Services order delivering - When User navigates to vRack Services Listing page - Then User sees an information message about the order status of his vRack Services - Then User sees a data grid containing his vRack Services information - - Scenario Outline: User wants to edit a vRack Services display name - Given User has 19 vRack Services - Given User has a vRack Services in DRAFT state - Given The service to edit a vRack Services is - When User navigates to vRack Services Listing page - And User updates the display name of a vRack Services - Then User sees error message - And User sees success message - - Examples: - | apiOk | anyErrorMessage | anySuccessMessage | - | OK | no | an | - | KO | an | no | - - Scenario: User cannot modify a vRack Services in ERROR - Given User has 19 vRack Services - Given User has a vRack Services with a status ERROR - When User navigates to vRack Services Listing page - Then User sees a data grid containing his vRack Services information - Then User sees the edit and associate a vRack buttons as disabled - - Scenario Outline: User wants to delete a vRack Services - Given User has 8 vRack Services - Given User has a vRack Services with a status READY - Given The service to delete a vRack Services is - When User navigates to vRack Services Listing page - And User opens vrack-services delete modal - When User fills the vrack-services delete form - Then User sees error message - - Examples: - | apiOk | anyErrorMessage | - | OK | no | - | KO | an | diff --git a/packages/manager/apps/vrack-services/e2e/features/onboarding.feature b/packages/manager/apps/vrack-services/e2e/features/onboarding.feature deleted file mode 100644 index ea7c9e7621da..000000000000 --- a/packages/manager/apps/vrack-services/e2e/features/onboarding.feature +++ /dev/null @@ -1,19 +0,0 @@ -Feature: Onboarding page - - Scenario: User wants to find informations related to vRack Services - Given User has 0 vRack Services - When User navigates to vRack Services Listing page - Then User gets redirected to Onboarding page - Then User sees 2 guides on vRack Services - - Scenario: Users wants to create his first vRack Services - Given User has 1 vRack Services - Given User is on Onboarding page - When User clicks on the vRack Services configuration button - Then User is redirected to vRack Services Configuration page - - Scenario: Users gets redirected to the Listing page if a vRack Services is ordered - Given User has 0 vRack Services - Given User is on Onboarding page - When User orders a vRack Services - Then User is redirected to vRack Services Listing page diff --git a/packages/manager/apps/vrack-services/e2e/features/overview.feature b/packages/manager/apps/vrack-services/e2e/features/overview.feature deleted file mode 100644 index be148f5d914b..000000000000 --- a/packages/manager/apps/vrack-services/e2e/features/overview.feature +++ /dev/null @@ -1,28 +0,0 @@ -Feature: Overview page - - Scenario Outline: User wants to update his vRack Services informations - Given User has 19 vRack Services - Given User has a vRack Services with a status - When User navigates to vRack Services Overview page - Then User sees the action buttons on the overview as - - Examples: - | resourceStatus | buttonState | - | UPDATING | disabled | - | DELETING | disabled | - | ERROR | disabled | - | READY | enabled | - - Scenario Outline: User want to edit his vRack Services display name - Given User has 19 vRack Services - Given User has a vRack Services with a status READY - Given The service to edit a vRack Services is - When User navigates to vRack Services Overview page - And User updates the display name of this vRack Services from the overview - Then User sees error message - And User sees success message - - Examples: - | apiOk | anyErrorMessage | anySuccessMessage | - | OK | no | an | - | KO | an | no | diff --git a/packages/manager/apps/vrack-services/e2e/features/subnet.feature b/packages/manager/apps/vrack-services/e2e/features/subnet.feature deleted file mode 100644 index fb22baae6473..000000000000 --- a/packages/manager/apps/vrack-services/e2e/features/subnet.feature +++ /dev/null @@ -1,78 +0,0 @@ -Feature: Subnet page - - Scenario Outline: User wants to see the subnets of a vRack Services - Given User has 20 vRack Services - Given User has a vRack Services that "" a subnet and a status READY - When User navigates to subnets page - Then User sees the subnets page - - Examples: - | hasSubnet | page | - | has | Listing | - | doesn't have | Onboarding | - - Scenario Outline: User can create a subnet - Given User has 20 vRack Services - Given User has a vRack Services that "" a subnet and a status - When User navigates to subnets page - Then User sees the create a subnet button - - Examples: - | hasSubnet | resourceStatus | buttonState | - | has | UPDATING | disabled | - | has | DELETING | disabled | - | has | ERROR | disabled | - | has | READY | disabled | - | doesn't have | UPDATING | disabled | - | doesn't have | DELETING | disabled | - | doesn't have | ERROR | disabled | - | doesn't have | READY | enabled | - - Scenario Outline: User wants to create a new subnet for his vRack Services - Given User has 20 vRack Services - Given User has a vRack Services that "doesn't have" a subnet and a status READY - Given User wants to create a subnet with name "" and CIDR "" and service range "" and vlan "" - Given The service to create a subnet is - Given User is on subnets Creation page - When User fills the subnet form and clicks the submit button - Then User "" on the Subnet Listing page - Then User sees error message - - Examples: - | name | cidr | serviceRange | vlan | apiOk | returnListing | anyErrorMessage | - | | | | | OK | returns | no | - | sub-1 | | | | OK | returns | no | - | | 192.168.0.0/24 | | | OK | returns | no | - | | | 10.0.0.0/24 | | OK | returns | no | - | | | | 2 | OK | returns | no | - | sub-2 | 10.0.0.0/24 | 10.0.0.0/27 | 40 | OK | returns | no | - | | | | | KO | doesn't return | an | - - Scenario Outline: User wants to edit an existing subnet - Given User has 20 vRack Services - Given User has a vRack Services that "has" a subnet and a status READY - Given The service to edit a subnet is - When User navigates to subnets page - And User updates the configuration of his first subnet - Then User sees error message - Then User sees success message - - Examples: - | apiOk | anyErrorMessage | anySuccessMessage | - | OK | no | an | - | KO | an | no | - - Scenario Outline: User wants to delete an existing subnet - Given User has 20 vRack Services - Given User has a vRack Services that "has" a subnet and a status READY - Given The service to delete a subnet is - When User navigates to subnets page - And User opens subnets delete modal - When User fills the subnets delete form - Then User sees error message - Then User sees success message - - Examples: - | apiOk | anyErrorMessage | anySuccessMessage | - | OK | no | an | - | KO | an | no | diff --git a/packages/manager/apps/vrack-services/e2e/step-definitions/api.step.ts b/packages/manager/apps/vrack-services/e2e/step-definitions/api.step.ts deleted file mode 100644 index 29217d196eaf..000000000000 --- a/packages/manager/apps/vrack-services/e2e/step-definitions/api.step.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { Given } from '@cucumber/cucumber'; -import { ICustomWorld } from '@playwright-helpers'; -import { vsUpdateErrorMessage } from '../../mocks/vrack-services/vrack-services'; -import { servicesMockErrors } from '../../../../../manager-react-components/src/hooks/services/mocks'; -import { labels } from '../utils'; -import { ConfigParams } from '../../mocks/handlers'; -import vrackServicesList from '../../mocks/vrack-services/get-vrack-services.json'; - -Given('The vRack task service is {word}', function( - this: ICustomWorld, - okOrKo: 'ok' | 'ko', -) { - this.handlersConfig.vrackTaskKo = okOrKo === 'ko'; - this.testContext.errorMessage = labels.modalVrackAssociationError; - - const vsIndex = vrackServicesList.findIndex((v) => v.currentState.vrackId); - - this.testContext.data.vsIndex = vsIndex; - this.testContext.data.selectedVrackServices = vrackServicesList[vsIndex]; -}); - -Given('The webservice to dissociate a vRack is {word}', function( - this: ICustomWorld, - okOrKo: 'ok' | 'ko', -) { - this.handlersConfig.dissociateKo = okOrKo === 'ko'; - this.testContext.errorMessage = labels.modalDissociateError; - this.testContext.message = labels.vrackServicesDissociateSuccess; - - const vsIndex = vrackServicesList.findIndex((v) => v.currentState.vrackId); - - this.testContext.data.vsIndex = vsIndex; - this.testContext.data.selectedVrackServices = vrackServicesList[vsIndex]; -}); - -Given('The service to {word} a vRack Services is {word}', function( - this: ICustomWorld, - action: 'edit' | 'delete' | 'associate', - okOrKo: 'OK' | 'KO', -) { - const isKo = okOrKo === 'KO'; - if (action === 'edit') { - this.handlersConfig.updateServicesKo = isKo; - this.testContext.errorMessage = servicesMockErrors.update; - this.testContext.message = labels.updateVrackServicesDisplayNameSuccess; - } else if (action === 'delete') { - this.handlersConfig.deleteServicesKo = isKo; - this.testContext.errorMessage = servicesMockErrors.delete; - this.testContext.message = labels.terminateVrackServicesSuccess; - } else if (action === 'associate') { - this.handlersConfig.associationKo = isKo; - this.testContext.errorMessage = labels.modalVrackAssociationError; - this.testContext.message = labels.vrackServicesAssociateSuccess; - } -}); - -Given('The service to {word} a {word} is {word}', function( - this: ICustomWorld, - action: 'edit' | 'delete' | 'create', - tab: 'subnet' | 'endpoint', - okOrKo: 'OK' | 'KO', -) { - const errorMessageByAction = { - create: - tab === 'subnet' - ? labels.subnetCreationError - : labels.endpointCreationError, - edit: tab === 'subnet' ? vsUpdateErrorMessage : servicesMockErrors.update, - delete: vsUpdateErrorMessage, - }; - - const successMessageByAction = { - create: - tab === 'subnet' - ? labels.subnetCreationSuccess - : labels.endpointCreationSuccess, - edit: - tab === 'subnet' - ? labels.subnetUpdateSuccess - : labels.endpointUpdateDisplayNameSuccess, - delete: - tab === 'subnet' - ? labels.subnetDeleteSuccess - : labels.endpointDeleteSuccess, - }; - - this.handlersConfig.updateKo = okOrKo === 'KO'; - if (this.handlersConfig.updateKo) { - this.testContext.errorMessage = errorMessageByAction[action]; - } else { - this.testContext.message = successMessageByAction[action]; - } -}); - -Given('Feature availability service is {word}', function( - this: ICustomWorld, - okOrKo: 'ok' | 'ko', -) { - this.handlersConfig.isFeatureAvailabilityServiceKo = okOrKo === 'ko'; -}); - -Given('vRack Services feature is {word}', function( - this: ICustomWorld, - availability: 'available' | 'unavailable', -) { - this.handlersConfig.isVrackServicesFeatureUnavailable = - availability === 'unavailable'; -}); diff --git a/packages/manager/apps/vrack-services/e2e/step-definitions/given.step.ts b/packages/manager/apps/vrack-services/e2e/step-definitions/given.step.ts deleted file mode 100644 index e2fce38dea7c..000000000000 --- a/packages/manager/apps/vrack-services/e2e/step-definitions/given.step.ts +++ /dev/null @@ -1,147 +0,0 @@ -import { Given } from '@cucumber/cucumber'; -import { OrderStatus } from '@ovh-ux/manager-module-order'; -import { ICustomWorld } from '@playwright-helpers'; -import { getUrl } from '../utils'; -import { ConfigParams } from '../../mocks/handlers'; -import { ProductStatus, ResourceStatus } from '@/data'; -import vrackServicesList from '../../mocks/vrack-services/get-vrack-services.json'; - -Given('User has {word} vRack Services', function( - this: ICustomWorld, - nbVsStr: string, -) { - this.handlersConfig.nbVs = Number(nbVsStr); -}); - -Given('User wants to create a vRack Services with region {word}', function( - this: ICustomWorld, - region: string, -) { - this.testContext.data.selectedRegion = region; - this.testContext.initialUrl = getUrl('createVrackServices'); -}); - -Given('User has a vRack Services order delivering', function( - this: ICustomWorld, -) { - this.handlersConfig.deliveringVrackServicesOrders = true; -}); - -Given('User has a vRack Services in {word} state', function( - this: ICustomWorld, - productStatus: ProductStatus, -) { - const vsIndex = vrackServicesList.findIndex( - (v) => v.currentState.productStatus === productStatus, - ); - this.testContext.data.vsIndex = vsIndex; - this.testContext.data.selectedVrackServices = vrackServicesList[vsIndex]; -}); - -Given('User has a vRack Services with a status {word}', function( - this: ICustomWorld, - resourceStatus: ResourceStatus, -) { - const vsIndex = vrackServicesList.findIndex( - (v) => v.resourceStatus === resourceStatus, - ); - - this.testContext.data.vsIndex = vsIndex; - this.testContext.data.selectedVrackServices = vrackServicesList[vsIndex]; -}); - -Given( - 'User has {word} eligible vRacks to be associated to his vRack Services', - function(this: ICustomWorld, anyEligibleVrack: 'an' | 'no') { - this.handlersConfig.nbEligibleVrackServices = - anyEligibleVrack === 'an' ? 5 : 0; - }, -); - -Given('User has a vRack order {word}', function( - this: ICustomWorld, - orderStatus: OrderStatus, -) { - this.handlersConfig.deliveringVrackOrders = orderStatus === 'delivering'; -}); - -Given('User {string} a vRack Services associated to a vRack', function( - this: ICustomWorld, - hasVrack: 'has' | "doesn't have", -) { - const vsIndex = vrackServicesList.findIndex( - (v) => - (hasVrack === 'has' && v.currentState.vrackId) || - (hasVrack === "doesn't have" && !v.currentState.vrackId), - ); - this.testContext.data.vsIndex = vsIndex; - this.testContext.data.selectedVrackServices = vrackServicesList[vsIndex]; -}); - -Given( - 'User has a vRack Services that {string} a subnet and a status {word}', - function( - this: ICustomWorld, - hasSubnet: 'has' | "doesn't have", - resourceStatus: ResourceStatus, - ) { - const index = vrackServicesList.findIndex( - (v) => - (hasSubnet === 'has' - ? v.currentState.subnets.length > 0 - : v.currentState.subnets.length === 0) && - v.resourceStatus === resourceStatus, - ); - - this.testContext.data.selectedVrackServices = vrackServicesList[index]; - this.testContext.data.vsIndex = index; - }, -); - -Given( - 'User has a vRack Services that {string} a subnet and {string} an endpoint and a status {word}', - function( - this: ICustomWorld, - hasSubnet: 'has' | "doesn't have", - hasEndpoint: 'has' | "doesn't have", - resourceStatus: ResourceStatus, - ) { - const index = vrackServicesList.findIndex((v) => { - if (hasSubnet === 'has' && v.currentState.subnets.length === 0) { - return false; - } - if (hasSubnet === "doesn't have" && v.currentState.subnets.length > 0) { - return false; - } - if (v.resourceStatus !== resourceStatus) { - return false; - } - return hasEndpoint === 'has' - ? v.currentState.subnets.some( - (subnet) => subnet.serviceEndpoints.length > 0, - ) - : v.currentState.subnets.every( - (subnet) => subnet.serviceEndpoints.length === 0, - ); - }); - - this.testContext.data.selectedVrackServices = vrackServicesList[index]; - this.testContext.data.vsIndex = index; - }, -); - -Given( - 'User wants to create a subnet with name {string} and CIDR {string} and service range {string} and vlan {string}', - function( - this: ICustomWorld, - name: string, - cidr: string, - serviceRange: string, - vlan: string, - ) { - this.testContext.data.name = name; - this.testContext.data.cidr = cidr; - this.testContext.data.serviceRange = serviceRange; - this.testContext.data.vlan = vlan; - }, -); diff --git a/packages/manager/apps/vrack-services/e2e/step-definitions/navigation.step.ts b/packages/manager/apps/vrack-services/e2e/step-definitions/navigation.step.ts deleted file mode 100644 index 3351addd8a8f..000000000000 --- a/packages/manager/apps/vrack-services/e2e/step-definitions/navigation.step.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { Given, When, Then } from '@cucumber/cucumber'; -import { ICustomWorld } from '@playwright-helpers'; -import { setupNetwork, getUrl } from '../utils'; -import { ConfigParams } from '../../mocks/handlers'; - -Given('User is on {word} page', function( - this: ICustomWorld, - pageType: 'Overview' | 'Onboarding', -) { - this.testContext.initialUrl = getUrl( - pageType === 'Onboarding' ? 'onboarding' : 'overview', - { - id: this.testContext.data?.selectedVrackServices?.id, - }, - ); -}); - -Given('User is on {word} Creation page', function( - this: ICustomWorld, - tab: 'subnets' | 'endpoints', -) { - this.testContext.initialUrl = getUrl( - tab === 'subnets' ? 'createSubnet' : 'createEndpoint', - { - id: this.testContext.data.selectedVrackServices.id, - }, - ); -}); - -When('User navigates to vRack Services {word} page', async function( - this: ICustomWorld, - pageType: 'Listing' | 'Overview', -) { - await setupNetwork(this); - await this.page.goto( - getUrl(pageType === 'Listing' ? 'listing' : 'overview', { - id: this.testContext.data?.selectedVrackServices?.id, - }), - { waitUntil: 'load' }, - ); -}); - -When('User navigates to {word} page', async function( - this: ICustomWorld, - tabName: 'subnets' | 'endpoints', -) { - await setupNetwork(this); - await this.page.goto( - getUrl(tabName, { id: this.testContext.data?.selectedVrackServices?.id }), - { - waitUntil: 'load', - }, - ); -}); - -Then('User is redirected to vRack Services {word} page', async function( - this: ICustomWorld, - pageType: 'Configuration' | 'Listing', -) { - await this.page.waitForURL( - getUrl(pageType === 'Configuration' ? 'createVrackServices' : 'listing'), - { - waitUntil: 'load', - }, - ); -}); diff --git a/packages/manager/apps/vrack-services/e2e/step-definitions/then.step.ts b/packages/manager/apps/vrack-services/e2e/step-definitions/then.step.ts deleted file mode 100644 index 016925ec970a..000000000000 --- a/packages/manager/apps/vrack-services/e2e/step-definitions/then.step.ts +++ /dev/null @@ -1,468 +0,0 @@ -import { Then } from '@cucumber/cucumber'; -import { expect } from '@playwright/test'; -import { ICustomWorld } from '@playwright-helpers'; -import { - AppRoute, - getActionMenu, - getDashboardEditButton, - getUrl, - labels, -} from '../utils'; -import { ConfigParams } from '../../mocks/handlers'; -import { Subnet } from '@/data'; - -Then('User sees the create a vRack Services button {word}', async function( - this: ICustomWorld, - buttonState: 'enabled' | 'disabled', -) { - const button = await this.page.locator('osds-button', { - hasText: labels.createVrackServicesButtonLabel, - }); - if (buttonState === 'enabled') { - await expect(button).not.toHaveAttribute('disabled', ''); - } else { - await expect(button).toHaveAttribute('disabled', ''); - } -}); - -Then( - 'A modal appear to ask if the user wants to create a new vRack', - async function(this: ICustomWorld) { - const modalDescriptionLine = await this.page?.locator('osds-text', { - hasText: labels.modalDescriptionLine1, - }); - await expect(modalDescriptionLine).toBeVisible(); - }, -); - -Then('User {string} on the Listing page', async function( - this: ICustomWorld, - returnsListing: 'returns' | "doesn't return", -) { - if (returnsListing === 'returns') { - await expect(this.page).toHaveURL(getUrl('listing')); - } else { - await expect(this.page).not.toHaveURL(getUrl('listing')); - } -}); - -Then('User {string} on the {word} Listing page', async function( - this: ICustomWorld, - returnsListing: 'returns' | "doesn't return", - tab: 'Subnet' | 'Endpoints', -) { - const { selectedVrackServices } = this.testContext.data; - - if (returnsListing === 'returns') { - await this.page.waitForURL( - getUrl(tab === 'Subnet' ? 'subnets' : 'endpoints', { - id: selectedVrackServices.id, - }), - { waitUntil: 'load' }, - ); - } else { - const routes: AppRoute[] = - tab === 'Subnet' - ? ['subnets', 'subnetsListing', 'subnetsOnboarding'] - : ['endpoints', 'endpointsListing', 'endpointsOnboarding']; - routes.forEach(async (route) => { - await expect(this.page.url()).not.toBe( - getUrl(route, { id: selectedVrackServices.id }), - ); - }); - } -}); - -Then('User sees {word} error message', async function( - this: ICustomWorld, - anyErrorMessage: 'an' | 'no', -) { - const error = await this.page.locator('osds-message', { - hasText: new RegExp( - this.testContext.errorMessage?.replace(/{{[a-zA-Z]+}}/gm, '.*'), - ), - }); - if (anyErrorMessage === 'an') { - await expect(error).toBeVisible({ timeout: 300000 }); - } -}); - -Then('User sees {word} success message', async function( - this: ICustomWorld, - anySuccessMessage: 'an' | 'no', -) { - const message = await this.page.locator('osds-message', { - hasText: new RegExp( - this.testContext.message?.replace(/{{[a-zA-Z]+}}/gm, '.*'), - ), - }); - if (anySuccessMessage === 'an') { - await expect(message).toBeVisible({ timeout: 300000 }); - } -}); - -Then('User gets redirected to Onboarding page', async function( - this: ICustomWorld, -) { - await this.page.waitForURL(getUrl('onboarding'), { waitUntil: 'load' }); -}); -Then('User sees {int} guides on vRack Services', async function( - this: ICustomWorld, - guideNumber: number, -) { - const guideList = await Promise.all( - [labels.guide1Title, labels.guide2Title].map((guideTitle) => - this.page.locator('div', { - hasText: guideTitle, - }), - ), - ); - await expect(guideList).toHaveLength(guideNumber); -}); - -Then( - 'User sees an information message about the order status of his vRack Services', - async function(this: ICustomWorld) { - const message = await this.page.locator('osds-message', { - hasText: new RegExp( - labels.deliveringVrackServicesMessage.replace(/{{date}}.*/, '.*'), - ), - }); - await expect(message).toBeVisible(); - }, -); -Then('User sees an empty listing page', async function( - this: ICustomWorld, -) { - const message = await this.page.getByText( - labels.vrackServicesEmptyDataGridMessage, - ); - await expect(message).toBeVisible(); -}); - -Then( - 'User sees a data grid containing his vRack Services information', - async function(this: ICustomWorld) { - const { selectedVrackServices } = this.testContext.data; - const displayName = - selectedVrackServices.iam?.displayName || selectedVrackServices.id; - const vsDisplayName = await this.page.getByText(displayName, { - exact: true, - }); - await expect(vsDisplayName).toBeVisible(); - }, -); - -Then('User sees a modal to select an eligible vRack', async function( - this: ICustomWorld, -) { - const modalDescription = await this.page.getByText( - labels.modalVrackAssociationDescription, - ); - await expect(modalDescription).toBeVisible(); -}); - -Then('User sees a modal to create a new vRack', async function( - this: ICustomWorld, -) { - const modalDescription = await this.page.getByText( - labels.modalVrackCreationDescriptionLine1, - ); - await expect(modalDescription).toBeVisible(); -}); - -Then( - 'User sees {word} information message about the order status of his vRack', - async function(this: ICustomWorld, anyMessage: 'an' | 'no') { - const message = await this.page - .getByText( - new RegExp(labels.deliveringVrackMessage.replace(/{{date}}.*/, '.*')), - ) - .nth(0); - - if (anyMessage === 'an') { - await expect(message).toBeVisible(); - } else { - await expect(message).not.toBeVisible(); - } - }, -); - -Then('The button to create a vRack is {word}', async function( - this: ICustomWorld, - buttonState: 'disabled' | 'enabled', -) { - const button = await this.page.locator('osds-button', { - hasText: labels.modalCreateNewVrackButtonLabel, - }); - if (buttonState === 'disabled') { - await expect(button).toHaveAttribute('disabled', ''); - } else { - await expect(button).not.toHaveAttribute('disabled', ''); - } -}); - -Then( - 'User sees the edit and associate a vRack buttons as {word}', - async function( - this: ICustomWorld, - buttonState: 'disabled' | 'enabled', - ) { - const menuIndex = this.testContext.data.vsIndex || 0; - - const actionMenu = await getActionMenu({ - ctx: this, - menuIndex, - }); - - await actionMenu.click(); - - const associateButton = await this.page - .locator('osds-button', { - hasText: labels.associateVrackButtonLabel, - }) - .nth(menuIndex); - - const editButton = await this.page - .locator('osds-button', { - hasText: labels['action-editDisplayName'], - }) - .nth(menuIndex); - - if (buttonState === 'disabled') { - await expect(associateButton).toHaveAttribute('disabled', ''); - await expect(editButton).toHaveAttribute('disabled', ''); - } else { - await expect(associateButton).not.toHaveAttribute('disabled'); - await expect(editButton).not.toHaveAttribute('disabled'); - } - }, -); - -Then('User sees the action buttons on the overview as {word}', async function( - this: ICustomWorld, - buttonState: 'disabled' | 'enabled', -) { - const actionMenu = await getActionMenu({ ctx: this }); - const editButton = await getDashboardEditButton({ ctx: this }); - - if (buttonState === 'disabled') { - await expect(actionMenu).toHaveAttribute('disabled', ''); - await expect(editButton).toHaveAttribute('disabled', ''); - } else { - await expect(actionMenu).not.toHaveAttribute('disabled'); - await expect(editButton).not.toHaveAttribute('disabled'); - } -}); - -Then('User sees the {word} Onboarding page', async function( - this: ICustomWorld, - tabName: 'subnets' | 'endpoints', -) { - const title = await this.page.getByText( - new RegExp( - tabName === 'subnets' - ? labels.subnetsOnboardingTitle - : labels.endpointsOnboardingTitle, - ), - ); - await expect(title).toBeVisible(); - - const createButton = await this.page.locator('osds-button', { - hasText: - tabName === 'subnets' - ? labels.createSubnetButtonLabel - : labels.createEndpointButtonLabel, - }); - await expect(createButton).toBeVisible(); -}); - -Then('User sees the subnets Listing page', async function( - this: ICustomWorld, -) { - const createButton = await this.page.locator('osds-button', { - hasText: labels.createSubnetButtonLabel, - }); - await expect(createButton).toBeVisible(); - - const subnetData = this.testContext.data.selectedVrackServices.currentState - .subnets[0]; - - const displayName = await this.page.getByText(subnetData.displayName); - if (displayName) { - await expect(displayName).toBeVisible(); - } - - const cidr = await this.page.locator('osds-clipboard'); - await expect(cidr).toHaveAttribute('value', subnetData.cidr); - - const serviceRange = await this.page.getByText( - new RegExp(subnetData.serviceRange.cidr), - ); - await expect(serviceRange).toBeVisible(); - - const vlan = await this.page.getByText(subnetData.vlan); - if (vlan) { - await expect(vlan).toBeVisible(); - } -}); - -Then('User sees the endpoints Listing page', async function( - this: ICustomWorld, -) { - const createButton = await this.page.locator('osds-button', { - hasText: labels.createEndpointButtonLabel, - }); - await expect(createButton).toBeVisible(); - - const subnetData = this.testContext.data.selectedVrackServices.currentState.subnets.find( - (s: Subnet) => s.serviceEndpoints.length > 0, - ); - - const subnetNameCount = await this.page - .getByText(subnetData.displayName || subnetData.cidr) - .count(); - await expect(subnetNameCount).toBeGreaterThan(0); - - const subnetTableHeader = this.page - .getByTestId('header-subnet') - .getByText(labels.endpointDatagridSubnetLabel); - await expect(subnetTableHeader).toBeVisible(); - - const ipTableHeader = this.page - .getByTestId('header-ip') - .getByText(labels.endpointDatagridIpLabel); - await expect(ipTableHeader).toBeVisible(); - - const serviceTypeTableHeader = this.page - .getByTestId('header-serviceType') - .getByText(labels.endpointDatagridServiceTypeLabel); - await expect(serviceTypeTableHeader).toBeVisible(); -}); - -Then('User {string} the action menu with button dissociate', async function( - this: ICustomWorld, - seeActionMenu: 'see' | "doesn't see", -) { - const actionMenu = await this.page.getByTestId('action-menu-icon'); - if (seeActionMenu === 'see') { - await expect(actionMenu).toBeVisible(); - } else { - await expect(actionMenu).not.toBeVisible(); - } -}); - -Then('User sees button dissociate', async function( - this: ICustomWorld, -) { - const dissociateButton = this.page.getByText(labels.vrackActionDissociate, { - exact: true, - }); - if (await this.page.getByTestId('action-menu-icon').count()) { - await expect(dissociateButton).toBeVisible(); - } else { - await expect(dissociateButton).not.toBeVisible(); - } -}); - -Then('User sees button associate another', async function( - this: ICustomWorld, -) { - const associateToAnotherButton = this.page.getByText( - labels.vrackActionAssociateToAnother, - { - exact: true, - }, - ); - if (await this.page.getByTestId('action-menu-icon').count()) { - await expect(associateToAnotherButton).toBeVisible(); - } else { - await expect(associateToAnotherButton).not.toBeVisible(); - } -}); - -Then( - 'A modal appears to ask if the user wants to dissociate the vRack', - async function(this: ICustomWorld) { - const modalTitle = await this.page.getByText( - labels.modalDissociateHeadline, - ); - await expect(modalTitle).toBeVisible(); - }, -); - -Then( - 'A modal appears to associate the vRack Services to another vRack', - async function(this: ICustomWorld) { - const modalTitle = await this.page.getByText( - labels.modalAssociateAnotherVrackTitle, - ); - await expect(modalTitle).toBeVisible(); - }, -); - -Then( - 'User {string} on the Overview page from dissociation modal', - async function( - this: ICustomWorld, - returnOverview: 'returns' | "doesn't returns", - ) { - const modalTitle = await this.page.getByText( - labels.modalDissociateHeadline, - ); - - if (returnOverview === 'returns') { - await expect(modalTitle).not.toBeVisible(); - } else { - await expect(modalTitle).toBeVisible(); - } - }, -); - -Then( - 'User {string} on the Overview page from associate another modal', - async function( - this: ICustomWorld, - returnOverview: 'returns' | "doesn't returns", - ) { - const modalTitle = await this.page.getByText( - labels.modalAssociateAnotherVrackTitle, - ); - - if (returnOverview === 'returns') { - await expect(modalTitle).not.toBeVisible(); - } else { - await expect(modalTitle).toBeVisible(); - } - }, -); - -Then('User sees the create a {word} button {word}', async function( - this: ICustomWorld, - tab: 'subnet' | 'endpoint', - buttonState: 'enabled' | 'disabled', -) { - const button = await this.page.locator('osds-button', { - hasText: - tab === 'subnet' - ? labels.createSubnetButtonLabel - : labels.createEndpointButtonLabel, - }); - if (buttonState === 'enabled') { - await expect(button).not.toHaveAttribute('disabled'); - } else { - await expect(button).toHaveAttribute('disabled'); - } -}); - -Then('User {string} redirected to HUB', async function( - this: ICustomWorld, - isRedirected: 'is' | 'is not', -) { - if (isRedirected === 'is') { - await expect(this.page).toHaveURL(/.*\/#\/hub/); - } else { - const description = await this.page.getByText(labels.listingDescription); - await expect(description).toBeVisible(); - } -}); diff --git a/packages/manager/apps/vrack-services/e2e/step-definitions/when.step.ts b/packages/manager/apps/vrack-services/e2e/step-definitions/when.step.ts deleted file mode 100644 index 590672cfb844..000000000000 --- a/packages/manager/apps/vrack-services/e2e/step-definitions/when.step.ts +++ /dev/null @@ -1,365 +0,0 @@ -import { When } from '@cucumber/cucumber'; -import { ICustomWorld } from '@playwright-helpers'; -import { expect } from '@playwright/test'; -import { vrackList } from '../../mocks/vrack/vrack'; -import { - setupNetwork, - getUrl, - clickMenuButton, - getDashboardEditButton, - labels, - managerComponentsLabels, -} from '../utils'; -import { ConfigParams } from '../../mocks/handlers'; -import { - defaultCidr, - defaultServiceRange, -} from '../../src/pages/create-subnet/subnetCreate.constants'; - -When('User clicks on the vRack Services configuration button', async function( - this: ICustomWorld, -) { - await setupNetwork(this); - await this.page.goto(this.testContext.initialUrl || getUrl('root'), { - waitUntil: 'load', - }); - await this.page - .locator('osds-button', { hasText: labels.orderButtonLabel }) - .click(); -}); - -When('User orders a vRack Services', async function( - this: ICustomWorld, -) { - this.handlersConfig.deliveringVrackServicesOrders = true; - await setupNetwork(this); - await this.page.goto(this.testContext.initialUrl || getUrl('root'), { - waitUntil: 'load', - }); -}); - -When( - 'User fills the configuration form and clicks the submit button', - async function(this: ICustomWorld) { - await setupNetwork(this); - await this.page.goto(this.testContext.initialUrl || getUrl('root'), { - waitUntil: 'load', - }); - await this.page - ?.locator(`osds-radio[id="${this.testContext.data.selectedRegion}"]`) - .click(); - await this.page?.locator('button[type="submit"]').click(); - }, -); - -When('User {word}', async function( - this: ICustomWorld, - acceptOrDenyOrCancel: 'accepts' | 'denies' | 'cancel', -) { - const labelToButton = { - accepts: labels.modalConfirmVrackButtonLabel, - denies: labels.modalNoVrackButtonLabel, - cancel: labels.modalCancelButtonLabel, - }; - const buttonLabel = labelToButton[acceptOrDenyOrCancel]; - const button = await this.page.locator('osds-button', { - hasText: buttonLabel, - }); - await button.click(); - - if (acceptOrDenyOrCancel !== 'cancel') { - const checkbox = await this.page.locator('osds-checkbox'); - await checkbox.click(); - - const confirmButton = await this.page.locator('osds-button', { - hasText: labels.modalSubmitOrderButtonLabel, - }); - await expect(confirmButton).toBeEnabled(); - await confirmButton.click(); - } -}); - -When('User clicks on the link to associate a vRack', async function( - this: ICustomWorld, -) { - await setupNetwork(this); - await this.page.goto(this.testContext.initialUrl || getUrl('root'), { - waitUntil: 'load', - }); - - await clickMenuButton({ - ctx: this, - label: labels.associateVrackButtonLabel, - menuIndex: this.testContext.data.vsIndex || 0, - }); -}); - -When( - 'User selects a vRack in the association list and submits the form', - async function(this: ICustomWorld) { - await this.page.locator('osds-select').click(); - await this.page.getByText(vrackList[0]).click(); - - await this.page - .getByText(labels.modalConfirmVrackAssociationButtonLabel) - .click(); - }, -); - -When('User click on the private network action menu button', async function( - this: ICustomWorld, -) { - await setupNetwork(this); - - const { selectedVrackServices } = this.testContext.data; - - await this.page.waitForURL( - getUrl('overview', { id: selectedVrackServices.id }), - { - waitUntil: 'load', - }, - ); - - if (await this.page.getByTestId('action-menu-icon').count()) { - await this.page.getByTestId('action-menu-icon').click(); - } -}); - -When( - 'User click on dissociate in action menu of private network', - async function(this: ICustomWorld) { - await setupNetwork(this); - const button = await this.page.getByText(labels.vrackActionDissociate, { - exact: true, - }); - - await expect(button).toBeVisible(); - - await button.click(); - }, -); - -When( - 'User click on associate another in action menu of private network', - async function(this: ICustomWorld) { - await setupNetwork(this); - const button = await this.page.getByText( - labels.vrackActionAssociateToAnother, - { - exact: true, - }, - ); - - await expect(button).toBeVisible(); - - await button.click(); - }, -); - -When( - 'User select the first vRack on the associate another vRack list and confirm', - async function(this: ICustomWorld) { - await setupNetwork(this); - await this.page.getByText(labels.vrackSelectPlaceholder).click(); - await this.page.getByText(vrackList[1]).click(); - await this.page - .getByText(labels.modalConfirmVrackAssociationButtonLabel) - .click(); - }, -); - -When('User {word} dissociate modal', async function( - this: ICustomWorld, - acceptOrCancel: 'accept' | 'cancel', -) { - await setupNetwork(this); - - const labelToButton = { - accept: labels.modalDissociateConfirmButton, - cancel: labels.modalDissociateCancelButton, - }; - const buttonLabel = labelToButton[acceptOrCancel]; - const button = await this.page.getByText(buttonLabel, { exact: true }); - - await expect(button).toBeVisible(); - - await button.click(); -}); - -When('User fills the subnet form and clicks the submit button', async function( - this: ICustomWorld, -) { - await setupNetwork(this); - - await this.page.goto(this.testContext.initialUrl, { - waitUntil: 'load', - }); - - await this.page - .getByRole('textbox', { name: labels.subnetNamePlaceholder }) - .fill(this.testContext.data.name); - await this.page - .getByRole('textbox', { name: defaultCidr }) - .fill(this.testContext.data.cidr); - await this.page - .getByRole('textbox', { name: defaultServiceRange }) - .fill(this.testContext.data.serviceRange); - - if (this.testContext.data.vlan) { - await this.page - .locator('osds-radio-button', { - hasText: labels.vlanSelectVlanOptionLabel, - }) - .click(); - - const vlanInput = await this.page - .locator('osds-form-field', { hasText: labels.vlanNumberLabel }) - .locator('input'); - - await expect(vlanInput).toBeVisible(); - - await vlanInput.fill(this.testContext.data.vlan); - } - - await this.page - .locator('osds-button', { hasText: labels.createSubnetButtonLabel }) - .click(); -}); - -When( - 'User fills the endpoints form and clicks the submit button', - async function(this: ICustomWorld) { - await setupNetwork(this); - - await this.page.goto(this.testContext.initialUrl, { - waitUntil: 'load', - }); - - const select = await this.page.locator('osds-select', { - hasText: labels.serviceNamePlaceholder, - }); - - await expect(select).toBeVisible(); - - select.click(); - await this.page.getByText('My-mongodb').click(); - - await this.page - .locator('osds-select', { hasText: labels.subnetPlaceholder }) - .click(); - await this.page.getByText('My.Subnet').click(); - - await this.page - .locator('osds-button', { - hasText: labels.createEndpointButtonLabel, - }) - .click(); - }, -); - -When('User updates the display name of a vRack Services', async function( - this: ICustomWorld, -) { - await clickMenuButton({ - ctx: this, - label: labels['action-editDisplayName'], - }); - - const input = await this.page.locator('osds-form-field').locator('input'); - - await expect(input).toBeVisible(); - - await input.clear(); - - await input.fill('test'); - - await this.page - .getByText(managerComponentsLabels.updateModalConfirmButton) - .click(); -}); - -When( - 'User updates the display name of this vRack Services from the overview', - async function(this: ICustomWorld) { - const editButton = await getDashboardEditButton({ ctx: this }); - await editButton.click(); - - const input = await this.page.locator('osds-form-field').locator('input'); - - await expect(input).toBeVisible(); - - await input.clear(); - - await input.fill('test'); - - await this.page - .getByText(managerComponentsLabels.updateModalConfirmButton, { - exact: true, - }) - .click(); - }, -); - -When('User updates the configuration of his first subnet', async function( - this: ICustomWorld, -) { - await clickMenuButton({ - ctx: this, - label: labels['action-editSubnet'], - }); - - const input = await this.page.getByRole('textbox', { - name: labels.subnetNamePlaceholder, - }); - - await expect(input).toBeVisible(); - - await input.clear(); - - await input.fill('test'); - - await this.page - .getByText(labels.modalSubnetUpdateConfirmButton, { exact: true }) - .click(); -}); - -When('User opens {word} delete modal', async function( - this: ICustomWorld, - page: 'vrack-services' | 'subnets' | 'endpoints', -) { - const labelByPage = { - 'vrack-services': labels['action-deleteVrackServices'], - subnets: labels['action-deleteSubnet'], - endpoints: labels['action-deleteServiceEndpoint'], - }; - await clickMenuButton({ - ctx: this, - label: labelByPage[page], - }); -}); - -When('User fills the {word} delete form', async function( - this: ICustomWorld, - page: 'vrack-services' | 'subnets' | 'endpoints', -) { - const headlineByPage = { - 'vrack-services': labels.modalDeleteVrackServicesHeadline, - subnets: labels.modalDeleteSubnetHeadline, - endpoints: labels.modalDeleteEndpointHeadline, - }; - - await expect( - this.page.locator('osds-modal').getByText(headlineByPage[page]), - ).toBeVisible(); - - const input = await this.page.locator('osds-form-field').locator('input'); - - await expect(input).toBeVisible(); - - await input.fill('TERMINATE'); - - await this.page - .locator('osds-modal') - .getByText(managerComponentsLabels.deleteModalDeleteButton, { exact: true }) - .click(); -}); diff --git a/packages/manager/apps/vrack-services/e2e/utils/action-menu.ts b/packages/manager/apps/vrack-services/e2e/utils/action-menu.ts deleted file mode 100644 index 7e1695652a87..000000000000 --- a/packages/manager/apps/vrack-services/e2e/utils/action-menu.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { ICustomWorld } from '@playwright-helpers'; -import { expect } from '@playwright/test'; - -export const getActionMenu = async ({ - ctx, - menuIndex = 0, -}: { - ctx: ICustomWorld; - menuIndex?: number; -}) => { - const actionMenu = await ctx.page - .locator('osds-button', { - has: ctx.page.locator('osds-icon[name="ellipsis"]'), - }) - .nth(menuIndex); - - await expect(actionMenu).toBeVisible(); - return actionMenu; -}; - -export const clickMenuButton = async ({ - ctx, - label, - menuIndex, -}: { - ctx: ICustomWorld; - menuIndex?: number; - label: string; -}) => { - const actionMenu = await getActionMenu({ ctx, menuIndex }); - await actionMenu.click(); - - const button = await ctx.page - .locator('osds-button', { hasText: label }) - .nth(0); - - await expect(button).toBeVisible(); - - await button.click(); -}; - -export const getDashboardEditButton = async ({ - ctx, -}: { - ctx: ICustomWorld; -}) => { - return ctx.page.locator('osds-button', { - has: ctx.page.locator('osds-icon[name="pen"]'), - }); -}; diff --git a/packages/manager/apps/vrack-services/e2e/utils/constants.ts b/packages/manager/apps/vrack-services/e2e/utils/constants.ts deleted file mode 100644 index d8e04f1bb0e8..000000000000 --- a/packages/manager/apps/vrack-services/e2e/utils/constants.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { urls } from '../../src/routes/routes.constants'; - -export const appUrl = 'http://localhost:9001/app/'; - -export type AppRoute = keyof typeof urls; - -export const getUrl = ( - route: AppRoute, - params?: { - id?: string; - vrackId?: string; - cidr?: string; - urn?: string; - region?: string; - }, -) => { - const suffix = params - ? Object.entries(params).reduce( - (url, [key, value]) => url.replace(`:${key}`, value), - urls[route], - ) - : urls[route]; - return `${appUrl}#${suffix}`; -}; diff --git a/packages/manager/apps/vrack-services/e2e/utils/index.tsx b/packages/manager/apps/vrack-services/e2e/utils/index.tsx deleted file mode 100644 index 93c35409957d..000000000000 --- a/packages/manager/apps/vrack-services/e2e/utils/index.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import listingLabels from '../../public/translations/vrack-services/listing/Messages_fr_FR.json'; -import generalLabels from '../../public/translations/vrack-services/Messages_fr_FR.json'; -import associateLabels from '../../public/translations/vrack-services/associate/Messages_fr_FR.json'; -import dissociateLabels from '../../public/translations/vrack-services/dissociate/Messages_fr_FR.json'; -import createVrackLabels from '../../public/translations/vrack-services/create-vrack/Messages_fr_FR.json'; -import createLabels from '../../public/translations/vrack-services/create/Messages_fr_FR.json'; -import onboardingLabels from '../../public/translations/vrack-services/onboarding/Messages_fr_FR.json'; -import dashboardLabels from '../../public/translations/vrack-services/dashboard/Messages_fr_FR.json'; -import subnetsLabels from '../../public/translations/vrack-services/subnets/Messages_fr_FR.json'; -import endpointsLabels from '../../public/translations/vrack-services/endpoints/Messages_fr_FR.json'; -import updateNameModalLabels from '../../../../../manager-react-components/src/components/templates/update-name-modal/translations/Messages_fr_FR.json'; -import deleteModalLabels from '../../../../../manager-react-components/src/components/templates/delete-modal/translations/Messages_fr_FR.json'; - -export * from './constants'; -export * from './network'; -export * from './action-menu'; - -export const labels = { - ...listingLabels, - ...createLabels, - ...generalLabels, - ...associateLabels, - ...dissociateLabels, - ...onboardingLabels, - ...dashboardLabels, - ...subnetsLabels, - ...endpointsLabels, - ...createVrackLabels, -}; - -export const managerComponentsLabels = { - ...updateNameModalLabels, - ...deleteModalLabels, -}; diff --git a/packages/manager/apps/vrack-services/e2e/utils/network.ts b/packages/manager/apps/vrack-services/e2e/utils/network.ts deleted file mode 100644 index ebe31ea7c2c4..000000000000 --- a/packages/manager/apps/vrack-services/e2e/utils/network.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { BrowserContext } from '@playwright/test'; -import { ICustomWorld } from '@playwright-helpers'; -import { toPlaywrightMockHandler } from '../../../../../../playwright-helpers'; -import { getConfig, ConfigParams } from '../../mocks/handlers'; - -export const setupNetwork = async (world: ICustomWorld) => - Promise.all( - getConfig({ - ...((world?.handlersConfig as ConfigParams) || ({} as ConfigParams)), - isAuthMocked: true, - }) - .reverse() - .map(toPlaywrightMockHandler(world.context as BrowserContext)), - ); diff --git a/packages/manager/apps/vrack-services/mocks/setup.ts b/packages/manager/apps/vrack-services/mocks/setup.ts deleted file mode 100644 index 7c761038d0c1..000000000000 --- a/packages/manager/apps/vrack-services/mocks/setup.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { setupWorker } from 'msw/browser'; -import { toMswHandlers } from '../../../../../playwright-helpers/msw'; -import { getConfig } from './handlers'; - -export const setupMocks = async () => - setupWorker( - ...toMswHandlers( - getConfig({ - nbVs: 19, - delayedOrders: true, - deliveringVrackServicesOrders: false, - deliveringVrackOrders: false, - updateServicesKo: true, - }), - ), - ).start({ - onUnhandledRequest: 'bypass', - }); diff --git a/packages/manager/apps/vrack-services/mocks/vrack/association.ts b/packages/manager/apps/vrack-services/mocks/vrack/association.ts index 6e5164347940..b71e467b6b8e 100644 --- a/packages/manager/apps/vrack-services/mocks/vrack/association.ts +++ b/packages/manager/apps/vrack-services/mocks/vrack/association.ts @@ -1,6 +1,4 @@ import { PathParams } from 'msw'; -import { Request as PlaywrightRequest } from '@playwright/test'; -import { getParamsFromUrl } from '../../../../../../playwright-helpers/network'; import { AllowedServicesResponse, Status, Task } from '../../src/data/api.type'; import vrackServicesList from '../vrack-services/get-vrack-services.json'; @@ -28,10 +26,8 @@ export const getAssociationResponse = async ( ): Promise => { const date = new Date(); const dateString = date.toISOString(); - const vrackId = (params || getParamsFromUrl(request, { id: -2 })).id; - const json = - (await request.json?.()) || - ((request as unknown) as PlaywrightRequest).postData(); + const vrackId = params.id; + const json = await request.json?.(); const { vrackServices } = json; return { createdAt: dateString, diff --git a/packages/manager/apps/vrack-services/package.json b/packages/manager/apps/vrack-services/package.json index 9915f84a819d..11f514c7a22c 100644 --- a/packages/manager/apps/vrack-services/package.json +++ b/packages/manager/apps/vrack-services/package.json @@ -11,10 +11,7 @@ "license": "BSD-3-Clause", "author": "OVH SAS", "scripts": { - "beta-test:e2e": "tsc && node ../../../../scripts/run-playwright-bdd.js", - "beta-test:e2e:cii": "tsc && node ../../../../scripts/run-playwright-bdd.js --ci", "build": "tsc && vite build", - "coverage": "vitest run --coverage", "dev": "tsc && vite", "start": "lerna exec --stream --scope='@ovh-ux/manager-vrack-services-app' --include-dependencies -- npm run build --if-present", "start:dev": "lerna exec --stream --scope='@ovh-ux/manager-vrack-services-app' --include-dependencies -- npm run dev --if-present", @@ -26,7 +23,7 @@ "@ovh-ux/manager-config": "^8.0.1", "@ovh-ux/manager-core-api": "^0.9.0", "@ovh-ux/manager-core-utils": "*", - "@ovh-ux/manager-module-common-api": "^0.1.0", + "@ovh-ux/manager-module-common-api": "^0.2.0", "@ovh-ux/manager-module-order": "^0.9.1", "@ovh-ux/manager-react-components": "^1.41.1", "@ovh-ux/manager-react-core-application": "^0.11.3", @@ -48,7 +45,7 @@ "tailwindcss": "^3.4.4" }, "devDependencies": { - "@ovh-ux/manager-core-test-utils": "^0.1.0", + "@ovh-ux/manager-core-test-utils": "^0.2.0", "@ovh-ux/manager-vite-config": "^0.8.3", "@tanstack/react-query-devtools": "^5.51.21", "@testing-library/jest-dom": "^6.6.3", diff --git a/packages/manager/apps/vrack-services/playwright.config.ts b/packages/manager/apps/vrack-services/playwright.config.ts deleted file mode 100644 index feb249bcbe3f..000000000000 --- a/packages/manager/apps/vrack-services/playwright.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { defineConfig } from '@playwright/test'; - -export default defineConfig({ - workers: 3, - fullyParallel: false, - timeout: 30 * 1000, - reporter: [['html', { open: 'on-failure' }]], - expect: { - timeout: 20000, - }, - use: { - // Collect trace when retrying the failed test. - trace: 'retain-on-failure', - }, - testMatch: '**/*.e2e.ts', - webServer: { - command: 'yarn run dev', - url: 'http://localhost:9000/', - }, -}); diff --git a/packages/manager/apps/vrack-services/src/main.tsx b/packages/manager/apps/vrack-services/src/main.tsx index fa1f3d44913c..514c0d877718 100644 --- a/packages/manager/apps/vrack-services/src/main.tsx +++ b/packages/manager/apps/vrack-services/src/main.tsx @@ -5,24 +5,13 @@ import { initShellContext, initI18n, } from '@ovh-ux/manager-react-shell-client'; -import { setupMocks } from '../mocks/setup'; import { App } from './App'; import '@ovhcloud/ods-theme-blue-jeans/dist/index.css'; import './index.css'; import './vite-hmr'; import { getTrackingContext } from './utils/tracking'; -const init = async ({ - appName, - mockNetwork, -}: { - appName: string; - mockNetwork?: boolean; -}) => { - if (mockNetwork) { - await setupMocks(); - } - +const init = async ({ appName }: { appName: string }) => { const context = await initShellContext(appName, getTrackingContext(appName)); await initI18n({ context, @@ -45,7 +34,4 @@ const init = async ({ init({ appName: 'vrack-services', - mockNetwork: - window.location.href.includes('localhost:9001') && - !import.meta.env.VITE_TEST_BDD, });