prototypey.org - atproto lexicon typescript toolkit - mirror https://github.com/tylersayshi/prototypey

fix act error

Tyler 8c94efac 305a208f

+20 -5
+14 -4
packages/site/tests/components/Editor.test.tsx
··· 1 1 import { describe, it, expect, vi } from "vitest"; 2 - import { render, screen } from "@testing-library/react"; 2 + import { render, screen, waitFor } from "@testing-library/react"; 3 3 import { userEvent } from "@testing-library/user-event"; 4 4 import { Editor } from "../../src/components/Editor"; 5 5 ··· 53 53 expect(screen.getByText("Input")).toBeInTheDocument(); 54 54 55 55 // Wait for loader to complete 56 - await screen.findByTestId("monaco-editor"); 56 + await waitFor(() => { 57 + expect(screen.getByTestId("monaco-editor")).toBeInTheDocument(); 58 + }); 57 59 }); 58 60 59 61 it("calls onChange when value changes", async () => { ··· 61 63 render(<Editor value="" onChange={mockOnChange} />); 62 64 63 65 // Wait for loader to complete 64 - const editor = await screen.findByTestId("monaco-editor"); 66 + await waitFor(() => { 67 + expect(screen.getByTestId("monaco-editor")).toBeInTheDocument(); 68 + }); 69 + 70 + const editor = screen.getByTestId("monaco-editor"); 65 71 await userEvent.type(editor, "test"); 66 72 67 73 expect(mockOnChange).toHaveBeenCalled(); ··· 72 78 render(<Editor value="const x = 1" onChange={mockOnChange} />); 73 79 74 80 // Wait for loader to complete 75 - const editor = await screen.findByTestId("monaco-editor"); 81 + await waitFor(() => { 82 + expect(screen.getByTestId("monaco-editor")).toBeInTheDocument(); 83 + }); 84 + 85 + const editor = screen.getByTestId("monaco-editor"); 76 86 expect(editor).toHaveValue("const x = 1"); 77 87 }); 78 88 });
+6 -1
packages/site/tests/components/Playground.test.tsx
··· 61 61 })); 62 62 63 63 describe("Playground", () => { 64 - it("renders Editor and OutputPanel components", () => { 64 + it("renders Editor and OutputPanel components", async () => { 65 65 render(<Playground />); 66 66 67 67 expect(screen.getByText("Input")).toBeInTheDocument(); 68 68 expect(screen.getByText("Output")).toBeInTheDocument(); 69 + 70 + // Wait for async state updates to complete 71 + await waitFor(() => { 72 + expect(screen.getAllByTestId("monaco-editor").length).toBeGreaterThan(0); 73 + }); 69 74 }); 70 75 71 76 it("starts with default code in editor", async () => {