Skip to content

feat: amending the test setup in the project - #161

Merged
sdh100shaun merged 12 commits into
mainfrom
feat-testing-editing
Aug 30, 2026
Merged

feat: amending the test setup in the project#161
sdh100shaun merged 12 commits into
mainfrom
feat-testing-editing

Conversation

@sdh100shaun

@sdh100shaun sdh100shaun commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Amends the testing setup sligthly - builds on the work @thebiggh started
Adds coverage and provides some extra gated assurance prior to deploy


What's on the branch now

Two commits were added after the original description, and the branch was
separated from the dependabot bumps it had been sharing a branch with —
those now live in #171, so this PR is test/tooling work only and contains
no version bumps.

Test setup. A second runner joins Playwright, split by filename so the
two can't collide: tests/**/*.spec.ts is Playwright (testMatch) and
tests/{unit,integration}/**/*.test.ts is vitest (include). Without both
filters vitest picks up a .spec.ts, imports test from
@playwright/test, and fails on it. New scripts: test:unit,
test:unit:watch, test:all.

Coverage added. 31 tests across three files:

  • tests/unit/apply-suggestion.test.ts — issue-body parsing, link parsing,
    and the YAML splicing, including a regression test pinning that editing
    one field leaves every other byte of the file identical.
  • tests/unit/suggest-edit-contract.test.ts — the seam that made this
    worth testing. The suggest-an-edit flow restates the same field ids and
    labels across the issue template, EditPanelScript.astro and
    apply-suggestion.mjs, while the workflow trigger matches the template's
    title prefix. A rename in any one of them breaks the flow silently, at
    runtime, for a real contributor. This test reads all of those files and
    asserts they still line up.
  • tests/integration/process-suggestion.test.ts — runs
    apply-suggestion.mjs as a real subprocess against a temp copy of the
    meetups, pinning the stdin / $GITHUB_OUTPUT / MEETUPS_DIR contract the
    workflow depends on.

Deploy gating. deploy.yml's deploy job now needs
[build, unit, test], re-running the suites rather than trusting the PR
run, so a direct push, an admin merge or the cron can't republish a broken
build. Both workflows cache ~/.cache/ms-playwright keyed on the lockfile
hash.

@types/node was added as a devDependency because the new test files,
playwright.config.ts and src/pages/index.astro all reference node
builtins and reported ts(2591) without it. This takes npm run check
from 27 errors to 3.

CLAUDE.md was updated to match: it documented only Playwright, never
mentioned the suggest-an-edit pipeline at all, and its npm run check note
claimed 4 errors from a source that is now only a warning.

Verification

npm ci, npm run build, npm run test:unit (31 passing) and
npm run check (the 3 documented errors) all run clean on this branch on
its own. The three remaining check errors are implicit anys — one in
index.astro, two in the new unit test — and fixing them is what would let
check become a CI gate.

Merge note

This PR and #171 touch ci.yml, deploy.yml and the manifests in
different places. Whichever lands second conflicts only in
package-lock.json; resolve with npm install. The CI jobs added here pin
actions/setup-node@v4 to match main's current convention — #171 moves
everything else to v7, so these will want the same bump once both land.

🤖 Generated with Claude Code

https://claude.ai/code/session_018P7xBafhEuazagBUqaRFo3

@sdh100shaun
sdh100shaun requested review from adam-blakey, chrisemerson and thebiggh and a lite review from Copilot August 29, 2026 08:43
@sdh100shaun sdh100shaun changed the title Feat testing editing feat: amending the test setup in the project Aug 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Vitest-based unit/integration test layer alongside the existing Playwright E2E suite, and wires those tests into CI and the deploy workflow to prevent publishing a broken build—particularly around the “suggest an edit” automation flow.

Changes:

  • Add Vitest configuration plus new unit/integration tests covering the suggest-edit template/client/apply-script contract and apply-suggestion behavior.
  • Refactor scripts/apply-suggestion.mjs to export pure functions for testability, while retaining the CLI entrypoint.
  • Gate GitHub Pages deploys on unit + Playwright test jobs, and tighten Playwright’s matcher to *.spec.ts only.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vitest.config.ts Adds Vitest config with a narrow include pattern to avoid Playwright specs.
