-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #628 from cardano-foundation/feat/DTIS-1103-rareev…
…o-credential feat(ui): New Credential Issuance for RareEvo
- Loading branch information
Showing
16 changed files
with
605 additions
and
131 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
55 changes: 19 additions & 36 deletions
55
src/ui/components/CredentialCardTemplate/CredentialCardTemplate.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 |
---|---|---|
@@ -1,74 +1,57 @@ | ||
import { act, fireEvent, render, waitFor } from "@testing-library/react"; | ||
import { act, fireEvent, render } from "@testing-library/react"; | ||
import { Provider } from "react-redux"; | ||
import { store } from "../../../store"; | ||
import { CredentialCardTemplate } from "./CredentialCardTemplate"; | ||
import { store } from "../../../store"; | ||
import { shortCredsFix } from "../../__fixtures__/shortCredsFix"; | ||
import { formatShortDate } from "../../utils/formatters"; | ||
|
||
describe("CredentialCardTemplate", () => { | ||
it("renders Credential Card Template", async () => { | ||
describe("Credential Card Template", () => { | ||
it("Renders Rare Evo Card Template", async () => { | ||
const handleShowCardDetails = jest.fn(); | ||
const { getByText, getByTestId, getByAltText } = render( | ||
<Provider store={store}> | ||
<CredentialCardTemplate | ||
name="name" | ||
index={0} | ||
cardData={shortCredsFix[3]} | ||
cardData={shortCredsFix[5]} | ||
isActive={true} | ||
onHandleShowCardDetails={() => handleShowCardDetails(0)} | ||
/> | ||
</Provider> | ||
); | ||
const card = getByTestId("cred-card-template-name-index-0"); | ||
expect(getByText("Qualified vLEI Issuer Credential")).toBeInTheDocument(); | ||
expect(getByText("22/01/2024")).toBeInTheDocument(); | ||
const card = getByTestId("rare-card-template-name-index-0"); | ||
expect(getByText(shortCredsFix[5].credentialType)).toBeInTheDocument(); | ||
expect( | ||
getByText(formatShortDate(shortCredsFix[5].issuanceDate)) | ||
).toBeInTheDocument(); | ||
expect(getByAltText(/card-logo/i)).toBeInTheDocument(); | ||
act(() => { | ||
fireEvent.click(card); | ||
}); | ||
expect(handleShowCardDetails).toBeCalledTimes(1); | ||
}); | ||
|
||
it("Click pending card", async () => { | ||
it("Renders Keri Card Template", async () => { | ||
const handleShowCardDetails = jest.fn(); | ||
const { getByTestId } = render( | ||
const { getByText, getByTestId, getByAltText } = render( | ||
<Provider store={store}> | ||
<CredentialCardTemplate | ||
name="name" | ||
index={0} | ||
cardData={shortCredsFix[4]} | ||
cardData={shortCredsFix[3]} | ||
isActive={true} | ||
onHandleShowCardDetails={() => handleShowCardDetails(0)} | ||
/> | ||
</Provider> | ||
); | ||
const card = getByTestId("cred-card-template-name-index-0"); | ||
|
||
const card = getByTestId("keri-card-template-name-index-0"); | ||
expect(getByText("Qualified vLEI Issuer Credential")).toBeInTheDocument(); | ||
expect(getByText("22/01/2024")).toBeInTheDocument(); | ||
expect(getByAltText(/card-logo/i)).toBeInTheDocument(); | ||
act(() => { | ||
fireEvent.click(card); | ||
}); | ||
|
||
expect(handleShowCardDetails).toBeCalledTimes(0); | ||
|
||
await waitFor(() => { | ||
expect(getByTestId("alert-confirm")).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it("In active card status", async () => { | ||
const handleShowCardDetails = jest.fn(); | ||
const { getByTestId } = render( | ||
<Provider store={store}> | ||
<CredentialCardTemplate | ||
name="name" | ||
index={0} | ||
cardData={shortCredsFix[4]} | ||
isActive={false} | ||
onHandleShowCardDetails={() => handleShowCardDetails(0)} | ||
/> | ||
</Provider> | ||
); | ||
const card = getByTestId("cred-card-template-name-index-0"); | ||
|
||
expect(card.classList.contains("active")).toBe(false); | ||
expect(handleShowCardDetails).toBeCalledTimes(1); | ||
}); | ||
}); |
103 changes: 14 additions & 89 deletions
103
src/ui/components/CredentialCardTemplate/CredentialCardTemplate.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
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
74 changes: 74 additions & 0 deletions
74
...i/components/CredentialCardTemplate/components/KeriCardTemplate/KeriCardTemplate.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,74 @@ | ||
import { act, fireEvent, render, waitFor } from "@testing-library/react"; | ||
import { Provider } from "react-redux"; | ||
import { store } from "../../../../../store"; | ||
import { KeriCardTemplate } from "./KeriCardTemplate"; | ||
import { shortCredsFix } from "../../../../__fixtures__/shortCredsFix"; | ||
|
||
describe("KeriCardTemplate", () => { | ||
it("renders Keri Card Template", async () => { | ||
const handleShowCardDetails = jest.fn(); | ||
const { getByText, getByTestId, getByAltText } = render( | ||
<Provider store={store}> | ||
<KeriCardTemplate | ||
name="name" | ||
index={0} | ||
cardData={shortCredsFix[3]} | ||
isActive={true} | ||
onHandleShowCardDetails={() => handleShowCardDetails(0)} | ||
/> | ||
</Provider> | ||
); | ||
const card = getByTestId("keri-card-template-name-index-0"); | ||
expect(getByText("Qualified vLEI Issuer Credential")).toBeInTheDocument(); | ||
expect(getByText("22/01/2024")).toBeInTheDocument(); | ||
expect(getByAltText(/card-logo/i)).toBeInTheDocument(); | ||
act(() => { | ||
fireEvent.click(card); | ||
}); | ||
expect(handleShowCardDetails).toBeCalledTimes(1); | ||
}); | ||
|
||
it("Click pending card", async () => { | ||
const handleShowCardDetails = jest.fn(); | ||
const { getByTestId } = render( | ||
<Provider store={store}> | ||
<KeriCardTemplate | ||
name="name" | ||
index={0} | ||
cardData={shortCredsFix[4]} | ||
isActive={true} | ||
onHandleShowCardDetails={() => handleShowCardDetails(0)} | ||
/> | ||
</Provider> | ||
); | ||
const card = getByTestId("keri-card-template-name-index-0"); | ||
|
||
act(() => { | ||
fireEvent.click(card); | ||
}); | ||
|
||
expect(handleShowCardDetails).toBeCalledTimes(0); | ||
|
||
await waitFor(() => { | ||
expect(getByTestId("alert-confirm")).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it("In active card status", async () => { | ||
const handleShowCardDetails = jest.fn(); | ||
const { getByTestId } = render( | ||
<Provider store={store}> | ||
<KeriCardTemplate | ||
name="name" | ||
index={0} | ||
cardData={shortCredsFix[4]} | ||
isActive={false} | ||
onHandleShowCardDetails={() => handleShowCardDetails(0)} | ||
/> | ||
</Provider> | ||
); | ||
const card = getByTestId("keri-card-template-name-index-0"); | ||
|
||
expect(card.classList.contains("active")).toBe(false); | ||
}); | ||
}); |
Oops, something went wrong.