Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/CardGeneratorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ export default function CardGeneratorModal({
const previousFocusRef = useRef<HTMLElement | null>(null);

useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect
setMounted(true);
const timer = setTimeout(() => setMounted(true), 0);
return () => clearTimeout(timer);
}, []);

const {
Expand Down
9 changes: 6 additions & 3 deletions src/components/__tests__/CardGeneratorModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

vi.mock("next/image", () => ({
__esModule: true,
default: (props: Record<string, unknown>) => <img alt="Mocked Next Image" {...props} data-testid="next-image" />,

Check warning on line 26 in src/components/__tests__/CardGeneratorModal.test.tsx

View workflow job for this annotation

GitHub Actions / Lint

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` or a custom image loader to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
}));

const mockSummary: UserSummary = {
Expand Down Expand Up @@ -101,8 +101,8 @@
summary={mockSummary}
/>
);
expect(screen.getByRole("dialog")).toBeInTheDocument();
expect(screen.getByText("Profile Card")).toBeInTheDocument();
expect(await screen.findByRole("dialog")).toBeInTheDocument();
expect(await screen.findByText("Profile Card")).toBeInTheDocument();
});

it("switches tabs between Settings and Layout", async () => {
Expand All @@ -116,7 +116,7 @@
);

// Default tab is Settings
expect(screen.getByText("Avatar")).toBeInTheDocument(); // part of Detail Options
expect(await screen.findByText("Avatar")).toBeInTheDocument(); // part of Detail Options
expect(screen.queryByTestId("layout-editor")).not.toBeInTheDocument();

// Click Edit Layout tab
Expand All @@ -141,6 +141,9 @@
/>
);

// Wait for the modal to be fully mounted
await screen.findByRole("dialog");

await user.keyboard("{Escape}");
expect(handleClose).toHaveBeenCalledTimes(1);
});
Expand Down
Loading