Skip to content

Commit edc305b

Browse files
committed
refactor(test): cleans up BDD step definitions per review
1 parent 9ab4a45 commit edc305b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

tests/acceptance/steps/org-order-stability.steps.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { vi, expect } from "vitest";
22

3-
// Prevent @solidjs/testing-library from auto-cleaning the DOM between steps.
4-
// vitest-cucumber maps each Given/When/Then to a separate test(), so the DOM
5-
// must persist across steps within a scenario. Cleanup is done manually in
6-
// AfterEachScenario instead.
3+
// vitest-cucumber maps each Given/When/Then to a separate test(). The DOM must
4+
// persist across steps within a scenario, but @solidjs/testing-library registers
5+
// afterEach(cleanup) at import time — vi.hoisted ensures the env var is set
6+
// BEFORE that import evaluates. Manual cleanup in AfterEachScenario replaces it.
77
vi.hoisted(() => {
88
process.env.STL_SKIP_AUTO_CLEANUP = "true";
99
});
10-
import type { RepoEntry } from "../../../src/app/services/api";
10+
import type { RepoEntry, OrgEntry } from "../../../src/app/services/api";
1111

1212
// Mock getClient before importing component
1313
const mockRequest = vi.fn().mockResolvedValue({ data: {} });
@@ -75,14 +75,12 @@ function getAccordionOrder(orgNames: string[]): string[] {
7575
}
7676

7777
// ── State shared across steps within a scenario ───────────────────────────────
78-
type OrgEntry = { login: string; avatarUrl: string; type: "user" | "org" };
79-
let setSelectedOrgs: (orgs: string[]) => void;
80-
let setOrgEntries: (entries: OrgEntry[]) => void;
78+
let setSelectedOrgs: (orgs: string[]) => void = () => {};
79+
let setOrgEntries: (entries: OrgEntry[]) => void = () => {};
8180

8281
describeFeature(feature, ({ Scenario, Background, BeforeEachScenario, AfterEachScenario }) => {
8382
BeforeEachScenario(() => {
8483
vi.clearAllMocks();
85-
vi.restoreAllMocks();
8684
mockRequest.mockResolvedValue({ data: {} });
8785
vi.mocked(api.fetchOrgs).mockResolvedValue([]);
8886
vi.mocked(api.discoverUpstreamRepos).mockResolvedValue([]);

0 commit comments

Comments
 (0)