-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(vrack-services): listing and create endpoint it
ref: MANAGER-16104 Signed-off-by: Quentin Pavy <[email protected]>
- Loading branch information
Quentin Pavy
committed
Dec 17, 2024
1 parent
4f857b3
commit 78426aa
Showing
5 changed files
with
173 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/manager/apps/vrack-services/src/pages/create-endpoint/EndpointCreate.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { describe, it } from 'vitest'; | ||
import '@testing-library/jest-dom'; | ||
import { assertTextVisibility } from '@ovh-ux/manager-core-test-utils'; | ||
import { waitFor, fireEvent } from '@testing-library/react'; | ||
import { ODS_BUTTON_VARIANT } from '@ovhcloud/ods-components'; | ||
import { eligibleManagedServiceResponse } from 'mocks/vrack-services/vrack-services'; | ||
import { | ||
assertOsdFormInputInError, | ||
changeInputValueByLabelText, | ||
changeSelectValueByLabelText, | ||
clickOnRadioByName, | ||
getButtonByVariant, | ||
labels, | ||
renderTest, | ||
} from '../../test-utils'; | ||
import vrackServicesList from '../../../mocks/vrack-services/get-vrack-services.json'; | ||
import { urls } from '@/routes/routes.constants'; | ||
import { iamResources } from '../../../mocks/iam/iam'; | ||
|
||
describe('Vrack Services endpoint creation page test suite', () => { | ||
it('should create an endpoint', async () => { | ||
const { container } = await renderTest({ | ||
nbVs: 21, | ||
initialRoute: urls.createEndpoint.replace( | ||
':id', | ||
vrackServicesList[20].id, | ||
), | ||
nbEligibleService: 1, | ||
}); | ||
|
||
await assertTextVisibility(labels.endpoints.createEndpointPageDescription); | ||
|
||
await getButtonByVariant({ | ||
container, | ||
variant: ODS_BUTTON_VARIANT.flat, | ||
disabled: true, | ||
}); | ||
|
||
await changeSelectValueByLabelText({ | ||
selectLabel: labels.endpoints.serviceNameLabel, | ||
value: iamResources[0].displayName, | ||
}); | ||
|
||
await getButtonByVariant({ | ||
container, | ||
variant: ODS_BUTTON_VARIANT.flat, | ||
disabled: true, | ||
}); | ||
|
||
await changeSelectValueByLabelText({ | ||
selectLabel: labels.endpoints.subnetLabel, | ||
value: vrackServicesList[20].currentState.subnets[0].cidr, | ||
}); | ||
|
||
await getButtonByVariant({ | ||
container, | ||
variant: ODS_BUTTON_VARIANT.flat, | ||
disabled: false, | ||
}); | ||
}); | ||
}); |
95 changes: 93 additions & 2 deletions
95
packages/manager/apps/vrack-services/src/pages/listing/Listing.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,103 @@ | ||
import { describe, it } from 'vitest'; | ||
import '@testing-library/jest-dom'; | ||
import { assertTextVisibility } from '@ovh-ux/manager-core-test-utils'; | ||
import { labels, renderTest } from '../../test-utils'; | ||
import { | ||
assertTextVisibility, | ||
getButtonByLabel, | ||
} from '@ovh-ux/manager-core-test-utils'; | ||
import { ODS_BUTTON_VARIANT, ODS_ICON_NAME } from '@ovhcloud/ods-components'; | ||
import { fireEvent, waitFor } from '@testing-library/react'; | ||
import { | ||
assertModalTitle, | ||
getButtonByIcon, | ||
getButtonByVariant, | ||
labels, | ||
renderTest, | ||
} from '../../test-utils'; | ||
|
||
describe('Vrack Services listing test suite', () => { | ||
it('should redirect to the onboarding page when the VRS list is empty', async () => { | ||
await renderTest({ nbVs: 0 }); | ||
|
||
await assertTextVisibility(labels.onboarding.onboardingPageTitle); | ||
}); | ||
|
||
it('should show list of vrack services', async () => { | ||
const { container } = await renderTest({ nbVs: 7 }); | ||
|
||
await assertTextVisibility(labels.listing.createVrackServicesButtonLabel); | ||
|
||
const actionMenuDisabled = await getButtonByIcon({ | ||
container, | ||
iconName: ODS_ICON_NAME.ELLIPSIS, | ||
nth: 6, | ||
}); | ||
|
||
await waitFor(() => fireEvent.click(actionMenuDisabled)); | ||
|
||
await getButtonByLabel({ | ||
container, | ||
label: labels.common['action-editDisplayName'], | ||
nth: 6, | ||
disabled: true, | ||
}); | ||
await getButtonByLabel({ | ||
container, | ||
label: labels.common['action-deleteVrackServices'], | ||
nth: 6, | ||
disabled: true, | ||
}); | ||
await getButtonByLabel({ | ||
container, | ||
label: labels.common['action-goDetails'], | ||
nth: 6, | ||
disabled: false, | ||
}); | ||
|
||
const actionMenuActive = await getButtonByIcon({ | ||
container, | ||
iconName: ODS_ICON_NAME.ELLIPSIS, | ||
nth: 1, | ||
}); | ||
|
||
await waitFor(() => fireEvent.click(actionMenuActive)); | ||
|
||
const editDisplayNameModalButton = await getButtonByLabel({ | ||
container, | ||
label: labels.common['action-editDisplayName'], | ||
nth: 1, | ||
disabled: false, | ||
}); | ||
await getButtonByLabel({ | ||
container, | ||
label: labels.common['action-deleteVrackServices'], | ||
nth: 1, | ||
disabled: false, | ||
}); | ||
const goToDEtailButton = await getButtonByLabel({ | ||
container, | ||
label: labels.common['action-goDetails'], | ||
nth: 1, | ||
disabled: false, | ||
}); | ||
|
||
await waitFor(() => fireEvent.click(editDisplayNameModalButton)); | ||
|
||
await assertModalTitle({ | ||
container, | ||
title: labels.common.modalUpdateVrackServicesHeadline.replace( | ||
'{{id}}', | ||
'vrs-ahz-9t0-7lb-b5r', | ||
), | ||
}); | ||
|
||
const closeDisplayNameModal = await getButtonByVariant({ | ||
container, | ||
variant: ODS_BUTTON_VARIANT.ghost, | ||
}); | ||
await waitFor(() => fireEvent.click(closeDisplayNameModal)); | ||
|
||
await waitFor(() => fireEvent.click(goToDEtailButton)); | ||
|
||
await assertTextVisibility(labels.dashboard.dashboardPageDescription); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters