@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,159 @@
1
+ ---
2
+ name: create-graphql-layer
3
+ description: "Add xAPI GraphQL operations and fragments as .graphql documents, regenerate the typed documents with GraphQL Code Generator, and add arrange methods around them when several specs need the same setup"
4
+ argument-hint: "<area> <operation>"
5
+ ---
6
+
7
+ ## GraphQL Layer
8
+
9
+ There are no hand-written operation classes or model types. An operation is a `.graphql` document; GraphQL Code
10
+ Generator turns it into a typed `…Document` constant plus result and variable types, and the framework's
11
+ `GraphqlClient` (`shopper.graphql`, the `graphql` fixture) executes it.
12
+
13
+ Read first: skill `framework-rules`, then `project-facts` (`node .claude/checks/project-facts.mts`).
14
+
15
+ ## File Locations
16
+
17
+ - Operations: `virtocommerce/graphql/operations/<area>/<operation-name>.graphql` (kebab-case, one operation per file)
18
+ - Fragments: `virtocommerce/graphql/fragments/<entity>.graphql`
19
+ - Generated, never edited: `virtocommerce/graphql/generated/` (`graphql.ts`, `gql.ts`, `index.ts`, `schema.graphql`)
20
+ - Codegen config: `virtocommerce/codegen.ts` (`graphqlCodegenConfig` from the framework; schema from
21
+ `BACKEND_BASE_URL/graphql`, custom scalars listed with `strictScalars`)
22
+ - Line-item lookup: `virtocommerce/graphql/line-items.ts` (`lineItemOf`)
23
+
24
+ ## Step 1: Check What Exists
25
+
26
+ ```
27
+ virtocommerce/graphql/operations/<area>/ the operation may exist, or a sibling needs one more field
28
+ virtocommerce/graphql/fragments/ reuse fragments instead of listing fields again
29
+ virtocommerce/graphql/generated/schema.graphql the platform schema: argument names, input types, nullability
30
+ ```
31
+
32
+ ## Step 2: Write the Document
33
+
34
+ Mutation (`virtocommerce/graphql/operations/cart/add-item.graphql`):
35
+
36
+ ```graphql
37
+ mutation AddItem($command: InputAddItemType!) {
38
+ addItem(command: $command) {
39
+ ...Cart
40
+ }
41
+ }
42
+ ```
43
+
44
+ Query (`virtocommerce/graphql/operations/cart/get-cart.graphql`):
45
+
46
+ ```graphql
47
+ query GetCart(
48
+ $storeId: String!
49
+ $userId: String!
50
+ $currencyCode: String!
51
+ $cultureName: String!
52
+ $cartId: String
53
+ $cartName: String
54
+ ) {
55
+ cart(
56
+ storeId: $storeId
57
+ userId: $userId
58
+ currencyCode: $currencyCode
59
+ cultureName: $cultureName
60
+ cartId: $cartId
61
+ cartName: $cartName
62
+ ) {
63
+ ...Cart
64
+ }
65
+ }
66
+ ```
67
+
68
+ - Operation names are PascalCase and unique; the constant is `<Name>Document` (`GetCart` → `GetCartDocument`).
69
+ - Variable names match `StoreContext` (`storeId`, `userId`, `currencyCode`, `cultureName`) so specs can spread
70
+ `shopper.storeContext`.
71
+ - Select through fragments (`...Cart`, `...Money`); add a field to the fragment when every user needs it.
72
+ - Mutations take the `command` input object the schema defines.
73
+ - Select only what tests read. Fields of an optional module stay out of shared fragments.
74
+
75
+ ## Step 3: Regenerate
76
+
77
+ ```shell
78
+ npm run codegen:vc # builds the framework, then regenerates the GraphQL and REST types
79
+ npm run codegen:vc:graphql # GraphQL only, once the framework is built (npm run build)
80
+ npm run typecheck
81
+ npm run check
82
+ ```
83
+
84
+ The generation needs the platform running at `BACKEND_BASE_URL` (read from `virtocommerce/.env` by
85
+ `virtocommerce/env.ts`), and `virtocommerce/codegen.ts` loads the framework from its built `dist/`, so
86
+ `codegen:vc:graphql` alone works only after `npm run build`. Commit the documents and the regenerated files
87
+ together.
88
+
89
+ ## Step 4: Use It
90
+
91
+ ```ts
92
+ import { AddItemDocument } from "@graphql/generated/graphql.ts";
93
+ import { requireFields } from "@support/require-fields.ts";
94
+ import { uniqueId } from "@support/unique-id.ts";
95
+
96
+ const { addItem } = await shopper.graphql.execute(AddItemDocument, {
97
+ command: { ...shopper.storeContext, cartName: uniqueId("test-cart"), productId, quantity: 1 },
98
+ });
99
+ const cart = requireFields(addItem, ["id"], "Cart with the product");
100
+ ```
101
+
102
+ - `execute(document, variables)` returns typed `data` and throws a `GraphqlError` on errors; specs assert expected
103
+ errors with `rejects.toThrow("[CODE]")`.
104
+ - `executeRaw(document, variables)` returns `data` and `errors` without throwing, for partial data or several
105
+ errors.
106
+ - Variables are optional only when every variable of the document is optional.
107
+ - Results are nullable as in the schema: unwrap with `requireFields` / `requireDefined` / `lineItemOf`.
108
+
109
+ ## Step 5: Arrange Method (when several specs need it)
110
+
111
+ Setup that more than one spec performs becomes a method of the `arrange` domain in
112
+ `virtocommerce/arrange/<domain>.ts`. A domain is a factory function, such as `cartsArrange(context)`, that returns
113
+ the methods of its interface (`CartsArrange`). Add the method in three places: the interface, with a short JSDoc
114
+ saying what it creates and what it removes; a `function` declaration inside the factory; and the returned object.
115
+ The method takes the `Shopper` it acts for, registers its own removal with `later` from the `ArrangeContext`, and
116
+ imports the generated documents and support code by relative paths (`cart` of `carts.ts`, shortened):
117
+
118
+ ```ts
119
+ async function cart(shopper: Shopper, items: readonly CartItem[]): Promise<ArrangedCart> {
120
+ removeDefaultCartLater(shopper);
121
+ const { addItemsCart } = await shopper.graphql.execute(AddItemsCartDocument, {
122
+ command: { ...shopper.storeContext, cartItems: [...items] },
123
+ });
124
+ return requireFields(addItemsCart, ["id"], `The cart of ${shopper.userId}`);
125
+ }
126
+ ```
127
+
128
+ The platform assigns GraphQL ids, so removal is registered right after the create, or before it when the removal
129
+ finds the record itself (`removeDefaultCartLater` reads the default cart). Data created as the admin role (`roleFor.admin`)
130
+ uses `await admin()` from the context. Export new result types from `virtocommerce/arrange/index.ts`. A read that one
131
+ spec uses stays in that spec, as a table row lambda or a `function` declaration at its end.
132
+
133
+ ## Where REST Is Needed
134
+
135
+ Some setup or checks have no xAPI operation. There are no REST clients: call the endpoint directly with the
136
+ `HttpClient` (`api`, `shopper.api`, or `await admin()` inside `arrange`), such as
137
+ `(await api.get(path)).expectOk().json<T>()`, and type the body with `@rest/generated/platform.ts`
138
+ (`../rest/generated/platform.ts` inside `arrange`). Missing or outdated REST types: regenerate with
139
+ `npm run codegen:vc:rest` (needs the running platform); never edit the generated file.
140
+
141
+ ## Rules
142
+
143
+ 1. Documents only under `virtocommerce/graphql/operations` and `virtocommerce/graphql/fragments`; no inline query
144
+ strings.
145
+ 2. Never edit `virtocommerce/graphql/generated/`; regenerate.
146
+ 3. Reuse and extend fragments instead of duplicating field lists.
147
+ 4. Remove documents no spec or arrange method uses, then regenerate.
148
+ 5. Methods that create data live in `virtocommerce/arrange/` and register their own removal.
149
+ 6. JSDoc only for what the signature cannot say; the rest of the style comes from the repository's `CLAUDE.md`.
150
+
151
+ ## Example from this repository
152
+
153
+ - Reference documents: `virtocommerce/graphql/operations/cart/add-item.graphql`,
154
+ `virtocommerce/graphql/operations/cart/get-cart.graphql`; codegen config `virtocommerce/codegen.ts`.
155
+ - Operation areas: cart, category, contact, marketing, order, page-context, pickup-location, product, quote,
156
+ save-for-later, seo, shopping-list.
157
+ - Regenerate with `npm run codegen:vc` (or `npm run build && npm run codegen:vc:graphql`), then
158
+ `npm run typecheck`.
159
+ - Reference arrange method: `cart` in `virtocommerce/arrange/carts.ts` (`arrange.carts.cart`).
@@ -0,0 +1,189 @@
1
+ ---
2
+ name: create-ui-layer
3
+ description: "Create frontend page objects (MainLayout pages, components, ui-kit wrappers, the Frontend factory) and admin UI objects (vc-shell Blade, DataGrid and other controls, page builder and page designer) with readonly Playwright locators, data-test-id selectors and actions that hide frontend settings from specs"
4
+ argument-hint: "<page-or-component>"
5
+ ---
6
+
7
+ ## UI Layer
8
+
9
+ Page objects hold locators and user actions: no API calls, no test data, no test assertions. Specs hold no selectors,
10
+ so every locator a test needs lives here. In this suite they live in `virtocommerce/pages/` and import only
11
+ `@playwright/test` and each other, by relative paths; specs and fixtures import them through `@pages/*`.
12
+
13
+ Read first: skill `framework-rules`, then `project-facts` (`node .claude/checks/project-facts.mts`), then
14
+ `virtocommerce/pages/README.md`, which holds the naming and placement rules.
15
+
16
+ ## Where Things Live
17
+
18
+ | Directory | Holds |
19
+ |---|---|
20
+ | `frontend/frontend.ts` | `Frontend`, the factory the `frontend` fixture gives to specs |
21
+ | `frontend/layouts/` | `MainLayout`, the base of every frontend page |
22
+ | `frontend/pages/<area>/` | one page object per frontend page (`account`, `cart`, `catalog`, `checkout`, `lists`, `site`) |
23
+ | `frontend/components/<area>/` | parts pages are built from (`address`, `cart`, `catalog`, `checkout`, `coupons`, `header`, `lists`) |
24
+ | `frontend/ui-kit/` | elements of the frontend's UI kit, such as `QuantityControl`, `ConfirmationModal` |
25
+ | `frontend/flows/` | steps over several pages, such as `CheckoutFlow` |
26
+ | `backend/vc-shell/` | the vc-shell UI kit the admin apps share: `Blade`, `DataGrid`, `Card`, `Select`, `DatePicker`, … |
27
+ | `backend/page-builder/` | the page builder app: `PageBuilderShell` (the `pageBuilder` fixture), blades, `routes.ts`, `requests.ts` |
28
+ | `backend/page-designer/` | the page designer: `PageDesigner` (the `pageDesigner` fixture), its panels and rows |
29
+ | `shared/` | `selectors.ts` (`exactText`, `startsWithText`, `attributeSelector`), `responses.ts` (`whenResponse`, `whenGraphql`) |
30
+
31
+ One class per file, the file named after the class in kebab case (Biome fails anything else); the last word of the
32
+ name says what it is (`-page`, `-modal`, `-section`, `-blade`, `-flow`, …); no `index.ts` files.
33
+
34
+ ## Step 1: Check What Exists
35
+
36
+ Search the directories above first. Often a component exists and needs one more locator, or a page needs a
37
+ method.
38
+
39
+ ## Step 2: Page
40
+
41
+ ```ts
42
+ import type { Locator, Page } from "@playwright/test";
43
+ import type { QuantityControlKind } from "../../ui-kit/quantity-control.ts";
44
+
45
+ import { LineItem } from "../../components/cart/line-item.ts";
46
+ import { productItem, productItems } from "../../components/catalog/product-items.ts";
47
+ import { MainLayout } from "../../layouts/main-layout.ts";
48
+ import { ConfirmationModal } from "../../ui-kit/confirmation-modal.ts";
49
+
50
+ /** Cart page; in single-page checkout mode it also holds the shipping and payment sections (`CheckoutFlow`). */
51
+ export class CartPage extends MainLayout {
52
+ readonly path = "/cart";
53
+ readonly products: Locator;
54
+ readonly lineItems: Locator;
55
+ readonly clearCartButton: Locator;
56
+ readonly clearCartModal: ConfirmationModal;
57
+ readonly #quantityControl: QuantityControlKind;
58
+
59
+ constructor(page: Page, quantityControl: QuantityControlKind) {
60
+ super(page);
61
+ this.#quantityControl = quantityControl;
62
+ this.products = page.getByTestId("cart.products-section");
63
+ this.lineItems = productItems(this.products);
64
+ this.clearCartButton = page.getByTestId("clear-cart-button");
65
+ this.clearCartModal = new ConfirmationModal(page.getByTestId("clear-cart-modal"), "yes-button");
66
+ }
67
+
68
+ /** @param sku - Product SKU. */
69
+ lineItem(sku: string): LineItem {
70
+ return new LineItem(productItem(this.products, sku), this.#quantityControl);
71
+ }
72
+ }
73
+ ```
74
+
75
+ - Frontend pages extend `MainLayout` and declare a relative `path` (`baseURL` is set by the project); `navigate()`
76
+ goes there and waits for `load` only.
77
+ - A page with a variable path takes it in the constructor (`ContentPage`, `CategoryPage`).
78
+ - Add a factory method to `Frontend` for every new page, passing the frontend settings it needs. Modals that open over
79
+ any page are fields of the factory.
80
+
81
+ ## Step 3: Component
82
+
83
+ ```ts
84
+ import type { Locator } from "@playwright/test";
85
+
86
+ /** Frontend modal that asks to confirm an action, such as clearing the cart. */
87
+ export class ConfirmationModal {
88
+ readonly root: Locator;
89
+ readonly confirmButton: Locator;
90
+
91
+ /** @param confirmButtonId - `data-test-id` of the confirm button, such as `yes-button`. */
92
+ constructor(root: Locator, confirmButtonId: string) {
93
+ this.root = root;
94
+ this.confirmButton = root.getByTestId(confirmButtonId);
95
+ }
96
+ }
97
+ ```
98
+
99
+ - Every component takes its `root: Locator`; child locators are relative to it.
100
+ - Extra constructor data only when the markup or a setting needs it (`LineItem(root, quantityControl)`).
101
+ - Admin UI blades extend `Blade` (`backend/vc-shell/blade.ts`) and use its helpers (`toolbarButton`, `card`,
102
+ `field`, `textInput`, `select`, `datePicker`, `firstSwitch`, `grid`).
103
+
104
+ ## Step 4: Hide Frontend Settings
105
+
106
+ A frontend can run in several modes (a quantity control, a checkout mode, a range filter type). The page object takes
107
+ the setting in its constructor, keeps it in a `readonly #private` field and branches inside, so specs never do. The
108
+ settings come from `FrontendSettings`, which the `frontend` fixture builds from `QUANTITY_CONTROL`,
109
+ `RANGE_FILTER_TYPE` and `CHECKOUT_MODE`. The checkout flow shows the shape:
110
+
111
+ ```ts
112
+ /** Opens the cart (and in multi-step mode clicks checkout), then waits for the shipping section. */
113
+ async start(): Promise<void> {
114
+ await this.cartPage.navigate();
115
+ if (this.mode === "multi-step") {
116
+ await this.cartPage.checkoutButton.click();
117
+ }
118
+ await this.shippingDetails.root.waitFor();
119
+ }
120
+ ```
121
+
122
+ ## Step 5: Actions
123
+
124
+ Methods for multi-step interactions. They wait for the state or response they produce, never for time, and the
125
+ JSDoc says what they wait for:
126
+
127
+ ```ts
128
+ /** Clicks save and waits for the save response (POST/PUT), whatever its status; assert the outcome after. */
129
+ async save(): Promise<void> {
130
+ await whenResponse(this.root.page(), isPageSave, () => this.saveButton.click());
131
+ }
132
+ ```
133
+
134
+ For a GraphQL operation, `whenGraphql(this.root.page(), "AddCoupon", () => this.applyButton.click())`; take the
135
+ operation name from what the frontend sends (the request's `operationName`), not from the mutation field. Response
136
+ predicates of a backend app live in its `requests.ts`.
137
+
138
+ - An action that can open a new tab returns the `Page` the user ends up on (`ProductCard.openConfigurations()`).
139
+ - `expect` from `@playwright/test` may be used inside an action to wait for a state (`expect.poll`, `toPass`);
140
+ page objects never assert test outcomes.
141
+
142
+ ## Locator Conventions
143
+
144
+ ```ts
145
+ page.getByTestId("clear-cart-button");
146
+ root.locator(attributeSelector({ "data-item-sku": sku }));
147
+ page.locator(".coupons-section");
148
+ locator.filter({ hasText: exactText(name) });
149
+ ```
150
+
151
+ - `getByTestId` first: the suite's `testIdAttribute` is `data-test-id` (the framework's `defaultUse`). Then roles,
152
+ data attributes for item identity, and component classes only where there is no test id yet.
153
+ - `exactText` narrows by text when names share prefixes.
154
+ - A UI-kit class (`.vc-*`) goes into a wrapper in `frontend/ui-kit/` or `backend/vc-shell/`, never into a component
155
+ or page.
156
+ - `.first()` / `.nth()` only when the markup repeats an element by design, never to pick a list item by position.
157
+
158
+ ## Rules
159
+
160
+ 1. Public locators and child components are `readonly` fields assigned in the constructor; other state is
161
+ `readonly #private`.
162
+ 2. `data-test-id` first; ask for a test id in the frontend when a stable one is missing.
163
+ 3. No test assertions, API calls or test data; imports only from `@playwright/test` and other page objects.
164
+ 4. No `waitForTimeout`, no `networkidle`; wait for locators, states or responses.
165
+ 5. Settings-dependent behaviour is hidden in the page object; specs never branch or skip on settings.
166
+ 6. Short JSDoc for waits and side effects; the rest of the style (exports, comments, naming) comes from the
167
+ repository's `CLAUDE.md`.
168
+
169
+ ## Verify
170
+
171
+ Run `commands.typecheck`, `commands.lint` and `commands.test["<browser project>"]` from the project facts on a spec
172
+ that uses the page object. Run the spec with each relevant setting value when the page object branches on it.
173
+
174
+ ## Example from this repository
175
+
176
+ - Rules for the directory: `virtocommerce/pages/README.md`; Biome's one-class-per-file and kebab-case rules for it are
177
+ in `.biome/layers.json`.
178
+ - Frontend factory: `virtocommerce/pages/frontend/frontend.ts` (`Frontend`, `FrontendSettings`).
179
+ - Frontend layout: `virtocommerce/pages/frontend/layouts/main-layout.ts` (`MainLayout`, with `cartQuantityLabel` and
180
+ `topHeader`). The multi-step checkout steps use the frontend's secure layout and are driven by `CheckoutFlow`.
181
+ - Admin UI kit: `virtocommerce/pages/backend/vc-shell/blade.ts` (`Blade`, `blades`, `DISABLED_TOOLBAR_BUTTON`),
182
+ `data-grid.ts`, `grid-row.ts`, `notifications.ts`, `confirmation-popup.ts`. The only backend files with `.vc-*`
183
+ classes.
184
+ - Page builder: `virtocommerce/pages/backend/page-builder/page-builder-shell.ts`, `routes.ts` (`Route`, `Column`,
185
+ `DetailsToolbar`), `requests.ts` (`isPageSave`, `isPagePublishing`).
186
+ - Frontend settings: run a spec with `QUANTITY_CONTROL=button` or `CHECKOUT_MODE=multi-step` when the page object
187
+ branches on it.
188
+ - Commands: `npm run typecheck && npm run check`, then
189
+ `npx --no playwright test --config=virtocommerce --no-deps <a spec that uses the page object> --project=e2e-frontend`.
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: explore-api
3
+ description: "Map an area of an API on the stand: the operations the schema declares, and what the page's own traffic shows the live service answering, with every difference. Read-only; sends no request of its own; writes only the report under .qa/reports/"
4
+ argument-hint: "<api-area>"
5
+ ---
6
+
7
+ ## Explore API
8
+
9
+ Used by `qa-explorer`. The result is the two API sections of `.qa/reports/explore-<slug>.md`. It writes no
10
+ request code, no query and no test. Read first: the skill `framework-rules`, then `project-facts`
11
+ (`node .claude/checks/project-facts.mts`).
12
+
13
+ ## Step 1: The Schema
14
+
15
+ - Find the schema the repository holds for the area: a generated schema file, an OpenAPI document, or the operations the
16
+ existing specs and `arrange` methods call (Grep, Glob). Read the knowledge snapshot (`knowledgeDir`) too.
17
+ - No schema in the repository: the live service is the only source, and the report says so.
18
+
19
+ ## Step 2: Operations
20
+
21
+ For each operation of the area, one row:
22
+
23
+ | Operation | Kind | Arguments | Returns | Used by |
24
+ |---|---|---|---|---|
25
+
26
+ `Kind` is query, mutation, GET, POST and so on; `Used by` is the existing spec or `arrange` method that calls it, or
27
+ `none`.
28
+ List a mutation and any state-changing request here, but never call one.
29
+
30
+ ## Step 3: Schema vs Live
31
+
32
+ Your only live source is what the page itself sends: open the pages of the area with the browser (the stand's origins:
33
+ `node .claude/checks/stand.mts`) and read the requests and answers with `browser_network_requests`; read one answer's
34
+ body with `browser_network_request`, passing only its `index` and `part: "response-body"` (the hook refuses any other
35
+ form). Never open the body of a sign-in, token or refresh request (`/connect/token`, an `auth` or `login` path): it
36
+ holds credentials. Never copy personal data from a body into a report. You send no request of your own: no `fetch`, no
37
+ script, no call from the shell.
38
+
39
+ - Take the operation, its arguments and the answer's shape from the requests the page made. Use the session the
40
+ browser already has. Do not type or look up credentials. A request that answered 401 or 403 is recorded as
41
+ `not reached: needs <role>`; it is not a difference.
42
+ - Keep no response body in the report beyond the field names and types, except, when observing for a contract, the
43
+ values its cases assert; never copy personal data or a secret.
44
+
45
+ Compare each observed answer with the schema and list every difference, one row each: the operation, the field or
46
+ status, what the schema says, what the page's traffic showed. Differences to look for: a field the schema declares but
47
+ the answer does not return; a field the answer returns that the schema lacks; a nullable field that is never null, or
48
+ the other way; a type, enum value or error shape that does not match; an operation the page sends that the schema
49
+ does not declare.
50
+
51
+ An operation the page did not send is listed as `not seen: <why>` (the page never uses it, it changes state, it
52
+ needs a role). Never trigger one to see it.
53
+
54
+ ## Observing for a Contract
55
+
56
+ The explorer's `observe` mode records the value one case asserts. First confirm who is signed in, from the page (the
57
+ account menu) or from the page's own answer that names the current user: it must be `roles[<the case's data role>]`, or
58
+ no account for `none`. Any other account, or none you can confirm: write `not reached: needs <role>`. Then take the
59
+ value from the answer of the request the page sent for that case (`browser_network_request`, `part: "response-body"`)
60
+ and write it raw, never quoted or escaped: a JSON string value without its JSON quotes. A value no request of the page
61
+ shows is `not reached: no page sends it`.
62
+
63
+ ## Done
64
+
65
+ The two sections are in the report, each with its rows or `none observed`, and every row says where it was seen:
66
+ schema file, existing spec or `arrange` method, or the page's traffic. Nothing outside `.qa/reports/` changed
67
+ (`git status`), and you sent no request of your own.
68
+
69
+ ## Example from this repository
70
+
71
+ - GraphQL: schema `virtocommerce/graphql/generated/schema.graphql`, operations in `virtocommerce/graphql/operations/`,
72
+ endpoint `/graphql` on the backend host.
73
+ - REST: types generated from the platform's API in `virtocommerce/rest/generated/platform.ts`; specs and
74
+ `virtocommerce/arrange/` call the endpoints directly by path.
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: explore-frontend
3
+ description: "Map an area of a frontend on the stand: its pages, the selectors in the framework's priority, the test ids that are missing, and a page-object proposal. Read-only; writes only the report under .qa/reports/"
4
+ argument-hint: "<page-or-area>"
5
+ ---
6
+
7
+ ## Explore Frontend
8
+
9
+ Used by `qa-explorer`. The result is the first four sections of `.qa/reports/explore-<slug>.md`. It writes no
10
+ page object and no test; the proposal is text for `qa-planner` and `qa-automation-expert`. Read first: the skill
11
+ `framework-rules`, then `project-facts` (`node .claude/checks/project-facts.mts`).
12
+
13
+ ## Step 1: What Exists
14
+
15
+ - Search the page objects, components and specs for the area (Grep, Glob) and read the ones that match. Note each
16
+ page object's path, its locators and the test ids it uses.
17
+ - Read the knowledge snapshot (`knowledgeDir`) for the area. Use what it says; open a page only for what it
18
+ cannot answer or what its date makes unsafe.
19
+ - Find where the frontend source lives from the project facts or the repository's README. No pointer: the source
20
+ comparison in step 4 is "source not available".
21
+
22
+ ## Step 2: Pages
23
+
24
+ Walk the area with the browser as `qa-explorer` allows, from the origin `node .claude/checks/stand.mts` prints (the
25
+ frontend's, or the backend's for the platform's own pages). For each page or state reached, one row:
26
+
27
+ | Path | What it shows | Reached as | Page object |
28
+ |---|---|---|---|
29
+
30
+ `Reached as` is the role or "anonymous", checked in the account menu (another account's session: the skill
31
+ `project-facts`, "Someone else's session"); `Page object` is the existing class, or `none`. Dialogs, tabs and states
32
+ the user can reach on the page (empty, filled, error shown) are rows of their own. A page you could not reach is
33
+ a row with `not reached: <why>`.
34
+
35
+ ## Step 3: Selectors
36
+
37
+ From the page snapshot and the shipped page extractor (`browser_evaluate` with `PAGE_EXTRACTOR` from
38
+ `.claude/checks/explore-extractors.mts`, the only script the hook allows), list the elements a test
39
+ would use: for each, the best selector in the framework's order from `create-ui-layer` "Locator Conventions":
40
+
41
+ 1. the test id attribute (`getByTestId`);
42
+ 2. a data attribute that names the item (a SKU, an id);
43
+ 3. a component class, only where no test id exists;
44
+ 4. anything else (text, position, generated class names) is marked `fragile`.
45
+
46
+ One row per element: `name`, `selector`, `kind` (test id, data attribute, class, fragile), `seen on` (the page).
47
+ Mark which already exist in a page object. Never write a selector you did not see in the page.
48
+
49
+ ## Step 4: Missing Test Ids
50
+
51
+ List the elements a test needs but that carry no test id: the element, the page, the selector it would use today
52
+ and why that is fragile. Add the elements whose test id differs between the page object and the page.
53
+
54
+ When the source is available, also compare: test ids the page objects use that the source no longer has, and
55
+ elements in the source with no test id. Name the source file and line for each. Without the source, write
56
+ "source not available" and compare against the live page only.
57
+
58
+ These are requests to the frontend team: give each as one line they can act on.
59
+
60
+ ## Step 5: Page-Object Proposal
61
+
62
+ For each page or component with no page object, or whose page object lacks a locator or action: a short outline,
63
+ not code. Name the class, where it would live under the repository's layer rules, its `readonly` locators (name and
64
+ the selector from step 3), its actions and what each waits for, and which existing page object it extends or reuses.
65
+ Say which proposed locators wait on a missing test id from step 4.
66
+
67
+ ## Observing for a Contract
68
+
69
+ The explorer's `observe` mode records the value one case asserts, as the page shows it. First confirm from the page
70
+ (the account menu) that the signed-in account is `roles[<the case's data role>]`, or that no one is signed in for
71
+ `none`; otherwise write `not reached: needs <role>`. Write the value raw, never quoted or escaped.
72
+
73
+ ## Done
74
+
75
+ The four sections are in the report, each with its items or `none observed`, and every item says where it was seen.
76
+ Nothing outside `.qa/reports/` changed (`git status`).
77
+
78
+ ## Example from this repository
79
+
80
+ - Test id attribute: `data-test-id` (the default `testIdAttribute` of the framework's `defaultUse`, which
81
+ `virtocommerce/playwright.config.ts` uses).
82
+ - Page objects: `virtocommerce/pages/frontend/pages/<area>/`, components
83
+ `virtocommerce/pages/frontend/components/<area>/`, UI-kit wrappers `virtocommerce/pages/frontend/ui-kit/`; the factory
84
+ is `virtocommerce/pages/frontend/frontend.ts`. Admin UI apps are in `virtocommerce/pages/backend/`;
85
+ `virtocommerce/pages/README.md` names and places each kind.