Skip to content
Merged
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
6 changes: 2 additions & 4 deletions apps/studio/src/ui/StudioWorkspace.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ describe("StudioWorkspace", () => {
expect(status.getByText("Draft saved")).toBeInTheDocument();
fireEvent.input(title, { target: { value: "Pods!" } });
expect(status.getByText("Saving the draft…")).toBeInTheDocument();
expect(await status.findByText("Draft saved", {}, { timeout: 3000 })).toBeInTheDocument();
expect(await status.findByText("Draft saved")).toBeInTheDocument();
expect(useCases.editReleaseDraft).toHaveBeenCalledTimes(1);
});

Expand All @@ -1666,9 +1666,7 @@ describe("StudioWorkspace", () => {
const title = await screen.findByRole("textbox", { name: "Title" });
await waitFor(() => expect(title).toBeEnabled());
fireEvent.input(title, { target: { value: "Pods!" } });
expect(
await status.findByText("Last change not saved", {}, { timeout: 3000 }),
).toBeInTheDocument();
expect(await status.findByText("Last change not saved")).toBeInTheDocument();
});

it("keeps the cards' view in the URL, replacing the entry", async () => {
Expand Down
7 changes: 6 additions & 1 deletion docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,12 @@ runs every package's tests at once with coverage on, and takes some
tests fifty times as long as a laptop does: the generator's check of
`ns/` took over 5 s there, against 0.1 s. Tests that read a file at the
size limits, about a second on a laptop, ran out of 30 s on a slow
runner. A test that hangs still fails.
runner. A test that hangs still fails. For the same reason, a
Testing Library query that waits (`findBy…`, `waitFor`) waits 10 s,
not its 1 s. The setting is in `packages/ui/src/test/setup.ts`, which
the Studio's and the web app's setup import. A screen whose button came
after a few reads of its data, about 0.1 s on a laptop, ran out of 1 s
in CI.

## Strategy per layer

Expand Down
9 changes: 9 additions & 0 deletions packages/ui/src/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
// SPDX-License-Identifier: MIT

import "@testing-library/jest-dom/vitest";
import { configure } from "@testing-library/preact";
import { LOCALES } from "@solid-memo/domain/locale";
import { loadLocale } from "../ui/i18n";

// Every language's messages, fetched as the page fetches the one it speaks
// before it renders (apps/web/src/main.tsx), so a test speaks any of them.
await Promise.all(LOCALES.map(loadLocale));

// A findBy query or waitFor waits 10 s, not Testing Library's 1 s, for
// what it waits for, as a test may take 60 s, not vitest's 5
// (vitest.shared.ts): CI takes some tests fifty times as long as a
// laptop does, and a screen that reads its data in a few steps, about
// 0.1 s on a laptop, ran out of the 1 s there. A query that never
// matches still fails, later.
configure({ asyncUtilTimeout: 10_000 });

// happy-dom has no HTMLElement.translate. Browsers reflect it as the
// translate="yes"/"no" attribute, which Preact sets as a property
// (`translate={false}` on code from data), so the tests see the same.
Expand Down
Loading