@testspectra/cli 1.0.33 → 1.0.35
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/dist/types/generator.d.ts +13 -4
- package/dist/types/generator.js +131 -49
- package/package.json +1 -1
- package/templates/nx/tsconfig.spectra.android.json +1 -2
- package/templates/nx/tsconfig.spectra.ios.json +1 -2
- package/templates/nx/tsconfig.spectra.shared.json +2 -2
- package/templates/nx/tsconfig.spectra.web.json +1 -2
- package/templates/nx/modules/auth/e2e/actions/applyDiscount/mobile.action.ts +0 -6
- package/templates/nx/modules/auth/e2e/actions/applyDiscount/web.action.ts +0 -6
- package/templates/nx/modules/auth/e2e/fixtures/couponCode.json +0 -1
- package/templates/nx/modules/auth/e2e/fixtures/searchQuery.json +0 -1
- package/templates/nx/modules/auth/e2e/page-objects/ProductPage/mobile.ts +0 -39
- package/templates/nx/modules/auth/e2e/page-objects/ProductPage/web.ts +0 -38
- package/templates/nx/modules/auth/e2e/specs/Product/TC-PROD-01/mobile.test.ts +0 -8
- package/templates/nx/modules/auth/e2e/specs/Product/TC-PROD-01/web.test.ts +0 -8
- package/templates/nx/modules/auth/e2e/specs/Product/TC-PROD-02/mobile.test.ts +0 -6
- package/templates/nx/modules/auth/e2e/specs/Product/TC-PROD-02/web.test.ts +0 -6
- package/templates/nx/modules/auth/e2e/specs/Product/hooks/before.web.hook.ts +0 -3
- package/templates/nx/modules/auth/e2e/steps/searchProduct/mobile.step.ts +0 -5
- package/templates/nx/modules/auth/e2e/steps/searchProduct/web.step.ts +0 -5
- package/templates/nx/modules/catalog/e2e/actions/applyDiscount/mobile.action.ts +0 -6
- package/templates/nx/modules/catalog/e2e/actions/applyDiscount/web.action.ts +0 -6
- package/templates/nx/modules/catalog/e2e/actions/verifyOtp/mobile.action.ts +0 -6
- package/templates/nx/modules/catalog/e2e/actions/verifyOtp/web.action.ts +0 -6
- package/templates/nx/modules/catalog/e2e/fixtures/couponCode.json +0 -1
- package/templates/nx/modules/catalog/e2e/fixtures/searchQuery.json +0 -1
- package/templates/nx/modules/catalog/e2e/fixtures/userData.json +0 -1
- package/templates/nx/modules/catalog/e2e/global-hooks/before.web.hook.ts +0 -4
- package/templates/nx/modules/catalog/e2e/package.json +0 -18
- package/templates/nx/modules/catalog/e2e/page-objects/LoginPage/mobile.ts +0 -32
- package/templates/nx/modules/catalog/e2e/page-objects/LoginPage/web.ts +0 -32
- package/templates/nx/modules/catalog/e2e/page-objects/ProductPage/mobile.ts +0 -39
- package/templates/nx/modules/catalog/e2e/page-objects/ProductPage/web.ts +0 -38
- package/templates/nx/modules/catalog/e2e/page-objects/SettingsPage/common.ts +0 -26
- package/templates/nx/modules/catalog/e2e/project.json +0 -34
- package/templates/nx/modules/catalog/e2e/specs/Auth/TC-AUTH-01/android.test.ts +0 -6
- package/templates/nx/modules/catalog/e2e/specs/Auth/TC-AUTH-01/ios.test.ts +0 -6
- package/templates/nx/modules/catalog/e2e/specs/Auth/TC-AUTH-01/web.test.ts +0 -13
- package/templates/nx/modules/catalog/e2e/specs/Auth/TC-AUTH-02/android.test.ts +0 -5
- package/templates/nx/modules/catalog/e2e/specs/Auth/TC-AUTH-02/web.test.ts +0 -5
- package/templates/nx/modules/catalog/e2e/specs/Auth/hooks/before.android.hook.ts +0 -3
- package/templates/nx/modules/catalog/e2e/specs/Auth/hooks/before.ios.hook.ts +0 -3
- package/templates/nx/modules/catalog/e2e/specs/Auth/hooks/before.web.hook.ts +0 -3
- package/templates/nx/modules/catalog/e2e/specs/Product/TC-PROD-01/mobile.test.ts +0 -8
- package/templates/nx/modules/catalog/e2e/specs/Product/TC-PROD-01/web.test.ts +0 -8
- package/templates/nx/modules/catalog/e2e/specs/Product/TC-PROD-02/mobile.test.ts +0 -6
- package/templates/nx/modules/catalog/e2e/specs/Product/TC-PROD-02/web.test.ts +0 -6
- package/templates/nx/modules/catalog/e2e/specs/Product/hooks/before.web.hook.ts +0 -3
- package/templates/nx/modules/catalog/e2e/specs/Settings/TC-SET-01/common.test.ts +0 -8
- package/templates/nx/modules/catalog/e2e/steps/loginUser/mobile.step.ts +0 -4
- package/templates/nx/modules/catalog/e2e/steps/loginUser/web.step.ts +0 -4
- package/templates/nx/modules/catalog/e2e/steps/searchProduct/mobile.step.ts +0 -5
- package/templates/nx/modules/catalog/e2e/steps/searchProduct/web.step.ts +0 -5
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
export type PlatformTarget = "web" | "android" | "ios" | "mobile" | "common";
|
|
2
2
|
export declare class TypeGenerator {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Discovers all feature directories and shared library directories.
|
|
5
|
+
* Returns a map of scope -> base directory (e.g. { "shared": ".../shared/testing", "auth": ".../packages/features/auth/e2e" })
|
|
6
|
+
*/
|
|
7
|
+
static getEntityScopes(cwd: string): {
|
|
8
|
+
name: string;
|
|
9
|
+
dir: string;
|
|
10
|
+
isShared: boolean;
|
|
11
|
+
}[];
|
|
12
|
+
static getPageObjectsDirsForScope(scopeDir: string, sharedDir?: string): string[];
|
|
13
|
+
static getEntityDirsForScope(entityType: "actions" | "steps" | "fixtures", scopeDir: string, sharedDir?: string): string[];
|
|
14
|
+
static generateDeclarationsForScope(cwd: string, outputTypesDir: string, scopeDir: string, sharedDir?: string): Record<string, string>;
|
|
15
|
+
static generateFixturesDeclarationForScope(scopeDir: string, sharedDir?: string): string;
|
|
7
16
|
static writeDeclarationFiles(cwd: string): void;
|
|
8
17
|
}
|
package/dist/types/generator.js
CHANGED
|
@@ -8,7 +8,54 @@ const PLATFORM_HIERARCHY = {
|
|
|
8
8
|
common: ["common"],
|
|
9
9
|
};
|
|
10
10
|
export class TypeGenerator {
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Discovers all feature directories and shared library directories.
|
|
13
|
+
* Returns a map of scope -> base directory (e.g. { "shared": ".../shared/testing", "auth": ".../packages/features/auth/e2e" })
|
|
14
|
+
*/
|
|
15
|
+
static getEntityScopes(cwd) {
|
|
16
|
+
const scopes = [];
|
|
17
|
+
// 1. Scan for shared directories
|
|
18
|
+
const sharedCandidates = [
|
|
19
|
+
path.join(cwd, "shared", "testing"),
|
|
20
|
+
path.join(cwd, "shared"),
|
|
21
|
+
path.join(cwd, "testing"),
|
|
22
|
+
];
|
|
23
|
+
for (const cand of sharedCandidates) {
|
|
24
|
+
if (fs.existsSync(cand) && (fs.existsSync(path.join(cand, "page-objects")) || fs.existsSync(path.join(cand, "steps")) || fs.existsSync(path.join(cand, "actions")))) {
|
|
25
|
+
if (!scopes.some((s) => s.dir === cand)) {
|
|
26
|
+
scopes.push({ name: "shared", dir: cand, isShared: true });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// 2. Scan recursively for feature e2e directories
|
|
31
|
+
function scanForFeatures(dir, depth) {
|
|
32
|
+
if (depth <= 0 || !fs.existsSync(dir))
|
|
33
|
+
return;
|
|
34
|
+
const base = path.basename(dir);
|
|
35
|
+
if (base === "node_modules" || base === "dist" || base === ".git" || base === ".testspectra")
|
|
36
|
+
return;
|
|
37
|
+
if (base === "e2e" || base === "tests" || base === "specs") {
|
|
38
|
+
const featureDir = path.dirname(dir);
|
|
39
|
+
const featureName = path.basename(featureDir);
|
|
40
|
+
if (!scopes.some((s) => s.dir === dir)) {
|
|
41
|
+
scopes.push({ name: featureName, dir: dir, isShared: false });
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
if (entry.isDirectory()) {
|
|
49
|
+
scanForFeatures(path.join(dir, entry.name), depth - 1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch { }
|
|
54
|
+
}
|
|
55
|
+
scanForFeatures(cwd, 6);
|
|
56
|
+
return scopes;
|
|
57
|
+
}
|
|
58
|
+
static getPageObjectsDirsForScope(scopeDir, sharedDir) {
|
|
12
59
|
const dirs = [];
|
|
13
60
|
function scanDir(dir, maxDepth) {
|
|
14
61
|
if (maxDepth <= 0 || !fs.existsSync(dir))
|
|
@@ -31,20 +78,26 @@ export class TypeGenerator {
|
|
|
31
78
|
}
|
|
32
79
|
catch { }
|
|
33
80
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
81
|
+
if (!sharedDir && (fs.existsSync(path.join(scopeDir, "pnpm-workspace.yaml")) || fs.existsSync(path.join(scopeDir, "nx.json")))) {
|
|
82
|
+
scanDir(scopeDir, 6);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const candidates = [
|
|
86
|
+
path.join(scopeDir, "page-objects"),
|
|
87
|
+
path.join(scopeDir, "pageobjects"),
|
|
88
|
+
];
|
|
89
|
+
if (sharedDir) {
|
|
90
|
+
candidates.push(path.join(sharedDir, "page-objects"));
|
|
91
|
+
candidates.push(path.join(sharedDir, "pageobjects"));
|
|
92
|
+
}
|
|
93
|
+
for (const c of candidates) {
|
|
94
|
+
if (fs.existsSync(c) && !dirs.includes(c))
|
|
95
|
+
dirs.push(c);
|
|
42
96
|
}
|
|
43
|
-
cur = path.dirname(cur);
|
|
44
97
|
}
|
|
45
98
|
return dirs;
|
|
46
99
|
}
|
|
47
|
-
static
|
|
100
|
+
static getEntityDirsForScope(entityType, scopeDir, sharedDir) {
|
|
48
101
|
const dirs = [];
|
|
49
102
|
function scanDir(dir, maxDepth) {
|
|
50
103
|
if (maxDepth <= 0 || !fs.existsSync(dir))
|
|
@@ -67,23 +120,25 @@ export class TypeGenerator {
|
|
|
67
120
|
}
|
|
68
121
|
catch { }
|
|
69
122
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
123
|
+
if (!sharedDir && (fs.existsSync(path.join(scopeDir, "pnpm-workspace.yaml")) || fs.existsSync(path.join(scopeDir, "nx.json")))) {
|
|
124
|
+
scanDir(scopeDir, 6);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const candidates = [path.join(scopeDir, entityType)];
|
|
128
|
+
if (sharedDir) {
|
|
129
|
+
candidates.push(path.join(sharedDir, entityType));
|
|
130
|
+
}
|
|
131
|
+
for (const c of candidates) {
|
|
132
|
+
if (fs.existsSync(c) && !dirs.includes(c))
|
|
133
|
+
dirs.push(c);
|
|
78
134
|
}
|
|
79
|
-
cur = path.dirname(cur);
|
|
80
135
|
}
|
|
81
136
|
return dirs;
|
|
82
137
|
}
|
|
83
|
-
static
|
|
84
|
-
const poDirs = this.
|
|
85
|
-
const actionsDirs = this.
|
|
86
|
-
const stepsDirs = this.
|
|
138
|
+
static generateDeclarationsForScope(cwd, outputTypesDir, scopeDir, sharedDir) {
|
|
139
|
+
const poDirs = this.getPageObjectsDirsForScope(scopeDir, sharedDir);
|
|
140
|
+
const actionsDirs = this.getEntityDirsForScope("actions", scopeDir, sharedDir);
|
|
141
|
+
const stepsDirs = this.getEntityDirsForScope("steps", scopeDir, sharedDir);
|
|
87
142
|
const platforms = ["web", "android", "ios", "mobile", "common"];
|
|
88
143
|
const results = {};
|
|
89
144
|
for (const platform of platforms) {
|
|
@@ -147,7 +202,7 @@ export class TypeGenerator {
|
|
|
147
202
|
content += ` shouldHaveClass(this: Promise<WebdriverIO.Element>, className: string): Promise<WebdriverIO.Element>;\n`;
|
|
148
203
|
content += ` shouldHaveAttribute(this: Promise<WebdriverIO.Element>, attributeName: string, expectedValue?: string): Promise<WebdriverIO.Element>;\n`;
|
|
149
204
|
content += `}\n\n`;
|
|
150
|
-
// 1. Page Objects Global Declarations
|
|
205
|
+
// 1. Page Objects Global Declarations
|
|
151
206
|
const declaredPOMs = new Set();
|
|
152
207
|
for (const poDir of poDirs) {
|
|
153
208
|
if (!fs.existsSync(poDir))
|
|
@@ -165,7 +220,7 @@ export class TypeGenerator {
|
|
|
165
220
|
for (const stem of hierarchy) {
|
|
166
221
|
const cand = path.join(classFolder, `${stem}.ts`);
|
|
167
222
|
if (fs.existsSync(cand)) {
|
|
168
|
-
matchedFile = path.relative(
|
|
223
|
+
matchedFile = path.relative(outputTypesDir, cand).replace(/\\/g, "/").replace(/\.ts$/, ".js");
|
|
169
224
|
if (!matchedFile.startsWith("."))
|
|
170
225
|
matchedFile = `./${matchedFile}`;
|
|
171
226
|
break;
|
|
@@ -180,7 +235,7 @@ export class TypeGenerator {
|
|
|
180
235
|
const className = entry.name.split(".")[0];
|
|
181
236
|
if (declaredPOMs.has(className))
|
|
182
237
|
continue;
|
|
183
|
-
let rel = path.relative(
|
|
238
|
+
let rel = path.relative(outputTypesDir, path.join(poDir, entry.name)).replace(/\\/g, "/").replace(/\.ts$/, ".js");
|
|
184
239
|
if (!rel.startsWith("."))
|
|
185
240
|
rel = `./${rel}`;
|
|
186
241
|
content += `declare const ${className}: typeof import('${rel}').default;\n`;
|
|
@@ -228,11 +283,11 @@ export class TypeGenerator {
|
|
|
228
283
|
const cand1 = path.join(actionFolder, `${stem}.action.ts`);
|
|
229
284
|
const cand2 = path.join(actionFolder, `${stem}.ts`);
|
|
230
285
|
if (fs.existsSync(cand1)) {
|
|
231
|
-
matchedFile = path.relative(
|
|
286
|
+
matchedFile = path.relative(outputTypesDir, cand1).replace(/\\/g, "/").replace(/\.ts$/, ".js");
|
|
232
287
|
break;
|
|
233
288
|
}
|
|
234
289
|
else if (fs.existsSync(cand2)) {
|
|
235
|
-
matchedFile = path.relative(
|
|
290
|
+
matchedFile = path.relative(outputTypesDir, cand2).replace(/\\/g, "/").replace(/\.ts$/, ".js");
|
|
236
291
|
break;
|
|
237
292
|
}
|
|
238
293
|
}
|
|
@@ -250,7 +305,7 @@ export class TypeGenerator {
|
|
|
250
305
|
if (hierarchy.includes(stem) || hierarchy.includes(parts[1])) {
|
|
251
306
|
if (declaredActions.has(actionName))
|
|
252
307
|
continue;
|
|
253
|
-
let rel = path.relative(
|
|
308
|
+
let rel = path.relative(outputTypesDir, path.join(actionsDir, entry.name)).replace(/\\/g, "/").replace(/\.ts$/, ".js");
|
|
254
309
|
if (!rel.startsWith("."))
|
|
255
310
|
rel = `./${rel}`;
|
|
256
311
|
content += ` ${actionName}: (typeof import('${rel}') extends { default: infer T } ? T : typeof import('${rel}'));\n`;
|
|
@@ -262,7 +317,7 @@ export class TypeGenerator {
|
|
|
262
317
|
content += `}\n`;
|
|
263
318
|
content += `type TestSpectraActions = SpectraStaticInstance & TestSpectraCustomActions;\n`;
|
|
264
319
|
content += `declare const Spectra: TestSpectraActions;\n\n`;
|
|
265
|
-
// 3.
|
|
320
|
+
// 3. Built-in Steps Declaration
|
|
266
321
|
content += `interface TestSpectraSteps {\n`;
|
|
267
322
|
const declaredSteps = new Set();
|
|
268
323
|
for (const stepsDir of stepsDirs) {
|
|
@@ -282,11 +337,11 @@ export class TypeGenerator {
|
|
|
282
337
|
const cand1 = path.join(stepFolder, `${stem}.step.ts`);
|
|
283
338
|
const cand2 = path.join(stepFolder, `${stem}.ts`);
|
|
284
339
|
if (fs.existsSync(cand1)) {
|
|
285
|
-
matchedFile = path.relative(
|
|
340
|
+
matchedFile = path.relative(outputTypesDir, cand1).replace(/\\/g, "/").replace(/\.ts$/, ".js");
|
|
286
341
|
break;
|
|
287
342
|
}
|
|
288
343
|
else if (fs.existsSync(cand2)) {
|
|
289
|
-
matchedFile = path.relative(
|
|
344
|
+
matchedFile = path.relative(outputTypesDir, cand2).replace(/\\/g, "/").replace(/\.ts$/, ".js");
|
|
290
345
|
break;
|
|
291
346
|
}
|
|
292
347
|
}
|
|
@@ -304,7 +359,7 @@ export class TypeGenerator {
|
|
|
304
359
|
if (hierarchy.includes(stem) || hierarchy.includes(parts[1])) {
|
|
305
360
|
if (declaredSteps.has(stepName))
|
|
306
361
|
continue;
|
|
307
|
-
let rel = path.relative(
|
|
362
|
+
let rel = path.relative(outputTypesDir, path.join(stepsDir, entry.name)).replace(/\\/g, "/").replace(/\.ts$/, ".js");
|
|
308
363
|
if (!rel.startsWith("."))
|
|
309
364
|
rel = `./${rel}`;
|
|
310
365
|
content += ` ${stepName}: (typeof import('${rel}') extends { default: infer T } ? T : typeof import('${rel}'));\n`;
|
|
@@ -319,8 +374,8 @@ export class TypeGenerator {
|
|
|
319
374
|
}
|
|
320
375
|
return results;
|
|
321
376
|
}
|
|
322
|
-
static
|
|
323
|
-
const fixturesDirs = this.
|
|
377
|
+
static generateFixturesDeclarationForScope(scopeDir, sharedDir) {
|
|
378
|
+
const fixturesDirs = this.getEntityDirsForScope("fixtures", scopeDir, sharedDir);
|
|
324
379
|
let content = `// Auto-generated ambient fixture declarations for TestSpectra\n`;
|
|
325
380
|
content += `// Managed automatically by TestSpectra Language Service Plugin.\n\n`;
|
|
326
381
|
content += `interface TestSpectraFixtures {\n`;
|
|
@@ -345,21 +400,48 @@ export class TypeGenerator {
|
|
|
345
400
|
return content;
|
|
346
401
|
}
|
|
347
402
|
static writeDeclarationFiles(cwd) {
|
|
348
|
-
const
|
|
349
|
-
if (!fs.existsSync(
|
|
350
|
-
fs.mkdirSync(
|
|
403
|
+
const rootTypesDir = path.join(cwd, ".testspectra", "types");
|
|
404
|
+
if (!fs.existsSync(rootTypesDir)) {
|
|
405
|
+
fs.mkdirSync(rootTypesDir, { recursive: true });
|
|
406
|
+
}
|
|
407
|
+
const scopes = this.getEntityScopes(cwd);
|
|
408
|
+
const sharedScope = scopes.find((s) => s.isShared);
|
|
409
|
+
// 1. Generate Global / Standalone Root Types (or fallback)
|
|
410
|
+
const rootFixtures = this.generateFixturesDeclarationForScope(cwd);
|
|
411
|
+
fs.writeFileSync(path.join(rootTypesDir, "fixtures.d.ts"), rootFixtures, "utf-8");
|
|
412
|
+
const rootDeclarations = this.generateDeclarationsForScope(cwd, rootTypesDir, cwd);
|
|
413
|
+
for (const [platform, content] of Object.entries(rootDeclarations)) {
|
|
414
|
+
fs.writeFileSync(path.join(rootTypesDir, `${platform}.d.ts`), content, "utf-8");
|
|
351
415
|
}
|
|
352
|
-
//
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
416
|
+
// 2. Generate Scoped Types for Shared Library: .testspectra/types/shared/
|
|
417
|
+
if (sharedScope) {
|
|
418
|
+
const sharedTypesDir = path.join(rootTypesDir, "shared");
|
|
419
|
+
if (!fs.existsSync(sharedTypesDir))
|
|
420
|
+
fs.mkdirSync(sharedTypesDir, { recursive: true });
|
|
421
|
+
const sharedFixtures = this.generateFixturesDeclarationForScope(sharedScope.dir);
|
|
422
|
+
fs.writeFileSync(path.join(sharedTypesDir, "fixtures.d.ts"), sharedFixtures, "utf-8");
|
|
423
|
+
// Shared scope has NO feature dependencies (only shared itself)
|
|
424
|
+
const sharedDeclarations = this.generateDeclarationsForScope(cwd, sharedTypesDir, sharedScope.dir);
|
|
425
|
+
for (const [platform, content] of Object.entries(sharedDeclarations)) {
|
|
426
|
+
fs.writeFileSync(path.join(sharedTypesDir, `${platform}.d.ts`), content, "utf-8");
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
// 3. Generate Scoped Types for Feature Modules: .testspectra/types/features/<featureName>/
|
|
430
|
+
const featureScopes = scopes.filter((s) => !s.isShared);
|
|
431
|
+
for (const feature of featureScopes) {
|
|
432
|
+
const featureTypesDir = path.join(rootTypesDir, "features", feature.name);
|
|
433
|
+
if (!fs.existsSync(featureTypesDir))
|
|
434
|
+
fs.mkdirSync(featureTypesDir, { recursive: true });
|
|
435
|
+
const featureFixtures = this.generateFixturesDeclarationForScope(feature.dir, sharedScope?.dir);
|
|
436
|
+
fs.writeFileSync(path.join(featureTypesDir, "fixtures.d.ts"), featureFixtures, "utf-8");
|
|
437
|
+
// Feature scope gets (feature + shared) ONLY
|
|
438
|
+
const featureDeclarations = this.generateDeclarationsForScope(cwd, featureTypesDir, feature.dir, sharedScope?.dir);
|
|
439
|
+
for (const [platform, content] of Object.entries(featureDeclarations)) {
|
|
440
|
+
fs.writeFileSync(path.join(featureTypesDir, `${platform}.d.ts`), content, "utf-8");
|
|
441
|
+
}
|
|
360
442
|
}
|
|
361
|
-
//
|
|
362
|
-
const universalPath = path.join(
|
|
443
|
+
// Universal ambient index
|
|
444
|
+
const universalPath = path.join(rootTypesDir, "index.d.ts");
|
|
363
445
|
fs.writeFileSync(universalPath, `/// <reference path="./common.d.ts" />\n`, "utf-8");
|
|
364
446
|
}
|
|
365
447
|
}
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"types": ["node", "@wdio/globals/types", "@wdio/mocha-framework"]
|
|
11
11
|
},
|
|
12
12
|
"include": [
|
|
13
|
-
".testspectra/types/common.d.ts",
|
|
14
|
-
".testspectra/types/fixtures.d.ts",
|
|
13
|
+
".testspectra/types/shared/common.d.ts",
|
|
14
|
+
".testspectra/types/shared/fixtures.d.ts",
|
|
15
15
|
"shared/testing/**/*.ts"
|
|
16
16
|
],
|
|
17
17
|
"exclude": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"DISCOUNT50"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"Laptop Gaming"
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export default class ProductPage {
|
|
2
|
-
static get searchInput(): ChainablePromiseElement {
|
|
3
|
-
return $('~search_input');
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static get categorySelect(): ChainablePromiseElement {
|
|
7
|
-
return $('~category_picker');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static get productList(): ChainablePromiseElement {
|
|
11
|
-
return $('~product_list');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static get firstProductCard(): ChainablePromiseElement {
|
|
15
|
-
return $('~product_item_0');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static get addToCartButton(): ChainablePromiseElement {
|
|
19
|
-
return $('~btn_add_to_cart');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static get cartBadge(): ChainablePromiseElement {
|
|
23
|
-
return $('~cart_badge');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static async open() {
|
|
27
|
-
// Mobile in-app navigation to products tab
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static async filterByCategory(category: string) {
|
|
31
|
-
await Spectra.click(this.categorySelect);
|
|
32
|
-
await Spectra.click(`~option_${category}`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static async addFirstProductToCart() {
|
|
36
|
-
await Spectra.swipe({ direction: "down", distance: 400 });
|
|
37
|
-
await Spectra.click(this.addToCartButton);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export default class ProductPage {
|
|
2
|
-
static get searchInput(): ChainablePromiseElement {
|
|
3
|
-
return $('#search-input');
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static get categorySelect(): ChainablePromiseElement {
|
|
7
|
-
return $('#category-select');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static get productList(): ChainablePromiseElement {
|
|
11
|
-
return $('#product-grid');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static get firstProductCard(): ChainablePromiseElement {
|
|
15
|
-
return $('.product-card');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static get addToCartButton(): ChainablePromiseElement {
|
|
19
|
-
return $('#add-to-cart');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static get cartBadge(): ChainablePromiseElement {
|
|
23
|
-
return $('#cart-count');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static async open() {
|
|
27
|
-
await Spectra.navigate('/products');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static async filterByCategory(category: string) {
|
|
31
|
-
await Spectra.select(this.categorySelect, category);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static async addFirstProductToCart() {
|
|
35
|
-
await Spectra.scroll({ selector: this.firstProductCard });
|
|
36
|
-
await Spectra.click(this.addToCartButton);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
it("should filter products by category and add to cart on Mobile (Android & iOS)", async () => {
|
|
2
|
-
await ProductPage.open();
|
|
3
|
-
await ProductPage.filterByCategory("Electronics");
|
|
4
|
-
await ProductPage.addFirstProductToCart();
|
|
5
|
-
|
|
6
|
-
await ProductPage.cartBadge.shouldBeVisible();
|
|
7
|
-
await ProductPage.cartBadge.shouldHaveText("1");
|
|
8
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
it("should filter products by category and add to cart on Web", async () => {
|
|
2
|
-
await ProductPage.open();
|
|
3
|
-
await ProductPage.filterByCategory("Electronics");
|
|
4
|
-
await ProductPage.addFirstProductToCart();
|
|
5
|
-
|
|
6
|
-
await ProductPage.cartBadge.shouldBeVisible();
|
|
7
|
-
await ProductPage.cartBadge.shouldHaveText("1");
|
|
8
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"DISCOUNT50"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"Laptop Gaming"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"username": "tomsmith", "role": "admin"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "catalog-e2e",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "spectra run",
|
|
8
|
-
"type-check": "tsc -b"
|
|
9
|
-
},
|
|
10
|
-
"devDependencies": {
|
|
11
|
-
"@testspectra/cli": "workspace:*",
|
|
12
|
-
"@types/node": "^20.14.0",
|
|
13
|
-
"@wdio/globals": "^9.2.8",
|
|
14
|
-
"@wdio/mocha-framework": "^9.2.8",
|
|
15
|
-
"webdriverio": "^9.2.8",
|
|
16
|
-
"typescript": "^5.4.5"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export default class LoginPage {
|
|
2
|
-
static get usernameInput(): ChainablePromiseElement {
|
|
3
|
-
return $('~username_input');
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static get passwordInput(): ChainablePromiseElement {
|
|
7
|
-
return $('~password_input');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static get rememberMeCheckbox(): ChainablePromiseElement {
|
|
11
|
-
return $('~remember_me_checkbox');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static get submitButton(): ChainablePromiseElement {
|
|
15
|
-
return $('~login_button');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static get welcomeText(): ChainablePromiseElement {
|
|
19
|
-
return $('~welcome_text');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static async open() {
|
|
23
|
-
// Mobile app launch handled by Appium capabilities
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static async login(username: string, pass: string) {
|
|
27
|
-
await Spectra.waitForElement(this.usernameInput);
|
|
28
|
-
await Spectra.type(this.usernameInput, username, { clearFirst: true });
|
|
29
|
-
await Spectra.type(this.passwordInput, pass, { clearFirst: true });
|
|
30
|
-
await Spectra.click(this.submitButton);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export default class LoginPage {
|
|
2
|
-
static get usernameInput(): ChainablePromiseElement {
|
|
3
|
-
return $('#username');
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static get passwordInput(): ChainablePromiseElement {
|
|
7
|
-
return $('#password');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static get rememberMeCheckbox(): ChainablePromiseElement {
|
|
11
|
-
return $('#remember-me');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static get submitButton(): ChainablePromiseElement {
|
|
15
|
-
return $('button[type="submit"]');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static get flashAlert(): ChainablePromiseElement {
|
|
19
|
-
return $('#flash');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static async open() {
|
|
23
|
-
await Spectra.navigate('/login');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static async login(username: string, pass: string) {
|
|
27
|
-
await Spectra.waitForElement(this.usernameInput);
|
|
28
|
-
await Spectra.type(this.usernameInput, username, { clearFirst: true });
|
|
29
|
-
await Spectra.type(this.passwordInput, pass, { clearFirst: true });
|
|
30
|
-
await Spectra.click(this.submitButton);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export default class ProductPage {
|
|
2
|
-
static get searchInput(): ChainablePromiseElement {
|
|
3
|
-
return $('~search_input');
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static get categorySelect(): ChainablePromiseElement {
|
|
7
|
-
return $('~category_picker');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static get productList(): ChainablePromiseElement {
|
|
11
|
-
return $('~product_list');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static get firstProductCard(): ChainablePromiseElement {
|
|
15
|
-
return $('~product_item_0');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static get addToCartButton(): ChainablePromiseElement {
|
|
19
|
-
return $('~btn_add_to_cart');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static get cartBadge(): ChainablePromiseElement {
|
|
23
|
-
return $('~cart_badge');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static async open() {
|
|
27
|
-
// Mobile in-app navigation to products tab
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static async filterByCategory(category: string) {
|
|
31
|
-
await Spectra.click(this.categorySelect);
|
|
32
|
-
await Spectra.click(`~option_${category}`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static async addFirstProductToCart() {
|
|
36
|
-
await Spectra.swipe({ direction: "down", distance: 400 });
|
|
37
|
-
await Spectra.click(this.addToCartButton);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export default class ProductPage {
|
|
2
|
-
static get searchInput(): ChainablePromiseElement {
|
|
3
|
-
return $('#search-input');
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static get categorySelect(): ChainablePromiseElement {
|
|
7
|
-
return $('#category-select');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static get productList(): ChainablePromiseElement {
|
|
11
|
-
return $('#product-grid');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static get firstProductCard(): ChainablePromiseElement {
|
|
15
|
-
return $('.product-card');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static get addToCartButton(): ChainablePromiseElement {
|
|
19
|
-
return $('#add-to-cart');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static get cartBadge(): ChainablePromiseElement {
|
|
23
|
-
return $('#cart-count');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static async open() {
|
|
27
|
-
await Spectra.navigate('/products');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static async filterByCategory(category: string) {
|
|
31
|
-
await Spectra.select(this.categorySelect, category);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static async addFirstProductToCart() {
|
|
35
|
-
await Spectra.scroll({ selector: this.firstProductCard });
|
|
36
|
-
await Spectra.click(this.addToCartButton);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export default class SettingsPage {
|
|
2
|
-
static get darkModeToggle(): ChainablePromiseElement {
|
|
3
|
-
return $('[data-testid="dark-mode-toggle"]');
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static get languageDropdown(): ChainablePromiseElement {
|
|
7
|
-
return $('[data-testid="language-select"]');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static get saveButton(): ChainablePromiseElement {
|
|
11
|
-
return $('[data-testid="save-settings"]');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static get statusMessage(): ChainablePromiseElement {
|
|
15
|
-
return $('[data-testid="status-message"]');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static async open() {
|
|
19
|
-
await Spectra.navigate('/settings');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static async toggleDarkMode() {
|
|
23
|
-
await Spectra.click(this.darkModeToggle);
|
|
24
|
-
await Spectra.click(this.saveButton);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "catalog-e2e",
|
|
3
|
-
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"projectType": "application",
|
|
5
|
-
"sourceRoot": "modules/catalog/e2e",
|
|
6
|
-
"targets": {
|
|
7
|
-
"e2e": {
|
|
8
|
-
"executor": "nx:run-commands",
|
|
9
|
-
"options": {
|
|
10
|
-
"command": "spectra run",
|
|
11
|
-
"cwd": "modules/catalog/e2e"
|
|
12
|
-
},
|
|
13
|
-
"configurations": {
|
|
14
|
-
"android": {
|
|
15
|
-
"command": "spectra run --target android"
|
|
16
|
-
},
|
|
17
|
-
"ios": {
|
|
18
|
-
"command": "spectra run --target ios"
|
|
19
|
-
},
|
|
20
|
-
"headless": {
|
|
21
|
-
"command": "spectra run --headless"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"type-check": {
|
|
26
|
-
"executor": "nx:run-commands",
|
|
27
|
-
"options": {
|
|
28
|
-
"command": "tsc -b tsconfig.spectra.json",
|
|
29
|
-
"cwd": "."
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"tags": ["scope:catalog", "type:e2e"]
|
|
34
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
it("should authenticate user and verify flash message across specific platforms", async () => {
|
|
2
|
-
await browser.intercept("/api/status", "GET", Fixture.userData);
|
|
3
|
-
|
|
4
|
-
// 1. Navigation via Page Object
|
|
5
|
-
await LoginPage.open();
|
|
6
|
-
|
|
7
|
-
// 2. High-level business flow via Shared Step & Page Object
|
|
8
|
-
await Step.loginUser("tomsmith", "SuperSecretPassword!");
|
|
9
|
-
|
|
10
|
-
// 3. Direct callable assertion on Page Object element
|
|
11
|
-
await LoginPage.flashAlert.shouldBeVisible();
|
|
12
|
-
await LoginPage.flashAlert.shouldContainText("You logged into a secure area!");
|
|
13
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
it("should filter products by category and add to cart on Mobile (Android & iOS)", async () => {
|
|
2
|
-
await ProductPage.open();
|
|
3
|
-
await ProductPage.filterByCategory("Electronics");
|
|
4
|
-
await ProductPage.addFirstProductToCart();
|
|
5
|
-
|
|
6
|
-
await ProductPage.cartBadge.shouldBeVisible();
|
|
7
|
-
await ProductPage.cartBadge.shouldHaveText("1");
|
|
8
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
it("should filter products by category and add to cart on Web", async () => {
|
|
2
|
-
await ProductPage.open();
|
|
3
|
-
await ProductPage.filterByCategory("Electronics");
|
|
4
|
-
await ProductPage.addFirstProductToCart();
|
|
5
|
-
|
|
6
|
-
await ProductPage.cartBadge.shouldBeVisible();
|
|
7
|
-
await ProductPage.cartBadge.shouldHaveText("1");
|
|
8
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
it("should toggle dark mode setting across all platforms (Common)", async () => {
|
|
2
|
-
await SettingsPage.open();
|
|
3
|
-
await SettingsPage.darkModeToggle.shouldBeVisible();
|
|
4
|
-
await SettingsPage.toggleDarkMode();
|
|
5
|
-
|
|
6
|
-
await SettingsPage.statusMessage.shouldBeVisible();
|
|
7
|
-
await SettingsPage.statusMessage.shouldContainText("Settings saved");
|
|
8
|
-
});
|