Repository navigation
Run Playwright specs that use a local fixtures file under playwright test, and let a repo send chosen tests to its own runner - #4347
Conversation
…test, and let a repo name its own runner per path
pregate marked a spec as Playwright only when the spec itself imported
@playwright/test. Specs that take `test` from a local fixtures module
(`export const test = base.extend(...)`) went to the package's vitest,
which found no test files and failed the lane. pregate now follows the
modules a test takes `test` from.
A spec whose harness must build first cannot run under a bare
`playwright test`, so `.gstack/pregate.json` gains `runners`:
`{ when: [globs], runner, cwd? }` rules that send matching selected
files to the repo's own command, ahead of `runner` and detection.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A runners rule is a command like runner. Adding or editing one on the base now changes the trusted command set, so nothing runs until the user agrees again, and detect and the consent refusal name each rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
Thanks for this, and for the live runs and the sabotage table. The detection half (a spec that takes |
|
Thank you for this. We're picking up the idea. A maintainer agent working through a batch of fixes (our tracking thread GSTA-805) will first reproduce the problem on current main. If it reproduces, the agent rebuilds the fix on main with you credited as co-author, because we don't merge outside branches directly, and we'll close this PR with a link when it lands. If it no longer reproduces, we'll close this and say what changed. The rebuild will likely take only the detection half. Other work on the same pregate files has to land first, so this may take a few days. |
…xture specs run under Playwright (#4702) Deleting or renaming a test now runs the tests of files that still list it even when another test already covers it, and Playwright specs that take `test` from a local fixtures file run under `playwright test`. Why: a deleted test could pass the local checks while a stale curation list failed after merge (#3536), and fixture-based Playwright specs went to the unit runner and failed (#4347). Nothing to do. A repo whose specs import `@playwright/test` directly sees no change. Co-authored-by: Yuan S. <[email protected]> Co-authored-by: marcode <[email protected]> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: review-p1/specialist-batched#1 reader=specialist-batched Review-Finding: review-p1/specialist-batched#2 reader=specialist-batched Review-Finding: review-p1/red-team#1 reader=red-team Review-Finding: review-v1/outside-voice#1 reader=outside-voice Review-Finding: review-v1/outside-voice#2 reader=outside-voice Review-Finding: review-v1/outside-voice#3 reader=outside-voice Review-Finding: review-v1/outside-voice#4 reader=outside-voice Review-Finding: review-p2/specialist-batched#1 reader=specialist-batched Review-Finding: review-p2/red-team#1 reader=red-team
|
Thank you @vilano93. The detection half of this landed in #4702, rebuilt on current main with you credited as co-author: a spec that takes |
Why (in your own words)
My app repo has vitest unit tests and Playwright specs in one package. Every spec takes
testfrom its own fixtures file (export const test = base.extend(…), thenimport { expect, test } from './fixture'), which is Playwright's documented fixtures pattern. pregate only marks a spec as Playwright when the spec itself imports@playwright/test(#3741). So a diff that touches only a spec, even one comment line, sends it tovitest run <spec>. Vitest finds no test files, the lane fails, and/shipcannot publish a record. This PR follows the modules a test takestestfrom. A unit test that imports some other Playwright-based helper keeps its unit runner.Detection alone does not get my specs to pass. My harness has to build the native engine and the bundle before a spec can start, and the repo's entry point
pnpm run e2e -- <spec>does that build, while a bareplaywright testdeliberately never builds. A repo can declare only onerunnerfor every file today, so I addrunnersto.gstack/pregate.json. A rule is{ when: [globs], runner, cwd? }, and the selected files it matches go to that command ahead ofrunnerand detection, first match wins. Every other file keeps today's plan.gstack-checkstreats each rule as a command that needs consent, likerunner.Live evidence
Same branch, where one commit changes one comment line in
app/e2e/smoke.spec.ts(laterediting-flag.spec.ts). Command:gstack-pregate run --stage tests --allow-repo-commands --base <base>.Installed 1.99.2.0, the spec goes to vitest:
This branch, no
runnersrule: the spec is now seen as Playwright. My harness then refuses to start on a stale bundle, which is why the second part exists:This branch, base policy with
"runners": [{ "when": ["app/e2e/*.spec.ts"], "runner": "pnpm run e2e -- {files}", "cwd": "app/e2e" }]: the spec runs through the repo's entry point, which builds and then runs it:The two requires-remote obligations are the repo's Linux CI lanes, unchanged by this PR.
The four new tests were red before the fix:
The first one was red because the specs went into the vitest group (
e2e/smoke.spec.ts,e2e/deep.spec.tsunderpnpm exec vitest run). The consent test was red because a rule added on the base ran with exit 0 and no new consent.To confirm the tests can fail, I broke the code on purpose:
runnersignored (planRunsskips the rules)cwdvalidation removedScope
lib/pregate/checks/lanes.ts:playwrightSpecfollows the modules a test takestestfrom, throughimport { test }, aliases,export { test } from,indexmodules and.jsspecifiers that name.tssources, up to 8 hops and only inside the repo.planRunsappliesrunnersrules first. A matched file outside the rule'scwdisunclaimed, so the lane readsincomplete.lib/pregate/config.ts: therunnerskey, with validation (non-empty globs, a{files}command, a containedcwd, no unknown keys, at most 32 rules) and the--explainline.lib/pregate/head-policy.ts:runnersis frozen under--policy-from head, likerunner.lib/checks.ts,bin/gstack-checks:detectand the consent refusal list each rule.docs/pregate.md: therunnerrow gets the fixtures detection, and there is a newrunnersrow.test/pregate-selection.test.ts,test/gstack-checks.test.ts: the four tests above.changelog.d/fix-pregate-playwright-fixtures.md: the changelog fragment.bun run typecheckis clean, andbun run typecheck:testreports none new.test_backend: they still receive the whole selection, and the docs say so.test:quickfails inqa-functional-observer-atomic,relink-disabled-router,render-sections-provenanceandtranscript-consent.pregate-head-policyfails twice andpregate-guardsonce. All of these fail the same way on an untouched upstream/main checkout on this machine, so CI is the judge here.runnerscommand that wraps Playwright gets the generic summary parser. My entry point prints a fixture project's1 passedbefore the spec's2 passed, so the lane says "1 tests ran" for two tests. The verdict comes from the exit code and stays right. Picking the Playwright parser for any output with Playwright'sRunning N tests usingheader would fix the count. I left that out to keep this PR to one concern.testfrom a local module built on@playwright/testmoves from the unit runner toplaywright test. Before, a diff that also touched a unit test made vitest drop the spec silently, so the spec now really runs, and a stale harness can turn the lane red for the first time.runnersis the way out for such a repo.Liveness proof (required for external contributors)
Checklist
GSTACK PRtyped live into a real surface) or PR author is@garrytan(owner exemption)🤖 Generated with Claude Code