-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add info dialog & login/logout for provider (#212)
* Add ProviderInfoDialog component * Add useProviderInfoDialog hook * Add Info button to topbar * Add providerInfoDialog to app * Add login/logout provider button * Fix login/logout provider * Improve add/remove provider * Improve CertificatesTopbar * Fix and add tests for CertificatesTopbar * Fix certificate list loading skeleton * Fix dialogs display * Add more properties to ProviderInfoDialog * Add isRemovable propertie to ProviderInfoDialog * Refactoring useApp hook * Closes the dialogs belonging to the extracted token * Disable the "Delete Certificate" button when you are not logged in * Add certificate with privat key icon to certificate list item * Add title to copy certificate button in certificates list * Add certificate with privat key label to certificate list item * Change information button text * Add toast when provider doesn’t support signing in * Add action buttons overlay for certificate list item * Hide "New" & "Delete" certificate buttons when provider is readOnly * Add tests for ProviderInfoDialog component * Improve CertificatesTopbar tests * Add test for useProviderInfoDialog hook * Add tests for CertificateDeleteDialog component * Add test for useCertificateDeleteDialog hook * Add tests for CertificateViewerDialog component * Add test for useCertificateViewerDialog hook * Change version * Fix certificate type label * Fix certificate creation button * Fix certificate creation button * Fix reload provider * Fix tests * Change version * Fix get data * Fix certificate type label styles * Remove console * Change version --------- Co-authored-by: alex-slobodian <[email protected]>
- Loading branch information
1 parent
f1b29b5
commit 695e317
Showing
31 changed files
with
1,244 additions
and
137 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
39 changes: 39 additions & 0 deletions
39
src/components/certificate-delete-dialog/CertificateDeleteDialog.test.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,39 @@ | ||
import { ComponentProps } from "react"; | ||
import { render, userEvent, screen } from "@testing"; | ||
import { CertificateDeleteDialog } from "./CertificateDeleteDialog"; | ||
|
||
describe("<CertificateDeleteDialog />", () => { | ||
const defaultProps: ComponentProps<typeof CertificateDeleteDialog> = { | ||
certificateName: "Certificate Name", | ||
certificateId: "1", | ||
onDialogClose: vi.fn(), | ||
onDeleteClick: vi.fn((data) => data), | ||
}; | ||
|
||
it("Should render and handle buttons click", async () => { | ||
render(<CertificateDeleteDialog {...defaultProps} />); | ||
|
||
expect( | ||
screen.getByText( | ||
`Are you sure you want to delete “${defaultProps.certificateName}”?` | ||
) | ||
).toBeInTheDocument(); | ||
|
||
await userEvent.click(screen.getByRole("button", { name: /Cancel/ })); | ||
|
||
expect(defaultProps.onDialogClose).toBeCalledTimes(1); | ||
|
||
await userEvent.click(screen.getByRole("button", { name: /Delete/ })); | ||
|
||
expect(defaultProps.onDeleteClick).toBeCalledTimes(1); | ||
expect(defaultProps.onDeleteClick).toBeCalledWith( | ||
defaultProps.certificateId | ||
); | ||
}); | ||
|
||
it("Should render loading", () => { | ||
render(<CertificateDeleteDialog {...defaultProps} loading={true} />); | ||
|
||
expect(screen.getByText(/Deleting certificate/)).toBeInTheDocument(); | ||
}); | ||
}); |
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
50 changes: 50 additions & 0 deletions
50
src/components/certificate-viewer-dialog/CertificateViewerDialog.test.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,50 @@ | ||
import { render, userEvent, screen } from "@testing"; | ||
import { CertificateViewerDialog } from "./CertificateViewerDialog"; | ||
import { CertificateProps } from "../../types"; | ||
|
||
vi.mock("@peculiar/certificates-viewer-react", () => ({ | ||
PeculiarCertificateViewer: () => "x509 certificate viewer component", | ||
PeculiarCsrViewer: () => "CSR certificate viewer component", | ||
})); | ||
|
||
describe("<CertificateViewerDialog />", () => { | ||
const certificate = { | ||
raw: new ArrayBuffer(0), | ||
subjectName: "Certificate name", | ||
type: "x509", | ||
label: "Certificate name", | ||
subject: { | ||
commonName: "Certificate name", | ||
}, | ||
} as unknown as CertificateProps; | ||
|
||
it("Should render as x509 and handle close", async () => { | ||
const onCloseMock = vi.fn(); | ||
|
||
render( | ||
<CertificateViewerDialog | ||
certificate={certificate} | ||
onClose={onCloseMock} | ||
/> | ||
); | ||
|
||
expect(screen.getByText(`“${certificate.label}” details`)); | ||
expect(screen.getByText(/x509 certificate viewer component/)); | ||
|
||
await userEvent.click(screen.getByRole("button", { name: /Cancel/ })); | ||
|
||
expect(onCloseMock).toBeCalledTimes(1); | ||
}); | ||
|
||
it("Should render as CSR", async () => { | ||
render( | ||
<CertificateViewerDialog | ||
certificate={ | ||
{ ...certificate, type: "csr" } as unknown as CertificateProps | ||
} | ||
onClose={vi.fn()} | ||
/> | ||
); | ||
expect(screen.getByText(/CSR certificate viewer component/)); | ||
}); | ||
}); |
Oops, something went wrong.