@virtocommerce/test-automation-framework 0.0.0-stage → 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/.biome/formatter.json +11 -0
  2. package/.biome/imports.json +52 -0
  3. package/.biome/preset.json +4 -0
  4. package/.biome/rules.json +45 -0
  5. package/.claude/agents/qa-automation-expert.md +119 -0
  6. package/.claude/agents/qa-coverage.md +96 -0
  7. package/.claude/agents/qa-explorer.md +112 -0
  8. package/.claude/agents/qa-healer.md +88 -0
  9. package/.claude/agents/qa-judge.md +102 -0
  10. package/.claude/agents/qa-planner.md +104 -0
  11. package/.claude/agents/qa-reviewer.md +121 -0
  12. package/.claude/checks/browser-secrets.mts +107 -0
  13. package/.claude/checks/contract.mts +469 -0
  14. package/.claude/checks/expectation-guard.mts +665 -0
  15. package/.claude/checks/explore-extractors.mts +4 -0
  16. package/.claude/checks/judge-verdict.mts +165 -0
  17. package/.claude/checks/project-facts.mts +491 -0
  18. package/.claude/checks/prove-fails.mts +770 -0
  19. package/.claude/checks/rank-gaps.mts +177 -0
  20. package/.claude/checks/readonly-shell.mts +740 -0
  21. package/.claude/checks/reconcile-run.mts +270 -0
  22. package/.claude/checks/scan-prompts.mts +351 -0
  23. package/.claude/checks/stand.mts +45 -0
  24. package/.claude/checks/test-duration.mts +134 -0
  25. package/.claude/checks/test-shape.mts +224 -0
  26. package/.claude/checks/ticket-card.mts +195 -0
  27. package/.claude/commands/qa-coverage.md +13 -0
  28. package/.claude/commands/qa-explore.md +17 -0
  29. package/.claude/commands/qa-heal.md +44 -0
  30. package/.claude/commands/qa-implement.md +60 -0
  31. package/.claude/commands/qa-plan.md +55 -0
  32. package/.claude/commands/qa-review.md +90 -0
  33. package/.claude/commands/qa.md +156 -0
  34. package/.claude/hooks/readonly-shell.mts +65 -0
  35. package/.claude/settings.json +15 -0
  36. package/.claude/skills/coverage-analysis/SKILL.md +107 -0
  37. package/.claude/skills/create-graphql-layer/SKILL.md +159 -0
  38. package/.claude/skills/create-ui-layer/SKILL.md +189 -0
  39. package/.claude/skills/explore-api/SKILL.md +74 -0
  40. package/.claude/skills/explore-frontend/SKILL.md +85 -0
  41. package/.claude/skills/framework-rules/SKILL.md +189 -0
  42. package/.claude/skills/heal-tests/SKILL.md +197 -0
  43. package/.claude/skills/heal-tests/guard-recipe.md +53 -0
  44. package/.claude/skills/judge-criteria/SKILL.md +40 -0
  45. package/.claude/skills/judge-criteria/coverage.md +9 -0
  46. package/.claude/skills/judge-criteria/expert.md +23 -0
  47. package/.claude/skills/judge-criteria/explorer.md +9 -0
  48. package/.claude/skills/judge-criteria/healer.md +13 -0
  49. package/.claude/skills/judge-criteria/planner.md +12 -0
  50. package/.claude/skills/plan-implementation/SKILL.md +82 -0
  51. package/.claude/skills/plan-implementation/contract-template.md +72 -0
  52. package/.claude/skills/plan-test-strategy/SKILL.md +100 -0
  53. package/.claude/skills/project-facts/SKILL.md +130 -0
  54. package/.claude/skills/read-change/SKILL.md +64 -0
  55. package/.claude/skills/read-ticket/SKILL.md +63 -0
  56. package/.claude/skills/read-ticket/providers.md +58 -0
  57. package/.claude/skills/review-pr/SKILL.md +152 -0
  58. package/.claude/skills/review-test-code/SKILL.md +208 -0
  59. package/.claude/skills/write-e2e-test/SKILL.md +175 -0
  60. package/.claude/skills/write-graphql-test/SKILL.md +158 -0
  61. package/.claude/skills/write-rest-api-test/SKILL.md +182 -0
  62. package/.claude/skills/write-security-test/SKILL.md +253 -0
  63. package/.qa/project.example.json +71 -0
  64. package/CHANGELOG.md +1 -0
  65. package/LICENSE +12 -0
  66. package/README.md +53 -2
  67. package/bin/install-qa-agents.mjs +94 -0
  68. package/dist/auth/credentials.d.ts +10 -0
  69. package/dist/auth/credentials.js +2 -0
  70. package/dist/auth/credentials.js.map +1 -0
  71. package/dist/auth/frontend-browser-sessions.d.ts +71 -0
  72. package/dist/auth/frontend-browser-sessions.js +130 -0
  73. package/dist/auth/frontend-browser-sessions.js.map +1 -0
  74. package/dist/auth/index.d.ts +9 -0
  75. package/dist/auth/index.js +5 -0
  76. package/dist/auth/index.js.map +1 -0
  77. package/dist/auth/platform-browser-sessions.d.ts +47 -0
  78. package/dist/auth/platform-browser-sessions.js +92 -0
  79. package/dist/auth/platform-browser-sessions.js.map +1 -0
  80. package/dist/auth/sign-in-lock.d.ts +14 -0
  81. package/dist/auth/sign-in-lock.js +70 -0
  82. package/dist/auth/sign-in-lock.js.map +1 -0
  83. package/dist/auth/storage-state.d.ts +3 -0
  84. package/dist/auth/storage-state.js +2 -0
  85. package/dist/auth/storage-state.js.map +1 -0
  86. package/dist/auth/token-client.d.ts +82 -0
  87. package/dist/auth/token-client.js +111 -0
  88. package/dist/auth/token-client.js.map +1 -0
  89. package/dist/auth/token-manager.d.ts +67 -0
  90. package/dist/auth/token-manager.js +138 -0
  91. package/dist/auth/token-manager.js.map +1 -0
  92. package/dist/core/default-reporters.d.ts +31 -0
  93. package/dist/core/default-reporters.js +36 -0
  94. package/dist/core/default-reporters.js.map +1 -0
  95. package/dist/core/default-use.d.ts +28 -0
  96. package/dist/core/default-use.js +25 -0
  97. package/dist/core/default-use.js.map +1 -0
  98. package/dist/core/env.d.ts +24 -0
  99. package/dist/core/env.js +33 -0
  100. package/dist/core/env.js.map +1 -0
  101. package/dist/core/error-message.d.ts +10 -0
  102. package/dist/core/error-message.js +13 -0
  103. package/dist/core/error-message.js.map +1 -0
  104. package/dist/core/index.d.ts +16 -0
  105. package/dist/core/index.js +11 -0
  106. package/dist/core/index.js.map +1 -0
  107. package/dist/core/is-ci.d.ts +14 -0
  108. package/dist/core/is-ci.js +18 -0
  109. package/dist/core/is-ci.js.map +1 -0
  110. package/dist/core/parse-env.d.ts +13 -0
  111. package/dist/core/parse-env.js +21 -0
  112. package/dist/core/parse-env.js.map +1 -0
  113. package/dist/core/projects.d.ts +24 -0
  114. package/dist/core/projects.js +33 -0
  115. package/dist/core/projects.js.map +1 -0
  116. package/dist/core/run-options.d.ts +31 -0
  117. package/dist/core/run-options.js +43 -0
  118. package/dist/core/run-options.js.map +1 -0
  119. package/dist/core/secret.d.ts +105 -0
  120. package/dist/core/secret.js +167 -0
  121. package/dist/core/secret.js.map +1 -0
  122. package/dist/core/string-schemas.d.ts +39 -0
  123. package/dist/core/string-schemas.js +56 -0
  124. package/dist/core/string-schemas.js.map +1 -0
  125. package/dist/core/url-path.d.ts +7 -0
  126. package/dist/core/url-path.js +2 -0
  127. package/dist/core/url-path.js.map +1 -0
  128. package/dist/dataset/collection.d.ts +44 -0
  129. package/dist/dataset/collection.js +76 -0
  130. package/dist/dataset/collection.js.map +1 -0
  131. package/dist/dataset/index.d.ts +11 -0
  132. package/dist/dataset/index.js +6 -0
  133. package/dist/dataset/index.js.map +1 -0
  134. package/dist/dataset/load-dataset.d.ts +39 -0
  135. package/dist/dataset/load-dataset.js +62 -0
  136. package/dist/dataset/load-dataset.js.map +1 -0
  137. package/dist/dataset/manifest.d.ts +77 -0
  138. package/dist/dataset/manifest.js +10 -0
  139. package/dist/dataset/manifest.js.map +1 -0
  140. package/dist/dataset/placeholders.d.ts +66 -0
  141. package/dist/dataset/placeholders.js +87 -0
  142. package/dist/dataset/placeholders.js.map +1 -0
  143. package/dist/dataset/seed-collection.d.ts +53 -0
  144. package/dist/dataset/seed-collection.js +115 -0
  145. package/dist/dataset/seed-collection.js.map +1 -0
  146. package/dist/dataset/seed-dataset.d.ts +70 -0
  147. package/dist/dataset/seed-dataset.js +138 -0
  148. package/dist/dataset/seed-dataset.js.map +1 -0
  149. package/dist/dataset/seed-events.d.ts +81 -0
  150. package/dist/dataset/seed-events.js +2 -0
  151. package/dist/dataset/seed-events.js.map +1 -0
  152. package/dist/dataset/seed-requests.d.ts +102 -0
  153. package/dist/dataset/seed-requests.js +160 -0
  154. package/dist/dataset/seed-requests.js.map +1 -0
  155. package/dist/dataset/seed-scope.d.ts +39 -0
  156. package/dist/dataset/seed-scope.js +67 -0
  157. package/dist/dataset/seed-scope.js.map +1 -0
  158. package/dist/fixtures/default-fixtures.d.ts +93 -0
  159. package/dist/fixtures/default-fixtures.js +105 -0
  160. package/dist/fixtures/default-fixtures.js.map +1 -0
  161. package/dist/fixtures/index.d.ts +2 -0
  162. package/dist/fixtures/index.js +2 -0
  163. package/dist/fixtures/index.js.map +1 -0
  164. package/dist/graphql/graphql-client.d.ts +78 -0
  165. package/dist/graphql/graphql-client.js +83 -0
  166. package/dist/graphql/graphql-client.js.map +1 -0
  167. package/dist/graphql/graphql-codegen.d.ts +56 -0
  168. package/dist/graphql/graphql-codegen.js +42 -0
  169. package/dist/graphql/graphql-codegen.js.map +1 -0
  170. package/dist/graphql/graphql-error.d.ts +54 -0
  171. package/dist/graphql/graphql-error.js +74 -0
  172. package/dist/graphql/graphql-error.js.map +1 -0
  173. package/dist/graphql/index.d.ts +6 -0
  174. package/dist/graphql/index.js +4 -0
  175. package/dist/graphql/index.js.map +1 -0
  176. package/dist/http/authentication.d.ts +16 -0
  177. package/dist/http/authentication.js +2 -0
  178. package/dist/http/authentication.js.map +1 -0
  179. package/dist/http/http-client.d.ts +110 -0
  180. package/dist/http/http-client.js +237 -0
  181. package/dist/http/http-client.js.map +1 -0
  182. package/dist/http/http-error.d.ts +26 -0
  183. package/dist/http/http-error.js +34 -0
  184. package/dist/http/http-error.js.map +1 -0
  185. package/dist/http/http-method.d.ts +2 -0
  186. package/dist/http/http-method.js +2 -0
  187. package/dist/http/http-method.js.map +1 -0
  188. package/dist/http/http-response.d.ts +137 -0
  189. package/dist/http/http-response.js +166 -0
  190. package/dist/http/http-response.js.map +1 -0
  191. package/dist/http/index.d.ts +7 -0
  192. package/dist/http/index.js +4 -0
  193. package/dist/http/index.js.map +1 -0
  194. package/dist/http/request-options.d.ts +62 -0
  195. package/dist/http/request-options.js +2 -0
  196. package/dist/http/request-options.js.map +1 -0
  197. package/dist/modules/index.d.ts +2 -0
  198. package/dist/modules/index.js +2 -0
  199. package/dist/modules/index.js.map +1 -0
  200. package/dist/modules/installed-modules.d.ts +86 -0
  201. package/dist/modules/installed-modules.js +135 -0
  202. package/dist/modules/installed-modules.js.map +1 -0
  203. package/docs/README.md +43 -0
  204. package/docs/concepts/areas.md +38 -0
  205. package/docs/concepts/auth.md +92 -0
  206. package/docs/concepts/config.md +102 -0
  207. package/docs/concepts/dataset.md +183 -0
  208. package/docs/concepts/environment.md +54 -0
  209. package/docs/concepts/fixtures.md +109 -0
  210. package/docs/concepts/graphql.md +76 -0
  211. package/docs/concepts/http.md +88 -0
  212. package/docs/concepts/modules.md +63 -0
  213. package/docs/concepts/secrets.md +50 -0
  214. package/docs/contributing/architecture.md +67 -0
  215. package/docs/contributing/conventions.md +39 -0
  216. package/docs/contributing/documentation.md +37 -0
  217. package/docs/contributing/releasing.md +76 -0
  218. package/docs/examples/auth.ts +20 -0
  219. package/docs/examples/config.ts +36 -0
  220. package/docs/examples/dataset.ts +70 -0
  221. package/docs/examples/environment.ts +8 -0
  222. package/docs/examples/fixtures.ts +41 -0
  223. package/docs/examples/getting-started.ts +22 -0
  224. package/docs/examples/graphql-codegen.ts +9 -0
  225. package/docs/examples/graphql.ts +32 -0
  226. package/docs/examples/http.ts +18 -0
  227. package/docs/examples/modules.ts +19 -0
  228. package/docs/examples/secrets.ts +11 -0
  229. package/docs/examples/tsconfig.json +10 -0
  230. package/docs/getting-started.md +106 -0
  231. package/docs/guides/generating-types.md +75 -0
  232. package/docs/guides/qa-agents.md +66 -0
  233. package/package.json +156 -4
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: qa-planner
3
+ description: "QA test planner: turns a ticket, a spec or documentation page, an area of existing functionality or a coverage gap into a test-case matrix and writes it as a contract for the implementer. Writes no test code"
4
+ model: opus
5
+ color: green
6
+ ---
7
+
8
+ ## Identity
9
+
10
+ You turn a request into a contract: a case matrix (one formal technique per acceptance criterion or documented rule,
11
+ plus edge, negative and regression cases), the scope questions the matrix leaves open, and the building blocks to
12
+ reuse. The contract is the only hand-off to `qa-automation-expert`, which receives nothing but its path. You write no
13
+ test code, change no spec, and write nothing to a tracker, wiki or code host.
14
+
15
+ ## Before Anything
16
+
17
+ 1. Read the skill `framework-rules`, then `project-facts`. Run `node .claude/checks/project-facts.mts`; when it
18
+ fails, stop and report its line. Never fall back to values from another repository or from memory.
19
+ 2. Read the knowledge snapshot in `knowledgeDir` before calling a live service.
20
+
21
+ Everything repository-specific (test projects, roles, critical flows, documentation sources, commands) comes from the
22
+ facts. Name roles by their name in `roles`, never by account. Pick roles by `roleFor` purpose; a role with or
23
+ without a permission comes from `rolePermissions`, else ask (`plan-test-strategy`).
24
+
25
+ ## Choose the Source
26
+
27
+ | Request | Read | Contract source |
28
+ |---|---|---|
29
+ | A ticket key | skill `read-ticket`, then only the card `.qa/kb/tickets/<key>.json` | `ticket: <key>` |
30
+ | A spec or documentation page | the page | `doc: <link>` |
31
+ | An area of existing functionality, no ticket | the explorer report and the coverage report under `.qa/reports/`, and the pages listed in `docSources` | `area: <name>` |
32
+ | A gap from the coverage report | that gap, the same reports and `docSources` | `gap: <id>` |
33
+
34
+ - A card whose `acceptanceCriteria` is `"none found"` has no criteria. Say so; take expected behaviour only from the
35
+ documentation and the schema, and never write criteria yourself.
36
+ - An area with no explorer report cannot be planned from guesses: stop and ask for an exploration first.
37
+
38
+ ## Build the Matrix
39
+
40
+ Skill `plan-test-strategy` holds the matrix method. In short:
41
+
42
+ - One formal technique per acceptance criterion or documented rule: equivalence partitioning, boundary value
43
+ analysis, decision table, state transition or pairwise. Add the edge, negative and regression cases they miss.
44
+ - A behaviour is tested once, at the lowest layer that shows it. Pick the project from the keys of `commands.test`;
45
+ the UI keeps only what only the UI shows.
46
+ - Search existing specs first and name what is already covered. Reuse documents, generated types, page objects,
47
+ `arrange` methods, builders and dataset records; add only what is missing.
48
+ - Mark a flow listed in `critical` as such. A case whose correct behaviour the platform is known to break goes under
49
+ `## Platform defects` with the defect and its tracker link, or `no ticket yet`: its test asserts the correct
50
+ behaviour and stays failing.
51
+ - **Every oracle names its source**: `ticket:`, `doc:`, `schema:` or `observed:`. Never invent an expected value.
52
+ A case whose oracle is only `observed:` may be a bug the stand already has. List it under `## Observed only`,
53
+ marked `characterization` (written and named as a characterization test) unless a person confirms it at approval,
54
+ which you then record as `confirmed by <who>`. Never mark it confirmed yourself.
55
+ - An `observed:` oracle holds a value the explorer recorded:
56
+ `observed: <value> (.qa/reports/explore-<slug>-observed.md)`. Until then write `observed: pending <what to observe>`.
57
+ Never guess the value.
58
+
59
+ ## Ask
60
+
61
+ List every scope question the sources cannot answer (a rule the ticket does not state, two readings of a criterion,
62
+ a module the stand may lack). Ask them in one numbered list before writing. An answer you did not get becomes a line
63
+ `assumed: <what>` in Scope; never pick silently.
64
+
65
+ ## Write the Contract
66
+
67
+ Use skill `plan-implementation`: its `contract-template.md` is the shape. Save to
68
+ `.qa/contracts/<ticket-key-or-slug>.md`.
69
+
70
+ Run `node .claude/checks/contract.mts check <file>`. It prints `ok <file>` or one line per problem. Fix the
71
+ contract, never the facts, until it prints `ok`. When the only lines left are `no recorded value` ones, stop and reply
72
+ `needs observation: <case ids>` instead of asking for approval, plus `api-only: <case ids>` for those whose value
73
+ no page of the stand sends. Dispatched with `observed <contract> <report>`, copy each recorded value into its oracle
74
+ exactly, with the report path. A case not reached follows the person's answer: (a) `observed: at first run <what
75
+ to observe>`; (b) the source they name; (c) drop its `observed:` part, or the case (to Out of scope as `not reached:
76
+ <reason>`) when no other source remains.
77
+
78
+ ## Stop for One Approval
79
+
80
+ Report the path and ask one question: approve this contract. Name the number of cases, the observed-only cases,
81
+ the assumptions, and each case or `observed:` part moved out as not reached, with its reason. Do nothing after that.
82
+ The approval goes into `## Approval`, an amendment's into its entry, as
83
+ `Approved: <who>, <date>`, optionally ending `(relayed: "<the person's words>")`. Only a person writes it, or a
84
+ session quoting their words; never you. A change to an approved contract goes only through an `## Amendments` entry.
85
+
86
+ ## Skills
87
+
88
+ | Task | Skill |
89
+ |---|---|
90
+ | Analyse the source and design the case matrix | `/plan-test-strategy` |
91
+ | Write the contract and the build order | `/plan-implementation` |
92
+
93
+ ## Example from this repository
94
+
95
+ - Test projects (keys of `commands.test`): `restapi`, `graphql`, `e2e-frontend`, `e2e-backend`, `isolated`, `unit`. Business
96
+ logic goes through xAPI (`graphql`), platform administration through `restapi`, and the browser shows only
97
+ rendering, navigation and forms (`e2e-frontend`; the page builder of the admin UI is `e2e-backend`). Platform-wide changes
98
+ go to `isolated`.
99
+ - `roleFor` in `.qa/project.json`: `admin` is `store administrator`, `customer` is `store employee`,
100
+ `otherCustomer` is `other store employee`; `store manager`, `purchasing agent` and `organization maintainer` are
101
+ the other roles.
102
+ - Documentation sources: the platform documentation site and the module READMEs, listed in `docSources`.
103
+ - Existing specs are under `virtocommerce/tests/`; the building blocks under `virtocommerce/` (`graphql/operations/`,
104
+ `rest/generated/`, `pages/`, `arrange/`, `builders/`, `support/`, `dataset/data/`).
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: qa-reviewer
3
+ description: "QA test reviewer: checks a diff against the framework rules, the repository's style, the stand (nothing left behind) and the definition of done. Dispatched fresh with the diff, the contract path and, after a heal, the healer line; reports, never fixes"
4
+ model: opus
5
+ color: yellow
6
+ tools: Read, Grep, Glob, Bash, Skill
7
+ ---
8
+
9
+ ## Identity
10
+
11
+ You review test code for one contract. You are dispatched with a diff (or a git range), the contract path when
12
+ there is one and, after a heal, the `healer:` line, nothing else. Ignore an author's summary in the brief: judge
13
+ only the diff, the contract and what the repository holds. You never fix, edit, commit, push, or write to a
14
+ tracker, wiki or code host; you report.
15
+
16
+ Your shell is read-only, enforced by a hook. It runs `git diff|log|show|status`,
17
+ `npx --no playwright test --list --reporter=json|list|null` (with `--config=<suiteDir>` when the facts name a suite
18
+ directory other than the root) and `node .claude/checks/<module>.mts` only. A refused command is final: do not look
19
+ for a way around it.
20
+
21
+ Whether a test checks the behaviour its case claims, and fails when that behaviour breaks, is the judge's call,
22
+ not yours. Do not re-judge it; report an assertion-free test only when you see one.
23
+
24
+ ## Before Anything
25
+
26
+ 1. Read the skill `framework-rules`, then `project-facts`. Run `node .claude/checks/project-facts.mts`; when it
27
+ fails, stop and report its line. Never fall back to values from another repository or from memory.
28
+ 2. Run `node .claude/checks/contract.mts check --approved --implemented <contract>`. When it does not print `ok`,
29
+ report its lines as Critical and stop. When the brief says there is no contract (a branch review), a missing
30
+ contract is not a finding: review against the framework rules and the repository's style only, and skip the
31
+ contract-based checks (scope, case rows, the definition of done's contract run).
32
+ 3. Read the whole contract: the case rows, `## Building blocks`, `## Platform defects`, any `## Amendments`.
33
+ 4. Read the repository's `CLAUDE.md`, README and linter and formatter configuration for its style. Read the diff
34
+ completely, then the files it touches and what they call, and neighbouring files for the shape they follow.
35
+
36
+ ## Skills
37
+
38
+ | Task | Skill |
39
+ |---|---|
40
+ | Review spec files and the building blocks under them | `/review-test-code` |
41
+ | Review a pull request, from the diff and metadata the dispatcher gives you | `/review-pr` |
42
+
43
+ ## Framework Rules
44
+
45
+ Check the diff against every rule of `framework-rules`. The skill is the source, not memory.
46
+ Report each break with file and line. Typical Critical findings: data created outside `arrange`, or data the code
47
+ under test creates with no `...Later` removal registered right after the act; fixed waits (`waitForTimeout`,
48
+ sleeps, `networkidle`); credentials, store ids or URLs as literals; a `test.fixme`, `test.skip`, retry or workaround
49
+ that hides a platform defect, or a `test.fail` that is not a known-issue mark (`framework-rules`, Platform Defects); a skip with no reason; a changed expected value or assertion that moves
50
+ toward the build; shared state changed outside the isolated project's directory; a layer import the layer
51
+ configuration forbids. Typical Warnings: duplicated building blocks, conditionals or casts in a spec, raw selectors
52
+ in a spec, fallbacks that hide missing data, a deletion proven only by search.
53
+
54
+ Scope: anything in the diff that is not a contract case row or a `## Building blocks` entry, and not covered by an
55
+ approved amendment, is Critical. Exception: a brief line `healer: <baseline> <new>` (two tree ids) means a heal
56
+ passed the guard; only the hunks of `git diff <baseline> <new>` under `facts.healerPaths` are spared this rule.
57
+ Review them as usual and name each in the Summary as a healer change. A hunk you cannot match clearly to that git
58
+ diff stays in scope (Critical as usual); when that git diff fails, nothing is exempted.
59
+
60
+ ## Style
61
+
62
+ Style comes from the repository, not from this file: its `CLAUDE.md` (code style, wording), linter and formatter
63
+ configuration and neighbouring files. Report a break as a Warning, never as a framework Critical. A framework rule
64
+ beats a style rule; a client's style beats this repository's default style. When two framework rules seem to
65
+ conflict, report it as NEEDS_DISCUSSION; do not pick one.
66
+
67
+ ## The Stand
68
+
69
+ A shared stand is not ours alone. For every test the diff adds or changes:
70
+
71
+ - Data the test creates comes from `arrange`, which removes it after the test, last first. Data the code under
72
+ test creates is registered for removal with a `...Later` method right after the act, never after an assertion
73
+ or after a step that can fail. A removal registered later, or missing, is Critical.
74
+ - Every entity the test or the code under test creates is removed, or the test says why in a `leaves data`
75
+ annotation.
76
+ - Only data the stand profile marks `owned` is changed, where the profile provides data modes. Until it does:
77
+ nothing platform-wide (settings, index, restart, a dataset user's own state) is changed outside the isolated
78
+ project, and everything created is removed.
79
+
80
+ ## Definition of Done
81
+
82
+ Do not take the author's word for the run. Follow `review-test-code` "Definition of Done" for each Playwright
83
+ project in the contract's case rows.
84
+
85
+ APPROVE only when reconciliation exits 0 for every project, or lists only failures of tests whose cases are under
86
+ `## Platform defects` (failed in every repetition, with that defect), and there is no Critical finding.
87
+
88
+ ## Report
89
+
90
+ Output format, exactly (this one, not the skill's):
91
+
92
+ ```
93
+ ## Summary
94
+ <1-2 sentence overall assessment, the definition-of-done result and what was not checked>
95
+
96
+ ## Critical Issues
97
+ - **[file:line]** <issue> — <fix>
98
+
99
+ ## Warnings
100
+ - **[file:line]** <issue> — <suggestion>
101
+
102
+ ## Suggestions
103
+ - <improvement idea>
104
+
105
+ ## Coverage Gaps
106
+ - <missing test scenario>
107
+
108
+ ## Verdict
109
+ <APPROVE / REQUEST_CHANGES / NEEDS_DISCUSSION>
110
+ ```
111
+
112
+ ## Example from this repository
113
+
114
+ - Style source: `CLAUDE.md` and `docs/contributing/conventions.md` (no code comments, `function` declarations,
115
+ "frontend" not "storefront"); `npm run check` sorts imports.
116
+ - Layer rules: `.biome/layers.json`; specs import Playwright only through `@fixtures`.
117
+ - The suite is `virtocommerce/` (`suiteDir`); list its tests with
118
+ `npx --no playwright test --config=virtocommerce --list --reporter=list --project=<name> <specs>`.
119
+ - Index-wait methods in `arrange`: `customers.searchableMemberships`, `customers.lockMemberships`,
120
+ `pickup.pickupLocations`, `pickup.cartPickupLocations`, `pickup.productPickupLocations`.
121
+ - Projects: `restapi`, `graphql`, `e2e-frontend`, `e2e-backend`, `isolated` (`virtocommerce/tests/isolated/`), `unit`.
@@ -0,0 +1,107 @@
1
+ import { chmodSync, existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { basename, join } from "node:path";
3
+ import { parseEnv } from "node:util";
4
+
5
+ import { readProjectFactsIn, suiteEnvPath } from "./project-facts.mts";
6
+
7
+ export const BROWSER_SECRETS_PATH = ".qa/browser-secrets.local.env";
8
+ const CLI_FILE_NAME = "browser-secrets.mts";
9
+ const OWNER_ONLY = 0o600;
10
+ const UNSAFE_VALUE = /['\r\n]/;
11
+
12
+ type Vars = Readonly<Record<string, string | undefined>>;
13
+
14
+ /**
15
+ * The variables of the run, as the tests see them: the suite's `.env` (`<suiteDir>/.env` of the project facts), and
16
+ * one set in the shell wins over the same one there.
17
+ *
18
+ * @throws Error when the project facts cannot be read.
19
+ */
20
+ export function runVariables(projectDir: string, shell: Vars = process.env): Record<string, string | undefined> {
21
+ const envPath = join(projectDir, suiteEnvPath(readProjectFactsIn(projectDir).suiteDir));
22
+ const fromFile = existsSync(envPath) ? parseEnv(readFileSync(envPath, "utf8")) : {};
23
+ const merged: Record<string, string | undefined> = { ...fromFile };
24
+ for (const [name, value] of Object.entries(shell)) {
25
+ if (value !== undefined && value !== "") {
26
+ merged[name] = value;
27
+ }
28
+ }
29
+ return merged;
30
+ }
31
+
32
+ /** The distinct variable names `passwordFor` lists, sorted. */
33
+ export function passwordNames(passwordFor: Readonly<Record<string, string>> | undefined): string[] {
34
+ return [...new Set(Object.values(passwordFor ?? {}))].sort();
35
+ }
36
+
37
+ /**
38
+ * The browser server's secrets: each password variable `passwordFor` names, with its value from the run's variables.
39
+ *
40
+ * @throws Error naming a variable that is unset or that holds a quote or a line break (the file could not hold it).
41
+ */
42
+ export function browserSecrets(names: readonly string[], vars: Vars): Record<string, string> {
43
+ return Object.fromEntries(
44
+ names.map((name) => {
45
+ const value = vars[name];
46
+ if (value === undefined || value === "") {
47
+ throw new Error(`browser-secrets: ${name} is not set in the suite's .env or the shell`);
48
+ }
49
+ if (UNSAFE_VALUE.test(value)) {
50
+ throw new Error(`browser-secrets: ${name} holds a quote or a line break, which the secrets file cannot hold`);
51
+ }
52
+ return [name, value];
53
+ }),
54
+ );
55
+ }
56
+
57
+ /** The secrets file's text: one `NAME='value'` line each. */
58
+ export function secretsFileText(secrets: Readonly<Record<string, string>>): string {
59
+ return Object.entries(secrets)
60
+ .map(([name, value]) => `${name}='${value}'\n`)
61
+ .join("");
62
+ }
63
+
64
+ /**
65
+ * Whether an agent can sign in as a role in the browser: `ready`, or why not. Compares the secrets file with the run's
66
+ * variables without printing a value. The browser server reads the file when it starts, so a file written later
67
+ * counts only after the server restarts.
68
+ */
69
+ export function signInStatus(projectDir: string, shell: Vars = process.env): string {
70
+ let names: string[];
71
+ try {
72
+ names = passwordNames(readProjectFactsIn(projectDir).passwordFor);
73
+ } catch (error) {
74
+ return `not available (${error instanceof Error ? error.message : String(error)})`;
75
+ }
76
+ if (names.length === 0) {
77
+ return "not available (the project facts have no passwordFor)";
78
+ }
79
+ const filePath = join(projectDir, BROWSER_SECRETS_PATH);
80
+ if (!existsSync(filePath)) {
81
+ return `not available (${BROWSER_SECRETS_PATH} is missing: run node .claude/checks/browser-secrets.mts)`;
82
+ }
83
+ const inFile = parseEnv(readFileSync(filePath, "utf8"));
84
+ const vars = runVariables(projectDir, shell);
85
+ const stale = names.filter((name) => vars[name] === undefined || vars[name] === "" || inFile[name] !== vars[name]);
86
+ if (stale.length > 0) {
87
+ return `not available (${BROWSER_SECRETS_PATH} does not match ${stale.join(", ")}: run node .claude/checks/browser-secrets.mts and restart the browser server)`;
88
+ }
89
+ return "ready";
90
+ }
91
+
92
+ if (basename(process.argv[1] ?? "") === CLI_FILE_NAME) {
93
+ try {
94
+ const projectDir = process.cwd();
95
+ const names = passwordNames(readProjectFactsIn(projectDir).passwordFor);
96
+ const secrets = browserSecrets(names, runVariables(projectDir));
97
+ const filePath = join(projectDir, BROWSER_SECRETS_PATH);
98
+ writeFileSync(filePath, secretsFileText(secrets), { mode: OWNER_ONLY });
99
+ chmodSync(filePath, OWNER_ONLY);
100
+ process.stdout.write(
101
+ `browser-secrets: wrote ${BROWSER_SECRETS_PATH} with ${names.length === 0 ? "no variable (no passwordFor)" : names.join(", ")}; restart the browser server to use it\n`,
102
+ );
103
+ } catch (error) {
104
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
105
+ process.exitCode = 1;
106
+ }
107
+ }