From 05bfbcb55c145203a8e5c109aba65d6f53de0977 Mon Sep 17 00:00:00 2001 From: Guus Ekkelenkamp Date: Sun, 31 May 2026 18:26:48 +0200 Subject: [PATCH 1/2] ci: run test suite + comment coverage on PRs and main pushes Adds a GitHub Actions workflow that runs the Vitest suite with v8 coverage on every pull request and on pushes to main. The coverage report is posted as a sticky PR comment and written to the job summary via davelosert/vitest-coverage-report-action. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d79f011 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + pull-requests: write + +jobs: + test: + name: Test & coverage + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Run tests with coverage + run: > + npx vitest run --coverage + --coverage.reporter=json + --coverage.reporter=json-summary + --coverage.reporter=text-summary + --coverage.reportOnFailure + + # Posts/updates a coverage comment on PRs and writes a coverage summary + # to the job summary on every run (incl. pushes to main). + - name: Coverage report + if: ${{ !cancelled() }} + uses: davelosert/vitest-coverage-report-action@v2 From 1efa87a6f565dce14f0a82c69e7098007b6cd3a9 Mon Sep 17 00:00:00 2001 From: Guus Ekkelenkamp Date: Sun, 31 May 2026 20:12:38 +0200 Subject: [PATCH 2/2] test: pin VITE_SIMPLICATE_BASE_URL fallback so suite is hermetic AccountSettings tests asserted createSimplicateRepository was called with a base URL (expect.anything()), but that URL comes from import.meta.env.VITE_SIMPLICATE_BASE_URL. Locally a gitignored .env supplied it; on CI (no .env) it was undefined, failing the assertion. Pin a deterministic fallback in the global test setup so unit tests no longer depend on a local .env. A real env value still takes precedence. Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/setup.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/setup.ts b/tests/setup.ts index c44951a..e8a874e 100644 --- a/tests/setup.ts +++ b/tests/setup.ts @@ -1 +1,9 @@ import '@testing-library/jest-dom' + +// Make unit tests hermetic. The app reads VITE_SIMPLICATE_BASE_URL from +// import.meta.env at module-load time. Locally a developer's (gitignored) .env +// supplies it, but CI has no .env, leaving the value `undefined` and breaking +// tests that assert a base URL was passed. Pin a deterministic fallback so the +// suite never depends on a local .env. A real env value (if set) still wins. +import.meta.env.VITE_SIMPLICATE_BASE_URL ??= + 'https://test.simplicate.test/api/v2'