-
Notifications
You must be signed in to change notification settings - Fork 4
Remove wallet cookie migration, Update AGENTS about clean code, Improve DateAccordion accessibility #1516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Remove wallet cookie migration, Update AGENTS about clean code, Improve DateAccordion accessibility #1516
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cee0e70
Remove wallet cookie migration, Update AGENTS about clean code, Impro…
prxt6529 a2c5320
WIP
prxt6529 0110059
Merge branch 'main' into merging-prs-07-10-25
prxt6529 a367a05
WIP
prxt6529 27d17b3
Revert husky
prxt6529 8febfdb
WIP
prxt6529 6daf30a
Merge branch 'main' into merging-prs-07-10-25
prxt6529 8ef0826
WIP
prxt6529 8e747ae
WIP
prxt6529 149eba5
Test
prxt6529 b54b322
Test
prxt6529 ae672c4
Hook test
prxt6529 2c27cd7
Hook test
prxt6529 0a69c84
WIP
prxt6529 6d4fce0
Merge branch 'main' into merging-prs-07-10-25
prxt6529 2af0db5
WIP
prxt6529 b394a2e
Merge branch 'main' into merging-prs-07-10-25
prxt6529 f2cdf82
WIP
prxt6529 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,40 +1,57 @@ | ||
| import { render, screen, fireEvent } from '@testing-library/react'; | ||
| import React from 'react'; | ||
| import { fireEvent, render, screen } from "@testing-library/react"; | ||
|
|
||
| jest.mock('framer-motion', () => ({ | ||
| jest.mock("framer-motion", () => ({ | ||
| motion: { | ||
| div: ({ children, ...props }: any) => <div {...props}>{children}</div>, | ||
| }, | ||
| AnimatePresence: ({ children }: any) => <div>{children}</div>, | ||
| })); | ||
|
|
||
| jest.mock('@fortawesome/react-fontawesome', () => ({ | ||
| jest.mock("@fortawesome/react-fontawesome", () => ({ | ||
| FontAwesomeIcon: () => <span data-testid="icon" />, | ||
| })); | ||
|
|
||
| import DateAccordion from '@/components/common/DateAccordion'; | ||
| import DateAccordion from "@/components/common/DateAccordion"; | ||
|
|
||
| describe('DateAccordion', () => { | ||
| it('shows collapsed content when not expanded and triggers toggle', () => { | ||
| describe("DateAccordion", () => { | ||
| it("shows collapsed content when not expanded, exposes aria attributes, and triggers toggle", () => { | ||
| const toggle = jest.fn(); | ||
| render( | ||
| <DateAccordion title="Title" isExpanded={false} onToggle={toggle} collapsedContent={<span>info</span>}> | ||
| <DateAccordion | ||
| title="Title" | ||
| isExpanded={false} | ||
| onToggle={toggle} | ||
| collapsedContent={<span>info</span>}> | ||
| <div data-testid="child" /> | ||
| </DateAccordion> | ||
| ); | ||
| expect(screen.getByText('info')).toBeInTheDocument(); | ||
| expect(screen.queryByTestId('child')).not.toBeInTheDocument(); | ||
| fireEvent.click(screen.getByText('Title')); | ||
| expect(screen.getByText("info")).toBeInTheDocument(); | ||
| expect(screen.queryByTestId("child")).not.toBeInTheDocument(); | ||
| const button = screen.getByRole("button", { name: /Title/ }); | ||
| expect(button).toHaveAttribute("aria-expanded", "false"); | ||
| expect(button).toHaveAttribute("aria-controls"); | ||
| fireEvent.click(button); | ||
| expect(toggle).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('renders children when expanded', () => { | ||
| it("renders children when expanded and links aria-controls to the content region", () => { | ||
| render( | ||
| <DateAccordion title="Title" isExpanded={true} onToggle={() => {}} collapsedContent={<span>info</span>}> | ||
| <DateAccordion | ||
| title="Title" | ||
| isExpanded={true} | ||
| onToggle={() => {}} | ||
| collapsedContent={<span>info</span>}> | ||
| <div data-testid="child" /> | ||
| </DateAccordion> | ||
| ); | ||
| expect(screen.getByTestId('child')).toBeInTheDocument(); | ||
| expect(screen.queryByText('info')).not.toBeInTheDocument(); | ||
| const button = screen.getByRole("button", { name: /Title/ }); | ||
| expect(button).toHaveAttribute("aria-expanded", "true"); | ||
| const controls = button.getAttribute("aria-controls"); | ||
| expect(controls).toBeTruthy(); | ||
| expect(screen.getByTestId("child")).toBeInTheDocument(); | ||
| expect(screen.queryByText("info")).not.toBeInTheDocument(); | ||
| const region = controls ? document.getElementById(controls) : null; | ||
| expect(region).toBeInTheDocument(); | ||
| expect(region).toContainElement(screen.getByTestId("child")); | ||
| }); | ||
| }); |
This file contains hidden or 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,62 @@ | ||
| import { fireEvent, render, screen, waitFor } from "@testing-library/react"; | ||
|
|
||
| import { FallbackImage } from "../../../components/common/FallbackImage"; | ||
|
|
||
| describe("FallbackImage", () => { | ||
| afterEach(() => { | ||
| jest.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it("falls back without logging to the console", async () => { | ||
| const errorSpy = jest.spyOn(console, "error").mockImplementation(() => {}); | ||
| const onPrimaryError = jest.fn(); | ||
|
|
||
| render( | ||
| <FallbackImage | ||
| primarySrc="primary.gif" | ||
| fallbackSrc="fallback.gif" | ||
| alt="fallback example" | ||
| onPrimaryError={onPrimaryError} | ||
| /> | ||
| ); | ||
|
|
||
| const image = screen.getByRole("img", { name: "fallback example" }); | ||
| expect(image).toHaveAttribute("src", "primary.gif"); | ||
|
|
||
| fireEvent.error(image); | ||
|
|
||
| await waitFor(() => { | ||
| expect(image).toHaveAttribute("src", "fallback.gif"); | ||
| }); | ||
|
|
||
| expect(onPrimaryError).toHaveBeenCalledTimes(1); | ||
| expect(errorSpy).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("calls onError when both primary and fallback fail", async () => { | ||
| const onPrimaryError = jest.fn(); | ||
| const onError = jest.fn(); | ||
|
|
||
| render( | ||
| <FallbackImage | ||
| primarySrc="primary.gif" | ||
| fallbackSrc="fallback.gif" | ||
| alt="fallback example" | ||
| onPrimaryError={onPrimaryError} | ||
| onError={onError} | ||
| /> | ||
| ); | ||
|
|
||
| const image = screen.getByRole("img", { name: "fallback example" }); | ||
|
|
||
| fireEvent.error(image); | ||
| await waitFor(() => { | ||
| expect(image).toHaveAttribute("src", "fallback.gif"); | ||
| }); | ||
|
|
||
| fireEvent.error(image); | ||
|
|
||
| expect(onPrimaryError).toHaveBeenCalledTimes(1); | ||
| expect(onError).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.