tests/unit/suggest-edit-contract.test.ts Adds contract tests pinning template/client/workflow/apply-script seams.
tests/unit/apply-suggestion.test.ts Adds unit tests for parsing and patching logic in apply-suggestion.
tests/integration/process-suggestion.test.ts Adds a subprocess-level integration test for the CLI and step outputs.
scripts/apply-suggestion.mjs Exports functions and introduces a pure applySuggestion function used by tests.
playwright.config.ts Restricts Playwright discovery to *.spec.ts so Vitest can own *.test.ts.
package.json Adds Vitest dependency and scripts (test:unit, test:all, etc.).
package-lock.json Locks Vitest and its transitive deps.
.github/workflows/deploy.yml Adds unit + Playwright test jobs and makes deploy depend on them.
.github/workflows/ci.yml Adds a unit-test job and Playwright browser caching in CI.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/integration/process-suggestion.test.ts Outdated
Comment thread scripts/apply-suggestion.mjs
thebiggh
thebiggh previously approved these changes Aug 29, 2026
adam-blakey
adam-blakey previously approved these changes Aug 29, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@sdh100shaun
sdh100shaun dismissed stale reviews from adam-blakey and thebiggh via aec3631 August 29, 2026 14:26
Copilot AI and others added 2 commits August 29, 2026 14:28
Co-authored-by: sdh100shaun <79883+sdh100shaun@users.noreply.github.com>
Co-authored-by: sdh100shaun <79883+sdh100shaun@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 29, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated no new comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

scripts/apply-suggestion.mjs:119

  • The "no meetup file found" error message says the group name must match exactly as shown on the site, but findMeetupFile() actually matches case-insensitively and trims whitespace. This message is misleading for contributors troubleshooting a failure.
		throw new Error(
			`No meetup file found with name "${groupName}" — it must match exactly as shown on the site.`,
		);

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Comment thread tests/unit/apply-suggestion.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Comment thread scripts/apply-suggestion.mjs
Comment thread .github/workflows/ci.yml Outdated
sdh100shaun and others added 2 commits August 30, 2026 08:43
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 30, 2026 07:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated no new comments.

Suppressed comments (1)

scripts/apply-suggestion.mjs:197

  • The script-entry guard compares import.meta.url (a URL-encoded string) to process.argv[1] (a filesystem path). If the path contains characters that get percent-encoded in a file URL (e.g. spaces), endsWith() will be false and main() won’t run when invoked as a script. Decoding the URL before the comparison avoids this class of false negatives.
// Only run main() when invoked as a script, not when imported by a test.
const invokedAsScript =
	process.argv[1] &&
	import.meta.url.endsWith(process.argv[1].replaceAll('\\', '/'));

@thebiggh
thebiggh self-requested a review August 30, 2026 08:16
thebiggh
thebiggh previously approved these changes Aug 30, 2026
sdh100shaun and others added 2 commits August 30, 2026 09:22
Every file that touches node builtins — src/pages/index.astro,
playwright.config.ts and the three new test files — reported
ts(2591) 'Cannot find name node:fs/promises' because @types/node was
never installed. tsconfig.json sets no "types" field, so installing the
package is enough for TS to pick it up.

npm run check: 27 errors -> 3. Pinned to ^22 to match the node-version
used by every workflow. Unit/integration (31) and Playwright (30, 1
data-conditional skip) all still pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The guide predated the test/ and suggestion work now on this branch, so it
described a repo that no longer exists in three places:

- Only Playwright was documented. There are now two runners split by
  filename (*.spec.ts vs tests/{unit,integration}/**/*.test.ts), which is a
  rule a new test file has to obey — so it needs to be written down.
- The "suggest an edit" flow — edit panel to issue form to
  apply-suggestion.mjs to PR — was entirely absent, including the label
  contract spread across five files that suggest-edit-contract.test.ts
  exists to pin.
- CI had drifted: four jobs on PRs, deploy gated on [build, unit, test],
  Playwright browser caching. The `npm run check` note also claimed 4 errors
  from z.string().url(); it is now 3 errors elsewhere and that one is a
  warning.

Verified against the tree rather than the diff: npm run test:unit (31
passing), npm run build, and npm run check for the error count. Both new
example commands were run.
Copilot AI review requested due to automatic review settings August 30, 2026 08:26
@sdh100shaun
sdh100shaun requested a review from a team August 30, 2026 08:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

.github/workflows/deploy.yml:61

  • The new test job also inherits workflow-level pages: write / id-token: write permissions even though it only needs to read the repo. Consider overriding job permissions to contents: read to reduce the token scope.
  test:
    runs-on: ubuntu-latest
    steps:

Comment thread .github/workflows/deploy.yml
adam-blakey
adam-blakey previously approved these changes Aug 30, 2026
Comment thread .github/workflows/deploy.yml
…oy.yml

Co-authored-by: sdh100shaun <79883+sdh100shaun@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated no new comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

scripts/apply-suggestion.mjs:119

  • The error message says the group name must "match exactly as shown on the site", but findMeetupFile() matches case-insensitively and trims whitespace (name.trim().toLowerCase() === groupName.trim().toLowerCase()). This is misleading for users who only differ by case/spacing.
	if (!match) {
		throw new Error(
			`No meetup file found with name "${groupName}" — it must match exactly as shown on the site.`,
		);

@thebiggh
thebiggh self-requested a review August 30, 2026 13:40
@sdh100shaun
sdh100shaun merged commit a79d7cb into main Aug 30, 2026
13 of 16 checks passed
@sdh100shaun
sdh100shaun deleted the feat-testing-editing branch August 30, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants