@continuum8032/playwright-ai-test-management 0.2.0-oidc-bootstrap.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Continuum8032 contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @continuum8032/playwright-ai-test-management
2
+
3
+ Optional read-only adapters for importing manual test cases into the generic `ManualTestCase` shape used by `@continuum8032/playwright-ai-tools`.
4
+
5
+ ```bash
6
+ ZEPHYR_SCALE_API_TOKEN=... npx -p @continuum8032/playwright-ai-test-management playwright-ai-tms pull --provider zephyr-scale --project PAY --out manual-cases.json
7
+ QASE_API_TOKEN=... npx -p @continuum8032/playwright-ai-test-management playwright-ai-tms pull --provider qase --project PAY --out manual-cases.json
8
+ TESTINY_API_KEY=... npx -p @continuum8032/playwright-ai-test-management playwright-ai-tms pull --provider testiny --project PAY --out manual-cases.json
9
+ ```
10
+
11
+ The adapters do not publish results, statuses, or attachments back to the source system. Tokens are read from environment variables and redacted from CLI errors.
package/dist/index.cjs ADDED
@@ -0,0 +1,278 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.ts
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ createTestManagementProvider: () => createTestManagementProvider,
35
+ main: () => main
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+ var import_promises = require("fs/promises");
39
+ var import_node_path = __toESM(require("path"), 1);
40
+ var DEFAULT_BASE_URLS = {
41
+ "zephyr-scale": "https://api.zephyrscale.smartbear.com/v2",
42
+ qase: "https://api.qase.io/v1",
43
+ testiny: "https://app.testiny.io/api/v1"
44
+ };
45
+ async function defaultTransport(url, init) {
46
+ return fetch(url, init);
47
+ }
48
+ function trimSlash(value) {
49
+ return value.replace(/\/+$/, "");
50
+ }
51
+ function stringValue(value) {
52
+ if (value === null || value === void 0) return void 0;
53
+ const text = String(value).trim();
54
+ return text || void 0;
55
+ }
56
+ function listValue(value) {
57
+ return Array.isArray(value) ? value : [];
58
+ }
59
+ function recordValue(value) {
60
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
61
+ }
62
+ function compact(value) {
63
+ return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0 && item !== "" && item !== null));
64
+ }
65
+ function mapSteps(rawSteps, mapper) {
66
+ return rawSteps.map((step, index) => mapper(recordValue(step), index)).filter((step) => step.action || step.expected);
67
+ }
68
+ async function readJson(response, provider) {
69
+ if (!response.ok) {
70
+ const body = response.text ? await response.text().catch(() => "") : "";
71
+ throw new Error(`${provider} request failed with status ${response.status}${body ? `: ${body}` : ""}`);
72
+ }
73
+ return response.json();
74
+ }
75
+ function source(provider, project, url) {
76
+ return compact({ provider, project, url });
77
+ }
78
+ function labelsFrom(value) {
79
+ return listValue(value).map((item) => typeof item === "string" ? item : stringValue(recordValue(item).title || recordValue(item).name)).filter((item) => Boolean(item));
80
+ }
81
+ function qaseArtifacts(value) {
82
+ return listValue(value).map((item) => stringValue(item)).filter((item) => Boolean(item)).map((hash) => ({ type: "attachment", path: hash, metadata: { hash } }));
83
+ }
84
+ function testinyArtifacts(value) {
85
+ const artifacts = [];
86
+ for (const item of listValue(value)) {
87
+ const attachment = recordValue(item);
88
+ const id = stringValue(attachment.id);
89
+ if (!id) continue;
90
+ artifacts.push(
91
+ compact({
92
+ type: "attachment",
93
+ path: id,
94
+ contentType: stringValue(attachment.mimeType || attachment.contentType),
95
+ metadata: compact({ filename: stringValue(attachment.filename || attachment.name) })
96
+ })
97
+ );
98
+ }
99
+ return artifacts;
100
+ }
101
+ var ZephyrScaleProvider = class {
102
+ constructor(baseUrl, token, transport) {
103
+ this.baseUrl = baseUrl;
104
+ this.token = token;
105
+ this.transport = transport;
106
+ }
107
+ async listCases(input) {
108
+ const url = new URL(`${trimSlash(this.baseUrl)}/testcases`);
109
+ url.searchParams.set("projectKey", input.project);
110
+ url.searchParams.set("maxResults", String(input.limit ?? 50));
111
+ if (input.query) url.searchParams.set("query", input.query);
112
+ const payload = recordValue(await readJson(await this.transport(url.toString(), {
113
+ method: "GET",
114
+ headers: { authorization: `Bearer ${this.token}`, accept: "application/json" }
115
+ }), "zephyr-scale"));
116
+ return listValue(payload.values || payload.items || payload.data).map((item) => this.normalizeCase(recordValue(item), input.project));
117
+ }
118
+ normalizeCase(item, project) {
119
+ const script = recordValue(item.testScript);
120
+ const links = recordValue(item.links);
121
+ const webLink = recordValue(listValue(links.webLinks)[0]);
122
+ return {
123
+ id: stringValue(item.id) || stringValue(item.key) || "unknown",
124
+ key: stringValue(item.key),
125
+ title: stringValue(item.name || item.title) || "Untitled manual case",
126
+ description: stringValue(item.objective || item.description),
127
+ preconditions: stringValue(item.precondition || item.preconditions),
128
+ labels: labelsFrom(item.labels),
129
+ steps: mapSteps(listValue(script.steps || item.steps), (step, index) => ({
130
+ index: index + 1,
131
+ action: stringValue(step.description || step.action || step.name) || "",
132
+ expected: stringValue(step.expectedResult || step.expected || step.expected_result)
133
+ })),
134
+ source: source("zephyr-scale", project, stringValue(webLink.url)),
135
+ metadata: compact({ rawStatus: stringValue(recordValue(item.status).name || item.status) })
136
+ };
137
+ }
138
+ };
139
+ var QaseProvider = class {
140
+ constructor(baseUrl, token, transport) {
141
+ this.baseUrl = baseUrl;
142
+ this.token = token;
143
+ this.transport = transport;
144
+ }
145
+ async listCases(input) {
146
+ const url = new URL(`${trimSlash(this.baseUrl)}/case/${encodeURIComponent(input.project)}`);
147
+ url.searchParams.set("limit", String(input.limit ?? 50));
148
+ if (input.query) url.searchParams.set("search", input.query);
149
+ const payload = recordValue(await readJson(await this.transport(url.toString(), {
150
+ method: "GET",
151
+ headers: { Token: this.token, accept: "application/json" }
152
+ }), "qase"));
153
+ const result = recordValue(payload.result);
154
+ return listValue(result.entities || payload.entities || payload.data).map((item) => this.normalizeCase(recordValue(item), input.project));
155
+ }
156
+ normalizeCase(item, project) {
157
+ const caseNumber = stringValue(item.case_id || item.caseId || item.id);
158
+ return {
159
+ id: stringValue(item.id) || caseNumber || "unknown",
160
+ key: caseNumber ? `${project}-${caseNumber}` : void 0,
161
+ title: stringValue(item.title) || "Untitled manual case",
162
+ description: stringValue(item.description),
163
+ preconditions: stringValue(item.preconditions || item.precondition),
164
+ labels: labelsFrom(item.tags),
165
+ artifacts: qaseArtifacts(item.attachments),
166
+ steps: mapSteps(listValue(item.steps), (step, index) => ({
167
+ index: index + 1,
168
+ action: stringValue(step.action || step.description) || "",
169
+ expected: stringValue(step.expected_result || step.expectedResult || step.expected)
170
+ })),
171
+ source: source("qase", project),
172
+ metadata: compact({ priority: stringValue(item.priority), severity: stringValue(item.severity) })
173
+ };
174
+ }
175
+ };
176
+ var TestinyProvider = class {
177
+ constructor(baseUrl, token, transport) {
178
+ this.baseUrl = baseUrl;
179
+ this.token = token;
180
+ this.transport = transport;
181
+ }
182
+ async listCases(input) {
183
+ const url = new URL(`${trimSlash(this.baseUrl)}/testcases`);
184
+ url.searchParams.set("project", input.project);
185
+ url.searchParams.set("limit", String(input.limit ?? 50));
186
+ if (input.query) url.searchParams.set("search", input.query);
187
+ const payload = recordValue(await readJson(await this.transport(url.toString(), {
188
+ method: "GET",
189
+ headers: { "X-Api-Key": this.token, accept: "application/json" }
190
+ }), "testiny"));
191
+ return listValue(payload.data || payload.items || payload.values).map((item) => this.normalizeCase(recordValue(item), input.project));
192
+ }
193
+ normalizeCase(item, project) {
194
+ return {
195
+ id: stringValue(item.id) || stringValue(item.key) || "unknown",
196
+ key: stringValue(item.key),
197
+ title: stringValue(item.title || item.name) || "Untitled manual case",
198
+ description: stringValue(item.description),
199
+ preconditions: stringValue(item.precondition || item.preconditions),
200
+ artifacts: testinyArtifacts(item.attachments),
201
+ steps: mapSteps(listValue(item.steps), (step, index) => ({
202
+ index: index + 1,
203
+ action: stringValue(step.action || step.description || step.title) || "",
204
+ expected: stringValue(step.expected || step.expectedResult || step.expected_result)
205
+ })),
206
+ source: source("testiny", project),
207
+ metadata: compact({ status: stringValue(item.status) })
208
+ };
209
+ }
210
+ };
211
+ function createTestManagementProvider(options) {
212
+ const baseUrl = options.baseUrl || DEFAULT_BASE_URLS[options.provider];
213
+ const transport = options.transport || defaultTransport;
214
+ if (!options.token) throw new Error(`Missing API token for ${options.provider}`);
215
+ if (options.provider === "zephyr-scale") return new ZephyrScaleProvider(baseUrl, options.token, transport);
216
+ if (options.provider === "qase") return new QaseProvider(baseUrl, options.token, transport);
217
+ if (options.provider === "testiny") return new TestinyProvider(baseUrl, options.token, transport);
218
+ throw new Error(`Unsupported test-management provider: ${String(options.provider)}`);
219
+ }
220
+ function argValue(args, name) {
221
+ const index = args.indexOf(name);
222
+ return index >= 0 ? args[index + 1] : void 0;
223
+ }
224
+ function providerToken(provider, env) {
225
+ const token = provider === "zephyr-scale" ? env.ZEPHYR_SCALE_API_TOKEN : provider === "qase" ? env.QASE_API_TOKEN : env.TESTINY_API_KEY;
226
+ if (!token) throw new Error(`Missing token environment variable for ${provider}`);
227
+ return token;
228
+ }
229
+ function providerBaseUrl(provider, env) {
230
+ return (provider === "zephyr-scale" ? env.ZEPHYR_SCALE_BASE_URL : provider === "qase" ? env.QASE_BASE_URL : env.TESTINY_BASE_URL) || DEFAULT_BASE_URLS[provider];
231
+ }
232
+ function redactSecrets(message, tokens) {
233
+ return tokens.filter(Boolean).reduce((value, token) => value.split(token).join("[REDACTED]"), message).replace(/\b(authorization\s*:\s*bearer)\s+[A-Za-z0-9._~+/-]+=*/gi, "$1 [REDACTED]").replace(/\b(Token|X-Api-Key)\s*:\s*[^\s,}]+/gi, "$1: [REDACTED]");
234
+ }
235
+ async function writeJson(output, payload) {
236
+ await (0, import_promises.mkdir)(import_node_path.default.dirname(output), { recursive: true });
237
+ await (0, import_promises.writeFile)(output, `${JSON.stringify(payload, null, 2)}
238
+ `, "utf8");
239
+ }
240
+ async function main(argv = process.argv.slice(2), env = process.env, transport = defaultTransport) {
241
+ const [command, ...rest] = argv;
242
+ const secrets = [];
243
+ try {
244
+ if (command !== "pull") {
245
+ throw new Error("Usage: playwright-ai-tms pull --provider <zephyr-scale|qase|testiny> --project <id> --out <manual-cases.json>");
246
+ }
247
+ const provider = argValue(rest, "--provider");
248
+ const project = argValue(rest, "--project");
249
+ const out = argValue(rest, "--out");
250
+ if (!provider || !["zephyr-scale", "qase", "testiny"].includes(provider)) throw new Error("Missing --provider <zephyr-scale|qase|testiny>");
251
+ if (!project) throw new Error("Missing --project <id>");
252
+ if (!out) throw new Error("Missing --out <manual-cases.json>");
253
+ const token = providerToken(provider, env);
254
+ secrets.push(token);
255
+ const adapter = createTestManagementProvider({
256
+ provider,
257
+ token,
258
+ baseUrl: providerBaseUrl(provider, env),
259
+ transport
260
+ });
261
+ const cases = await adapter.listCases({ project });
262
+ await writeJson(out, cases);
263
+ console.log(`Wrote ${cases.length} manual case${cases.length === 1 ? "" : "s"} to ${out}`);
264
+ } catch (error) {
265
+ throw new Error(redactSecrets(error?.message || String(error), secrets));
266
+ }
267
+ }
268
+ if (process.argv[1] && /(?:playwright-ai-tms|index\.(?:cjs|js|ts))$/.test(import_node_path.default.basename(process.argv[1]))) {
269
+ main().catch((error) => {
270
+ console.error(error.message);
271
+ process.exit(1);
272
+ });
273
+ }
274
+ // Annotate the CommonJS export names for ESM import in node:
275
+ 0 && (module.exports = {
276
+ createTestManagementProvider,
277
+ main
278
+ });
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ interface ManualTestArtifact {
3
+ type: string;
4
+ path?: string;
5
+ url?: string;
6
+ contentType?: string;
7
+ metadata?: Record<string, unknown>;
8
+ }
9
+ interface ManualTestStep {
10
+ index?: number;
11
+ action: string;
12
+ expected?: string;
13
+ data?: Record<string, unknown>;
14
+ artifacts?: ManualTestArtifact[];
15
+ }
16
+ interface ManualTestCase {
17
+ id: string;
18
+ key?: string;
19
+ title: string;
20
+ description?: string;
21
+ preconditions?: string;
22
+ steps: ManualTestStep[];
23
+ artifacts?: ManualTestArtifact[];
24
+ labels?: string[];
25
+ source?: {
26
+ provider?: string;
27
+ project?: string;
28
+ url?: string;
29
+ };
30
+ metadata?: Record<string, unknown>;
31
+ }
32
+ interface ManualTestCaseQuery {
33
+ project: string;
34
+ query?: string;
35
+ limit?: number;
36
+ }
37
+ interface ManualTestProvider {
38
+ listCases(input: ManualTestCaseQuery): Promise<ManualTestCase[]>;
39
+ }
40
+
41
+ type TmsProviderName = 'zephyr-scale' | 'qase' | 'testiny';
42
+ interface TmsTransportResponse {
43
+ ok: boolean;
44
+ status: number;
45
+ json(): Promise<unknown>;
46
+ text?(): Promise<string>;
47
+ }
48
+ type TmsTransport = (url: string, init: {
49
+ method?: string;
50
+ headers: Record<string, string>;
51
+ }) => Promise<TmsTransportResponse>;
52
+ interface TestManagementAdapterOptions {
53
+ provider: TmsProviderName;
54
+ token: string;
55
+ baseUrl?: string;
56
+ transport?: TmsTransport;
57
+ }
58
+ declare function createTestManagementProvider(options: TestManagementAdapterOptions): ManualTestProvider;
59
+ declare function main(argv?: string[], env?: Record<string, string | undefined>, transport?: TmsTransport): Promise<void>;
60
+
61
+ export { type TestManagementAdapterOptions, type TmsProviderName, type TmsTransport, type TmsTransportResponse, createTestManagementProvider, main };
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ interface ManualTestArtifact {
3
+ type: string;
4
+ path?: string;
5
+ url?: string;
6
+ contentType?: string;
7
+ metadata?: Record<string, unknown>;
8
+ }
9
+ interface ManualTestStep {
10
+ index?: number;
11
+ action: string;
12
+ expected?: string;
13
+ data?: Record<string, unknown>;
14
+ artifacts?: ManualTestArtifact[];
15
+ }
16
+ interface ManualTestCase {
17
+ id: string;
18
+ key?: string;
19
+ title: string;
20
+ description?: string;
21
+ preconditions?: string;
22
+ steps: ManualTestStep[];
23
+ artifacts?: ManualTestArtifact[];
24
+ labels?: string[];
25
+ source?: {
26
+ provider?: string;
27
+ project?: string;
28
+ url?: string;
29
+ };
30
+ metadata?: Record<string, unknown>;
31
+ }
32
+ interface ManualTestCaseQuery {
33
+ project: string;
34
+ query?: string;
35
+ limit?: number;
36
+ }
37
+ interface ManualTestProvider {
38
+ listCases(input: ManualTestCaseQuery): Promise<ManualTestCase[]>;
39
+ }
40
+
41
+ type TmsProviderName = 'zephyr-scale' | 'qase' | 'testiny';
42
+ interface TmsTransportResponse {
43
+ ok: boolean;
44
+ status: number;
45
+ json(): Promise<unknown>;
46
+ text?(): Promise<string>;
47
+ }
48
+ type TmsTransport = (url: string, init: {
49
+ method?: string;
50
+ headers: Record<string, string>;
51
+ }) => Promise<TmsTransportResponse>;
52
+ interface TestManagementAdapterOptions {
53
+ provider: TmsProviderName;
54
+ token: string;
55
+ baseUrl?: string;
56
+ transport?: TmsTransport;
57
+ }
58
+ declare function createTestManagementProvider(options: TestManagementAdapterOptions): ManualTestProvider;
59
+ declare function main(argv?: string[], env?: Record<string, string | undefined>, transport?: TmsTransport): Promise<void>;
60
+
61
+ export { type TestManagementAdapterOptions, type TmsProviderName, type TmsTransport, type TmsTransportResponse, createTestManagementProvider, main };
package/dist/index.js ADDED
@@ -0,0 +1,243 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { mkdir, writeFile } from "fs/promises";
5
+ import path from "path";
6
+ var DEFAULT_BASE_URLS = {
7
+ "zephyr-scale": "https://api.zephyrscale.smartbear.com/v2",
8
+ qase: "https://api.qase.io/v1",
9
+ testiny: "https://app.testiny.io/api/v1"
10
+ };
11
+ async function defaultTransport(url, init) {
12
+ return fetch(url, init);
13
+ }
14
+ function trimSlash(value) {
15
+ return value.replace(/\/+$/, "");
16
+ }
17
+ function stringValue(value) {
18
+ if (value === null || value === void 0) return void 0;
19
+ const text = String(value).trim();
20
+ return text || void 0;
21
+ }
22
+ function listValue(value) {
23
+ return Array.isArray(value) ? value : [];
24
+ }
25
+ function recordValue(value) {
26
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
27
+ }
28
+ function compact(value) {
29
+ return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0 && item !== "" && item !== null));
30
+ }
31
+ function mapSteps(rawSteps, mapper) {
32
+ return rawSteps.map((step, index) => mapper(recordValue(step), index)).filter((step) => step.action || step.expected);
33
+ }
34
+ async function readJson(response, provider) {
35
+ if (!response.ok) {
36
+ const body = response.text ? await response.text().catch(() => "") : "";
37
+ throw new Error(`${provider} request failed with status ${response.status}${body ? `: ${body}` : ""}`);
38
+ }
39
+ return response.json();
40
+ }
41
+ function source(provider, project, url) {
42
+ return compact({ provider, project, url });
43
+ }
44
+ function labelsFrom(value) {
45
+ return listValue(value).map((item) => typeof item === "string" ? item : stringValue(recordValue(item).title || recordValue(item).name)).filter((item) => Boolean(item));
46
+ }
47
+ function qaseArtifacts(value) {
48
+ return listValue(value).map((item) => stringValue(item)).filter((item) => Boolean(item)).map((hash) => ({ type: "attachment", path: hash, metadata: { hash } }));
49
+ }
50
+ function testinyArtifacts(value) {
51
+ const artifacts = [];
52
+ for (const item of listValue(value)) {
53
+ const attachment = recordValue(item);
54
+ const id = stringValue(attachment.id);
55
+ if (!id) continue;
56
+ artifacts.push(
57
+ compact({
58
+ type: "attachment",
59
+ path: id,
60
+ contentType: stringValue(attachment.mimeType || attachment.contentType),
61
+ metadata: compact({ filename: stringValue(attachment.filename || attachment.name) })
62
+ })
63
+ );
64
+ }
65
+ return artifacts;
66
+ }
67
+ var ZephyrScaleProvider = class {
68
+ constructor(baseUrl, token, transport) {
69
+ this.baseUrl = baseUrl;
70
+ this.token = token;
71
+ this.transport = transport;
72
+ }
73
+ async listCases(input) {
74
+ const url = new URL(`${trimSlash(this.baseUrl)}/testcases`);
75
+ url.searchParams.set("projectKey", input.project);
76
+ url.searchParams.set("maxResults", String(input.limit ?? 50));
77
+ if (input.query) url.searchParams.set("query", input.query);
78
+ const payload = recordValue(await readJson(await this.transport(url.toString(), {
79
+ method: "GET",
80
+ headers: { authorization: `Bearer ${this.token}`, accept: "application/json" }
81
+ }), "zephyr-scale"));
82
+ return listValue(payload.values || payload.items || payload.data).map((item) => this.normalizeCase(recordValue(item), input.project));
83
+ }
84
+ normalizeCase(item, project) {
85
+ const script = recordValue(item.testScript);
86
+ const links = recordValue(item.links);
87
+ const webLink = recordValue(listValue(links.webLinks)[0]);
88
+ return {
89
+ id: stringValue(item.id) || stringValue(item.key) || "unknown",
90
+ key: stringValue(item.key),
91
+ title: stringValue(item.name || item.title) || "Untitled manual case",
92
+ description: stringValue(item.objective || item.description),
93
+ preconditions: stringValue(item.precondition || item.preconditions),
94
+ labels: labelsFrom(item.labels),
95
+ steps: mapSteps(listValue(script.steps || item.steps), (step, index) => ({
96
+ index: index + 1,
97
+ action: stringValue(step.description || step.action || step.name) || "",
98
+ expected: stringValue(step.expectedResult || step.expected || step.expected_result)
99
+ })),
100
+ source: source("zephyr-scale", project, stringValue(webLink.url)),
101
+ metadata: compact({ rawStatus: stringValue(recordValue(item.status).name || item.status) })
102
+ };
103
+ }
104
+ };
105
+ var QaseProvider = class {
106
+ constructor(baseUrl, token, transport) {
107
+ this.baseUrl = baseUrl;
108
+ this.token = token;
109
+ this.transport = transport;
110
+ }
111
+ async listCases(input) {
112
+ const url = new URL(`${trimSlash(this.baseUrl)}/case/${encodeURIComponent(input.project)}`);
113
+ url.searchParams.set("limit", String(input.limit ?? 50));
114
+ if (input.query) url.searchParams.set("search", input.query);
115
+ const payload = recordValue(await readJson(await this.transport(url.toString(), {
116
+ method: "GET",
117
+ headers: { Token: this.token, accept: "application/json" }
118
+ }), "qase"));
119
+ const result = recordValue(payload.result);
120
+ return listValue(result.entities || payload.entities || payload.data).map((item) => this.normalizeCase(recordValue(item), input.project));
121
+ }
122
+ normalizeCase(item, project) {
123
+ const caseNumber = stringValue(item.case_id || item.caseId || item.id);
124
+ return {
125
+ id: stringValue(item.id) || caseNumber || "unknown",
126
+ key: caseNumber ? `${project}-${caseNumber}` : void 0,
127
+ title: stringValue(item.title) || "Untitled manual case",
128
+ description: stringValue(item.description),
129
+ preconditions: stringValue(item.preconditions || item.precondition),
130
+ labels: labelsFrom(item.tags),
131
+ artifacts: qaseArtifacts(item.attachments),
132
+ steps: mapSteps(listValue(item.steps), (step, index) => ({
133
+ index: index + 1,
134
+ action: stringValue(step.action || step.description) || "",
135
+ expected: stringValue(step.expected_result || step.expectedResult || step.expected)
136
+ })),
137
+ source: source("qase", project),
138
+ metadata: compact({ priority: stringValue(item.priority), severity: stringValue(item.severity) })
139
+ };
140
+ }
141
+ };
142
+ var TestinyProvider = class {
143
+ constructor(baseUrl, token, transport) {
144
+ this.baseUrl = baseUrl;
145
+ this.token = token;
146
+ this.transport = transport;
147
+ }
148
+ async listCases(input) {
149
+ const url = new URL(`${trimSlash(this.baseUrl)}/testcases`);
150
+ url.searchParams.set("project", input.project);
151
+ url.searchParams.set("limit", String(input.limit ?? 50));
152
+ if (input.query) url.searchParams.set("search", input.query);
153
+ const payload = recordValue(await readJson(await this.transport(url.toString(), {
154
+ method: "GET",
155
+ headers: { "X-Api-Key": this.token, accept: "application/json" }
156
+ }), "testiny"));
157
+ return listValue(payload.data || payload.items || payload.values).map((item) => this.normalizeCase(recordValue(item), input.project));
158
+ }
159
+ normalizeCase(item, project) {
160
+ return {
161
+ id: stringValue(item.id) || stringValue(item.key) || "unknown",
162
+ key: stringValue(item.key),
163
+ title: stringValue(item.title || item.name) || "Untitled manual case",
164
+ description: stringValue(item.description),
165
+ preconditions: stringValue(item.precondition || item.preconditions),
166
+ artifacts: testinyArtifacts(item.attachments),
167
+ steps: mapSteps(listValue(item.steps), (step, index) => ({
168
+ index: index + 1,
169
+ action: stringValue(step.action || step.description || step.title) || "",
170
+ expected: stringValue(step.expected || step.expectedResult || step.expected_result)
171
+ })),
172
+ source: source("testiny", project),
173
+ metadata: compact({ status: stringValue(item.status) })
174
+ };
175
+ }
176
+ };
177
+ function createTestManagementProvider(options) {
178
+ const baseUrl = options.baseUrl || DEFAULT_BASE_URLS[options.provider];
179
+ const transport = options.transport || defaultTransport;
180
+ if (!options.token) throw new Error(`Missing API token for ${options.provider}`);
181
+ if (options.provider === "zephyr-scale") return new ZephyrScaleProvider(baseUrl, options.token, transport);
182
+ if (options.provider === "qase") return new QaseProvider(baseUrl, options.token, transport);
183
+ if (options.provider === "testiny") return new TestinyProvider(baseUrl, options.token, transport);
184
+ throw new Error(`Unsupported test-management provider: ${String(options.provider)}`);
185
+ }
186
+ function argValue(args, name) {
187
+ const index = args.indexOf(name);
188
+ return index >= 0 ? args[index + 1] : void 0;
189
+ }
190
+ function providerToken(provider, env) {
191
+ const token = provider === "zephyr-scale" ? env.ZEPHYR_SCALE_API_TOKEN : provider === "qase" ? env.QASE_API_TOKEN : env.TESTINY_API_KEY;
192
+ if (!token) throw new Error(`Missing token environment variable for ${provider}`);
193
+ return token;
194
+ }
195
+ function providerBaseUrl(provider, env) {
196
+ return (provider === "zephyr-scale" ? env.ZEPHYR_SCALE_BASE_URL : provider === "qase" ? env.QASE_BASE_URL : env.TESTINY_BASE_URL) || DEFAULT_BASE_URLS[provider];
197
+ }
198
+ function redactSecrets(message, tokens) {
199
+ return tokens.filter(Boolean).reduce((value, token) => value.split(token).join("[REDACTED]"), message).replace(/\b(authorization\s*:\s*bearer)\s+[A-Za-z0-9._~+/-]+=*/gi, "$1 [REDACTED]").replace(/\b(Token|X-Api-Key)\s*:\s*[^\s,}]+/gi, "$1: [REDACTED]");
200
+ }
201
+ async function writeJson(output, payload) {
202
+ await mkdir(path.dirname(output), { recursive: true });
203
+ await writeFile(output, `${JSON.stringify(payload, null, 2)}
204
+ `, "utf8");
205
+ }
206
+ async function main(argv = process.argv.slice(2), env = process.env, transport = defaultTransport) {
207
+ const [command, ...rest] = argv;
208
+ const secrets = [];
209
+ try {
210
+ if (command !== "pull") {
211
+ throw new Error("Usage: playwright-ai-tms pull --provider <zephyr-scale|qase|testiny> --project <id> --out <manual-cases.json>");
212
+ }
213
+ const provider = argValue(rest, "--provider");
214
+ const project = argValue(rest, "--project");
215
+ const out = argValue(rest, "--out");
216
+ if (!provider || !["zephyr-scale", "qase", "testiny"].includes(provider)) throw new Error("Missing --provider <zephyr-scale|qase|testiny>");
217
+ if (!project) throw new Error("Missing --project <id>");
218
+ if (!out) throw new Error("Missing --out <manual-cases.json>");
219
+ const token = providerToken(provider, env);
220
+ secrets.push(token);
221
+ const adapter = createTestManagementProvider({
222
+ provider,
223
+ token,
224
+ baseUrl: providerBaseUrl(provider, env),
225
+ transport
226
+ });
227
+ const cases = await adapter.listCases({ project });
228
+ await writeJson(out, cases);
229
+ console.log(`Wrote ${cases.length} manual case${cases.length === 1 ? "" : "s"} to ${out}`);
230
+ } catch (error) {
231
+ throw new Error(redactSecrets(error?.message || String(error), secrets));
232
+ }
233
+ }
234
+ if (process.argv[1] && /(?:playwright-ai-tms|index\.(?:cjs|js|ts))$/.test(path.basename(process.argv[1]))) {
235
+ main().catch((error) => {
236
+ console.error(error.message);
237
+ process.exit(1);
238
+ });
239
+ }
240
+ export {
241
+ createTestManagementProvider,
242
+ main
243
+ };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@continuum8032/playwright-ai-test-management",
3
+ "version": "0.2.0-oidc-bootstrap.0",
4
+ "description": "Optional read-only test-management adapters for playwright-ai-tools.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/Continuum8032/codex-playwright-tools.git",
9
+ "directory": "integrations/test-management"
10
+ },
11
+ "homepage": "https://github.com/Continuum8032/codex-playwright-tools#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/Continuum8032/codex-playwright-tools/issues"
14
+ },
15
+ "keywords": [
16
+ "playwright",
17
+ "testing",
18
+ "test-management",
19
+ "qase",
20
+ "zephyr",
21
+ "testiny"
22
+ ],
23
+ "type": "module",
24
+ "main": "./dist/index.cjs",
25
+ "module": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "bin": {
28
+ "playwright-ai-tms": "./dist/index.cjs"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean"
37
+ },
38
+ "peerDependencies": {
39
+ "@continuum8032/playwright-ai-tools": "0.2.0-oidc-bootstrap.0"
40
+ },
41
+ "devDependencies": {
42
+ "tsup": "^8.5.0",
43
+ "typescript": "^5.8.3"
44
+ }
45
+ }