-
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(hpc-vmware-managed-vcd): add integration tests
ref: MANAGER-15566 Signed-off-by: Nicolas Pierre-charles <[email protected]>
- Loading branch information
Nicolas Pierre-charles
committed
Oct 15, 2024
1 parent
d7a5c5f
commit fb5f369
Showing
14 changed files
with
326 additions
and
35 deletions.
There are no files selected for viewing
17 changes: 7 additions & 10 deletions
17
packages/manager/apps/hpc-vmware-managed-vcd/mocks/iam/iam.mock.ts
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,25 +1,22 @@ | ||
import { IamCheckResponse } from '@ovh-ux/manager-react-components'; | ||
import { organizationList } from '../vcd-organization/vcd-organization.mock'; | ||
import { iamActions } from '@/utils/iam.constants'; | ||
|
||
export const resourceList: IamCheckResponse[] = [ | ||
{ | ||
urn: organizationList[0].iam.urn, | ||
authorizedActions: [ | ||
'vmwareCloudDirectorBackup:apiovh:get', | ||
'vmwareCloudDirector:apiovh:organization/get', | ||
'account:apiovh:iam/resource/edit', | ||
'account:apiovh:service/terminate', | ||
iamActions.vmwareCloudDirectorApiovhOrganizationEdit, | ||
iamActions.vmwareCloudDirectorApiovhOrganizationVirtualDataCenterEdit, | ||
], | ||
unauthorizedActions: [], | ||
}, | ||
{ | ||
urn: organizationList[1].iam.urn, | ||
authorizedActions: [], | ||
unauthorizedActions: [ | ||
'vmwareCloudDirectorBackup:apiovh:get', | ||
'vmwareCloudDirector:apiovh:organization/get', | ||
'account:apiovh:iam/resource/edit', | ||
'account:apiovh:service/terminate', | ||
authorizedActions: [ | ||
iamActions.vmwareCloudDirectorApiovhOrganizationEdit, | ||
iamActions.vmwareCloudDirectorApiovhOrganizationVirtualDataCenterEdit, | ||
], | ||
unauthorizedActions: [], | ||
}, | ||
]; |
32 changes: 32 additions & 0 deletions
32
packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-datacentre.mock.ts
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,32 @@ | ||
import IVcdDatacentre from '../../src/types/vcd-datacenter.interface'; | ||
|
||
export const datacentreList: IVcdDatacentre[] = [ | ||
{ | ||
id: 'vdc-eu-central-waw-adc311b5-0c0b-4071-b48f-b20813868bcf', | ||
resourceStatus: 'READY', | ||
currentState: { | ||
commercialRange: 'STANDARD', | ||
description: | ||
'Pour vous proposer une description adaptée, pourriez-vous me donner plus de détails sur votre service ? Cela me permettra de créer une description précise et impactante qui tient dans la limite des 255 caractères.', | ||
ipQuota: 10, | ||
memoryQuota: 64, | ||
name: 'vdc-eu-central-waw-adc311b5-0c0b-4071-b48f-b20813868bcf', | ||
region: 'EU-CENTRAL-WAW', | ||
storageQuota: 1, | ||
vCPUCount: 16, | ||
vCPUSpeed: 3, | ||
}, | ||
currentTasks: [], | ||
targetSpec: { | ||
description: | ||
'Pour vous proposer une description adaptée, pourriez-vous me donner plus de détails sur votre service ? Cela me permettra de créer une description précise et impactante qui tient dans la limite des 255 caractères.', | ||
vCPUSpeed: 3, | ||
}, | ||
updatedAt: '2024-09-23T13:53:49Z', | ||
iam: { | ||
id: '33dda1c2-b24e-4db2-b7f3-4f3a8e08d68f', | ||
urn: | ||
'urn:v1:eu:resource:vmwareCloudDirector:org-eu-central-waw-366861de-e0e4-4ad5-a4c5-e9f80d744142/virtualDataCenter/vdc-eu-central-waw-adc311b5-0c0b-4071-b48f-b20813868bcf', | ||
}, | ||
}, | ||
]; |
35 changes: 34 additions & 1 deletion
35
...es/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-organization.handler.ts
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
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
37 changes: 37 additions & 0 deletions
37
...ps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/OrganizationDashboard.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,37 @@ | ||
import userEvents from '@testing-library/user-event'; | ||
import { screen, waitFor } from '@testing-library/react'; | ||
import { renderTest, labels } from '../../../test-utils'; | ||
import { organizationList } from '../../../../mocks/vcd-organization/vcd-organization.mock'; | ||
|
||
describe('Organization Dashboard Page', () => { | ||
it('display the dashboard page', async () => { | ||
await renderTest(); | ||
const link = screen.getByText(organizationList[0].currentState.fullName); | ||
await waitFor(() => userEvents.click(link)); | ||
|
||
await waitFor( | ||
() => | ||
expect( | ||
screen.getByText( | ||
labels.dashboard.managed_vcd_dashboard_data_protection, | ||
), | ||
).toBeVisible(), | ||
{ timeout: 30000 }, | ||
); | ||
|
||
expect( | ||
screen.getByText(organizationList[0].currentState.description), | ||
).toBeVisible(); | ||
}); | ||
|
||
it('display an error', async () => { | ||
await renderTest({ | ||
initialRoute: `/${organizationList[0].id}`, | ||
isOrganizationKo: true, | ||
}); | ||
await waitFor( | ||
() => expect(screen.getByText('Organization error')).toBeVisible(), | ||
{ timeout: 30000 }, | ||
); | ||
}); | ||
}); |
159 changes: 159 additions & 0 deletions
159
.../pages/dashboard/organization/general-information/OrganizationGeneralInformation.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,159 @@ | ||
import userEvents from '@testing-library/user-event'; | ||
import { screen, waitFor, fireEvent, within } from '@testing-library/react'; | ||
import { renderTest, labels } from '../../../../test-utils'; | ||
import { organizationList } from '../../../../../mocks/vcd-organization/vcd-organization.mock'; | ||
|
||
const changeInputAndSubmit = async () => { | ||
const input = screen.getByLabelText('edit-input'); | ||
const event = new CustomEvent('odsValueChange'); | ||
Object.defineProperty(event, 'target', { value: { value: 'new name' } }); | ||
await waitFor(() => fireEvent(input, event)); | ||
|
||
const modifyButton = screen.getByText( | ||
labels.dashboard.managed_vcd_dashboard_edit_modal_cta_edit, | ||
{ exact: true }, | ||
); | ||
|
||
return waitFor(() => userEvents.click(modifyButton)); | ||
}; | ||
|
||
const checkModal = async ({ | ||
container, | ||
isVisible, | ||
}: { | ||
container: HTMLElement; | ||
isVisible: boolean; | ||
}) => | ||
waitFor( | ||
() => { | ||
const modal = container.querySelector('osds-modal'); | ||
isVisible | ||
Check failure on line 30 in packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/general-information/OrganizationGeneralInformation.spec.tsx GitHub Actions / Lint Code Base
|
||
? expect(modal).toBeInTheDocument() | ||
: expect(modal).not.toBeInTheDocument(); | ||
}, | ||
{ timeout: 30000 }, | ||
); | ||
|
||
describe('Organization General Information Page', () => { | ||
it('modify the name of the company', async () => { | ||
const { container } = await renderTest({ | ||
initialRoute: `/${organizationList[1].id}`, | ||
}); | ||
|
||
await waitFor( | ||
() => | ||
expect( | ||
screen.getByText( | ||
labels.dashboard.managed_vcd_dashboard_data_protection, | ||
), | ||
).toBeVisible(), | ||
{ timeout: 30000 }, | ||
); | ||
|
||
let editButton: HTMLElement; | ||
await waitFor( | ||
() => { | ||
editButton = screen.getAllByTestId('editIcon')[0]; | ||
return expect(editButton).not.toHaveAttribute('disabled'); | ||
}, | ||
{ timeout: 30000 }, | ||
); | ||
await waitFor(() => userEvents.click(editButton)); | ||
|
||
await checkModal({ container, isVisible: true }); | ||
|
||
await changeInputAndSubmit(); | ||
|
||
await checkModal({ container, isVisible: false }); | ||
|
||
expect( | ||
screen.queryByText( | ||
labels.dashboard.managed_vcd_dashboard_edit_name_modal_success, | ||
), | ||
).toBeVisible(); | ||
}); | ||
|
||
it('trying to update name displays an error if update organization service is KO', async () => { | ||
const { container } = await renderTest({ | ||
initialRoute: `/${organizationList[0].id}/edit-name`, | ||
isOrganizationUpdateKo: true, | ||
}); | ||
|
||
await checkModal({ container, isVisible: true }); | ||
|
||
await changeInputAndSubmit(); | ||
|
||
await checkModal({ container, isVisible: true }); | ||
|
||
await waitFor( | ||
() => | ||
expect( | ||
within( | ||
container.querySelector('osds-modal') as HTMLElement, | ||
).getByText('Organization update error', { exact: false }), | ||
).toBeVisible(), | ||
{ timeout: 30000 }, | ||
); | ||
}); | ||
|
||
it('modify the description of the company', async () => { | ||
const { container } = await renderTest({ | ||
initialRoute: `/${organizationList[1].id}`, | ||
}); | ||
|
||
await waitFor( | ||
() => | ||
expect( | ||
screen.getByText( | ||
labels.dashboard.managed_vcd_dashboard_data_protection, | ||
), | ||
).toBeVisible(), | ||
{ timeout: 30000 }, | ||
); | ||
|
||
let editButton: HTMLElement; | ||
await waitFor( | ||
() => { | ||
editButton = screen.getAllByTestId('editIcon')[1]; | ||
return expect(editButton).not.toHaveAttribute('disabled'); | ||
}, | ||
{ timeout: 30000 }, | ||
); | ||
await waitFor(() => userEvents.click(editButton)); | ||
|
||
await checkModal({ container, isVisible: true }); | ||
|
||
await changeInputAndSubmit(); | ||
|
||
await checkModal({ container, isVisible: false }); | ||
|
||
expect( | ||
screen.queryByText( | ||
labels.dashboard.managed_vcd_dashboard_edit_description_modal_success, | ||
), | ||
).toBeVisible(); | ||
}); | ||
|
||
it('trying to update description displays an error if update organization service is KO', async () => { | ||
const { container } = await renderTest({ | ||
initialRoute: `/${organizationList[0].id}/edit-description`, | ||
isOrganizationUpdateKo: true, | ||
}); | ||
|
||
await checkModal({ container, isVisible: true }); | ||
|
||
await changeInputAndSubmit(); | ||
|
||
await checkModal({ container, isVisible: true }); | ||
|
||
await waitFor( | ||
() => | ||
expect( | ||
within( | ||
container.querySelector('osds-modal') as HTMLElement, | ||
).getByText('Organization update error', { exact: false }), | ||
).toBeVisible(), | ||
{ timeout: 30000 }, | ||
); | ||
}); | ||
}); |
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
12 changes: 10 additions & 2 deletions
12
...anager/apps/hpc-vmware-managed-vcd/src/pages/listing/organizations/Organizations.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,13 +1,21 @@ | ||
import { screen, waitFor } from '@testing-library/react'; | ||
import { renderTest, labels } from '../../../test-utils'; | ||
import { organizationList } from '../../../../mocks/vcd-organization/vcd-organization.mock'; | ||
|
||
describe('Organizations Listing Page', () => { | ||
it('display the listing page', async () => { | ||
await renderTest(); | ||
it('display the listing page if there is at least one organization', async () => { | ||
await renderTest({ nbOrganization: 1 }); | ||
|
||
await waitFor(() => | ||
expect( | ||
screen.getByText(labels.listing.managed_vcd_listing_description), | ||
).toBeVisible(), | ||
); | ||
|
||
await waitFor(() => | ||
expect( | ||
screen.getByText(organizationList[0].currentState.fullName), | ||
).toBeVisible(), | ||
); | ||
}); | ||
}); |
Oops, something went wrong.