-
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.
feat(vrack-services): subnets dissociate and create vs it (#14596)
Signed-off-by: Quentin Pavy <[email protected]>
- Loading branch information
Showing
8 changed files
with
550 additions
and
17 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
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
69 changes: 69 additions & 0 deletions
69
packages/manager/apps/vrack-services/src/pages/create-subnet/subnetCreate.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,69 @@ | ||
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 { | ||
assertOsdFormInputInError, | ||
changeInputValueByLabelText, | ||
clickOnRadioByName, | ||
getButtonByVariant, | ||
labels, | ||
renderTest, | ||
} from '../../test-utils'; | ||
import vrackServicesList from '../../../mocks/vrack-services/get-vrack-services.json'; | ||
import { urls } from '@/routes/routes.constants'; | ||
|
||
describe('Vrack Services subnets page test suite', () => { | ||
it('should create a subnet', async () => { | ||
const { container } = await renderTest({ | ||
nbVs: 2, | ||
initialRoute: urls.createSubnet.replace(':id', vrackServicesList[1].id), | ||
}); | ||
|
||
await assertTextVisibility(labels.subnets.subnetNameLabel); | ||
|
||
await changeInputValueByLabelText({ | ||
inputLabel: labels.subnets.cidrLabel, | ||
value: '10.0.0.0/23', | ||
}); | ||
await assertOsdFormInputInError({ | ||
inputLabel: labels.subnets.cidrLabel, | ||
inError: true, | ||
}); | ||
|
||
await changeInputValueByLabelText({ | ||
inputLabel: labels.subnets.cidrLabel, | ||
value: '10.0.0.0/24', | ||
}); | ||
await assertOsdFormInputInError({ | ||
inputLabel: labels.subnets.cidrLabel, | ||
inError: false, | ||
}); | ||
await getButtonByVariant({ | ||
container, | ||
variant: ODS_BUTTON_VARIANT.flat, | ||
disabled: false, | ||
}); | ||
|
||
clickOnRadioByName({ container, name: 'hasVlan', value: 'vlanNumber' }); | ||
await getButtonByVariant({ | ||
container, | ||
variant: ODS_BUTTON_VARIANT.flat, | ||
disabled: true, | ||
}); | ||
await changeInputValueByLabelText({ | ||
inputLabel: labels.subnets.vlanNumberLabel, | ||
value: '20', | ||
}); | ||
const submitButton = await getButtonByVariant({ | ||
container, | ||
variant: ODS_BUTTON_VARIANT.flat, | ||
disabled: false, | ||
}); | ||
|
||
await waitFor(() => fireEvent.click(submitButton)); | ||
|
||
await assertTextVisibility(labels.subnets.subnetDatagridDisplayNameLabel); | ||
}); | ||
}); |
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
112 changes: 112 additions & 0 deletions
112
packages/manager/apps/vrack-services/src/pages/dissociate/DissociateModal.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,112 @@ | ||
import { describe, it } from 'vitest'; | ||
import '@testing-library/jest-dom'; | ||
import { | ||
assertModalText, | ||
assertModalVisibility, | ||
getButtonByLabel, | ||
} from '@ovh-ux/manager-core-test-utils'; | ||
import { waitFor, fireEvent } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { ODS_ICON_NAME } from '@ovhcloud/ods-components'; | ||
import { | ||
assertModalTitle, | ||
changeOdsSelectValueByTestId, | ||
getButtonByIcon, | ||
labels, | ||
renderTest, | ||
} from '../../test-utils'; | ||
import vrackServicesList from '../../../mocks/vrack-services/get-vrack-services.json'; | ||
import { urls } from '@/routes/routes.constants'; | ||
import { vrackList } from '../../../mocks/vrack/vrack'; | ||
|
||
describe('Vrack Services dissociate vrack test suite', () => { | ||
it('from dashboard should dissociate vrack', async () => { | ||
const { container } = await renderTest({ | ||
initialRoute: urls.overview.replace(':id', vrackServicesList[5].id), | ||
nbVs: 6, | ||
}); | ||
|
||
const actionMenuButton = await getButtonByIcon({ | ||
container, | ||
iconName: ODS_ICON_NAME.ELLIPSIS, | ||
}); | ||
|
||
await waitFor(() => fireEvent.click(actionMenuButton)); | ||
|
||
const dissociateLink = await getButtonByLabel({ | ||
container, | ||
label: labels.common.vrackActionDissociate, | ||
}); | ||
|
||
await waitFor(() => fireEvent.click(dissociateLink)); | ||
|
||
await assertModalVisibility({ container, isVisible: true }); | ||
await assertModalTitle({ | ||
container, | ||
title: labels.dissociate.modalDissociateHeadline, | ||
}); | ||
|
||
await assertModalText({ | ||
container, | ||
text: labels.dissociate.modalDissociateDescription, | ||
}); | ||
|
||
const dissociateButton = await getButtonByLabel({ | ||
container, | ||
label: labels.dissociate.modalDissociateConfirmButton, | ||
}); | ||
|
||
await waitFor(() => userEvent.click(dissociateButton)); | ||
|
||
await assertModalVisibility({ container, isVisible: false }); | ||
}); | ||
|
||
it('from dashboard, should not display error if dissociate fails', async () => { | ||
const { container } = await renderTest({ | ||
initialRoute: urls.overviewDissociate | ||
.replace(':id', vrackServicesList[5].id) | ||
.replace('vrackId', vrackServicesList[5].currentState.vrackId), | ||
nbVs: 6, | ||
dissociateKo: true, | ||
}); | ||
|
||
await assertModalVisibility({ container, isVisible: true }); | ||
|
||
const dissociateButton = await getButtonByLabel({ | ||
container, | ||
label: labels.dissociate.modalDissociateConfirmButton, | ||
}); | ||
|
||
await waitFor(() => userEvent.click(dissociateButton)); | ||
|
||
await assertModalVisibility({ container, isVisible: true }); | ||
|
||
await assertModalText({ | ||
container, | ||
text: labels.dissociate.modalDissociateError.replace( | ||
'{{error}}', | ||
'Update error', | ||
), | ||
}); | ||
}); | ||
|
||
// it('from dashboard, display error when get vrack is in error', async () => { | ||
// const { container } = await renderTest({ | ||
// initialRoute: urls.overviewAssociateAnother.replace( | ||
// ':id', | ||
// vrackServicesList[5].id, | ||
// ), | ||
// nbVs: 6, | ||
// getVrackKo: true, | ||
// }); | ||
|
||
// await assertModalVisibility({ container, isVisible: true }); | ||
// await assertModalText({ | ||
// container, | ||
// text: labels.associate.modalVrackAssociationError.replace( | ||
// '{{error}}', | ||
// 'Get vRack KO', | ||
// ), | ||
// }); | ||
// }); | ||
}); |
Oops, something went wrong.