@msalaam/xray-qe-toolkit 1.4.0 → 1.4.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/.env.example +23 -9
- package/README.md +721 -1434
- package/bin/cli.js +92 -69
- package/commands/createExecution.js +112 -23
- package/commands/createPlan.js +121 -0
- package/commands/editJson.js +1 -1
- package/commands/genPipeline.js +1 -1
- package/commands/genTests.js +18 -18
- package/commands/importResults.js +107 -74
- package/commands/init.js +258 -70
- package/commands/pullTests.js +128 -0
- package/commands/pushTests.js +87 -43
- package/commands/status.js +108 -0
- package/commands/syncFolders.js +62 -0
- package/commands/validate.js +136 -0
- package/lib/config.js +50 -13
- package/lib/index.js +43 -4
- package/lib/playwrightConverter.js +91 -173
- package/lib/testCaseBuilder.js +116 -55
- package/lib/xrayClient.js +779 -202
- package/package.json +6 -8
- package/schema/business-rules.schema.json +110 -0
- package/schema/tests.schema.json +42 -16
- package/templates/README.template.md +570 -169
- package/templates/SPEC-DRIVEN-APPROACH.md +372 -0
- package/templates/azure-pipelines.yml +129 -77
- package/templates/business-rules.yaml +83 -0
- package/templates/resources-README.md +112 -0
- package/templates/tests.json +69 -51
- package/commands/compareOpenapi.js +0 -78
- package/commands/genPostman.js +0 -70
- package/commands/updateSnapshot.js +0 -34
- package/lib/postmanGenerator.js +0 -304
- package/templates/knowledge-README.md +0 -121
|
@@ -1,169 +1,570 @@
|
|
|
1
|
-
# XQT-GUIDE — Xray QE Toolkit
|
|
2
|
-
|
|
3
|
-
> Quality Engineering workflow automation for Xray Cloud
|
|
4
|
-
>
|
|
5
|
-
> This file was created by `npx xqt init`. It is intentionally
|
|
6
|
-
> so it never
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
1
|
+
# XQT-GUIDE — Xray QE Toolkit Reference
|
|
2
|
+
|
|
3
|
+
> **@msalaam/xray-qe-toolkit** — Quality Engineering workflow automation for Xray Cloud.
|
|
4
|
+
>
|
|
5
|
+
> This file was created by `npx xqt init`. It is intentionally saved as `XQT-GUIDE.md`
|
|
6
|
+
> so it never replaces your project's own `README.md`.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
1. [Architecture Overview](#1-architecture-overview)
|
|
13
|
+
2. [Setup & Credentials](#2-setup--credentials)
|
|
14
|
+
3. [Project Structure](#3-project-structure)
|
|
15
|
+
4. [tests.json Reference](#4-testsjson-reference)
|
|
16
|
+
5. [Command Reference](#5-command-reference)
|
|
17
|
+
6. [Test Plans & Executions](#6-test-plans--executions)
|
|
18
|
+
7. [Playwright Integration](#7-playwright-integration)
|
|
19
|
+
8. [Folder Structure in Xray](#8-folder-structure-in-xray)
|
|
20
|
+
9. [Business Rules](#9-business-rules)
|
|
21
|
+
10. [CI/CD Integration](#10-cicd-integration)
|
|
22
|
+
11. [xray-mapping.json](#11-xray-mappingjson)
|
|
23
|
+
12. [Configuration (.xrayrc)](#12-configuration-xrayrc)
|
|
24
|
+
|
|
25
|
+
> **This file covers the xqt toolkit commands and Xray configuration.**
|
|
26
|
+
> For the full QE process — spec-driven workflow, greenfield/brownfield steps, AI agent
|
|
27
|
+
> integration, and architecture patterns — see **[SPEC-DRIVEN-APPROACH.md](SPEC-DRIVEN-APPROACH.md)**.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 1. Architecture Overview
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
tests.json ← Source of truth for test case definitions
|
|
35
|
+
xray-mapping.json ← Maps local test_id → JIRA/Xray issue key + numeric ID
|
|
36
|
+
resources/ ← OpenAPI spec + business rules (inputs for tests.json generation)
|
|
37
|
+
tests/ ← Playwright spec files + helpers
|
|
38
|
+
SPEC-DRIVEN-APPROACH.md ← Full QE process and workflow
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**End-to-end flow:**
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
openapi.yaml + business-rules.yaml
|
|
45
|
+
↓ (AI agent generates tests.json)
|
|
46
|
+
xqt validate → xqt push-tests (creates Tests + Test Sets in Xray)
|
|
47
|
+
↓
|
|
48
|
+
xray-mapping.json populated with Jira issue keys
|
|
49
|
+
↓
|
|
50
|
+
Copilot creates Playwright tests (reads tests.json + xray-mapping.json)
|
|
51
|
+
↓
|
|
52
|
+
Sprint starts → xqt create-plan → link Test Sets
|
|
53
|
+
↓
|
|
54
|
+
CI: playwright test → xqt import-results → Test Execution in Xray
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Key design decisions:**
|
|
58
|
+
- **Test Sets are persistent** — tests live in Test Sets grouped by feature
|
|
59
|
+
- **Test Plans are per-sprint** — create one per sprint, link relevant Test Sets
|
|
60
|
+
- **Test Executions are ephemeral** — every CI run creates a fresh execution
|
|
61
|
+
- **Environments are labels** — `IOP-DEV`, `IOP-QA`, `IOP-PROD` tag each execution
|
|
62
|
+
- **tests.json is the source of truth** — never edit test metadata directly in JIRA
|
|
63
|
+
- **Playwright tests come after push** — created only once xray-mapping.json has real Jira keys
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 2. Setup & Credentials
|
|
68
|
+
|
|
69
|
+
### Install
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install --save-dev @msalaam/xray-qe-toolkit
|
|
73
|
+
# or globally
|
|
74
|
+
npm install -g @msalaam/xray-qe-toolkit
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Initialize a new project
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npx xqt init
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Configure `.env`
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
cp .env.example .env
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```env
|
|
90
|
+
# ── Xray Cloud ─────────────────────────────────────────────────
|
|
91
|
+
XRAY_ID=your_xray_cloud_client_id
|
|
92
|
+
XRAY_SECRET=your_xray_cloud_client_secret
|
|
93
|
+
|
|
94
|
+
# ── JIRA ───────────────────────────────────────────────────────
|
|
95
|
+
JIRA_PROJECT_KEY=APIEE
|
|
96
|
+
JIRA_URL=https://your-org.atlassian.net
|
|
97
|
+
JIRA_API_TOKEN=your_jira_api_token
|
|
98
|
+
JIRA_EMAIL=your.email@company.com
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
> **Important:** The JIRA credentials must belong to a user with permission to
|
|
102
|
+
> create and edit Xray tests in the target project.
|
|
103
|
+
|
|
104
|
+
### Get Xray API credentials
|
|
105
|
+
|
|
106
|
+
1. Go to [https://id.atlassian.com/manage-profile/security/api-tokens](https://id.atlassian.com/manage-profile/security/api-tokens)
|
|
107
|
+
2. In your JIRA instance, go to **Apps → Xray → API Keys**
|
|
108
|
+
3. Create a new Client ID / Client Secret pair
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 3. Project Structure
|
|
113
|
+
|
|
114
|
+
After running `npx xqt init`:
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
{{SERVICE_NAME}}/
|
|
118
|
+
├── resources/
|
|
119
|
+
│ ├── openapi.yaml ← OpenAPI spec (replace with your actual spec)
|
|
120
|
+
│ └── business-rules.yaml ← Business rules (scenarios → tests.json)
|
|
121
|
+
│
|
|
122
|
+
├── tests/
|
|
123
|
+
│ ├── models/ ← Data models, request/response fixtures
|
|
124
|
+
│ ├── resources/ ← Shared helpers, utilities, constants
|
|
125
|
+
│ ├── services/ ← Service-level setup/teardown
|
|
126
|
+
│ └── specs/ ← Playwright spec files (.spec.ts)
|
|
127
|
+
│
|
|
128
|
+
├── playwright.config.ts ← Reporters: JSON + JUnit + HTML
|
|
129
|
+
├── tests.json ← Test definitions (push to Xray with xqt push-tests)
|
|
130
|
+
├── xray-mapping.json ← Auto-managed: localId → Xray key
|
|
131
|
+
├── .xrayrc ← Project config (testPlanKey, environments…)
|
|
132
|
+
├── .env.example ← Credential template (commit this)
|
|
133
|
+
├── .env ← Your credentials (DO NOT commit)
|
|
134
|
+
└── XQT-GUIDE.md ← This file
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 4. tests.json Reference
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"testPlan": {
|
|
144
|
+
"key": "APIEE-1234",
|
|
145
|
+
"summary": "Sprint 12 — {{SERVICE_NAME}} API Regression"
|
|
146
|
+
},
|
|
147
|
+
"tests": [
|
|
148
|
+
{
|
|
149
|
+
"test_id": "TC-MYSVC-BR-001",
|
|
150
|
+
"type": "api",
|
|
151
|
+
"skip": false,
|
|
152
|
+
"tags": ["smoke", "regression"],
|
|
153
|
+
"folder": "/{{SERVICE_NAME}}/HealthCheck/Validation",
|
|
154
|
+
"testSet": "Health Check",
|
|
155
|
+
"requirementKeys": [],
|
|
156
|
+
"xray": {
|
|
157
|
+
"summary": "Service returns 200 OK when healthy",
|
|
158
|
+
"description": "Given Service is running, when GET /health is called, then Response is 200",
|
|
159
|
+
"testType": "Generic",
|
|
160
|
+
"definition": "Automated Playwright API test: GET /health — Service returns 200 OK",
|
|
161
|
+
"priority": "High",
|
|
162
|
+
"labels": ["smoke", "regression"]
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Field Reference
|
|
170
|
+
|
|
171
|
+
| Field | Type | Required | Description |
|
|
172
|
+
|---|---|---|---|
|
|
173
|
+
| `test_id` | string | Yes | Stable local identifier — maps to Xray key in xray-mapping.json |
|
|
174
|
+
| `type` | string | — | `api` / `ui` / `e2e` (informational) |
|
|
175
|
+
| `skip` | boolean | — | `true` to exclude from push-tests |
|
|
176
|
+
| `tags` | string[] | — | QE tags for categorisation and filtering |
|
|
177
|
+
| `folder` | string | — | Xray repository folder path — must start with `/` |
|
|
178
|
+
| `testSet` | string | — | Test Set name in Jira — groups tests by feature |
|
|
179
|
+
| `requirementKeys` | string[] | — | JIRA issue keys this test covers (creates coverage links) |
|
|
180
|
+
| `xray.summary` | string | Yes | Test case title (JIRA issue summary) |
|
|
181
|
+
| `xray.description` | string | — | Detailed description |
|
|
182
|
+
| `xray.testType` | string | — | `Generic` (default for automated) / `Manual` / `Cucumber` |
|
|
183
|
+
| `xray.definition` | string | — | Generic test definition field in Xray |
|
|
184
|
+
| `xray.priority` | string | — | `Highest` / `High` / `Medium` / `Low` / `Lowest` |
|
|
185
|
+
| `xray.labels` | string[] | — | JIRA labels on the test issue |
|
|
186
|
+
|
|
187
|
+
### testPlan block
|
|
188
|
+
|
|
189
|
+
| Field | Description |
|
|
190
|
+
|---|---|
|
|
191
|
+
| `testPlan.key` | Xray Test Plan issue key — populated by `xqt create-plan` |
|
|
192
|
+
| `testPlan.summary` | Human-readable description (not synced to Xray, local only) |
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## 5. Command Reference
|
|
197
|
+
|
|
198
|
+
### `xqt init`
|
|
199
|
+
|
|
200
|
+
Scaffold a new QA project in the current directory. Idempotent — never overwrites existing files.
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
npx xqt init
|
|
204
|
+
npx xqt init --verbose
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### `xqt create-plan`
|
|
208
|
+
|
|
209
|
+
Create a new Xray Test Plan in JIRA. Automatically updates `.xrayrc` and `tests.json`.
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
npx xqt create-plan --summary "{{SERVICE_NAME}} v2 Regression"
|
|
213
|
+
npx xqt create-plan --summary "Sprint 12 Smoke Tests" --version "2024.12"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### `xqt push-tests`
|
|
217
|
+
|
|
218
|
+
Create or update tests in Xray Cloud, then sync the Test Plan membership and folder structure.
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
npx xqt push-tests
|
|
222
|
+
npx xqt push-tests --plan APIEE-1234 # override plan key
|
|
223
|
+
npx xqt push-tests --verbose
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### `xqt pull-tests`
|
|
227
|
+
|
|
228
|
+
Fetch test definitions from Xray and merge them into `tests.json`.
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
npx xqt pull-tests --plan APIEE-1234
|
|
232
|
+
npx xqt pull-tests --project APIEE --limit 200
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### `xqt import-results`
|
|
236
|
+
|
|
237
|
+
Import test execution results into Xray. Creates a **new** Test Execution each time.
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
npx xqt import-results --file test-results/results.json --env IOP-QA
|
|
241
|
+
npx xqt import-results --file test-results/results.xml --env IOP-PROD
|
|
242
|
+
npx xqt import-results --file test-results/results.json --env IOP-DEV \
|
|
243
|
+
--plan APIEE-1234 --version "2024.12" --revision "a1b2c3d"
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Options:**
|
|
247
|
+
|
|
248
|
+
| Flag | Description |
|
|
249
|
+
|---|---|
|
|
250
|
+
| `--file <path>` | Path to results file (`.json` = Playwright, `.xml` = JUnit) |
|
|
251
|
+
| `--env <label>` | Environment label: `IOP-DEV`, `IOP-QA`, `IOP-PROD` |
|
|
252
|
+
| `--plan <key>` | Test Plan key (overrides `.xrayrc`) |
|
|
253
|
+
| `--version <ver>` | Fix version / release label |
|
|
254
|
+
| `--revision <sha>` | Build number or git SHA |
|
|
255
|
+
| `--summary <text>` | Custom execution summary |
|
|
256
|
+
|
|
257
|
+
### `xqt sync-folders`
|
|
258
|
+
|
|
259
|
+
Sync the Xray repository folder structure from `folder` fields in tests.json.
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
npx xqt sync-folders
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### `xqt status`
|
|
266
|
+
|
|
267
|
+
Show local and remote project status.
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
npx xqt status
|
|
271
|
+
npx xqt status --plan APIEE-1234
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### `xqt validate`
|
|
275
|
+
|
|
276
|
+
Validate `tests.json` against its schema.
|
|
277
|
+
Exit code 1 on errors — suitable for CI quality gates.
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
npx xqt validate
|
|
281
|
+
npx xqt validate --file path/to/tests.json
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### `xqt edit`
|
|
285
|
+
|
|
286
|
+
Launch a browser-based visual editor for `tests.json`.
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
npx xqt edit
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### `xqt gen-pipeline`
|
|
293
|
+
|
|
294
|
+
Generate an Azure Pipelines YAML template.
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
npx xqt gen-pipeline
|
|
298
|
+
npx xqt gen-pipeline --output .azure/ci.yml
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## 6. Test Sets, Plans & Executions
|
|
304
|
+
|
|
305
|
+
### Test Sets (persistent groupings)
|
|
306
|
+
|
|
307
|
+
Tests live in **Test Sets** in Jira, grouped by feature (matching the feature name in `business-rules.yaml`).
|
|
308
|
+
|
|
309
|
+
- Created automatically by `push-tests` from the `testSet` field in `tests.json`
|
|
310
|
+
- Persistent across sprints — they represent what tests exist
|
|
311
|
+
- Link Test Sets to Test Plans when entering a sprint
|
|
312
|
+
|
|
313
|
+
### Test Plans (per-sprint)
|
|
314
|
+
|
|
315
|
+
A Test Plan scopes testing for a specific sprint or release.
|
|
316
|
+
|
|
317
|
+
- Create per sprint: `npx xqt create-plan --summary "Sprint 12 — {{SERVICE_NAME}}"`
|
|
318
|
+
- Link relevant Test Sets to the Test Plan in Jira
|
|
319
|
+
- The key is stored in `.xrayrc` (`testPlanKey`)
|
|
320
|
+
- `import-results` links executions to the active plan
|
|
321
|
+
|
|
322
|
+
### Test Executions (ephemeral)
|
|
323
|
+
|
|
324
|
+
A Test Execution represents one CI run.
|
|
325
|
+
- Created automatically by `xqt import-results`
|
|
326
|
+
- Tagged with the environment (`IOP-DEV`, `IOP-QA`, `IOP-PROD`)
|
|
327
|
+
- Linked to the Test Plan
|
|
328
|
+
|
|
329
|
+
### Summary
|
|
330
|
+
|
|
331
|
+
| Concept | Lifecycle | Purpose |
|
|
332
|
+
|---------|-----------|--------|
|
|
333
|
+
| **Test Set** | Permanent | Groups tests by feature |
|
|
334
|
+
| **Test Plan** | Per-sprint | Scopes testing for a sprint |
|
|
335
|
+
| **Test Execution** | Per-CI-run | Records pass/fail for one run |
|
|
336
|
+
|
|
337
|
+
### Environment labels
|
|
338
|
+
|
|
339
|
+
Set the default environment and allowed values in `.xrayrc`:
|
|
340
|
+
|
|
341
|
+
```json
|
|
342
|
+
{
|
|
343
|
+
"defaultEnvironment": "IOP-QA",
|
|
344
|
+
"environments": ["IOP-DEV", "IOP-QA", "IOP-PROD"]
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Override per run with `--env`:
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
npx xqt import-results --file results.json --env IOP-PROD
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## 7. Playwright Integration
|
|
357
|
+
|
|
358
|
+
### Annotate tests with Xray keys
|
|
359
|
+
|
|
360
|
+
```typescript
|
|
361
|
+
import { test, expect } from '@playwright/test';
|
|
362
|
+
|
|
363
|
+
test('GET /users returns 200', async ({ request }) => {
|
|
364
|
+
// Link this Playwright test to an Xray test case
|
|
365
|
+
test.info().annotations.push({ type: 'xray', description: 'APIEE-1234' });
|
|
366
|
+
|
|
367
|
+
const response = await request.get('/users');
|
|
368
|
+
expect(response.status()).toBe(200);
|
|
369
|
+
});
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Alternatively, include the key in the test title:
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
test('[APIEE-1234] GET /users returns 200', async ({ request }) => { ... });
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### playwright.config.ts reporters
|
|
379
|
+
|
|
380
|
+
The generated `playwright.config.ts` configures three reporters:
|
|
381
|
+
|
|
382
|
+
- **JSON** → `test-results/results.json` (consumed by `xqt import-results`)
|
|
383
|
+
- **JUnit** → `test-results/results.xml` (also consumed by `xqt import-results --file *.xml`)
|
|
384
|
+
- **HTML** → `playwright-report/` (CI artifact)
|
|
385
|
+
|
|
386
|
+
### Import results
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
# After running: npx playwright test
|
|
390
|
+
npx xqt import-results --file test-results/results.json --env IOP-QA
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Test steps in Xray
|
|
394
|
+
|
|
395
|
+
Steps defined with `test.step()` are automatically mapped to Xray step results:
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
test('Create and retrieve user', async ({ request }) => {
|
|
399
|
+
test.info().annotations.push({ type: 'xray', description: 'APIEE-2001' });
|
|
400
|
+
|
|
401
|
+
await test.step('Create user via POST /users', async () => {
|
|
402
|
+
const r = await request.post('/users', { data: { name: 'Alice' } });
|
|
403
|
+
expect(r.status()).toBe(201);
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
await test.step('Retrieve user via GET /users/:id', async () => {
|
|
407
|
+
const r = await request.get('/users/1');
|
|
408
|
+
expect(r.status()).toBe(200);
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## 8. Folder Structure in Xray
|
|
416
|
+
|
|
417
|
+
Organise tests in the Xray Test Repository using the `folder` field.
|
|
418
|
+
|
|
419
|
+
```json
|
|
420
|
+
{
|
|
421
|
+
"test_id": "TC-MYSVC-BR-001",
|
|
422
|
+
"folder": "/{{SERVICE_NAME}}/HealthCheck/Validation"
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
- Paths must start with `/`
|
|
427
|
+
- The `folderRoot` in `.xrayrc` is used as the base (default: `/{{SERVICE_NAME}}`)
|
|
428
|
+
- Folders are created automatically by `push-tests` and `sync-folders`
|
|
429
|
+
- Run `xqt sync-folders` to update folders without pushing test changes
|
|
430
|
+
|
|
431
|
+
---
|
|
432
|
+
|
|
433
|
+
## 9. Business Rules
|
|
434
|
+
|
|
435
|
+
Business rules live in `resources/business-rules.yaml` and describe the
|
|
436
|
+
service's expected behaviour. They are the input (alongside `openapi.yaml`) for generating `tests.json`.
|
|
437
|
+
|
|
438
|
+
```yaml
|
|
439
|
+
service: "{{SERVICE_NAME}}"
|
|
440
|
+
version: "1.0"
|
|
441
|
+
|
|
442
|
+
features:
|
|
443
|
+
- name: "User Management"
|
|
444
|
+
endpoints:
|
|
445
|
+
- GET /api/v1/users
|
|
446
|
+
- POST /api/v1/users
|
|
447
|
+
rules:
|
|
448
|
+
- id: "BR-001"
|
|
449
|
+
description: "Valid user creation returns 201"
|
|
450
|
+
given: "Authenticated user with create permission"
|
|
451
|
+
when: "POST /api/v1/users with valid body"
|
|
452
|
+
then: "Response is 201 with user id"
|
|
453
|
+
category: "business-logic"
|
|
454
|
+
priority: "High"
|
|
455
|
+
tags: [regression, smoke]
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
- Each feature name becomes a **Test Set** in Jira
|
|
459
|
+
- Each rule maps 1:1 to a `tests.json` entry and a Playwright test
|
|
460
|
+
- See **[SPEC-DRIVEN-APPROACH.md](SPEC-DRIVEN-APPROACH.md)** for full generation rules
|
|
461
|
+
|
|
462
|
+
Validate the rules file with:
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
npx xqt validate --schema business-rules
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
## 10. CI/CD Integration
|
|
471
|
+
|
|
472
|
+
### Azure DevOps
|
|
473
|
+
|
|
474
|
+
`npx xqt init` scaffolds a ready-to-use `azure-pipelines.yml` with two stages:
|
|
475
|
+
|
|
476
|
+
- **Stage 1 `CodeQuality`** — ESLint + TypeScript type check
|
|
477
|
+
- **Stage 2 `QA_Regression`** — Playwright tests → `xqt import-results` → artifact publish
|
|
478
|
+
|
|
479
|
+
Key import step (runs even on test failure):
|
|
480
|
+
|
|
481
|
+
```yaml
|
|
482
|
+
- script: |
|
|
483
|
+
REVISION=$(echo "$(Build.SourceVersion)" | cut -c1-8)
|
|
484
|
+
npx xqt import-results \
|
|
485
|
+
--file test-results/results.json \
|
|
486
|
+
--version "$(Build.BuildNumber)" \
|
|
487
|
+
--revision "$REVISION"
|
|
488
|
+
condition: succeededOrFailed()
|
|
489
|
+
env:
|
|
490
|
+
XRAY_ID: $(xray_client_id)
|
|
491
|
+
XRAY_SECRET: $(xray_client_secret)
|
|
492
|
+
JIRA_PROJECT_KEY: $(JIRA_PROJECT_KEY)
|
|
493
|
+
JIRA_URL: $(JIRA_URL)
|
|
494
|
+
JIRA_API_TOKEN: $(JIRA_API_TOKEN)
|
|
495
|
+
JIRA_EMAIL: $(JIRA_EMAIL)
|
|
496
|
+
XRAY_GRAPHQL_URL: $(XRAY_GRAPHQL_URL_US)
|
|
497
|
+
XRAY_REST_URL: $(XRAY_REST_URL)
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### Required ADO variable groups
|
|
501
|
+
|
|
502
|
+
Create these in **ADO Library → Variable groups** before running the pipeline:
|
|
503
|
+
|
|
504
|
+
| Group | Variable | Description |
|
|
505
|
+
|---|---|---|
|
|
506
|
+
| `xray-qa-shared` *(shared — one-time)* | `xray_client_id` | Xray Cloud Client ID |
|
|
507
|
+
| | `xray_client_secret` | Xray Cloud Client Secret |
|
|
508
|
+
| | `JIRA_PROJECT_KEY` | JIRA project key |
|
|
509
|
+
| | `JIRA_URL` | JIRA instance URL |
|
|
510
|
+
| | `JIRA_API_TOKEN` | JIRA API token |
|
|
511
|
+
| | `JIRA_EMAIL` | JIRA user email |
|
|
512
|
+
| | `XRAY_GRAPHQL_URL_US` | Xray GraphQL endpoint |
|
|
513
|
+
| | `XRAY_REST_URL` | Xray REST endpoint |
|
|
514
|
+
| `{{SERVICE_NAME}}-qa` *(per-repo)* | `base_url` | API base URL for this service |
|
|
515
|
+
| | `gravitee_api_key` | Gateway API key |
|
|
516
|
+
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
## 11. xray-mapping.json
|
|
520
|
+
|
|
521
|
+
Auto-managed by `push-tests` — do not edit manually.
|
|
522
|
+
|
|
523
|
+
```json
|
|
524
|
+
{
|
|
525
|
+
"TC-MYSVC-BR-001": {
|
|
526
|
+
"key": "APIEE-1234",
|
|
527
|
+
"id": "8765432"
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
- `key` — JIRA issue key (e.g. `APIEE-1234`)
|
|
533
|
+
- `id` — Xray numeric issue ID (used for GraphQL operations)
|
|
534
|
+
- Entries are created by `push-tests` and updated on every push
|
|
535
|
+
- **Commit this file** — the whole team must share the same mapping
|
|
536
|
+
- Used by Copilot skill to generate Playwright tests with real Jira keys
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
## 12. Configuration (.xrayrc)
|
|
541
|
+
|
|
542
|
+
`.xrayrc` (JSON) at the project root configures xqt behaviour per-project.
|
|
543
|
+
|
|
544
|
+
```json
|
|
545
|
+
{
|
|
546
|
+
"testsPath": "tests.json",
|
|
547
|
+
"mappingPath": "xray-mapping.json",
|
|
548
|
+
"resourcesPath": "resources",
|
|
549
|
+
"playwrightDir": "tests",
|
|
550
|
+
"testPlanKey": "APIEE-1234",
|
|
551
|
+
"defaultEnvironment": "IOP-DEV",
|
|
552
|
+
"environments": ["IOP-DEV", "IOP-QA", "IOP-PROD"],
|
|
553
|
+
"folderRoot": "/{{SERVICE_NAME}}",
|
|
554
|
+
"xrayRegion": "us"
|
|
555
|
+
}
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### xrayRegion values
|
|
559
|
+
|
|
560
|
+
| Value | GraphQL endpoint |
|
|
561
|
+
|---|---|
|
|
562
|
+
| `us` (default) | `https://xray.cloud.getxray.app/` |
|
|
563
|
+
| `eu` | `https://eu.xray.cloud.getxray.app/` |
|
|
564
|
+
| `au` | `https://au.xray.cloud.getxray.app/` |
|
|
565
|
+
|
|
566
|
+
You can also set `XRAY_REGION=eu` in `.env`.
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
|
|
570
|
+
*Generated by @msalaam/xray-qe-toolkit — See [npm package](https://www.npmjs.com/package/@msalaam/xray-qe-toolkit) for updates.*
|