-
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.
ref: MANAGER-15107 Signed-off-by: Romain Jamet <[email protected]>
- Loading branch information
Romain Jamet
committed
Oct 10, 2024
1 parent
6edb862
commit 5746641
Showing
16 changed files
with
450 additions
and
101 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
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
11 changes: 10 additions & 1 deletion
11
.../key-management-service/src/hooks/serviceKey/useServiceKeyOperationsTranslations.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
11 changes: 10 additions & 1 deletion
11
...r/apps/key-management-service/src/hooks/serviceKey/useServiceKeyTypeTranslations.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
42 changes: 42 additions & 0 deletions
42
packages/manager/apps/key-management-service/src/mocks/okms.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,42 @@ | ||
import { PathParams } from 'msw'; | ||
import { Handler } from '../../../../../../playwright-helpers'; | ||
import { OKMS } from '@/types/okms.type'; | ||
|
||
export const okmsList: OKMS[] = [ | ||
{ | ||
iam: { | ||
displayName: 'kms-1', | ||
id: '1b4e7c8e-d1b8-4b46-a584-52c8b4b0225c', | ||
urn: `urn:v1:eu:resource:okms:1b4e7c8e-d1b8-4b46-a584-52c8b4b0225c`, | ||
}, | ||
id: '7f3a82ac-a8d8-4c2a-ab0c-f6e86ddf6a7c', | ||
kmipEndpoint: 'eu-west-rbx.okms.ovh.net:1234', | ||
region: 'EU_WEST_RBX', | ||
restEndpoint: 'https://eu-west-rbx.okms.ovh.net', | ||
swaggerEndpoint: '"https://swagger-eu-west-rbx.okms.ovh.net', | ||
}, | ||
]; | ||
|
||
export type GetOkmsMocksParams = { | ||
nbOkms?: number; | ||
}; | ||
|
||
const findOkmsById = (params: PathParams) => | ||
okmsList.find(({ id }) => id === params.id); | ||
|
||
export const getOkmsMocks = ({ | ||
nbOkms = okmsList.length, | ||
}: GetOkmsMocksParams): Handler[] => [ | ||
{ | ||
url: '/okms/resource/:id', | ||
response: (_: unknown, params: PathParams) => findOkmsById(params), | ||
status: 200, | ||
api: 'v2', | ||
}, | ||
{ | ||
url: '/okms/resource', | ||
response: okmsList.slice(0, nbOkms), | ||
status: 200, | ||
api: 'v2', | ||
}, | ||
]; |
36 changes: 36 additions & 0 deletions
36
packages/manager/apps/key-management-service/src/mocks/services.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,36 @@ | ||
import { KMSServiceInfos, OkmsState } from '@/types/okmsService.type'; | ||
import { Handler } from '../../../../../../playwright-helpers'; | ||
|
||
const serviceList: KMSServiceInfos[] = [ | ||
{ | ||
billing: { | ||
lifecycle: { current: { creationDate: '2024-04-12T18:00:00.000Z' } }, | ||
nextBillingDate: '2024-05-12T18:00:00.000Z', | ||
}, | ||
customer: { contacts: [{ customerCode: 'code', type: 'type' }] }, | ||
resource: { | ||
displayName: 'name', | ||
name: 'name', | ||
product: { name: 'name', description: 'descripton' }, | ||
resellingProvider: 'test', | ||
state: OkmsState.Active, | ||
}, | ||
}, | ||
]; | ||
|
||
export const getServicesMocks = (): Handler[] => [ | ||
{ | ||
url: '/services/:id', | ||
response: serviceList[0], | ||
status: 200, | ||
method: 'get', | ||
api: 'v6', | ||
}, | ||
{ | ||
url: '/services', | ||
response: () => [1234567890], | ||
status: 200, | ||
method: 'get', | ||
api: 'v6', | ||
}, | ||
]; |
102 changes: 102 additions & 0 deletions
102
packages/manager/apps/key-management-service/src/pages/listing/KmsListing.page.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,102 @@ | ||
import { act, screen, waitFor } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { renderTestApp } from '@/utils/tests/renderTestApp'; | ||
import '@testing-library/jest-dom'; | ||
import { labels } from '@/utils/tests/init.i18n'; | ||
import { okmsList } from '@/mocks/okms.mock'; | ||
|
||
describe('KMS listing test suite', () => { | ||
it('should redirect to the onboarding page when the kms list is empty', async () => { | ||
await renderTestApp({ nbOkms: 0 }); | ||
|
||
expect(screen.getByText(labels.onboarding.title)).toBeVisible(); | ||
|
||
expect( | ||
screen.queryByText(labels.listing.key_management_service_listing_title), | ||
).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should display the kms listing page', async () => { | ||
await renderTestApp(); | ||
|
||
expect( | ||
screen.getByText(labels.listing.key_management_service_listing_title), | ||
).toBeVisible(); | ||
|
||
expect( | ||
screen.queryByText(labels.onboarding.description), | ||
).not.toBeInTheDocument(); | ||
}); | ||
|
||
it(`should navigate to the kms creation form on click on "${labels.listing.key_management_service_listing_add_kms_button}" button`, async () => { | ||
await renderTestApp(); | ||
|
||
await waitFor( | ||
() => | ||
expect( | ||
screen.getByText( | ||
labels.listing.key_management_service_listing_add_kms_button, | ||
), | ||
).toBeEnabled(), | ||
{ | ||
timeout: 30_000, | ||
}, | ||
); | ||
|
||
await act(() => | ||
userEvent.click( | ||
screen.getByText( | ||
labels.listing.key_management_service_listing_add_kms_button, | ||
), | ||
), | ||
); | ||
|
||
await waitFor( | ||
() => | ||
expect( | ||
screen.getByText( | ||
labels.create.key_management_service_create_subtitle, | ||
), | ||
).toBeVisible(), | ||
{ timeout: 30_000 }, | ||
); | ||
}); | ||
|
||
it('should navigate to a kms dashboard on click on kms name', async () => { | ||
await renderTestApp(); | ||
|
||
await act(() => | ||
userEvent.click(screen.getByText(okmsList[0].iam.displayName)), | ||
); | ||
|
||
await waitFor( | ||
() => | ||
expect( | ||
screen.getByText(labels.dashboard.general_informations), | ||
).toBeVisible(), | ||
{ timeout: 30_000 }, | ||
); | ||
}); | ||
|
||
it(`should navigate to the kms delete modal on click on "${labels.listing.key_management_service_listing_terminate}" list action button`, async () => { | ||
await renderTestApp(); | ||
|
||
await act(() => | ||
userEvent.click( | ||
screen.getByText( | ||
labels.listing.key_management_service_listing_terminate, | ||
), | ||
), | ||
); | ||
|
||
await waitFor( | ||
() => | ||
expect( | ||
screen.getByText( | ||
labels.terminate.key_management_service_terminate_cancel, | ||
), | ||
).toBeVisible(), | ||
{ timeout: 30_000 }, | ||
); | ||
}); | ||
}); |
Oops, something went wrong.