@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,41 @@
1
+ import type { Credentials } from "@virtocommerce/test-automation-framework/auth";
2
+ import type { DefaultFixtures, DefaultWorkerFixtures } from "@virtocommerce/test-automation-framework/fixtures";
3
+ import type { HttpClient } from "@virtocommerce/test-automation-framework/http";
4
+ import type { ModuleRequirement } from "@virtocommerce/test-automation-framework/modules";
5
+
6
+ import { test as base, expect } from "@playwright/test";
7
+ import { envSchema, originUrl, parseEnv, Secret } from "@virtocommerce/test-automation-framework/core";
8
+ import { defaultFixtures } from "@virtocommerce/test-automation-framework/fixtures";
9
+
10
+ const suiteEnvSchema = envSchema.extend({ FRONTEND_BASE_URL: originUrl });
11
+ type SuiteEnv = ReturnType<typeof suiteEnvSchema.parse>;
12
+ const env = parseEnv(suiteEnvSchema);
13
+
14
+ const QUOTES: ModuleRequirement = { id: "VirtoCommerce.Quote", minVersion: "3.1005.0" };
15
+
16
+ const customer: Credentials = {
17
+ username: "customer@example.com",
18
+ password: Secret.of("Customer-Password-1"),
19
+ storeId: "B2B-store",
20
+ };
21
+
22
+ export const test = base.extend<DefaultFixtures, DefaultWorkerFixtures<SuiteEnv>>(defaultFixtures(env)).extend<{
23
+ customerApi: HttpClient;
24
+ }>({
25
+ customerApi: async ({ signIn }, use) => use(await signIn(customer)),
26
+ context: async ({ context, frontendSessions, env }, use) => {
27
+ await context.setStorageState(await frontendSessions.signedIn(env.FRONTEND_BASE_URL, customer));
28
+ await use(context);
29
+ },
30
+ });
31
+
32
+ test.describe("quotes", () => {
33
+ test.use({ modules: { QUOTES } });
34
+
35
+ test("a customer sees their quotes", async ({ customerApi, page }) => {
36
+ expect((await customerApi.get("/api/platform/security/currentuser")).ok).toBe(true);
37
+
38
+ await page.goto(new URL("/account/quotes", env.FRONTEND_BASE_URL).href);
39
+ await expect(page.getByRole("heading", { name: "Quotes" })).toBeVisible();
40
+ });
41
+ });
@@ -0,0 +1,22 @@
1
+ import { expect, request, test } from "@playwright/test";
2
+ import { TokenClient, TokenManager } from "@virtocommerce/test-automation-framework/auth";
3
+ import { envSchema, parseEnv } from "@virtocommerce/test-automation-framework/core";
4
+ import { HttpClient } from "@virtocommerce/test-automation-framework/http";
5
+
6
+ const env = parseEnv(envSchema);
7
+
8
+ test("the administrator can read the current user", async () => {
9
+ const context = await request.newContext({ ignoreHTTPSErrors: !env.VERIFY_SSL, timeout: env.REQUEST_TIMEOUT_MS });
10
+ const anonymous = new HttpClient(context, env.BACKEND_BASE_URL);
11
+ const tokens = new TokenManager(new TokenClient(anonymous));
12
+
13
+ try {
14
+ const admin = await tokens.signIn(anonymous, { username: env.ADMIN_USERNAME, password: env.ADMIN_PASSWORD });
15
+ const response = await admin.get("/api/platform/security/currentuser");
16
+
17
+ expect(response.json<{ userName: string }>().userName).toBe(env.ADMIN_USERNAME);
18
+ } finally {
19
+ await tokens.signOutAll();
20
+ await context.dispose();
21
+ }
22
+ });
@@ -0,0 +1,9 @@
1
+ import { graphqlCodegenConfig } from "@virtocommerce/test-automation-framework/graphql";
2
+
3
+ export default graphqlCodegenConfig({
4
+ schema: "https://platform.example.com/graphql",
5
+ documents: ["graphql/fragments/*.graphql", "graphql/operations/**/*.graphql"],
6
+ output: "graphql/generated/",
7
+ strictScalars: true,
8
+ scalars: { DateTime: "string" },
9
+ });
@@ -0,0 +1,32 @@
1
+ import type { GraphqlDocument } from "@virtocommerce/test-automation-framework/graphql";
2
+ import type { HttpClient } from "@virtocommerce/test-automation-framework/http";
3
+
4
+ import { expect } from "@playwright/test";
5
+ import { GraphqlClient, GraphqlError } from "@virtocommerce/test-automation-framework/graphql";
6
+
7
+ type Cart = { readonly cart: { readonly id: string; readonly itemsCount: number } };
8
+ type CartVariables = { readonly storeId: string; readonly userId: string };
9
+
10
+ export async function countCartItems(
11
+ signedIn: HttpClient,
12
+ getCart: GraphqlDocument<Cart, CartVariables>,
13
+ variables: CartVariables,
14
+ ): Promise<number> {
15
+ const { cart } = await new GraphqlClient(signedIn).execute(getCart, variables);
16
+ return cart.itemsCount;
17
+ }
18
+
19
+ export async function expectRejectedWithCode(
20
+ signedIn: HttpClient,
21
+ getCart: GraphqlDocument<Cart, CartVariables>,
22
+ variables: CartVariables,
23
+ code: string,
24
+ ): Promise<void> {
25
+ const result = await new GraphqlClient(signedIn).executeRaw(getCart, variables);
26
+
27
+ expect(result.errors.map((entry) => entry.extensions?.["code"])).toContain(code);
28
+ }
29
+
30
+ export function isMissingObject(error: unknown): boolean {
31
+ return GraphqlError.hasCode(error, "NOT_FOUND", "OBJECT_NOT_FOUND");
32
+ }
@@ -0,0 +1,18 @@
1
+ import type { HttpClient } from "@virtocommerce/test-automation-framework/http";
2
+
3
+ import { expect } from "@playwright/test";
4
+ import { object, string } from "zod";
5
+
6
+ const storeSchema = object({ id: string(), name: string() });
7
+
8
+ export async function readStore(client: HttpClient, id: string) {
9
+ const response = await client.get(`/api/stores/${encodeURIComponent(id)}`);
10
+ return response.parse(storeSchema);
11
+ }
12
+
13
+ export async function rejectionOf(client: HttpClient, path: string, body: unknown) {
14
+ const response = await client.post(path, { json: body });
15
+
16
+ expect(response.ok).toBe(false);
17
+ return response.errorJson();
18
+ }
@@ -0,0 +1,19 @@
1
+ import type { HttpClient } from "@virtocommerce/test-automation-framework/http";
2
+ import type { ModuleRequirement } from "@virtocommerce/test-automation-framework/modules";
3
+
4
+ import { InstalledModules } from "@virtocommerce/test-automation-framework/modules";
5
+
6
+ const QUOTES: ModuleRequirement = { id: "VirtoCommerce.Quote", minVersion: "3.1005.0" };
7
+
8
+ export async function quoteSkipReason(admin: HttpClient): Promise<string | undefined> {
9
+ const installed = await InstalledModules.read(admin);
10
+ return installed.unmetReason(QUOTES);
11
+ }
12
+
13
+ export function savedForWorkers(installed: InstalledModules): string {
14
+ return JSON.stringify(installed);
15
+ }
16
+
17
+ export function readFromSetup(saved: string): InstalledModules {
18
+ return new InstalledModules(JSON.parse(saved));
19
+ }
@@ -0,0 +1,11 @@
1
+ import { expect, test } from "@playwright/test";
2
+ import { maskSecrets, Secret } from "@virtocommerce/test-automation-framework/core";
3
+
4
+ test("a secret never appears in output", () => {
5
+ const password = Secret.of("Password1!");
6
+
7
+ expect(`${password}`).toBe("[SECRET]");
8
+ expect(JSON.stringify({ password })).toBe('{"password":"[SECRET]"}');
9
+ expect(maskSecrets("password=Password1%21")).toBe("password=[SECRET]");
10
+ expect(password.reveal()).toBe("Password1!");
11
+ });
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "paths": {
5
+ "@virtocommerce/test-automation-framework/*": ["../../src/*/index.ts"],
6
+ "@/*": ["../../src/*/index.ts"]
7
+ }
8
+ },
9
+ "include": ["."]
10
+ }
@@ -0,0 +1,106 @@
1
+ # Getting started
2
+
3
+ This guide sets up a test suite for a Virto Commerce-based solution and runs its first test. The `virtocommerce`
4
+ directory of the framework repository is a complete test suite that follows the same setup.
5
+
6
+ ## Install the framework
7
+
8
+ Follow the installation steps in the [package README](../README.md#installation), then install the peer dependencies:
9
+
10
+ ```shell
11
+ npm install --save-dev @playwright/test zod @types/node
12
+ ```
13
+
14
+ ## Configure TypeScript
15
+
16
+ The package publishes one entry point for each area, such as `@virtocommerce/test-automation-framework/core`.
17
+ TypeScript resolves them with the `nodenext` module resolution. Playwright runs the TypeScript files directly, so the
18
+ test suite does not emit JavaScript and can import its own files with the `.ts` extension:
19
+
20
+ ```json
21
+ {
22
+ "compilerOptions": {
23
+ "target": "es2024",
24
+ "module": "nodenext",
25
+ "moduleResolution": "nodenext",
26
+ "strict": true,
27
+ "noEmit": true,
28
+ "allowImportingTsExtensions": true,
29
+ "types": ["node"]
30
+ }
31
+ }
32
+ ```
33
+
34
+ ## Describe the environment
35
+
36
+ The framework defines the environment variables that every solution needs. Put their values in a `.env` file, which
37
+ must not be committed:
38
+
39
+ ```ini
40
+ BACKEND_BASE_URL=https://platform.example.com
41
+ ADMIN_USERNAME=admin
42
+ ADMIN_PASSWORD=...
43
+ ```
44
+
45
+ Load the file before the tests run, for example with `process.loadEnvFile()` in the Playwright configuration. See
46
+ [Environment](concepts/environment.md) for every variable and for adding your own.
47
+
48
+ ## Write the first test
49
+
50
+ The test signs in the platform administrator and reads the current user:
51
+
52
+ <!-- example: examples/getting-started.ts -->
53
+ ```ts
54
+ import { expect, request, test } from "@playwright/test";
55
+ import { TokenClient, TokenManager } from "@virtocommerce/test-automation-framework/auth";
56
+ import { envSchema, parseEnv } from "@virtocommerce/test-automation-framework/core";
57
+ import { HttpClient } from "@virtocommerce/test-automation-framework/http";
58
+
59
+ const env = parseEnv(envSchema);
60
+
61
+ test("the administrator can read the current user", async () => {
62
+ const context = await request.newContext({ ignoreHTTPSErrors: !env.VERIFY_SSL, timeout: env.REQUEST_TIMEOUT_MS });
63
+ const anonymous = new HttpClient(context, env.BACKEND_BASE_URL);
64
+ const tokens = new TokenManager(new TokenClient(anonymous));
65
+
66
+ try {
67
+ const admin = await tokens.signIn(anonymous, { username: env.ADMIN_USERNAME, password: env.ADMIN_PASSWORD });
68
+ const response = await admin.get("/api/platform/security/currentuser");
69
+
70
+ expect(response.json<{ userName: string }>().userName).toBe(env.ADMIN_USERNAME);
71
+ } finally {
72
+ await tokens.signOutAll();
73
+ await context.dispose();
74
+ }
75
+ });
76
+ ```
77
+
78
+ Run it with `npx playwright test`.
79
+
80
+ ## Share the code style
81
+
82
+ The package ships its [Biome](https://biomejs.dev) configuration, so test suites format and lint code the same way as
83
+ the framework. Install Biome and extend the preset in your `biome.json`:
84
+
85
+ ```shell
86
+ npm install --save-dev @biomejs/biome
87
+ ```
88
+
89
+ ```json
90
+ {
91
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
92
+ "extends": ["@virtocommerce/test-automation-framework/biome"],
93
+ "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
94
+ "files": { "includes": ["**"] }
95
+ }
96
+ ```
97
+
98
+ The preset combines three parts, which you can also extend one by one:
99
+
100
+ | Part | Contains |
101
+ | ---------------------------------------------------------- | ------------------------------------------------- |
102
+ | `@virtocommerce/test-automation-framework/biome/formatter` | Formatting: indentation, line width, line endings |
103
+ | `@virtocommerce/test-automation-framework/biome/rules` | Lint rules |
104
+ | `@virtocommerce/test-automation-framework/biome/imports` | Import grouping and order |
105
+
106
+ Rules set in your own `biome.json` override the preset's, for example the import boundaries of your test suite.
@@ -0,0 +1,75 @@
1
+ # Generating types
2
+
3
+ A test suite generates TypeScript types from the platform's GraphQL schema and OpenAPI documents, so its operations and
4
+ requests are typed. The framework never uses generated types; they belong to the test suite.
5
+
6
+ ## GraphQL
7
+
8
+ GraphQL Code Generator turns the test suite's operations into typed documents that `GraphqlClient` accepts. Install it
9
+ in the test suite:
10
+
11
+ ```shell
12
+ npm install --save-dev @graphql-codegen/cli @graphql-codegen/client-preset graphql
13
+ ```
14
+
15
+ Keep the operations in the test suite, for example one `.graphql` file for each operation in
16
+ `graphql/operations/<area>/` and shared fragments in `graphql/fragments/`. Create a `codegen.ts` file that exports the configuration from
17
+ `graphqlCodegenConfig`, which holds every setting the client depends on:
18
+
19
+ <!-- example: ../examples/graphql-codegen.ts -->
20
+ ```ts
21
+ import { graphqlCodegenConfig } from "@virtocommerce/test-automation-framework/graphql";
22
+
23
+ export default graphqlCodegenConfig({
24
+ schema: "https://platform.example.com/graphql",
25
+ documents: ["graphql/fragments/*.graphql", "graphql/operations/**/*.graphql"],
26
+ output: "graphql/generated/",
27
+ strictScalars: true,
28
+ scalars: { DateTime: "string" },
29
+ });
30
+ ```
31
+
32
+ Add a script to `package.json` and run it after each change to the schema or the operations:
33
+
34
+ ```json
35
+ {
36
+ "scripts": {
37
+ "codegen:graphql": "graphql-codegen --config codegen.ts"
38
+ }
39
+ }
40
+ ```
41
+
42
+ Each operation becomes a typed document, such as `GetCartDocument` for an operation named `GetCart`. Pass it to
43
+ `GraphqlClient.execute`, and the variables and the data are typed. Give the schema, the documents and the output as paths relative to the directory the generation runs from. On Windows,
44
+ an absolute path such as `C:/…` is read as a git reference, and the generation fails.
45
+
46
+ List the custom scalars of the schema in `scalars`;
47
+ the others are `unknown`. Set `strictScalars` to make the generation fail for a custom scalar that is not listed, so a
48
+ new scalar of the schema is noticed.
49
+
50
+ The generated files import each other with the `.ts` extension, so the TypeScript configuration of the test suite needs
51
+ `allowImportingTsExtensions`, as in [Getting started](../getting-started.md#configure-typescript).
52
+
53
+ ## REST
54
+
55
+ swagger-typescript-api generates types from OpenAPI documents. Install it in the test suite:
56
+
57
+ ```shell
58
+ npm install --save-dev swagger-typescript-api
59
+ ```
60
+
61
+ Generate one file for each module's OpenAPI document, with a script for each, such as:
62
+
63
+ ```json
64
+ {
65
+ "scripts": {
66
+ "codegen:rest": "swagger-typescript-api generate --path rest/specs/catalog.json --output rest/generated --name catalog.ts --no-client"
67
+ }
68
+ }
69
+ ```
70
+
71
+ The `--no-client` option generates types only. Do not use the generated clients: they send requests without
72
+ `HttpClient`, so the requests do not appear in test traces, secrets are not masked and the sign-in is not applied.
73
+ Use the types with `HttpClient`, for example `response.json<Store>()`, or validate the body with a schema.
74
+
75
+ The tool brings its own TypeScript version, so it works in a test suite with any TypeScript version.
@@ -0,0 +1,66 @@
1
+ # QA agents
2
+
3
+ The package ships a set of QA agents for [Claude Code](https://claude.com/claude-code) that plan, write, check, heal
4
+ and review the tests of a test suite built on the framework. They work for any solution: what they need to know about
5
+ your repository (where the suite is, the commands, the test projects, the roles and accounts, the tracker) comes from
6
+ one file, `.qa/project.json`.
7
+
8
+ ## Install
9
+
10
+ The agents run from your repository's `.claude/` directory, so the package copies them there:
11
+
12
+ ```shell
13
+ npm install --save-dev --save-exact @babel/parser
14
+ npx vc-qa-agents
15
+ ```
16
+
17
+ `vc-qa-agents` copies the agents, commands, skills, check scripts and hook into `.claude/`, replacing the copies of
18
+ an earlier version. It creates `.claude/settings.json` with the read-only shell hook and `.qa/project.json` from an
19
+ example, but never changes either one once it exists, and it lists the `.gitignore` entries that are missing. Run it
20
+ again after you upgrade the package. Commit `.claude/` and `.qa/project.json`; the other files under `.qa/` are the
21
+ agents' working files.
22
+
23
+ The check scripts are TypeScript, run by Node 22.18 or newer without a build, and parse specs with `@babel/parser`.
24
+
25
+ ## Describe your repository
26
+
27
+ Replace the example values in `.qa/project.json`, then check it with `node .claude/checks/project-facts.mts`, which
28
+ prints the facts or the first field that is wrong. Every agent reads the file through that command and stops when it
29
+ fails.
30
+
31
+ | Field | Holds |
32
+ | ----------------- | ------------------------------------------------------------------------------------------------ |
33
+ | `suiteDir` | The directory of the test suite with its own `playwright.config.ts` and `.env`; `.` for the root |
34
+ | `tracker` | The tracker kind, the pattern of its keys and the routes the agents may read a ticket by |
35
+ | `docSources` | Where the agents look up how the product should behave |
36
+ | `commands` | The type check, the lint and one test command for each Playwright project, plus `unit` and `all` |
37
+ | `critical` | The flows that coverage ranks first |
38
+ | `roles` | The data roles of the tests, each with its account |
39
+ | `roleFor` | Which role administers (`admin`), which is a customer, and optionally which is another customer |
40
+ | `rolePermissions` | The permissions of each role, for security tests |
41
+ | `passwordFor` | The environment variable that holds each role's password |
42
+ | `quality` | Limits on the size of a test, the stable series and the time budget of each project |
43
+ | `autonomy` | Whether the healer may apply a fix (`apply`) or only propose it (`propose`), by area |
44
+ | `healerPaths` | The directories the healer may change: page objects and test data, never the specs |
45
+
46
+ The prompts name no solution: `node .claude/checks/scan-prompts.mts` checks that the shipped files hold none of the
47
+ facts' accounts, role names or hosts.
48
+
49
+ ## Use
50
+
51
+ Start Claude Code in the repository and run `/qa <task>`: a ticket key, a link to a specification, an area such as
52
+ "cover the cart", a failing test, "review this branch" or "what is not covered". The orchestrator picks the flow and
53
+ runs each role as its own agent:
54
+
55
+ | Role | Does |
56
+ | ---------------------- | -------------------------------------------------------------------------------------------- |
57
+ | `qa-planner` | Turns the task into a contract of test cases under `.qa/contracts/`, which a person approves |
58
+ | `qa-explorer` | Maps pages and API operations on the stand, read-only |
59
+ | `qa-coverage` | Lists what the tests cover and ranks the gaps |
60
+ | `qa-automation-expert` | Implements an approved contract and leaves a run record |
61
+ | `qa-judge` | Checks the expert's tests and proves that they fail when an expected value is broken |
62
+ | `qa-healer` | Repairs failing tests in page objects and data, never by changing an expected value |
63
+ | `qa-reviewer` | Reviews the diff against the framework rules and the definition of done |
64
+
65
+ `/qa-plan`, `/qa-implement`, `/qa-review`, `/qa-heal`, `/qa-explore` and `/qa-coverage` run one role. The rules every
66
+ test follows are in the `framework-rules` skill; the read-only agents are held to their commands by the hook.
package/package.json CHANGED
@@ -1,6 +1,158 @@
1
1
  {
2
2
  "name": "@virtocommerce/test-automation-framework",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "Playwright Test framework for the API and browser test suites of Virto Commerce-based solutions",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/VirtoCommerce/vc-test-automation-framework.git"
9
+ },
10
+ "type": "module",
11
+ "engines": {
12
+ "node": ">=22.18"
13
+ },
14
+ "exports": {
15
+ "./auth": {
16
+ "types": "./dist/auth/index.d.ts",
17
+ "default": "./dist/auth/index.js"
18
+ },
19
+ "./core": {
20
+ "types": "./dist/core/index.d.ts",
21
+ "default": "./dist/core/index.js"
22
+ },
23
+ "./dataset": {
24
+ "types": "./dist/dataset/index.d.ts",
25
+ "default": "./dist/dataset/index.js"
26
+ },
27
+ "./fixtures": {
28
+ "types": "./dist/fixtures/index.d.ts",
29
+ "default": "./dist/fixtures/index.js"
30
+ },
31
+ "./graphql": {
32
+ "types": "./dist/graphql/index.d.ts",
33
+ "default": "./dist/graphql/index.js"
34
+ },
35
+ "./http": {
36
+ "types": "./dist/http/index.d.ts",
37
+ "default": "./dist/http/index.js"
38
+ },
39
+ "./modules": {
40
+ "types": "./dist/modules/index.d.ts",
41
+ "default": "./dist/modules/index.js"
42
+ },
43
+ "./biome": "./.biome/preset.json",
44
+ "./biome/*": "./.biome/*.json",
45
+ "./package.json": "./package.json"
46
+ },
47
+ "files": [
48
+ "dist",
49
+ "docs",
50
+ ".biome/preset.json",
51
+ ".biome/formatter.json",
52
+ ".biome/rules.json",
53
+ ".biome/imports.json",
54
+ ".claude/agents",
55
+ ".claude/commands",
56
+ "!.claude/commands/code-review-full.md",
57
+ ".claude/skills",
58
+ ".claude/checks",
59
+ "!.claude/checks/ours-only.json",
60
+ ".claude/hooks",
61
+ ".claude/settings.json",
62
+ ".qa/project.example.json",
63
+ "bin",
64
+ "CHANGELOG.md"
65
+ ],
66
+ "publishConfig": {
67
+ "registry": "https://registry.npmjs.org",
68
+ "access": "public",
69
+ "provenance": true
70
+ },
71
+ "scripts": {
72
+ "prepare": "simple-git-hooks",
73
+ "prepack": "npm run build",
74
+ "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
75
+ "build": "npm run clean && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths",
76
+ "typecheck": "tsc --noEmit && tsc -p virtocommerce --noEmit && tsc -p docs/examples --noEmit",
77
+ "check": "biome check --write .",
78
+ "check:ci": "biome ci --error-on-warnings .",
79
+ "test:unit": "playwright test --project=unit",
80
+ "docs:check": "node scripts/check-docs.ts",
81
+ "docs:sync": "biome format --write docs/examples && node scripts/check-docs.ts --write",
82
+ "docs:api": "node tools/typedoc/node_modules/typedoc/bin/typedoc",
83
+ "changeset": "changeset",
84
+ "release:version": "changeset version && biome format --write package.json",
85
+ "release:publish": "changeset publish",
86
+ "codegen:vc": "npm run build && npm run codegen:vc:graphql && npm run codegen:vc:rest",
87
+ "codegen:vc:graphql": "graphql-codegen --config virtocommerce/codegen.ts",
88
+ "codegen:vc:rest": "node virtocommerce/scripts/generate-rest-types.ts",
89
+ "facts:check": "node virtocommerce/scripts/check-role-permissions.ts",
90
+ "seed:vc": "playwright test -c virtocommerce --project=seed",
91
+ "pretest:vc": "node -e \"require('node:fs').rmSync('virtocommerce/reports/allure-results', { recursive: true, force: true })\"",
92
+ "test:vc": "playwright test -c virtocommerce --grep-invert @destructive",
93
+ "test:vc:isolated": "playwright test -c virtocommerce --project=isolated",
94
+ "test:vc:unit": "playwright test -c virtocommerce/playwright.unit.config.ts",
95
+ "report:vc": "cd virtocommerce && allure generate reports/allure-results --clean",
96
+ "report:vc:open": "cd virtocommerce && allure open reports/allure-report"
97
+ },
98
+ "simple-git-hooks": {
99
+ "pre-commit": "npx biome check --staged --no-errors-on-unmatched"
100
+ },
101
+ "peerDependencies": {
102
+ "@babel/parser": "^7.29.9",
103
+ "@biomejs/biome": "^2.6.8",
104
+ "@graphql-codegen/cli": "^8.0.0",
105
+ "@graphql-codegen/client-preset": "^7.0.0",
106
+ "@playwright/test": "^1.65.1",
107
+ "allure-playwright": "^3.14.0",
108
+ "graphql": "^16.0.0 || ^17.0.0",
109
+ "zod": "^4.0.7"
110
+ },
111
+ "peerDependenciesMeta": {
112
+ "@babel/parser": {
113
+ "optional": true
114
+ },
115
+ "@biomejs/biome": {
116
+ "optional": true
117
+ },
118
+ "@graphql-codegen/cli": {
119
+ "optional": true
120
+ },
121
+ "@graphql-codegen/client-preset": {
122
+ "optional": true
123
+ },
124
+ "allure-playwright": {
125
+ "optional": true
126
+ },
127
+ "graphql": {
128
+ "optional": true
129
+ }
130
+ },
131
+ "devDependencies": {
132
+ "@babel/parser": "7.29.9",
133
+ "@biomejs/biome": "^2.6.8",
134
+ "@changesets/changelog-github": "^1.0.1",
135
+ "@changesets/cli": "^3.0.3",
136
+ "@graphql-codegen/cli": "8.0.0",
137
+ "@graphql-codegen/client-preset": "7.0.0",
138
+ "@graphql-codegen/schema-ast": "7.0.0",
139
+ "@graphql-typed-document-node/core": "3.2.0",
140
+ "@playwright/test": "^1.65.1",
141
+ "@types/node": "^22.20.5",
142
+ "allure": "3.33.0",
143
+ "allure-playwright": "3.14.0",
144
+ "graphql": "16.15.0",
145
+ "simple-git-hooks": "2.14.0",
146
+ "swagger-typescript-api": "13.14.0",
147
+ "tsc-alias": "^1.9.10",
148
+ "typescript": "^7.0.2",
149
+ "zod": "^4.6.7"
150
+ },
151
+ "overrides": {
152
+ "glob": "14.0.4",
153
+ "minimatch": "11.0.5"
154
+ },
155
+ "bin": {
156
+ "vc-qa-agents": "bin/install-qa-agents.mjs"
157
+ }
158
+ }