@testspectra/cli 1.0.10 → 1.0.12
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/commands/init.d.ts +4 -2
- package/dist/commands/init.js +38 -5
- package/dist/commands/run.js +24 -17
- package/dist/index.js +1 -0
- package/package.json +2 -2
- package/templates/default/tsconfig.android.json +6 -6
- package/templates/default/tsconfig.ios.json +6 -6
- package/templates/default/tsconfig.web.json +8 -8
- package/templates/nx/actions/applyDiscount/mobile.action.ts +6 -0
- package/templates/nx/actions/applyDiscount/web.action.ts +6 -0
- package/templates/nx/actions/verifyOtp/mobile.action.ts +6 -0
- package/templates/nx/actions/verifyOtp/web.action.ts +6 -0
- package/templates/nx/default/actions/applyDiscount/mobile.action.ts +6 -0
- package/templates/nx/default/actions/applyDiscount/web.action.ts +6 -0
- package/templates/nx/default/actions/verifyOtp/mobile.action.ts +6 -0
- package/templates/nx/default/actions/verifyOtp/web.action.ts +6 -0
- package/templates/nx/default/fixtures/couponCode.json +1 -0
- package/templates/nx/default/fixtures/searchQuery.json +1 -0
- package/templates/nx/default/fixtures/userData.json +1 -0
- package/templates/nx/default/global-hooks/before.web.hook.ts +4 -0
- package/templates/nx/default/package.json +18 -0
- package/templates/nx/default/page-objects/LoginPage/mobile.ts +32 -0
- package/templates/nx/default/page-objects/LoginPage/web.ts +32 -0
- package/templates/nx/default/page-objects/ProductPage/mobile.ts +39 -0
- package/templates/nx/default/page-objects/ProductPage/web.ts +38 -0
- package/templates/nx/default/page-objects/SettingsPage/common.ts +26 -0
- package/templates/nx/default/specs/Auth/TC-AUTH-01/android.test.ts +6 -0
- package/templates/nx/default/specs/Auth/TC-AUTH-01/ios.test.ts +6 -0
- package/templates/nx/default/specs/Auth/TC-AUTH-01/web.test.ts +13 -0
- package/templates/nx/default/specs/Auth/TC-AUTH-02/android.test.ts +5 -0
- package/templates/nx/default/specs/Auth/TC-AUTH-02/web.test.ts +5 -0
- package/templates/nx/default/specs/Auth/hooks/before.android.hook.ts +3 -0
- package/templates/nx/default/specs/Auth/hooks/before.ios.hook.ts +3 -0
- package/templates/nx/default/specs/Auth/hooks/before.web.hook.ts +3 -0
- package/templates/nx/default/specs/Product/TC-PROD-01/mobile.test.ts +8 -0
- package/templates/nx/default/specs/Product/TC-PROD-01/web.test.ts +8 -0
- package/templates/nx/default/specs/Product/TC-PROD-02/mobile.test.ts +6 -0
- package/templates/nx/default/specs/Product/TC-PROD-02/web.test.ts +6 -0
- package/templates/nx/default/specs/Product/hooks/before.web.hook.ts +3 -0
- package/templates/nx/default/specs/Settings/TC-SET-01/common.test.ts +8 -0
- package/templates/nx/default/spectra.config.ts +61 -0
- package/templates/nx/default/steps/loginUser/mobile.step.ts +4 -0
- package/templates/nx/default/steps/loginUser/web.step.ts +4 -0
- package/templates/nx/default/steps/searchProduct/mobile.step.ts +5 -0
- package/templates/nx/default/steps/searchProduct/web.step.ts +5 -0
- package/templates/nx/default/tsconfig.android.json +39 -0
- package/templates/nx/default/tsconfig.ios.json +39 -0
- package/templates/nx/default/tsconfig.json +20 -0
- package/templates/nx/default/tsconfig.web.json +45 -0
- package/templates/nx/fixtures/couponCode.json +1 -0
- package/templates/nx/fixtures/searchQuery.json +1 -0
- package/templates/nx/fixtures/userData.json +1 -0
- package/templates/nx/global-hooks/before.web.hook.ts +4 -0
- package/templates/nx/package.json +18 -0
- package/templates/nx/page-objects/LoginPage/mobile.ts +32 -0
- package/templates/nx/page-objects/LoginPage/web.ts +32 -0
- package/templates/nx/page-objects/ProductPage/mobile.ts +39 -0
- package/templates/nx/page-objects/ProductPage/web.ts +38 -0
- package/templates/nx/page-objects/SettingsPage/common.ts +26 -0
- package/templates/nx/project.json +34 -0
- package/templates/nx/specs/Auth/TC-AUTH-01/android.test.ts +6 -0
- package/templates/nx/specs/Auth/TC-AUTH-01/ios.test.ts +6 -0
- package/templates/nx/specs/Auth/TC-AUTH-01/web.test.ts +13 -0
- package/templates/nx/specs/Auth/TC-AUTH-02/android.test.ts +5 -0
- package/templates/nx/specs/Auth/TC-AUTH-02/web.test.ts +5 -0
- package/templates/nx/specs/Auth/hooks/before.android.hook.ts +3 -0
- package/templates/nx/specs/Auth/hooks/before.ios.hook.ts +3 -0
- package/templates/nx/specs/Auth/hooks/before.web.hook.ts +3 -0
- package/templates/nx/specs/Product/TC-PROD-01/mobile.test.ts +8 -0
- package/templates/nx/specs/Product/TC-PROD-01/web.test.ts +8 -0
- package/templates/nx/specs/Product/TC-PROD-02/mobile.test.ts +6 -0
- package/templates/nx/specs/Product/TC-PROD-02/web.test.ts +6 -0
- package/templates/nx/specs/Product/hooks/before.web.hook.ts +3 -0
- package/templates/nx/specs/Settings/TC-SET-01/common.test.ts +8 -0
- package/templates/nx/spectra.config.ts +61 -0
- package/templates/nx/steps/loginUser/mobile.step.ts +4 -0
- package/templates/nx/steps/loginUser/web.step.ts +4 -0
- package/templates/nx/steps/searchProduct/mobile.step.ts +5 -0
- package/templates/nx/steps/searchProduct/web.step.ts +5 -0
- package/templates/nx/tsconfig.android.json +39 -0
- package/templates/nx/tsconfig.ios.json +39 -0
- package/templates/nx/tsconfig.json +20 -0
- package/templates/nx/tsconfig.web.json +45 -0
- /package/templates/default/{suites → specs}/Auth/TC-AUTH-01/android.test.ts +0 -0
- /package/templates/default/{suites → specs}/Auth/TC-AUTH-01/ios.test.ts +0 -0
- /package/templates/default/{suites → specs}/Auth/TC-AUTH-01/web.test.ts +0 -0
- /package/templates/default/{suites → specs}/Auth/TC-AUTH-02/android.test.ts +0 -0
- /package/templates/default/{suites → specs}/Auth/TC-AUTH-02/web.test.ts +0 -0
- /package/templates/default/{suites → specs}/Auth/hooks/before.android.hook.ts +0 -0
- /package/templates/default/{suites → specs}/Auth/hooks/before.ios.hook.ts +0 -0
- /package/templates/default/{suites → specs}/Auth/hooks/before.web.hook.ts +0 -0
- /package/templates/default/{suites → specs}/Product/TC-PROD-01/mobile.test.ts +0 -0
- /package/templates/default/{suites → specs}/Product/TC-PROD-01/web.test.ts +0 -0
- /package/templates/default/{suites → specs}/Product/TC-PROD-02/mobile.test.ts +0 -0
- /package/templates/default/{suites → specs}/Product/TC-PROD-02/web.test.ts +0 -0
- /package/templates/default/{suites → specs}/Product/hooks/before.web.hook.ts +0 -0
- /package/templates/default/{suites → specs}/Settings/TC-SET-01/common.test.ts +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { defineConfig } from "@testspectra/cli";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
webConfig: {
|
|
5
|
+
baseUrl: "https://the-internet.herokuapp.com",
|
|
6
|
+
maxConcurrentSessions: "1",
|
|
7
|
+
headlessMode: true,
|
|
8
|
+
implicitWait: "5000",
|
|
9
|
+
pageLoadTimeout: "30000",
|
|
10
|
+
scriptTimeout: "30000",
|
|
11
|
+
parallelizationMode: "testcase",
|
|
12
|
+
},
|
|
13
|
+
browsers: [
|
|
14
|
+
{
|
|
15
|
+
id: "chrome-desktop",
|
|
16
|
+
type: "chrome",
|
|
17
|
+
mobileEmulation: false,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
androidConfig: {
|
|
21
|
+
appiumServer: "http://127.0.0.1:4723",
|
|
22
|
+
platformName: "Android",
|
|
23
|
+
platformVersion: "13",
|
|
24
|
+
deviceName: "emulator-5554",
|
|
25
|
+
automationName: "UiAutomator2",
|
|
26
|
+
appPackage: "",
|
|
27
|
+
appActivity: "",
|
|
28
|
+
autoGrantPermissions: true,
|
|
29
|
+
noReset: false,
|
|
30
|
+
implicitWait: "10000",
|
|
31
|
+
parallelizationMode: "suite",
|
|
32
|
+
},
|
|
33
|
+
iosConfig: {
|
|
34
|
+
appiumServer: "http://127.0.0.1:4723",
|
|
35
|
+
platformName: "iOS",
|
|
36
|
+
platformVersion: "16.0",
|
|
37
|
+
deviceName: "iPhone 14",
|
|
38
|
+
automationName: "XCUITest",
|
|
39
|
+
bundleId: "",
|
|
40
|
+
udid: "auto",
|
|
41
|
+
xcodeOrgId: "",
|
|
42
|
+
xcodeSigningId: "iPhone Developer",
|
|
43
|
+
autoAcceptAlerts: true,
|
|
44
|
+
noReset: false,
|
|
45
|
+
implicitWait: "10000",
|
|
46
|
+
parallelizationMode: "suite",
|
|
47
|
+
},
|
|
48
|
+
loadConfig: {
|
|
49
|
+
virtualUsers: "10",
|
|
50
|
+
duration: "1m",
|
|
51
|
+
},
|
|
52
|
+
loadStages: [],
|
|
53
|
+
thresholds: [],
|
|
54
|
+
executionConfig: {
|
|
55
|
+
networkMonitoringEnabled: true,
|
|
56
|
+
fastResponseTime: "200",
|
|
57
|
+
normalResponseTime: "1000",
|
|
58
|
+
monitoredDomains: [],
|
|
59
|
+
environmentVariables: [],
|
|
60
|
+
},
|
|
61
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"composite": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"types": ["node", "@wdio/globals/types", "@wdio/mocha-framework"]
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
".testspectra/types/android.d.ts",
|
|
14
|
+
".testspectra/types/fixtures.d.ts",
|
|
15
|
+
"page-objects/**/*.ts",
|
|
16
|
+
"steps/**/*.ts",
|
|
17
|
+
"actions/**/*.ts",
|
|
18
|
+
"global-hooks/**/*.ts",
|
|
19
|
+
"specs/**/hooks/**/*.ts",
|
|
20
|
+
"specs/**/*.ts",
|
|
21
|
+
"spectra.config.ts"
|
|
22
|
+
],
|
|
23
|
+
"exclude": [
|
|
24
|
+
"node_modules",
|
|
25
|
+
"dist",
|
|
26
|
+
"page-objects/**/web.ts",
|
|
27
|
+
"page-objects/**/ios.ts",
|
|
28
|
+
"steps/**/web.step.ts",
|
|
29
|
+
"steps/**/ios.step.ts",
|
|
30
|
+
"actions/**/web.action.ts",
|
|
31
|
+
"actions/**/ios.action.ts",
|
|
32
|
+
"global-hooks/**/web.hook.ts",
|
|
33
|
+
"global-hooks/**/ios.hook.ts",
|
|
34
|
+
"specs/**/hooks/**/web.hook.ts",
|
|
35
|
+
"specs/**/hooks/**/ios.hook.ts",
|
|
36
|
+
"specs/**/web.test.ts",
|
|
37
|
+
"specs/**/ios.test.ts"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"composite": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"types": ["node", "@wdio/globals/types", "@wdio/mocha-framework"]
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
".testspectra/types/ios.d.ts",
|
|
14
|
+
".testspectra/types/fixtures.d.ts",
|
|
15
|
+
"page-objects/**/*.ts",
|
|
16
|
+
"steps/**/*.ts",
|
|
17
|
+
"actions/**/*.ts",
|
|
18
|
+
"global-hooks/**/*.ts",
|
|
19
|
+
"specs/**/hooks/**/*.ts",
|
|
20
|
+
"specs/**/*.ts",
|
|
21
|
+
"spectra.config.ts"
|
|
22
|
+
],
|
|
23
|
+
"exclude": [
|
|
24
|
+
"node_modules",
|
|
25
|
+
"dist",
|
|
26
|
+
"page-objects/**/web.ts",
|
|
27
|
+
"page-objects/**/android.ts",
|
|
28
|
+
"steps/**/web.step.ts",
|
|
29
|
+
"steps/**/android.step.ts",
|
|
30
|
+
"actions/**/web.action.ts",
|
|
31
|
+
"actions/**/android.action.ts",
|
|
32
|
+
"global-hooks/**/web.hook.ts",
|
|
33
|
+
"global-hooks/**/android.hook.ts",
|
|
34
|
+
"specs/**/hooks/**/web.hook.ts",
|
|
35
|
+
"specs/**/hooks/**/android.hook.ts",
|
|
36
|
+
"specs/**/web.test.ts",
|
|
37
|
+
"specs/**/android.test.ts"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"types": ["node", "@wdio/globals/types", "@wdio/mocha-framework"],
|
|
7
|
+
"plugins": [
|
|
8
|
+
{ "name": "@testspectra/cli" }
|
|
9
|
+
],
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"noEmit": true
|
|
13
|
+
},
|
|
14
|
+
"files": [],
|
|
15
|
+
"references": [
|
|
16
|
+
{ "path": "./tsconfig.web.json" },
|
|
17
|
+
{ "path": "./tsconfig.android.json" },
|
|
18
|
+
{ "path": "./tsconfig.ios.json" }
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"composite": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"types": ["node", "@wdio/globals/types", "@wdio/mocha-framework"]
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
".testspectra/types/web.d.ts",
|
|
14
|
+
".testspectra/types/fixtures.d.ts",
|
|
15
|
+
"page-objects/**/*.ts",
|
|
16
|
+
"steps/**/*.ts",
|
|
17
|
+
"actions/**/*.ts",
|
|
18
|
+
"global-hooks/**/*.ts",
|
|
19
|
+
"specs/**/hooks/**/*.ts",
|
|
20
|
+
"specs/**/*.ts",
|
|
21
|
+
"spectra.config.ts"
|
|
22
|
+
],
|
|
23
|
+
"exclude": [
|
|
24
|
+
"node_modules",
|
|
25
|
+
"dist",
|
|
26
|
+
"page-objects/**/android.ts",
|
|
27
|
+
"page-objects/**/ios.ts",
|
|
28
|
+
"page-objects/**/mobile.ts",
|
|
29
|
+
"steps/**/android.step.ts",
|
|
30
|
+
"steps/**/ios.step.ts",
|
|
31
|
+
"steps/**/mobile.step.ts",
|
|
32
|
+
"actions/**/android.action.ts",
|
|
33
|
+
"actions/**/ios.action.ts",
|
|
34
|
+
"actions/**/mobile.action.ts",
|
|
35
|
+
"global-hooks/**/android.hook.ts",
|
|
36
|
+
"global-hooks/**/ios.hook.ts",
|
|
37
|
+
"global-hooks/**/mobile.hook.ts",
|
|
38
|
+
"specs/**/hooks/**/android.hook.ts",
|
|
39
|
+
"specs/**/hooks/**/ios.hook.ts",
|
|
40
|
+
"specs/**/hooks/**/mobile.hook.ts",
|
|
41
|
+
"specs/**/android.test.ts",
|
|
42
|
+
"specs/**/ios.test.ts",
|
|
43
|
+
"specs/**/mobile.test.ts"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"DISCOUNT50"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"Laptop Gaming"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"username": "tomsmith", "role": "admin"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@testspectra/template-nx",
|
|
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
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{PROJECT_NAME}}",
|
|
3
|
+
"$schema": "node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"projectType": "application",
|
|
5
|
+
"sourceRoot": ".",
|
|
6
|
+
"targets": {
|
|
7
|
+
"e2e": {
|
|
8
|
+
"executor": "nx:run-commands",
|
|
9
|
+
"options": {
|
|
10
|
+
"command": "spectra run",
|
|
11
|
+
"cwd": "{{PROJECT_DIR}}"
|
|
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",
|
|
29
|
+
"cwd": "{{PROJECT_DIR}}"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"tags": ["type:e2e", "framework:testspectra"]
|
|
34
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { defineConfig } from "@testspectra/cli";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
webConfig: {
|
|
5
|
+
baseUrl: "https://the-internet.herokuapp.com",
|
|
6
|
+
maxConcurrentSessions: "1",
|
|
7
|
+
headlessMode: true,
|
|
8
|
+
implicitWait: "5000",
|
|
9
|
+
pageLoadTimeout: "30000",
|
|
10
|
+
scriptTimeout: "30000",
|
|
11
|
+
parallelizationMode: "testcase",
|
|
12
|
+
},
|
|
13
|
+
browsers: [
|
|
14
|
+
{
|
|
15
|
+
id: "chrome-desktop",
|
|
16
|
+
type: "chrome",
|
|
17
|
+
mobileEmulation: false,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
androidConfig: {
|
|
21
|
+
appiumServer: "http://127.0.0.1:4723",
|
|
22
|
+
platformName: "Android",
|
|
23
|
+
platformVersion: "13",
|
|
24
|
+
deviceName: "emulator-5554",
|
|
25
|
+
automationName: "UiAutomator2",
|
|
26
|
+
appPackage: "",
|
|
27
|
+
appActivity: "",
|
|
28
|
+
autoGrantPermissions: true,
|
|
29
|
+
noReset: false,
|
|
30
|
+
implicitWait: "10000",
|
|
31
|
+
parallelizationMode: "suite",
|
|
32
|
+
},
|
|
33
|
+
iosConfig: {
|
|
34
|
+
appiumServer: "http://127.0.0.1:4723",
|
|
35
|
+
platformName: "iOS",
|
|
36
|
+
platformVersion: "16.0",
|
|
37
|
+
deviceName: "iPhone 14",
|
|
38
|
+
automationName: "XCUITest",
|
|
39
|
+
bundleId: "",
|
|
40
|
+
udid: "auto",
|
|
41
|
+
xcodeOrgId: "",
|
|
42
|
+
xcodeSigningId: "iPhone Developer",
|
|
43
|
+
autoAcceptAlerts: true,
|
|
44
|
+
noReset: false,
|
|
45
|
+
implicitWait: "10000",
|
|
46
|
+
parallelizationMode: "suite",
|
|
47
|
+
},
|
|
48
|
+
loadConfig: {
|
|
49
|
+
virtualUsers: "10",
|
|
50
|
+
duration: "1m",
|
|
51
|
+
},
|
|
52
|
+
loadStages: [],
|
|
53
|
+
thresholds: [],
|
|
54
|
+
executionConfig: {
|
|
55
|
+
networkMonitoringEnabled: true,
|
|
56
|
+
fastResponseTime: "200",
|
|
57
|
+
normalResponseTime: "1000",
|
|
58
|
+
monitoredDomains: [],
|
|
59
|
+
environmentVariables: [],
|
|
60
|
+
},
|
|
61
|
+
});
|