Repository navigation
test(dashboard): cover environment parsing and subdomain editing - #243
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Vitest-based testing infrastructure to apps/dashboard, enabling .tsx component tests (via a jsdom project) while keeping existing logic tests on Node, and introduces initial unit test suites for several previously-untested modules. Also extends CONTRIBUTING.md with guidance on the new dashboard test setup and workflow.
Changes:
- Add
apps/dashboard/vitest.config.tswith@/*runtime aliasing, JSX transform override, and a split Node/jsdom project setup. - Add
apps/dashboard/vitest.setup.tsto register jest-dom matchers and ensure React Testing Library cleanup runs withglobals: false. - Add new unit test suites for dotenv parsing, subdomain normalization, project status derivation, and deployment phase detection; update dashboard devDependencies accordingly.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| CONTRIBUTING.md | Documents test layout and the dashboard’s split Vitest project approach. |
| bun.lock | Adds the new dashboard devDependencies (including jsdom/testing-library) and resulting lock updates. |
| apps/dashboard/package.json | Adds Vitest DOM/component testing devDependencies. |
| apps/dashboard/vitest.config.ts | Introduces Vitest config (alias + JSX override) and splits tests into Node vs jsdom projects by extension. |
| apps/dashboard/vitest.setup.ts | Adds jest-dom integration and explicit RTL cleanup after each test. |
| apps/dashboard/src/lib/dotenv.test.ts | Adds unit coverage for dotenv parsing behavior. |
| apps/dashboard/src/utils/deploymentPhaseDetector.test.ts | Adds extensive unit coverage for phase detection and log parsing/aggregation behavior. |
| apps/dashboard/src/utils/project-status.test.ts | Adds unit coverage for status precedence + label/meta utilities. |
| apps/dashboard/src/utils/subdomain.test.ts | Adds unit coverage for subdomain normalization behaviors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Tests are colocated with the code they cover: `foo.test.ts` sits next to `foo.ts`. Every | ||
| workspace uses [Vitest](https://vitest.dev/). |
| expect(normalizeSubdomain("café")).toBe("caf"); | ||
| }); | ||
|
|
||
| it("strips leading and trailing hyphens, unlike normalizeSubdomandInput", () => { |
| // Exhaustiveness guard: every ProjectStatus value must have non-empty | ||
| // styling, so adding a new status without wiring up its badge/dot fails | ||
| // this test loudly instead of silently rendering blank CSS classes. | ||
| const allStatuses: ProjectStatus[] = [ |
|
Thanks, all three were correct. Addressed in 07c7dc2. 1. 2. Typo fixed. 3. The "exhaustiveness guard" comment overclaimed. You were right that a manual array silently drifts. Rather than soften the wording, I made the guard real by keying it as a const STATUS_COVERAGE: Record<ProjectStatus, true> = { live: true, /* ... */ draft: true };
const allStatuses = Object.keys(STATUS_COVERAGE) as ProjectStatus[];Verified it actually fails now by temporarily adding So adding a status without covering it now breaks |
Adds 23 dashboard cases for pasted environment files and subdomain normalization, including quoted values, inline comments, CRLF, empty values, and preserving the hyphen a user is typing. CONTRIBUTING.md documents the workspace test conventions and local component cleanup.
Validation: 68 tests pass across the new suites and existing project-status and log-entry suites. Uses the dashboard’s existing Vitest configuration.
Related to #216. Integrates into the bug-review branch in #892; the contributor’s original commits are preserved.