@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.
- package/.biome/formatter.json +11 -0
- package/.biome/imports.json +52 -0
- package/.biome/preset.json +4 -0
- package/.biome/rules.json +45 -0
- package/.claude/agents/qa-automation-expert.md +119 -0
- package/.claude/agents/qa-coverage.md +96 -0
- package/.claude/agents/qa-explorer.md +112 -0
- package/.claude/agents/qa-healer.md +88 -0
- package/.claude/agents/qa-judge.md +102 -0
- package/.claude/agents/qa-planner.md +104 -0
- package/.claude/agents/qa-reviewer.md +121 -0
- package/.claude/checks/browser-secrets.mts +107 -0
- package/.claude/checks/contract.mts +469 -0
- package/.claude/checks/expectation-guard.mts +665 -0
- package/.claude/checks/explore-extractors.mts +4 -0
- package/.claude/checks/judge-verdict.mts +165 -0
- package/.claude/checks/project-facts.mts +491 -0
- package/.claude/checks/prove-fails.mts +770 -0
- package/.claude/checks/rank-gaps.mts +177 -0
- package/.claude/checks/readonly-shell.mts +740 -0
- package/.claude/checks/reconcile-run.mts +270 -0
- package/.claude/checks/scan-prompts.mts +351 -0
- package/.claude/checks/stand.mts +45 -0
- package/.claude/checks/test-duration.mts +134 -0
- package/.claude/checks/test-shape.mts +224 -0
- package/.claude/checks/ticket-card.mts +195 -0
- package/.claude/commands/qa-coverage.md +13 -0
- package/.claude/commands/qa-explore.md +17 -0
- package/.claude/commands/qa-heal.md +44 -0
- package/.claude/commands/qa-implement.md +60 -0
- package/.claude/commands/qa-plan.md +55 -0
- package/.claude/commands/qa-review.md +90 -0
- package/.claude/commands/qa.md +156 -0
- package/.claude/hooks/readonly-shell.mts +65 -0
- package/.claude/settings.json +15 -0
- package/.claude/skills/coverage-analysis/SKILL.md +107 -0
- package/.claude/skills/create-graphql-layer/SKILL.md +159 -0
- package/.claude/skills/create-ui-layer/SKILL.md +189 -0
- package/.claude/skills/explore-api/SKILL.md +74 -0
- package/.claude/skills/explore-frontend/SKILL.md +85 -0
- package/.claude/skills/framework-rules/SKILL.md +189 -0
- package/.claude/skills/heal-tests/SKILL.md +197 -0
- package/.claude/skills/heal-tests/guard-recipe.md +53 -0
- package/.claude/skills/judge-criteria/SKILL.md +40 -0
- package/.claude/skills/judge-criteria/coverage.md +9 -0
- package/.claude/skills/judge-criteria/expert.md +23 -0
- package/.claude/skills/judge-criteria/explorer.md +9 -0
- package/.claude/skills/judge-criteria/healer.md +13 -0
- package/.claude/skills/judge-criteria/planner.md +12 -0
- package/.claude/skills/plan-implementation/SKILL.md +82 -0
- package/.claude/skills/plan-implementation/contract-template.md +72 -0
- package/.claude/skills/plan-test-strategy/SKILL.md +100 -0
- package/.claude/skills/project-facts/SKILL.md +130 -0
- package/.claude/skills/read-change/SKILL.md +64 -0
- package/.claude/skills/read-ticket/SKILL.md +63 -0
- package/.claude/skills/read-ticket/providers.md +58 -0
- package/.claude/skills/review-pr/SKILL.md +152 -0
- package/.claude/skills/review-test-code/SKILL.md +208 -0
- package/.claude/skills/write-e2e-test/SKILL.md +175 -0
- package/.claude/skills/write-graphql-test/SKILL.md +158 -0
- package/.claude/skills/write-rest-api-test/SKILL.md +182 -0
- package/.claude/skills/write-security-test/SKILL.md +253 -0
- package/.qa/project.example.json +71 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE +12 -0
- package/README.md +53 -2
- package/bin/install-qa-agents.mjs +94 -0
- package/dist/auth/credentials.d.ts +10 -0
- package/dist/auth/credentials.js +2 -0
- package/dist/auth/credentials.js.map +1 -0
- package/dist/auth/frontend-browser-sessions.d.ts +71 -0
- package/dist/auth/frontend-browser-sessions.js +130 -0
- package/dist/auth/frontend-browser-sessions.js.map +1 -0
- package/dist/auth/index.d.ts +9 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/platform-browser-sessions.d.ts +47 -0
- package/dist/auth/platform-browser-sessions.js +92 -0
- package/dist/auth/platform-browser-sessions.js.map +1 -0
- package/dist/auth/sign-in-lock.d.ts +14 -0
- package/dist/auth/sign-in-lock.js +70 -0
- package/dist/auth/sign-in-lock.js.map +1 -0
- package/dist/auth/storage-state.d.ts +3 -0
- package/dist/auth/storage-state.js +2 -0
- package/dist/auth/storage-state.js.map +1 -0
- package/dist/auth/token-client.d.ts +82 -0
- package/dist/auth/token-client.js +111 -0
- package/dist/auth/token-client.js.map +1 -0
- package/dist/auth/token-manager.d.ts +67 -0
- package/dist/auth/token-manager.js +138 -0
- package/dist/auth/token-manager.js.map +1 -0
- package/dist/core/default-reporters.d.ts +31 -0
- package/dist/core/default-reporters.js +36 -0
- package/dist/core/default-reporters.js.map +1 -0
- package/dist/core/default-use.d.ts +28 -0
- package/dist/core/default-use.js +25 -0
- package/dist/core/default-use.js.map +1 -0
- package/dist/core/env.d.ts +24 -0
- package/dist/core/env.js +33 -0
- package/dist/core/env.js.map +1 -0
- package/dist/core/error-message.d.ts +10 -0
- package/dist/core/error-message.js +13 -0
- package/dist/core/error-message.js.map +1 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.js +11 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/is-ci.d.ts +14 -0
- package/dist/core/is-ci.js +18 -0
- package/dist/core/is-ci.js.map +1 -0
- package/dist/core/parse-env.d.ts +13 -0
- package/dist/core/parse-env.js +21 -0
- package/dist/core/parse-env.js.map +1 -0
- package/dist/core/projects.d.ts +24 -0
- package/dist/core/projects.js +33 -0
- package/dist/core/projects.js.map +1 -0
- package/dist/core/run-options.d.ts +31 -0
- package/dist/core/run-options.js +43 -0
- package/dist/core/run-options.js.map +1 -0
- package/dist/core/secret.d.ts +105 -0
- package/dist/core/secret.js +167 -0
- package/dist/core/secret.js.map +1 -0
- package/dist/core/string-schemas.d.ts +39 -0
- package/dist/core/string-schemas.js +56 -0
- package/dist/core/string-schemas.js.map +1 -0
- package/dist/core/url-path.d.ts +7 -0
- package/dist/core/url-path.js +2 -0
- package/dist/core/url-path.js.map +1 -0
- package/dist/dataset/collection.d.ts +44 -0
- package/dist/dataset/collection.js +76 -0
- package/dist/dataset/collection.js.map +1 -0
- package/dist/dataset/index.d.ts +11 -0
- package/dist/dataset/index.js +6 -0
- package/dist/dataset/index.js.map +1 -0
- package/dist/dataset/load-dataset.d.ts +39 -0
- package/dist/dataset/load-dataset.js +62 -0
- package/dist/dataset/load-dataset.js.map +1 -0
- package/dist/dataset/manifest.d.ts +77 -0
- package/dist/dataset/manifest.js +10 -0
- package/dist/dataset/manifest.js.map +1 -0
- package/dist/dataset/placeholders.d.ts +66 -0
- package/dist/dataset/placeholders.js +87 -0
- package/dist/dataset/placeholders.js.map +1 -0
- package/dist/dataset/seed-collection.d.ts +53 -0
- package/dist/dataset/seed-collection.js +115 -0
- package/dist/dataset/seed-collection.js.map +1 -0
- package/dist/dataset/seed-dataset.d.ts +70 -0
- package/dist/dataset/seed-dataset.js +138 -0
- package/dist/dataset/seed-dataset.js.map +1 -0
- package/dist/dataset/seed-events.d.ts +81 -0
- package/dist/dataset/seed-events.js +2 -0
- package/dist/dataset/seed-events.js.map +1 -0
- package/dist/dataset/seed-requests.d.ts +102 -0
- package/dist/dataset/seed-requests.js +160 -0
- package/dist/dataset/seed-requests.js.map +1 -0
- package/dist/dataset/seed-scope.d.ts +39 -0
- package/dist/dataset/seed-scope.js +67 -0
- package/dist/dataset/seed-scope.js.map +1 -0
- package/dist/fixtures/default-fixtures.d.ts +93 -0
- package/dist/fixtures/default-fixtures.js +105 -0
- package/dist/fixtures/default-fixtures.js.map +1 -0
- package/dist/fixtures/index.d.ts +2 -0
- package/dist/fixtures/index.js +2 -0
- package/dist/fixtures/index.js.map +1 -0
- package/dist/graphql/graphql-client.d.ts +78 -0
- package/dist/graphql/graphql-client.js +83 -0
- package/dist/graphql/graphql-client.js.map +1 -0
- package/dist/graphql/graphql-codegen.d.ts +56 -0
- package/dist/graphql/graphql-codegen.js +42 -0
- package/dist/graphql/graphql-codegen.js.map +1 -0
- package/dist/graphql/graphql-error.d.ts +54 -0
- package/dist/graphql/graphql-error.js +74 -0
- package/dist/graphql/graphql-error.js.map +1 -0
- package/dist/graphql/index.d.ts +6 -0
- package/dist/graphql/index.js +4 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/http/authentication.d.ts +16 -0
- package/dist/http/authentication.js +2 -0
- package/dist/http/authentication.js.map +1 -0
- package/dist/http/http-client.d.ts +110 -0
- package/dist/http/http-client.js +237 -0
- package/dist/http/http-client.js.map +1 -0
- package/dist/http/http-error.d.ts +26 -0
- package/dist/http/http-error.js +34 -0
- package/dist/http/http-error.js.map +1 -0
- package/dist/http/http-method.d.ts +2 -0
- package/dist/http/http-method.js +2 -0
- package/dist/http/http-method.js.map +1 -0
- package/dist/http/http-response.d.ts +137 -0
- package/dist/http/http-response.js +166 -0
- package/dist/http/http-response.js.map +1 -0
- package/dist/http/index.d.ts +7 -0
- package/dist/http/index.js +4 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/request-options.d.ts +62 -0
- package/dist/http/request-options.js +2 -0
- package/dist/http/request-options.js.map +1 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +2 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/installed-modules.d.ts +86 -0
- package/dist/modules/installed-modules.js +135 -0
- package/dist/modules/installed-modules.js.map +1 -0
- package/docs/README.md +43 -0
- package/docs/concepts/areas.md +38 -0
- package/docs/concepts/auth.md +92 -0
- package/docs/concepts/config.md +102 -0
- package/docs/concepts/dataset.md +183 -0
- package/docs/concepts/environment.md +54 -0
- package/docs/concepts/fixtures.md +109 -0
- package/docs/concepts/graphql.md +76 -0
- package/docs/concepts/http.md +88 -0
- package/docs/concepts/modules.md +63 -0
- package/docs/concepts/secrets.md +50 -0
- package/docs/contributing/architecture.md +67 -0
- package/docs/contributing/conventions.md +39 -0
- package/docs/contributing/documentation.md +37 -0
- package/docs/contributing/releasing.md +76 -0
- package/docs/examples/auth.ts +20 -0
- package/docs/examples/config.ts +36 -0
- package/docs/examples/dataset.ts +70 -0
- package/docs/examples/environment.ts +8 -0
- package/docs/examples/fixtures.ts +41 -0
- package/docs/examples/getting-started.ts +22 -0
- package/docs/examples/graphql-codegen.ts +9 -0
- package/docs/examples/graphql.ts +32 -0
- package/docs/examples/http.ts +18 -0
- package/docs/examples/modules.ts +19 -0
- package/docs/examples/secrets.ts +11 -0
- package/docs/examples/tsconfig.json +10 -0
- package/docs/getting-started.md +106 -0
- package/docs/guides/generating-types.md +75 -0
- package/docs/guides/qa-agents.md +66 -0
- package/package.json +156 -4
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# GraphQL
|
|
2
|
+
|
|
3
|
+
The `graphql` area runs typed GraphQL operations, such as the operations of the Virto Commerce API (xAPI).
|
|
4
|
+
|
|
5
|
+
## Documents
|
|
6
|
+
|
|
7
|
+
The framework does not define operations. A test suite generates typed documents from its operations with GraphQL
|
|
8
|
+
Code Generator, in the string document mode, and passes them to the client. Each document carries the types of its
|
|
9
|
+
result and its variables, so the data and the variables are typed without a GraphQL package in the framework.
|
|
10
|
+
|
|
11
|
+
For the setup, see [Generating types](../guides/generating-types.md#graphql). `graphqlCodegenConfig` returns the
|
|
12
|
+
configuration that produces documents the client accepts.
|
|
13
|
+
|
|
14
|
+
## The client
|
|
15
|
+
|
|
16
|
+
`GraphqlClient` sends operations through an `HttpClient`, usually a signed-in one, so sign-in, token renewal, the
|
|
17
|
+
single origin and test traces work as for any request. The endpoint is `/graphql` unless another path is given.
|
|
18
|
+
|
|
19
|
+
| Method | Returns | Throws a `GraphqlError` when |
|
|
20
|
+
| ------------ | ----------------------------------- | ----------------------------------------------------------- |
|
|
21
|
+
| `execute` | The data of the response | The response has errors, even with partial data, or no data |
|
|
22
|
+
| `executeRaw` | The data, the errors and the status | Never; use it in tests that check errors or partial data |
|
|
23
|
+
|
|
24
|
+
- Variables are optional only for an operation without required variables. Each string in them can be a `Secret`,
|
|
25
|
+
revealed only when the operation is sent.
|
|
26
|
+
- GraphQL errors are read from a response with any status, because a server can return them with a success status or,
|
|
27
|
+
for an invalid operation, with a 400 status.
|
|
28
|
+
- Both methods throw an `HttpError` for a failed status without GraphQL errors, and for a body that is not a GraphQL
|
|
29
|
+
response.
|
|
30
|
+
|
|
31
|
+
<!-- example: ../examples/graphql.ts -->
|
|
32
|
+
```ts
|
|
33
|
+
import type { GraphqlDocument } from "@virtocommerce/test-automation-framework/graphql";
|
|
34
|
+
import type { HttpClient } from "@virtocommerce/test-automation-framework/http";
|
|
35
|
+
|
|
36
|
+
import { expect } from "@playwright/test";
|
|
37
|
+
import { GraphqlClient, GraphqlError } from "@virtocommerce/test-automation-framework/graphql";
|
|
38
|
+
|
|
39
|
+
type Cart = { readonly cart: { readonly id: string; readonly itemsCount: number } };
|
|
40
|
+
type CartVariables = { readonly storeId: string; readonly userId: string };
|
|
41
|
+
|
|
42
|
+
export async function countCartItems(
|
|
43
|
+
signedIn: HttpClient,
|
|
44
|
+
getCart: GraphqlDocument<Cart, CartVariables>,
|
|
45
|
+
variables: CartVariables,
|
|
46
|
+
): Promise<number> {
|
|
47
|
+
const { cart } = await new GraphqlClient(signedIn).execute(getCart, variables);
|
|
48
|
+
return cart.itemsCount;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function expectRejectedWithCode(
|
|
52
|
+
signedIn: HttpClient,
|
|
53
|
+
getCart: GraphqlDocument<Cart, CartVariables>,
|
|
54
|
+
variables: CartVariables,
|
|
55
|
+
code: string,
|
|
56
|
+
): Promise<void> {
|
|
57
|
+
const result = await new GraphqlClient(signedIn).executeRaw(getCart, variables);
|
|
58
|
+
|
|
59
|
+
expect(result.errors.map((entry) => entry.extensions?.["code"])).toContain(code);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function isMissingObject(error: unknown): boolean {
|
|
63
|
+
return GraphqlError.hasCode(error, "NOT_FOUND", "OBJECT_NOT_FOUND");
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Errors
|
|
68
|
+
|
|
69
|
+
`GraphqlError` represents a response that has errors, or one that has no data.
|
|
70
|
+
|
|
71
|
+
- The message names the operation and the HTTP status, then lists each error with its code and path, such as
|
|
72
|
+
`- [VALIDATION_ERROR] Quantity must be positive (at addItem)`.
|
|
73
|
+
- `errors` holds the error entries of the response, including fields that the server adds, such as `locations`.
|
|
74
|
+
- Secrets are masked in the message and in the entries, because servers often quote variable values in their errors.
|
|
75
|
+
- `GraphqlError.hasCode(error, ...codes)` tells whether an unknown value is a `GraphqlError` with an entry whose
|
|
76
|
+
`extensions.code` is one of the codes.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# HTTP
|
|
2
|
+
|
|
3
|
+
`HttpClient` sends requests through a Playwright request context, so the requests appear in test traces. It returns
|
|
4
|
+
an `HttpResponse` whose body has already been read.
|
|
5
|
+
|
|
6
|
+
## The client
|
|
7
|
+
|
|
8
|
+
A client sends requests to one origin, given when it is created. It is immutable: `withHeaders` and
|
|
9
|
+
`withAuthentication` return a new client and leave the original unchanged.
|
|
10
|
+
|
|
11
|
+
- **One origin.** A path that resolves to another origin is refused before anything is sent, and redirects are not
|
|
12
|
+
followed. Headers, including sign-in headers, never reach another host.
|
|
13
|
+
- **No exceptions for a status.** The client returns every response, whatever its status. The response methods check
|
|
14
|
+
the status, as described below.
|
|
15
|
+
- **No retries.** A request is sent once. When no response arrives, the client throws an error with secrets masked.
|
|
16
|
+
The only resend is after a 401 status on a client with authentication, once the sign-in has been renewed.
|
|
17
|
+
- **Secrets revealed only when sent.** The query, headers and body accept `Secret` values.
|
|
18
|
+
|
|
19
|
+
### Headers
|
|
20
|
+
|
|
21
|
+
Headers are merged in this order, and a later header replaces an earlier one of the same name, whatever its case:
|
|
22
|
+
|
|
23
|
+
1. Headers from `withHeaders`, in the order the calls were made.
|
|
24
|
+
2. Sign-in headers from `withAuthentication`.
|
|
25
|
+
3. The content type of a JSON body.
|
|
26
|
+
4. Headers given with the request.
|
|
27
|
+
|
|
28
|
+
A header provider passed to `withHeaders` is called for each request, so values that change are picked up.
|
|
29
|
+
|
|
30
|
+
### Bodies
|
|
31
|
+
|
|
32
|
+
A request has at most one body:
|
|
33
|
+
|
|
34
|
+
| Option | Sent as |
|
|
35
|
+
| ----------- | --------------------------------------------------------------------------------------- |
|
|
36
|
+
| `json` | JSON with the `application/json` content type, with each `Secret` at any depth revealed |
|
|
37
|
+
| `form` | URL-encoded form fields |
|
|
38
|
+
| `multipart` | Multipart form data with text fields and files |
|
|
39
|
+
|
|
40
|
+
For `form` and `multipart` bodies, a content type set with `withHeaders` is ignored, so the body is encoded correctly.
|
|
41
|
+
|
|
42
|
+
## The response
|
|
43
|
+
|
|
44
|
+
| Member | Returns | Throws an `HttpError` when |
|
|
45
|
+
| ----------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
46
|
+
| `ok` | Whether the status is a success status (2xx) | Never |
|
|
47
|
+
| `expectOk()` | The response | The status is not a success status |
|
|
48
|
+
| `json<T>()` | The body parsed as JSON, not checked at run time | The status is not a success status, or the body is not JSON |
|
|
49
|
+
| `parse(schema)` | The body validated by a schema | As for `json`, or the body does not match the schema |
|
|
50
|
+
| `optionalJson<T>()` | As for `json`, or `undefined` for an empty or `null` body | As for `json` |
|
|
51
|
+
| `parseOptional(schema)` | As for `parse`, or `undefined` for an empty or `null` body | As for `parse` |
|
|
52
|
+
| `errorJson<T>()` | The body of an error response parsed as JSON, for negative tests | The status is a success status, or the body is not JSON |
|
|
53
|
+
| `toError(reason)` | An `HttpError` that describes the response, for other checks | Never; the caller throws it |
|
|
54
|
+
|
|
55
|
+
Because `json` and `parse` require a success status and `errorJson` requires an error status, a missed status check
|
|
56
|
+
cannot hide a failure.
|
|
57
|
+
|
|
58
|
+
A 404 status is an error for `optionalJson` and `parseOptional` too, because a server also returns it for an unknown
|
|
59
|
+
route. For an endpoint that answers a missing record with 404, pass `{ allow404: true }`, and the method returns
|
|
60
|
+
`undefined` for a 404 status as well.
|
|
61
|
+
|
|
62
|
+
<!-- example: ../examples/http.ts -->
|
|
63
|
+
```ts
|
|
64
|
+
import type { HttpClient } from "@virtocommerce/test-automation-framework/http";
|
|
65
|
+
|
|
66
|
+
import { expect } from "@playwright/test";
|
|
67
|
+
import { object, string } from "zod";
|
|
68
|
+
|
|
69
|
+
const storeSchema = object({ id: string(), name: string() });
|
|
70
|
+
|
|
71
|
+
export async function readStore(client: HttpClient, id: string) {
|
|
72
|
+
const response = await client.get(`/api/stores/${encodeURIComponent(id)}`);
|
|
73
|
+
return response.parse(storeSchema);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function rejectionOf(client: HttpClient, path: string, body: unknown) {
|
|
77
|
+
const response = await client.post(path, { json: body });
|
|
78
|
+
|
|
79
|
+
expect(response.ok).toBe(false);
|
|
80
|
+
return response.errorJson();
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Errors
|
|
85
|
+
|
|
86
|
+
An `HttpError` names the request and the status, and quotes the body. The URL in the message has no query or
|
|
87
|
+
fragment, the body is shortened after 1000 characters, and secrets are masked in the message and in `error.body`.
|
|
88
|
+
`HttpError.hasStatus(error, 404, 409)` tells whether an unknown value is an `HttpError` with one of the statuses.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Modules
|
|
2
|
+
|
|
3
|
+
A Virto Commerce platform runs a set of modules, and each solution installs its own. Tests and dataset collections
|
|
4
|
+
that need a module check that it is installed, in a version they work with, and are skipped otherwise.
|
|
5
|
+
|
|
6
|
+
## Requirements
|
|
7
|
+
|
|
8
|
+
A `ModuleRequirement` names a module and, optionally, a range of versions:
|
|
9
|
+
|
|
10
|
+
| Field | Meaning |
|
|
11
|
+
| --------------- | ----------------------------------------------------------------- |
|
|
12
|
+
| `id` | The identifier of the module, such as `VirtoCommerce.Catalog` |
|
|
13
|
+
| `minVersion` | The oldest version that meets the requirement, inclusive |
|
|
14
|
+
| `beforeVersion` | The first version that no longer meets the requirement, exclusive |
|
|
15
|
+
|
|
16
|
+
Without a range, any installed version meets the requirement. Set `minVersion` when the code relies on a fix or a
|
|
17
|
+
feature of that version, and `beforeVersion` when a later version changes the behaviour that the code checks. A test
|
|
18
|
+
suite keeps its requirements in one place, so a collection that the seed skips and the tests that use its data skip for
|
|
19
|
+
the same reason.
|
|
20
|
+
|
|
21
|
+
## Installed modules
|
|
22
|
+
|
|
23
|
+
`InstalledModules.read` reads the modules installed on a platform with a client signed in as a platform administrator.
|
|
24
|
+
Modules that the platform knows but has not installed are left out.
|
|
25
|
+
|
|
26
|
+
- `unmetReason` returns why a requirement is not met, such as `VirtoCommerce.Quote 3.1010.0 is older than 3.1020.0`,
|
|
27
|
+
or `undefined` when it is met. `unmetReasons` checks several requirements at once.
|
|
28
|
+
- `versionOf` returns the installed version of a module, and `count` the number of installed modules.
|
|
29
|
+
- `JSON.stringify` saves the set, and the constructor creates it again from the result. A setup project reads the
|
|
30
|
+
modules once and passes them to the test workers this way.
|
|
31
|
+
|
|
32
|
+
<!-- example: ../examples/modules.ts -->
|
|
33
|
+
```ts
|
|
34
|
+
import type { HttpClient } from "@virtocommerce/test-automation-framework/http";
|
|
35
|
+
import type { ModuleRequirement } from "@virtocommerce/test-automation-framework/modules";
|
|
36
|
+
|
|
37
|
+
import { InstalledModules } from "@virtocommerce/test-automation-framework/modules";
|
|
38
|
+
|
|
39
|
+
const QUOTES: ModuleRequirement = { id: "VirtoCommerce.Quote", minVersion: "3.1005.0" };
|
|
40
|
+
|
|
41
|
+
export async function quoteSkipReason(admin: HttpClient): Promise<string | undefined> {
|
|
42
|
+
const installed = await InstalledModules.read(admin);
|
|
43
|
+
return installed.unmetReason(QUOTES);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function savedForWorkers(installed: InstalledModules): string {
|
|
47
|
+
return JSON.stringify(installed);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function readFromSetup(saved: string): InstalledModules {
|
|
51
|
+
return new InstalledModules(JSON.parse(saved));
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Versions
|
|
56
|
+
|
|
57
|
+
`compareModuleVersions` compares versions such as `3.1034.0`. The parts are compared as numbers, so `3.1034.0` is newer
|
|
58
|
+
than `3.1012.1`, and a missing part counts as 0. A build with a suffix, such as `3.1035.0-pr-12`, comes before the
|
|
59
|
+
release of the same version, and build metadata after `+`, such as `3.1035.0+sha.5114f85`, is ignored.
|
|
60
|
+
|
|
61
|
+
A version in another form, such as the four-part `1.0.0.0` of some custom modules, is an error only when it is
|
|
62
|
+
compared. The installed modules are read whatever their versions, and `unmetReason` fails, naming the module, only
|
|
63
|
+
for a requirement with a range of versions on that module.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Secrets
|
|
2
|
+
|
|
3
|
+
Test suites handle passwords, tokens and keys. The framework keeps their values out of test output, traces of errors
|
|
4
|
+
and logs, without each test having to remember it.
|
|
5
|
+
|
|
6
|
+
## The `Secret` type
|
|
7
|
+
|
|
8
|
+
A `Secret` holds a value that never appears in output. String conversion, JSON serialization and console output all
|
|
9
|
+
produce `[SECRET]`. Only `reveal()` returns the value, and only code that sends or stores the value should call it.
|
|
10
|
+
|
|
11
|
+
<!-- example: ../examples/secrets.ts -->
|
|
12
|
+
```ts
|
|
13
|
+
import { expect, test } from "@playwright/test";
|
|
14
|
+
import { maskSecrets, Secret } from "@virtocommerce/test-automation-framework/core";
|
|
15
|
+
|
|
16
|
+
test("a secret never appears in output", () => {
|
|
17
|
+
const password = Secret.of("Password1!");
|
|
18
|
+
|
|
19
|
+
expect(`${password}`).toBe("[SECRET]");
|
|
20
|
+
expect(JSON.stringify({ password })).toBe('{"password":"[SECRET]"}');
|
|
21
|
+
expect(maskSecrets("password=Password1%21")).toBe("password=[SECRET]");
|
|
22
|
+
expect(password.reveal()).toBe("Password1!");
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Secrets are created with `Secret.of`, or by parsing a variable with the `secretString` schema. A secret must have at
|
|
27
|
+
least four characters, because a shorter value cannot be masked without also masking ordinary text.
|
|
28
|
+
|
|
29
|
+
## Masking
|
|
30
|
+
|
|
31
|
+
Each value created by `Secret.of` is registered for the lifetime of the process. `maskSecrets` replaces every
|
|
32
|
+
registered value in a text with `[SECRET]`:
|
|
33
|
+
|
|
34
|
+
- The value is also masked in its URI-encoded, form-encoded and JSON-escaped forms, so it is masked in URLs, form
|
|
35
|
+
bodies and JSON.
|
|
36
|
+
- A value is replaced only where it stands as a whole token. A password `admin` is masked in `password=admin`, but not
|
|
37
|
+
in `administrator`.
|
|
38
|
+
- `withPrefix` builds a secret from a prefix and a secret, such as `Bearer ` and an access token, without registering
|
|
39
|
+
another value: the registered value inside it is already masked.
|
|
40
|
+
|
|
41
|
+
The framework masks secrets in every message it produces: HTTP errors, their bodies, response URLs and failed
|
|
42
|
+
requests. Use `maskSecrets` for your own messages and logs that can contain requests or responses.
|
|
43
|
+
|
|
44
|
+
## Revealing
|
|
45
|
+
|
|
46
|
+
The HTTP client accepts secrets in the query, headers and body of a request, and reveals them only when it sends the
|
|
47
|
+
request. Test code passes `Secret` values and never calls `reveal()` itself.
|
|
48
|
+
|
|
49
|
+
For code that builds a request in another way, `revealedFields` and `revealedJson` reveal the secrets in fields or a
|
|
50
|
+
JSON body. Call them only where the result is sent, and keep the result out of messages, logs and assertions.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
## Repository layout
|
|
4
|
+
|
|
5
|
+
| Path | Contains |
|
|
6
|
+
| ---------------- | ------------------------------------------------------------------------------------------ |
|
|
7
|
+
| `src/<area>/` | The framework, one directory for each area, each with an `index.ts` that is its public API |
|
|
8
|
+
| `tests/unit/` | The unit tests of the framework, one directory for each area |
|
|
9
|
+
| `docs/` | This documentation, shipped with the package |
|
|
10
|
+
| `virtocommerce/` | The test suite of the Virto Commerce solution, which uses the framework like any suite |
|
|
11
|
+
| `.biome/` | The shared Biome configuration and the area boundaries |
|
|
12
|
+
| `.claude/` | The QA agents, their commands, skills, check scripts and hook, shipped with the package |
|
|
13
|
+
| `.qa/` | The facts the QA agents work from, and the example that the package ships |
|
|
14
|
+
| `bin/` | `vc-qa-agents`, which installs the QA agents into a repository |
|
|
15
|
+
| `scripts/` | Repository scripts, such as the documentation check |
|
|
16
|
+
| `tools/` | Tools with their own dependencies, such as TypeDoc |
|
|
17
|
+
|
|
18
|
+
The package publishes `dist`, `docs`, the shared Biome configuration, the QA agents (`.claude/` without what
|
|
19
|
+
`.claude/checks/ours-only.json` names), `.qa/project.example.json`, `bin` and the changelog. `virtocommerce/`,
|
|
20
|
+
`tests/`, `src/` and this repository's `.qa/project.json` are never published.
|
|
21
|
+
|
|
22
|
+
The QA agents work on one test suite, which `suiteDir` in `.qa/project.json` names: `virtocommerce` here. Their
|
|
23
|
+
check scripts in `.claude/checks/` import nothing from `src/` or from a test suite, and their prompts name no solution
|
|
24
|
+
(`scan-prompts.mts` checks it), so any repository installs them with `npx vc-qa-agents` and its own
|
|
25
|
+
`project.json`. Files only this repository uses, such as `/code-review-full`, are listed in
|
|
26
|
+
`.claude/checks/ours-only.json` and left out of the package.
|
|
27
|
+
|
|
28
|
+
The repository has one `package.json`, which is also the framework package. The `virtocommerce` test suite lives in
|
|
29
|
+
this repository, so that the CI pipelines of the Virto Commerce platform, frontend and modules run it against the
|
|
30
|
+
current framework. Its scripts end in `:vc`, and the tools that only it uses, such as the report generator and the type
|
|
31
|
+
generators, are dev dependencies; consumers of the package do not install them.
|
|
32
|
+
|
|
33
|
+
## Areas and their boundaries
|
|
34
|
+
|
|
35
|
+
Each area may import only the areas listed for it:
|
|
36
|
+
|
|
37
|
+
| Area | May import |
|
|
38
|
+
| ---------- | -------------------------------------------- |
|
|
39
|
+
| `core` | no other area |
|
|
40
|
+
| `http` | `core` |
|
|
41
|
+
| `auth` | `core`, `http` |
|
|
42
|
+
| `graphql` | `core`, `http` |
|
|
43
|
+
| `modules` | `core`, `http` |
|
|
44
|
+
| `dataset` | `core`, `http`, `modules` |
|
|
45
|
+
| `fixtures` | `core`, `http`, `auth`, `graphql`, `modules` |
|
|
46
|
+
|
|
47
|
+
- Inside an area, files import each other by relative paths with the `.ts` extension.
|
|
48
|
+
- Areas import each other only through the alias of the other area, such as `@/core`, which resolves to that area's
|
|
49
|
+
`index.ts`. An area cannot reach into another area's files.
|
|
50
|
+
- Tests import the framework only through the aliases, so they test the public API.
|
|
51
|
+
- The framework never imports the `virtocommerce` test suite. The test suite imports the framework only by its package
|
|
52
|
+
name, such as `@virtocommerce/test-automation-framework/core`, exactly as a partner's test suite does.
|
|
53
|
+
- The framework imports only its peer dependencies and Node built-ins, which a test suite is sure to have. A dev
|
|
54
|
+
dependency, such as a tool that only the `virtocommerce` test suite uses, cannot be imported in `src`.
|
|
55
|
+
|
|
56
|
+
Biome enforces these rules with the overrides in `.biome/layers.json`, which is maintained by hand. A new area needs
|
|
57
|
+
its own entry there, listing the areas it may import. An area that is not listed is blocked for all others, because
|
|
58
|
+
each rule allows only named exceptions.
|
|
59
|
+
|
|
60
|
+
## Build
|
|
61
|
+
|
|
62
|
+
`npm run build` compiles `src` to `dist` with declarations and source maps, then rewrites the `@/` aliases to relative
|
|
63
|
+
paths. CI fails when an alias remains in `dist`.
|
|
64
|
+
|
|
65
|
+
The `virtocommerce` test suite and the documentation examples map the package name to `src` in their own
|
|
66
|
+
`tsconfig.json`, so they run against the current source without a build. Only scripts that plain Node runs, such as
|
|
67
|
+
`codegen:vc`, load the framework through its `exports`, so `codegen:vc` builds the framework first.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Conventions
|
|
2
|
+
|
|
3
|
+
## Terms
|
|
4
|
+
|
|
5
|
+
Use the terms from the [documentation index](../README.md#terms): framework, solution and test suite. Use "frontend"
|
|
6
|
+
for the shop application and "platform" for the Virto Commerce backend. Do not call a test suite an "organization";
|
|
7
|
+
the platform has its own organizations.
|
|
8
|
+
|
|
9
|
+
## Code
|
|
10
|
+
|
|
11
|
+
- Declare named functions with `function`. Use arrow functions only for inline callbacks.
|
|
12
|
+
- Do not add code comments. Documentation comments on exported members are required.
|
|
13
|
+
- Name a file after the concept it holds, such as `secret.ts` or `http-client.ts`. Name a file that holds one tool
|
|
14
|
+
after the tool, such as `parse-env.ts`.
|
|
15
|
+
- Name schema values in camelCase, such as `envSchema`.
|
|
16
|
+
- Keep the framework free of anything specific to one solution or one store.
|
|
17
|
+
|
|
18
|
+
## Documentation comments
|
|
19
|
+
|
|
20
|
+
Every exported member has a documentation comment in a formal style that both people and AI agents can follow:
|
|
21
|
+
|
|
22
|
+
- The summary is a full sentence in the present tense that starts with a verb, such as "Returns…" or "Determines
|
|
23
|
+
whether…". A type or a constant starts with a noun phrase, such as "Represents…" or "The options of…".
|
|
24
|
+
- Functions, methods and constructors have `@param`, `@returns` and `@throws {Type}`, each a full sentence.
|
|
25
|
+
- Details go in `@remarks`, and examples in `@example`.
|
|
26
|
+
- Do not name the libraries that the framework uses internally. Write "schema", not the name of the schema library.
|
|
27
|
+
- Do not use shorthand in prose. Write "a success status (2xx)" rather than "2xx", and use words instead of arrows.
|
|
28
|
+
|
|
29
|
+
## Errors and retries
|
|
30
|
+
|
|
31
|
+
- Do not retry a failed request, and do not work around a platform failure. A failing test fails, and its cause is
|
|
32
|
+
found and reported. A platform defect is reported in the issue tracker, and the test keeps failing until it is fixed.
|
|
33
|
+
- Keep secrets out of every message: create them with `Secret.of`, and mask messages with `maskSecrets`.
|
|
34
|
+
|
|
35
|
+
## Tests
|
|
36
|
+
|
|
37
|
+
- Every public behaviour has a unit test. Tests of network code run against a local `node:http` server.
|
|
38
|
+
- After fixing a defect, check that its test fails without the fix.
|
|
39
|
+
- Do not add test retries.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Documentation
|
|
2
|
+
|
|
3
|
+
The documentation has four parts, and each part has its own way of staying accurate.
|
|
4
|
+
|
|
5
|
+
| Part | Location | Kept accurate by |
|
|
6
|
+
| ------------- | ------------------------- | ---------------------------------------------------------------------- |
|
|
7
|
+
| README | `README.md` | Kept short: what the package is, its requirements and its installation |
|
|
8
|
+
| Guides | `docs/getting-started.md` | Their examples are type-checked files |
|
|
9
|
+
| Concepts | `docs/concepts/` | Updated in the same pull request as the area they describe |
|
|
10
|
+
| API reference | Generated from the source | TypeDoc fails the build for an undocumented export or a broken link |
|
|
11
|
+
|
|
12
|
+
## Rules
|
|
13
|
+
|
|
14
|
+
- A pull request that changes the public API of an area updates the concept page of that area.
|
|
15
|
+
- Code in the documentation that uses the framework lives in `docs/examples/` as a TypeScript file. The examples are
|
|
16
|
+
type-checked against the current source by `npm run typecheck`, so a change to the API that breaks an example fails
|
|
17
|
+
the build.
|
|
18
|
+
- A page embeds an example with an `example` marker followed by an empty or outdated `ts` block. `npm run docs:sync`
|
|
19
|
+
copies the file into the block, and `npm run docs:check` fails when a block differs from its file.
|
|
20
|
+
- `npm run docs:check` also fails for a relative link to a missing file or a missing heading, and for an export in
|
|
21
|
+
`src` without a documentation comment, including exports that only other files of the same area use. TypeDoc checks
|
|
22
|
+
only what the entry points export.
|
|
23
|
+
|
|
24
|
+
## The API reference
|
|
25
|
+
|
|
26
|
+
The API reference is generated by TypeDoc from the documentation comments. TypeDoc does not support TypeScript 7, so
|
|
27
|
+
it runs from `tools/typedoc` with its own TypeScript version. Install it once, then generate the reference into
|
|
28
|
+
`api-reference/`:
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
npm ci --prefix tools/typedoc
|
|
32
|
+
npm run docs:api
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The reference is not committed and not published. CI generates it to check that every export is documented and every
|
|
36
|
+
link in a documentation comment resolves. Each CI run also uploads it as the `api-reference` artifact, kept for 14
|
|
37
|
+
days: open the run from the checks of a pull request and download the artifact from its summary page.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Releasing
|
|
2
|
+
|
|
3
|
+
## Development commands
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm ci # install dependencies
|
|
7
|
+
npm run typecheck # type-check the framework, the virtocommerce test suite and the documentation examples
|
|
8
|
+
npm run check # format, lint and sort imports, with fixes
|
|
9
|
+
npm run test:unit # run the unit tests of the framework
|
|
10
|
+
npm run docs:check # check the documentation links and examples
|
|
11
|
+
npm run build # compile src to dist
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The scripts of the `virtocommerce` test suite end in `:vc`:
|
|
15
|
+
|
|
16
|
+
```shell
|
|
17
|
+
npm run codegen:vc # build the framework, then generate the GraphQL and REST types
|
|
18
|
+
npm run seed:vc # seed the dataset into the platform
|
|
19
|
+
npm run test:vc # run the test suite, without the destructive tests
|
|
20
|
+
npm run test:vc:isolated # run the destructive tests alone, after test:vc
|
|
21
|
+
npm run test:vc:unit # check the dataset: unique ids, references that resolve, seed order; no platform needed
|
|
22
|
+
npm run facts:check # check that the role permissions in .qa/project.json match the seed
|
|
23
|
+
npm run report:vc # generate the Allure report from the last run
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The seed turns off the platform's scheduled indexing, so that a scheduled run cannot refuse an indexation that a test
|
|
27
|
+
starts. Rebuild the index by hand after seeding a local platform; the shared CI workflow indexes after its seed.
|
|
28
|
+
|
|
29
|
+
The destructive tests of the `isolated` project change global settings, such as anonymous access to the store, and
|
|
30
|
+
rebuild the search index, so they would break tests that run at the same time. `test:vc` always leaves them out, and
|
|
31
|
+
`test:vc:isolated` runs them in a separate run with one worker. They run only when `RUN_DESTRUCTIVE_TESTS` is on,
|
|
32
|
+
so set it only for an environment that may lose its settings, such as a platform made for one CI run. Run
|
|
33
|
+
`test:vc:isolated` after `test:vc`, without cleaning the results in between, and the report covers both runs.
|
|
34
|
+
|
|
35
|
+
The `Auto Tests Docker` workflow (`auto-tests.yml`) runs the test suite on GitHub Actions; start it from the Actions
|
|
36
|
+
tab. It calls `playwright-tests.yml` of `VirtoCommerce/.github`, the workflow that the platform, the frontends and
|
|
37
|
+
the modules also run against this repository's `dev` branch. For each database and search engine it starts a platform
|
|
38
|
+
with the modules of `virtocommerce/backend-packages.json` and a frontend, writes `virtocommerce/.env` from the
|
|
39
|
+
`VC_TESTING_MODULE_ENV_FILE_NEW` secret, seeds and indexes the dataset, runs each chosen project with
|
|
40
|
+
`--config=virtocommerce`, and uploads the Allure report. The suites it accepts are the project names: `restapi`,
|
|
41
|
+
`graphql`, `e2e-frontend`, `e2e-backend` (`e2e` is both) and `isolated`, which also needs
|
|
42
|
+
`RUN_DESTRUCTIVE_TESTS=true` in the secret. Since that workflow is shared, a project's name is a contract with every
|
|
43
|
+
caller: renaming one breaks their CI. The callers leave out the tests tagged `@platform-defect`, so a defect that a
|
|
44
|
+
ticket tracks does not fail their checks; `auto-tests.yml` runs them, unless its `skipPlatformDefects` input is on.
|
|
45
|
+
|
|
46
|
+
The `CI` workflow runs on every pull request to `dev`: the type check, Biome, the unit tests of the framework, the
|
|
47
|
+
dataset checks of the test suite, the documentation check, the API reference and the build. It needs no platform.
|
|
48
|
+
|
|
49
|
+
## Versions
|
|
50
|
+
|
|
51
|
+
While the version is `0.x`, any minor release may contain breaking changes. Every change that consumers see is
|
|
52
|
+
described in `CHANGELOG.md`.
|
|
53
|
+
|
|
54
|
+
## Releasing a version
|
|
55
|
+
|
|
56
|
+
Releases are made by GitHub Actions with [Changesets](https://github.com/changesets/changesets):
|
|
57
|
+
|
|
58
|
+
1. A pull request that changes what consumers get adds a changeset (`npm run changeset`). See
|
|
59
|
+
[the changeset guide](../../.changeset/README.md) for how to choose the bump and write the note. A pull request
|
|
60
|
+
with nothing for consumers adds an empty changeset (`npx changeset --empty`).
|
|
61
|
+
2. Merging to `dev` opens or updates the "chore: release" pull request, which bumps the version and updates
|
|
62
|
+
`CHANGELOG.md`.
|
|
63
|
+
3. Merging that pull request publishes the package to npmjs.org and creates the GitHub release.
|
|
64
|
+
|
|
65
|
+
When no changesets are pending, a merge to `dev` publishes the current version if it is not yet in the registry.
|
|
66
|
+
|
|
67
|
+
The `Release` workflow (`release.yml`) signs in to npm with Trusted Publishing: npm exchanges the workflow's GitHub
|
|
68
|
+
OIDC token for a short-lived publish credential and attaches provenance, so no npm token is kept in the repository
|
|
69
|
+
secrets. The trusted publisher on npmjs.com names this repository and the file `release.yml`; renaming the file or
|
|
70
|
+
moving the publish step to another workflow breaks publishing. Trusted Publishing needs npm 11.5.1 or newer, which
|
|
71
|
+
the workflow installs.
|
|
72
|
+
|
|
73
|
+
To try a branch before it is merged, push it to a branch under `alpha/` (`git push origin HEAD:alpha/<name>`), or
|
|
74
|
+
run the `Release` workflow on it by hand (Actions tab, or `gh workflow run release.yml --ref <branch>`). It publishes the branch as `<version>-alpha.<run number>` under the
|
|
75
|
+
`alpha` dist-tag, which consumers install with `npm install @virtocommerce/test-automation-framework@alpha`; `latest`
|
|
76
|
+
does not move.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Secret } from "@virtocommerce/test-automation-framework/core";
|
|
2
|
+
import type { HttpClient } from "@virtocommerce/test-automation-framework/http";
|
|
3
|
+
|
|
4
|
+
import { expect } from "@playwright/test";
|
|
5
|
+
import { TokenClient, TokenManager } from "@virtocommerce/test-automation-framework/auth";
|
|
6
|
+
|
|
7
|
+
export async function signInToTwoStores(anonymous: HttpClient, password: Secret) {
|
|
8
|
+
const tokens = new TokenManager(new TokenClient(anonymous));
|
|
9
|
+
const buyer = { username: "buyer@example.com", password };
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const inStoreA = await tokens.signIn(anonymous, { ...buyer, storeId: "store-a" });
|
|
13
|
+
const inStoreB = await tokens.signIn(anonymous, { ...buyer, storeId: "store-b" });
|
|
14
|
+
|
|
15
|
+
expect((await inStoreA.get("/api/platform/security/currentuser")).ok).toBe(true);
|
|
16
|
+
expect((await inStoreB.get("/api/platform/security/currentuser")).ok).toBe(true);
|
|
17
|
+
} finally {
|
|
18
|
+
await tokens.signOutAll();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
|
|
3
|
+
import { defineConfig, devices } from "@playwright/test";
|
|
4
|
+
import {
|
|
5
|
+
apiProject,
|
|
6
|
+
DESTRUCTIVE_TAG,
|
|
7
|
+
defaultReporters,
|
|
8
|
+
defaultRunOptions,
|
|
9
|
+
defaultUse,
|
|
10
|
+
e2eProject,
|
|
11
|
+
envSchema,
|
|
12
|
+
parseEnv,
|
|
13
|
+
} from "@virtocommerce/test-automation-framework/core";
|
|
14
|
+
|
|
15
|
+
const env = parseEnv(envSchema);
|
|
16
|
+
|
|
17
|
+
export default defineConfig({
|
|
18
|
+
...defaultRunOptions(env),
|
|
19
|
+
reporter: defaultReporters({
|
|
20
|
+
outputDir: fileURLToPath(new URL("reports", import.meta.url)),
|
|
21
|
+
environment: { backend: env.BACKEND_BASE_URL },
|
|
22
|
+
}),
|
|
23
|
+
use: defaultUse(env),
|
|
24
|
+
projects: [
|
|
25
|
+
{ name: "seed", testDir: "setup", testMatch: "seed.setup.ts" },
|
|
26
|
+
apiProject(env, { name: "rest", testDir: "tests/rest", dependencies: ["seed"] }),
|
|
27
|
+
e2eProject(env, {
|
|
28
|
+
name: "frontend",
|
|
29
|
+
testDir: "tests/e2e",
|
|
30
|
+
dependencies: ["seed"],
|
|
31
|
+
use: { ...devices["Desktop Chrome"] },
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const destructiveTestDetails = { tag: DESTRUCTIVE_TAG };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Manifest, SeedEvent, SeedSummary } from "@virtocommerce/test-automation-framework/dataset";
|
|
2
|
+
import type { HttpClient } from "@virtocommerce/test-automation-framework/http";
|
|
3
|
+
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
envPlaceholder,
|
|
8
|
+
loadDataset,
|
|
9
|
+
parseCollectionNames,
|
|
10
|
+
recordPlaceholder,
|
|
11
|
+
seedDataset,
|
|
12
|
+
} from "@virtocommerce/test-automation-framework/dataset";
|
|
13
|
+
import { InstalledModules } from "@virtocommerce/test-automation-framework/modules";
|
|
14
|
+
|
|
15
|
+
const CATALOG = { id: "VirtoCommerce.Catalog", minVersion: "3.1051.0" };
|
|
16
|
+
const SHIPPING = { id: "VirtoCommerce.Shipping", minVersion: "3.1010.0" };
|
|
17
|
+
|
|
18
|
+
export const MANIFEST = {
|
|
19
|
+
catalogs: { module: CATALOG, method: "POST", path: "/api/catalog/catalogs", send: "each" },
|
|
20
|
+
categories: {
|
|
21
|
+
module: CATALOG,
|
|
22
|
+
method: "POST",
|
|
23
|
+
path: "/api/catalog/categories",
|
|
24
|
+
send: "each",
|
|
25
|
+
key: "code",
|
|
26
|
+
parentField: "parentId",
|
|
27
|
+
},
|
|
28
|
+
shippingMethods: {
|
|
29
|
+
module: SHIPPING,
|
|
30
|
+
method: "PUT",
|
|
31
|
+
path: "/api/shipping",
|
|
32
|
+
send: "each",
|
|
33
|
+
key: "code",
|
|
34
|
+
storedIdFrom: {
|
|
35
|
+
searchPath: "/api/shipping/search",
|
|
36
|
+
criteria: { storeId: envPlaceholder("STORE_ID"), codes: [recordPlaceholder("code")] },
|
|
37
|
+
match: "code",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
} as const satisfies Manifest;
|
|
41
|
+
|
|
42
|
+
type Catalog = { readonly id: string; readonly name: string };
|
|
43
|
+
|
|
44
|
+
const PLACEHOLDERS = { STORE_ID: "B2B-store" };
|
|
45
|
+
|
|
46
|
+
export const dataset = loadDataset<typeof MANIFEST, { readonly catalogs: Catalog }>({
|
|
47
|
+
manifest: MANIFEST,
|
|
48
|
+
dataDir: fileURLToPath(new URL("data", import.meta.url)),
|
|
49
|
+
placeholders: PLACEHOLDERS,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export function catalogName(id: string): string {
|
|
53
|
+
return dataset.catalogs.get(id).name;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function seed(
|
|
57
|
+
admin: HttpClient,
|
|
58
|
+
only: string | undefined,
|
|
59
|
+
onEvent: (event: SeedEvent) => void,
|
|
60
|
+
): Promise<SeedSummary<typeof MANIFEST>> {
|
|
61
|
+
return seedDataset({
|
|
62
|
+
http: admin,
|
|
63
|
+
manifest: MANIFEST,
|
|
64
|
+
dataset,
|
|
65
|
+
installed: await InstalledModules.read(admin),
|
|
66
|
+
only: parseCollectionNames(MANIFEST, only),
|
|
67
|
+
placeholders: PLACEHOLDERS,
|
|
68
|
+
onEvent,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { absoluteUrl, envSchema, parseEnv, positiveInt } from "@virtocommerce/test-automation-framework/core";
|
|
2
|
+
|
|
3
|
+
export const suiteEnvSchema = envSchema.extend({
|
|
4
|
+
API_WORKERS: positiveInt.default(8),
|
|
5
|
+
MAILBOX_URL: absoluteUrl,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const env = parseEnv(suiteEnvSchema);
|