@testspectra/cli 1.1.7 → 1.1.8-rc.2
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/bin/.testspectra-runner.hash +1 -1
- package/bin/spectra.js +0 -0
- package/bin/testspectra-runner.exe +0 -0
- package/demo-app/assets/index-BhlW-eXG.css +1 -0
- package/demo-app/assets/index-DOtRypCa.js +154 -0
- package/demo-app/index.html +2 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/commands/__tests__/run-e2e.test.js +270 -29
- package/dist/commands/__tests__/run.test.js +92 -16
- package/dist/commands/demo.js +17 -7
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +154 -149
- package/dist/commands/lint.d.ts +5 -0
- package/dist/commands/lint.js +55 -0
- package/dist/commands/refactor.d.ts +2 -1
- package/dist/commands/refactor.js +129 -35
- package/dist/commands/run.d.ts +2 -3
- package/dist/commands/run.js +93 -28
- package/dist/commands/skills.d.ts +9 -0
- package/dist/commands/skills.js +28 -0
- package/dist/commands/sync-types.js +1 -0
- package/dist/commands/test.d.ts +17 -0
- package/dist/commands/test.js +104 -0
- package/dist/commands/watch.js +9 -3
- package/dist/config/loader.js +1 -1
- package/dist/config/schema.d.ts +5 -114
- package/dist/config/schema.js +1 -17
- package/dist/generator/__tests__/tsconfig-isolation.test.js +6 -2
- package/dist/generator/__tests__/type-generator.test.js +1 -1
- package/dist/generator/tsconfig-generator.js +44 -16
- package/dist/generator/type-generator.d.ts +24 -1
- package/dist/generator/type-generator.js +104 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +76 -40
- package/dist/linter/__tests__/anonymous-export.test.js +184 -0
- package/dist/linter/__tests__/component-test-imports.test.d.ts +1 -0
- package/dist/linter/__tests__/component-test-imports.test.js +115 -0
- package/dist/linter/__tests__/shared-lib-boundary.test.d.ts +1 -0
- package/dist/linter/__tests__/shared-lib-boundary.test.js +270 -0
- package/dist/linter/__tests__/spec-schema.test.d.ts +1 -0
- package/dist/linter/__tests__/spec-schema.test.js +369 -0
- package/dist/linter/__tests__/step-parity.test.d.ts +1 -0
- package/dist/linter/__tests__/step-parity.test.js +372 -0
- package/dist/linter/discovery.d.ts +30 -0
- package/dist/linter/discovery.js +249 -0
- package/dist/linter/extractor.d.ts +67 -0
- package/dist/linter/extractor.js +245 -0
- package/dist/linter/index.d.ts +7 -0
- package/dist/linter/index.js +7 -0
- package/dist/linter/parser.d.ts +24 -0
- package/dist/linter/parser.js +219 -0
- package/dist/linter/schemas/spec.schema.d.ts +83 -0
- package/dist/linter/schemas/spec.schema.js +150 -0
- package/dist/linter/schemas/suite.schema.d.ts +59 -0
- package/dist/linter/schemas/suite.schema.js +83 -0
- package/dist/linter/spec-linter.d.ts +23 -0
- package/dist/linter/spec-linter.js +630 -0
- package/dist/linter/types.d.ts +28 -0
- package/dist/linter/types.js +1 -0
- package/dist/refactor/__tests__/refactor-engine.test.js +698 -0
- package/dist/refactor/refactor-engine.d.ts +25 -0
- package/dist/refactor/refactor-engine.js +374 -42
- package/dist/reporter/semantic-formatter.js +22 -2
- package/dist/reporter/types.d.ts +1 -1
- package/dist/runner/bridge.d.ts +1 -1
- package/dist/runner/bridge.js +34 -21
- package/dist/runner/reporter.d.ts +2 -0
- package/dist/runner/reporter.js +11 -3
- package/dist/utils/__tests__/api-server.test.d.ts +1 -0
- package/dist/utils/__tests__/api-server.test.js +62 -0
- package/dist/utils/__tests__/demo-server.test.d.ts +1 -0
- package/dist/utils/__tests__/demo-server.test.js +35 -0
- package/dist/utils/api-server.d.ts +19 -0
- package/dist/utils/api-server.js +179 -0
- package/dist/utils/demo-server.d.ts +5 -0
- package/dist/utils/demo-server.js +8 -1
- package/package.json +29 -25
- package/templates/default/CLAUDE.md +16 -11
- package/templates/default/global-hooks/after/mobile.hook.ts +3 -3
- package/templates/default/global-hooks/after/web.hook.ts +3 -3
- package/templates/default/global-hooks/before/mobile.hook.ts +3 -3
- package/templates/default/global-hooks/before/web.hook.ts +3 -3
- package/templates/default/package.json +3 -3
- package/templates/default/page-objects/AuthPage/mobile.ts +5 -0
- package/templates/default/page-objects/AuthPage/web.ts +10 -0
- package/templates/default/page-objects/MatchersPage/mobile.ts +70 -46
- package/templates/default/page-objects/MatchersPage/web.ts +43 -37
- package/templates/default/page-objects/NavigationPage/mobile.ts +14 -14
- package/templates/default/page-objects/NavigationPage/web.ts +8 -8
- package/templates/default/page-objects/PlaygroundPage/mobile.ts +42 -36
- package/templates/default/page-objects/PlaygroundPage/web.ts +31 -31
- package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/mobile.test.ts +53 -11
- package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/spec.md +19 -12
- package/templates/default/specs/ApiInterception/TC-0008-fetch-mocking/web.test.ts +31 -27
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/android.test.ts +3 -0
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/common.test.ts +3 -0
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/mobile.test.ts +27 -16
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/spec.md +19 -12
- package/templates/default/specs/ApiInterception/TC-0009-post-mocking/web.test.ts +26 -24
- package/templates/default/specs/ApiInterception/TC-0012-direct-and-late-response/common.test.ts +30 -0
- package/templates/default/specs/ApiInterception/TC-0012-direct-and-late-response/spec.md +22 -0
- package/templates/default/specs/ApiInterception/TC-0013-real-network-call-recorded/common.test.ts +27 -0
- package/templates/default/specs/ApiInterception/TC-0013-real-network-call-recorded/spec.md +20 -0
- package/templates/default/specs/ApiInterception/TC-0015-mock-server-sent-events/spec.md +24 -0
- package/templates/default/specs/ApiInterception/TC-0015-mock-server-sent-events/web.test.ts +26 -0
- package/templates/default/specs/ApiInterception/TC-0016-bypass-websocket-with-app-level-mock/spec.md +37 -0
- package/templates/default/specs/ApiInterception/TC-0016-bypass-websocket-with-app-level-mock/web.test.ts +21 -0
- package/templates/default/specs/ApiInterception/TC-0017-bypass-captcha-with-test-mode-flag/spec.md +29 -0
- package/templates/default/specs/ApiInterception/TC-0017-bypass-captcha-with-test-mode-flag/web.test.ts +16 -0
- package/templates/default/specs/ApiInterception/suite.md +10 -9
- package/templates/default/specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/common.test.ts +30 -0
- package/templates/default/specs/ApiSeeding/TC-0014-seed-and-cleanup-via-hooks/spec.md +23 -0
- package/templates/default/specs/ApiSeeding/hooks/after/common.hook.ts +16 -0
- package/templates/default/specs/ApiSeeding/hooks/before/common.hook.ts +28 -0
- package/templates/default/specs/ApiSeeding/suite.md +9 -0
- package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/mobile.test.ts +7 -0
- package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/spec.md +19 -0
- package/templates/default/specs/Authentication/TC-0021-seed-authenticated-session/web.test.ts +9 -0
- package/templates/default/specs/Authentication/suite.md +9 -0
- package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +9 -9
- package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/spec.md +17 -12
- package/templates/default/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +19 -19
- package/templates/default/specs/BrowserContext/TC-0022-history-navigation/mobile.test.ts +17 -0
- package/templates/default/specs/BrowserContext/TC-0022-history-navigation/spec.md +28 -0
- package/templates/default/specs/BrowserContext/TC-0022-history-navigation/web.test.ts +26 -0
- package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/common.test.ts +26 -0
- package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/spec.md +19 -12
- package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +11 -11
- package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/spec.md +17 -12
- package/templates/default/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +11 -11
- package/templates/default/specs/ContentMatchers/TC-0020-scoped-element-access/common.test.ts +14 -0
- package/templates/default/specs/ContentMatchers/TC-0020-scoped-element-access/spec.md +21 -0
- package/templates/default/specs/DeepLink/TC-0018-navigate-via-deep-link/mobile.test.ts +28 -0
- package/templates/default/specs/DeepLink/TC-0018-navigate-via-deep-link/spec.md +29 -0
- package/templates/default/specs/DeepLink/suite.md +9 -0
- package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +11 -11
- package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/spec.md +17 -12
- package/templates/default/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +11 -11
- package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +29 -29
- package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/spec.md +19 -12
- package/templates/default/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +29 -29
- package/templates/default/specs/ElementMatchers/suite.md +10 -9
- package/templates/default/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/common.test.ts +5 -0
- package/templates/default/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/spec.md +16 -0
- package/templates/default/specs/EnvironmentConfig/suite.md +9 -0
- package/templates/default/specs/PermissionRationale/TC-0010-camera-permission-allow/mobile.test.ts +26 -0
- package/templates/default/specs/PermissionRationale/TC-0010-camera-permission-allow/spec.md +22 -0
- package/templates/default/specs/PermissionRationale/TC-0011-camera-permission-deny/mobile.test.ts +13 -0
- package/templates/default/specs/PermissionRationale/TC-0011-camera-permission-deny/spec.md +20 -0
- package/templates/default/specs/PermissionRationale/suite.md +9 -0
- package/templates/default/specs/Playground/TC-0001-form-controls/mobile.test.ts +6 -6
- package/templates/default/specs/Playground/TC-0001-form-controls/spec.md +18 -12
- package/templates/default/specs/Playground/TC-0001-form-controls/web.test.ts +6 -6
- package/templates/default/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +6 -6
- package/templates/default/specs/Playground/TC-0002-toggle-elements/spec.md +18 -12
- package/templates/default/specs/Playground/TC-0002-toggle-elements/web.test.ts +6 -6
- package/templates/default/spectra.config.ts +52 -68
- package/templates/default/support/actions/fillCredentials/mobile.action.ts +4 -4
- package/templates/default/support/actions/fillCredentials/web.action.ts +4 -4
- package/templates/default/support/actions/seedSession/mobile.action.ts +9 -0
- package/templates/default/support/actions/seedSession/web.action.ts +13 -0
- package/templates/default/support/steps/togglePlaygroundStates/mobile.step.ts +5 -5
- package/templates/default/support/steps/togglePlaygroundStates/web.step.ts +5 -5
- package/templates/default/support/steps/verifyPlaygroundState/mobile.step.ts +6 -6
- package/templates/default/support/steps/verifyPlaygroundState/web.step.ts +6 -6
- package/templates/nx/.nx/workspace-data/59842386-c7c4-44ca-b2c2-20e1700bd13d.db +0 -0
- package/templates/nx/.nx/workspace-data/59842386-c7c4-44ca-b2c2-20e1700bd13d.db-shm +0 -0
- package/templates/nx/.nx/workspace-data/59842386-c7c4-44ca-b2c2-20e1700bd13d.db-wal +0 -0
- package/templates/nx/.nx/workspace-data/d/daemon.log +1577 -168
- package/templates/nx/.nx/workspace-data/d/server-process.json +3 -0
- package/templates/nx/.nx/workspace-data/file-map.json +464 -0
- package/templates/nx/.nx/workspace-data/lockfile.hash +1 -0
- package/templates/nx/.nx/workspace-data/nx_files.nxt +0 -0
- package/templates/nx/.nx/workspace-data/parsed-lock-file.json +13485 -0
- package/templates/nx/.nx/workspace-data/project-graph.json +14389 -0
- package/templates/nx/CLAUDE.md +10 -10
- package/templates/nx/package.json +3 -3
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/mobile.test.ts +27 -3
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0008-fetch-mocking/web.test.ts +27 -27
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/mobile.test.ts +24 -3
- package/templates/nx/packages/matchers/e2e/specs/ApiInterception/TC-0009-post-mocking/web.test.ts +24 -24
- package/templates/nx/packages/matchers/e2e/specs/BrowserContext/TC-0007-title-and-navigation/mobile.test.ts +3 -3
- package/templates/nx/packages/matchers/e2e/specs/BrowserContext/TC-0007-title-and-navigation/web.test.ts +19 -19
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0005-text-and-values/mobile.test.ts +3 -3
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0005-text-and-values/web.test.ts +17 -17
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0006-collections-and-empty/mobile.test.ts +3 -3
- package/templates/nx/packages/matchers/e2e/specs/ContentMatchers/TC-0006-collections-and-empty/web.test.ts +11 -11
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0003-visibility-and-dom/mobile.test.ts +3 -3
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0003-visibility-and-dom/web.test.ts +11 -11
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0004-states-and-attributes/mobile.test.ts +3 -3
- package/templates/nx/packages/matchers/e2e/specs/ElementMatchers/TC-0004-states-and-attributes/web.test.ts +29 -29
- package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/common.test.ts +5 -0
- package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/TC-0019-read-custom-environment-variable/spec.md +16 -0
- package/templates/nx/packages/matchers/e2e/specs/EnvironmentConfig/suite.md +9 -0
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0001-form-controls/mobile.test.ts +3 -3
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0001-form-controls/web.test.ts +6 -6
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0002-toggle-elements/mobile.test.ts +3 -3
- package/templates/nx/packages/playground/e2e/specs/Playground/TC-0002-toggle-elements/web.test.ts +6 -6
- package/templates/nx/pnpm-lock.yaml +6663 -6663
- package/templates/nx/pnpm-workspace.yaml +9 -9
- package/templates/nx/shared/testing/page-objects/MatchersPage/mobile.ts +33 -33
- package/templates/nx/shared/testing/page-objects/MatchersPage/web.ts +91 -37
- package/templates/nx/shared/testing/page-objects/NavigationPage/mobile.ts +5 -5
- package/templates/nx/shared/testing/page-objects/NavigationPage/web.ts +8 -8
- package/templates/nx/shared/testing/page-objects/PlaygroundPage/mobile.ts +26 -26
- package/templates/nx/shared/testing/page-objects/PlaygroundPage/web.ts +31 -31
- package/templates/nx/shared/testing/project.json +19 -19
- package/templates/nx/shared/testing/support/actions/fillCredentials/mobile.action.ts +4 -4
- package/templates/nx/shared/testing/support/actions/fillCredentials/web.action.ts +4 -4
- package/templates/nx/shared/testing/support/steps/togglePlaygroundStates/mobile.step.ts +3 -3
- package/templates/nx/shared/testing/support/steps/togglePlaygroundStates/web.step.ts +5 -5
- package/templates/nx/shared/testing/support/steps/verifyPlaygroundState/mobile.step.ts +4 -4
- package/templates/nx/shared/testing/support/steps/verifyPlaygroundState/web.step.ts +6 -6
- package/templates/nx/spectra.config.ts +52 -68
- package/templates/react-component/.cursorrules +17 -0
- package/templates/react-component/.vscode/extensions.json +5 -0
- package/templates/react-component/CLAUDE.md +14 -0
- package/templates/react-component/README.md +69 -0
- package/templates/react-component/fixtures/component-mock.json +12 -0
- package/templates/react-component/global-hooks/after/web.hook.ts +3 -0
- package/templates/react-component/global-hooks/before/web.hook.ts +3 -0
- package/templates/react-component/package.json +27 -0
- package/templates/react-component/page-objects/BadgeComponent/web.ts +23 -0
- package/templates/react-component/page-objects/ButtonComponent/web.ts +23 -0
- package/templates/react-component/page-objects/InputComponent/web.ts +13 -0
- package/templates/react-component/specs/BadgeComponent/TC-0002-badge-severities-and-dot/spec.md +18 -0
- package/templates/react-component/specs/BadgeComponent/TC-0002-badge-severities-and-dot/web.test.tsx +11 -0
- package/templates/react-component/specs/BadgeComponent/TC-0006-badge-success-with-dot/spec.md +18 -0
- package/templates/react-component/specs/BadgeComponent/TC-0006-badge-success-with-dot/web.test.tsx +10 -0
- package/templates/react-component/specs/BadgeComponent/TC-0007-badge-by-severity-lookup/spec.md +18 -0
- package/templates/react-component/specs/BadgeComponent/TC-0007-badge-by-severity-lookup/web.test.tsx +16 -0
- package/templates/react-component/specs/BadgeComponent/suite.md +12 -0
- package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/spec.md +19 -0
- package/templates/react-component/specs/ButtonComponent/TC-0001-button-rendering-and-click/web.test.tsx +28 -0
- package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/spec.md +19 -0
- package/templates/react-component/specs/ButtonComponent/TC-0004-disabled-button-not-clickable/web.test.tsx +22 -0
- package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/spec.md +18 -0
- package/templates/react-component/specs/ButtonComponent/TC-0005-button-renders-icon/web.test.tsx +8 -0
- package/templates/react-component/specs/ButtonComponent/suite.md +12 -0
- package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/spec.md +20 -0
- package/templates/react-component/specs/InputComponent/TC-0003-input-typing-and-clear/web.test.tsx +28 -0
- package/templates/react-component/specs/InputComponent/TC-0008-disabled-input-not-editable/spec.md +18 -0
- package/templates/react-component/specs/InputComponent/TC-0008-disabled-input-not-editable/web.test.tsx +9 -0
- package/templates/react-component/specs/InputComponent/suite.md +12 -0
- package/templates/react-component/spectra.config.ts +27 -0
- package/templates/react-component/src/components/Badge/Badge.tsx +60 -0
- package/templates/react-component/src/components/Button/Button.tsx +57 -0
- package/templates/react-component/src/components/Input/Input.tsx +41 -0
- package/templates/react-component/src/test-utils.tsx +23 -0
- package/templates/react-component/support/actions/fillInputField/web.action.ts +9 -0
- package/templates/react-component/support/steps/verifyButtonState/web.step.ts +12 -0
- package/templates/react-component/tsconfig.json +8 -0
- package/bin/testspectra-runner +0 -0
- package/demo-app/assets/index-DPfv5_EF.js +0 -116
- package/demo-app/assets/index-gIwu2EMV.css +0 -1
- package/dist/commands/__tests__/cloud-run.test.js +0 -93
- package/dist/commands/cloud-run.d.ts +0 -13
- package/dist/commands/cloud-run.js +0 -120
- package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/mobile.test.ts +0 -17
- package/templates/default/specs/ContentMatchers/TC-0005-text-and-values/web.test.ts +0 -17
- /package/dist/{commands/__tests__/cloud-run.test.d.ts → linter/__tests__/anonymous-export.test.d.ts} +0 -0
|
@@ -1,46 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
get visibleElement() { return Spectra.get("~visible-element"); }
|
|
3
|
-
get hiddenElement() { return Spectra.get("~hidden-element"); }
|
|
4
|
-
get existingElement() { return Spectra.get("~existing-element"); }
|
|
5
|
-
get removableElement() { return Spectra.get("~removable-element"); }
|
|
6
|
-
get submitButton() { return Spectra.get("~submit-button"); }
|
|
7
|
-
get disabledButton() { return Spectra.get("~disabled-button"); }
|
|
8
|
-
get checkbox() { return Spectra.get("~terms-checkbox"); }
|
|
9
|
-
get radio() { return Spectra.get("~mode-radio"); }
|
|
10
|
-
get emailInput() { return Spectra.get("~email-input"); }
|
|
11
|
-
get tokenInput() { return Spectra.get("~token-input"); }
|
|
12
|
-
get exactText() { return Spectra.get("~exact-text"); }
|
|
13
|
-
get partialText() { return Spectra.get("~partial-text"); }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
get
|
|
18
|
-
get
|
|
19
|
-
get
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
get
|
|
23
|
-
get
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
get
|
|
31
|
-
get
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
class MatchersPage {
|
|
2
|
+
get visibleElement() { return Spectra.get("~visible-element"); }
|
|
3
|
+
get hiddenElement() { return Spectra.get("~hidden-element"); }
|
|
4
|
+
get existingElement() { return Spectra.get("~existing-element"); }
|
|
5
|
+
get removableElement() { return Spectra.get("~removable-element"); }
|
|
6
|
+
get submitButton() { return Spectra.get("~submit-button"); }
|
|
7
|
+
get disabledButton() { return Spectra.get("~disabled-button"); }
|
|
8
|
+
get checkbox() { return Spectra.get("~terms-checkbox"); }
|
|
9
|
+
get radio() { return Spectra.get("~mode-radio"); }
|
|
10
|
+
get emailInput() { return Spectra.get("~email-input"); }
|
|
11
|
+
get tokenInput() { return Spectra.get("~token-input"); }
|
|
12
|
+
get exactText() { return Spectra.get("~exact-text"); }
|
|
13
|
+
get partialText() { return Spectra.get("~partial-text"); }
|
|
14
|
+
// `#` = native id (RN testID → resource-id). Its accessibility label deliberately reads
|
|
15
|
+
// "active-tab is-active" (RN exposes no CSS classes, so the class is carried in the a11y label
|
|
16
|
+
// for `shouldHaveClass`), so it isn't addressable by the a11y-id form `~active-tab`.
|
|
17
|
+
get activeTab() { return Spectra.get("#active-tab"); }
|
|
18
|
+
get navLink() { return Spectra.get("~nav-link"); }
|
|
19
|
+
get styledElement() { return Spectra.get("~styled-element"); }
|
|
20
|
+
get focusInput() { return Spectra.get("~focus-input"); }
|
|
21
|
+
get productCards() { return Spectra.getAll("~product-item-1, ~product-item-2, ~product-item-3, ~product-item-4"); }
|
|
22
|
+
get emptyList() { return Spectra.getAll("~empty-list-item"); }
|
|
23
|
+
get overviewSection() { return Spectra.get("#overview-section"); }
|
|
24
|
+
// Scoped lookups via element.get() — resolved within overview-section's own bounds (Android
|
|
25
|
+
// has no ancestor API, so this is a bounds-containment lookup), not screen-wide.
|
|
26
|
+
overviewSubtitle() { return this.overviewSection.get("#demo-page-subtitle"); }
|
|
27
|
+
overviewOutsideElement() { return this.overviewSection.get("~submit-button"); }
|
|
28
|
+
|
|
29
|
+
// API Demo elements
|
|
30
|
+
get fetchApiButton() { return Spectra.get("~fetch-api-btn"); }
|
|
31
|
+
get fetchStatusBadge() { return Spectra.get("~fetch-status-badge"); }
|
|
32
|
+
get fetchedItems() { return Spectra.getAll("~api-post-item"); }
|
|
33
|
+
get fetchLoadingIndicator() { return Spectra.get("~fetch-loading-indicator"); }
|
|
34
|
+
get fetchCustomUrlInput() { return Spectra.get("~fetch-custom-url"); }
|
|
35
|
+
get postTitleInput() { return Spectra.get("~post-title-input"); }
|
|
36
|
+
get postBodyInput() { return Spectra.get("~post-body-input"); }
|
|
37
|
+
get submitPostButton() { return Spectra.get("~submit-post-btn"); }
|
|
38
|
+
get postStatusBadge() { return Spectra.get("~post-status-badge"); }
|
|
39
|
+
get postSuccessBanner() { return Spectra.get("~post-success-banner"); }
|
|
40
|
+
get postResponseJson() { return Spectra.get("~post-response-json"); }
|
|
41
|
+
|
|
42
|
+
async open(section = "") {
|
|
43
|
+
try {
|
|
44
|
+
// A fresh app process (relaunched by the orchestrator's bootstrap before every suite) has to
|
|
45
|
+
// fetch, parse, and execute the RN JS bundle from Metro before anything is on screen — on a
|
|
46
|
+
// cold start this can take well past a normal action's poll budget. Wait for the home screen
|
|
47
|
+
// itself first so that timing doesn't silently swallow the sidebar click below and leave the
|
|
48
|
+
// real failure to surface confusingly on whatever element the test touches next.
|
|
49
|
+
await Spectra.get("~toggle-sidebar-btn").waitForElement(30000);
|
|
50
|
+
|
|
51
|
+
const isDrawerOpen = await Spectra.get("~close-sidebar-btn").isDisplayed().catch(() => false);
|
|
52
|
+
if (!isDrawerOpen) {
|
|
53
|
+
await Spectra.get("~toggle-sidebar-btn").click();
|
|
54
|
+
// The mobile drawer is a React Native `<Modal>` — a separate OS-level window with its own
|
|
55
|
+
// slide-in animation, not a plain re-rendered View — so its content (including every
|
|
56
|
+
// nav-item below) isn't in the accessibility tree at all until Android actually finishes
|
|
57
|
+
// creating that window, which is async and occasionally slow under load. Without this
|
|
58
|
+
// wait, clicking a nav item right after the toggle relies entirely on click()'s own
|
|
59
|
+
// poll-retry to bridge that gap, which can eat most of the ~10s implicit-wait budget when
|
|
60
|
+
// the Modal is slow to materialize.
|
|
61
|
+
await Spectra.get("~close-sidebar-btn").waitForElement(10000);
|
|
62
|
+
}
|
|
63
|
+
if (section) {
|
|
64
|
+
await Spectra.get(`~nav-item-${section}`).click();
|
|
65
|
+
}
|
|
66
|
+
} catch {}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default new MatchersPage();
|
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
get visibleElement() { return Spectra.get("#demo-visible-el"); }
|
|
3
|
-
get hiddenElement() { return Spectra.get("#demo-hidden-el"); }
|
|
4
|
-
get existingElement() { return Spectra.get("#demo-existing-el"); }
|
|
5
|
-
get submitButton() { return Spectra.get("#demo-submit-btn"); }
|
|
6
|
-
get disabledButton() { return Spectra.get("#demo-disabled-btn"); }
|
|
7
|
-
get checkbox() { return Spectra.get("#demo-checkbox"); }
|
|
8
|
-
get radio() { return Spectra.get("#demo-radio"); }
|
|
9
|
-
get emailInput() { return Spectra.get("#demo-email-input"); }
|
|
10
|
-
get tokenInput() { return Spectra.get("#demo-token-input"); }
|
|
11
|
-
get exactText() { return Spectra.get("#demo-exact-text"); }
|
|
12
|
-
get partialText() { return Spectra.get("#demo-partial-text"); }
|
|
13
|
-
get activeTab() { return Spectra.get("#demo-active-tab"); }
|
|
14
|
-
get navLink() { return Spectra.get("#demo-nav-link"); }
|
|
15
|
-
get styledElement() { return Spectra.get("#demo-styled-el"); }
|
|
16
|
-
get focusInput() { return Spectra.get("#demo-focus-input"); }
|
|
17
|
-
get productCards() { return Spectra.getAll(".demo-product-card"); }
|
|
18
|
-
get emptyList() { return Spectra.getAll("#demo-empty-list > *"); }
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
get
|
|
27
|
-
get
|
|
28
|
-
get
|
|
29
|
-
get
|
|
30
|
-
get
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
class MatchersPage {
|
|
2
|
+
get visibleElement() { return Spectra.get("#demo-visible-el"); }
|
|
3
|
+
get hiddenElement() { return Spectra.get("#demo-hidden-el"); }
|
|
4
|
+
get existingElement() { return Spectra.get("#demo-existing-el"); }
|
|
5
|
+
get submitButton() { return Spectra.get("#demo-submit-btn"); }
|
|
6
|
+
get disabledButton() { return Spectra.get("#demo-disabled-btn"); }
|
|
7
|
+
get checkbox() { return Spectra.get("#demo-checkbox"); }
|
|
8
|
+
get radio() { return Spectra.get("#demo-radio"); }
|
|
9
|
+
get emailInput() { return Spectra.get("#demo-email-input"); }
|
|
10
|
+
get tokenInput() { return Spectra.get("#demo-token-input"); }
|
|
11
|
+
get exactText() { return Spectra.get("#demo-exact-text"); }
|
|
12
|
+
get partialText() { return Spectra.get("#demo-partial-text"); }
|
|
13
|
+
get activeTab() { return Spectra.get("#demo-active-tab"); }
|
|
14
|
+
get navLink() { return Spectra.get("#demo-nav-link"); }
|
|
15
|
+
get styledElement() { return Spectra.get("#demo-styled-el"); }
|
|
16
|
+
get focusInput() { return Spectra.get("#demo-focus-input"); }
|
|
17
|
+
get productCards() { return Spectra.getAll(".demo-product-card"); }
|
|
18
|
+
get emptyList() { return Spectra.getAll("#demo-empty-list > *"); }
|
|
19
|
+
get overviewSection() { return Spectra.get("#overview"); }
|
|
20
|
+
// Scoped lookups via element.get() — resolved within overview-section's own subtree, not
|
|
21
|
+
// document-wide.
|
|
22
|
+
overviewSubtitle() { return this.overviewSection.get("#demo-page-subtitle"); }
|
|
23
|
+
overviewOutsideElement() { return this.overviewSection.get("#demo-submit-btn"); }
|
|
24
|
+
|
|
25
|
+
// API Interception & Mocking elements
|
|
26
|
+
get fetchApiButton() { return Spectra.get("#fetch-api-btn"); }
|
|
27
|
+
get fetchStatusBadge() { return Spectra.get("#fetch-status-badge"); }
|
|
28
|
+
get fetchedItems() { return Spectra.getAll(".api-fetched-item"); }
|
|
29
|
+
get fetchLoadingIndicator() { return Spectra.get("#fetch-loading-indicator"); }
|
|
30
|
+
get fetchCustomUrlInput() { return Spectra.get("#fetch-custom-url-input"); }
|
|
31
|
+
get postTitleInput() { return Spectra.get("#post-input-title"); }
|
|
32
|
+
get postBodyInput() { return Spectra.get("#post-input-body"); }
|
|
33
|
+
get submitPostButton() { return Spectra.get("#submit-post-btn"); }
|
|
34
|
+
get postStatusBadge() { return Spectra.get("#post-status-badge"); }
|
|
35
|
+
get postSuccessBanner() { return Spectra.get("#post-success-banner"); }
|
|
36
|
+
get postResponseJson() { return Spectra.get("#post-response-json"); }
|
|
37
|
+
|
|
38
|
+
async open(section = "") {
|
|
39
|
+
await Spectra.navigate("/" + (section ? "#" + section : ""));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default new MatchersPage();
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
get sidebarLinks() {
|
|
3
|
-
return Spectra.getAll(
|
|
4
|
-
"~nav-item-overview, ~nav-item-element-matchers, ~nav-item-visibility, ~nav-item-existence, ~nav-item-state, ~nav-item-value, ~nav-item-text, ~nav-item-class-attr, ~nav-item-browser-matchers, ~nav-item-url, ~nav-item-title, ~nav-item-collection-matchers, ~nav-item-length, ~nav-item-api-matchers, ~nav-item-api-fetch, ~nav-item-api-post, ~nav-item-playground"
|
|
5
|
-
);
|
|
6
|
-
}
|
|
7
|
-
get toggleSidebarButton() { return Spectra.get("~toggle-sidebar-btn"); }
|
|
8
|
-
get closeSidebarButton() { return Spectra.get("~close-sidebar-btn"); }
|
|
9
|
-
get overviewLink() { return Spectra.get("~nav-item-overview"); }
|
|
10
|
-
get visibilityLink() { return Spectra.get("~nav-item-visibility"); }
|
|
11
|
-
get playgroundLink() { return Spectra.get("~nav-item-playground"); }
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default new NavigationPage();
|
|
1
|
+
class NavigationPage {
|
|
2
|
+
get sidebarLinks() {
|
|
3
|
+
return Spectra.getAll(
|
|
4
|
+
"~nav-item-overview, ~nav-item-element-matchers, ~nav-item-visibility, ~nav-item-existence, ~nav-item-state, ~nav-item-value, ~nav-item-text, ~nav-item-class-attr, ~nav-item-browser-matchers, ~nav-item-url, ~nav-item-title, ~nav-item-collection-matchers, ~nav-item-length, ~nav-item-api-matchers, ~nav-item-api-fetch, ~nav-item-api-post, ~nav-item-playground"
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
get toggleSidebarButton() { return Spectra.get("~toggle-sidebar-btn"); }
|
|
8
|
+
get closeSidebarButton() { return Spectra.get("~close-sidebar-btn"); }
|
|
9
|
+
get overviewLink() { return Spectra.get("~nav-item-overview"); }
|
|
10
|
+
get visibilityLink() { return Spectra.get("~nav-item-visibility"); }
|
|
11
|
+
get playgroundLink() { return Spectra.get("~nav-item-playground"); }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default new NavigationPage();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
get sidebarLinks() { return Spectra.getAll("aside a"); }
|
|
3
|
-
get overviewLink() { return Spectra.get("aside a[href='#overview']"); }
|
|
4
|
-
get visibilityLink() { return Spectra.get("aside a[href='#visibility']"); }
|
|
5
|
-
get playgroundLink() { return Spectra.get("aside a[href='#playground']"); }
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default new NavigationPage();
|
|
1
|
+
class NavigationPage {
|
|
2
|
+
get sidebarLinks() { return Spectra.getAll("aside a"); }
|
|
3
|
+
get overviewLink() { return Spectra.get("aside a[href='#overview']"); }
|
|
4
|
+
get visibilityLink() { return Spectra.get("aside a[href='#visibility']"); }
|
|
5
|
+
get playgroundLink() { return Spectra.get("aside a[href='#playground']"); }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default new NavigationPage();
|
|
@@ -1,36 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
get visibleElement() { return Spectra.get("~playground-visible"); }
|
|
3
|
-
get hiddenElement() { return Spectra.get("~playground-hidden"); }
|
|
4
|
-
get existingElement() { return Spectra.get("~playground-existing"); }
|
|
5
|
-
get removedElement() { return Spectra.get("~playground-removable"); }
|
|
6
|
-
get enabledButton() { return Spectra.get("~enabled-button"); }
|
|
7
|
-
get disabledButton() { return Spectra.get("~disabled-button"); }
|
|
8
|
-
get termsCheckbox() { return Spectra.get("~terms-checkbox"); }
|
|
9
|
-
get modeRadio() { return Spectra.get("~mode-radio"); }
|
|
10
|
-
get emailInput() { return Spectra.get("~email-input"); }
|
|
11
|
-
get tokenInput() { return Spectra.get("~token-input"); }
|
|
12
|
-
get exactText() { return Spectra.get("~exact-text-el"); }
|
|
13
|
-
get partialText() { return Spectra.get("~partial-text-el"); }
|
|
14
|
-
get activeTab() { return Spectra.get("~active-tab-el"); }
|
|
15
|
-
get navLink() { return Spectra.get("~nav-link-el"); }
|
|
16
|
-
get styledElement() { return Spectra.get("~playground-styled-element"); }
|
|
17
|
-
get focusInput() { return Spectra.get("~playground-focus-input"); }
|
|
18
|
-
get productItems() { return Spectra.getAll("~product-item-1, ~product-item-2, ~product-item-3, ~product-item-4"); }
|
|
19
|
-
get emptyList() { return Spectra.getAll("~empty-list-el-item"); }
|
|
20
|
-
|
|
21
|
-
async open() {
|
|
22
|
-
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
class PlaygroundPage {
|
|
2
|
+
get visibleElement() { return Spectra.get("~playground-visible"); }
|
|
3
|
+
get hiddenElement() { return Spectra.get("~playground-hidden"); }
|
|
4
|
+
get existingElement() { return Spectra.get("~playground-existing"); }
|
|
5
|
+
get removedElement() { return Spectra.get("~playground-removable"); }
|
|
6
|
+
get enabledButton() { return Spectra.get("~enabled-button"); }
|
|
7
|
+
get disabledButton() { return Spectra.get("~pg-disabled-button"); }
|
|
8
|
+
get termsCheckbox() { return Spectra.get("~pg-terms-checkbox"); }
|
|
9
|
+
get modeRadio() { return Spectra.get("~pg-mode-radio"); }
|
|
10
|
+
get emailInput() { return Spectra.get("~pg-email-input"); }
|
|
11
|
+
get tokenInput() { return Spectra.get("~pg-token-input"); }
|
|
12
|
+
get exactText() { return Spectra.get("~exact-text-el"); }
|
|
13
|
+
get partialText() { return Spectra.get("~partial-text-el"); }
|
|
14
|
+
get activeTab() { return Spectra.get("~active-tab-el"); }
|
|
15
|
+
get navLink() { return Spectra.get("~nav-link-el"); }
|
|
16
|
+
get styledElement() { return Spectra.get("~playground-styled-element"); }
|
|
17
|
+
get focusInput() { return Spectra.get("~playground-focus-input"); }
|
|
18
|
+
get productItems() { return Spectra.getAll("~product-item-1, ~product-item-2, ~product-item-3, ~product-item-4"); }
|
|
19
|
+
get emptyList() { return Spectra.getAll("~empty-list-el-item"); }
|
|
20
|
+
|
|
21
|
+
async open() {
|
|
22
|
+
try {
|
|
23
|
+
// See MatchersPage.open()'s equivalent comment: waits for the cold-start home screen, then
|
|
24
|
+
// for the drawer Modal to actually finish materializing before clicking a nav item inside
|
|
25
|
+
// it — both races that otherwise surface as an occasional ~10s stall on the next click.
|
|
26
|
+
await Spectra.get("~toggle-sidebar-btn").waitForElement(30000);
|
|
27
|
+
|
|
28
|
+
const isDrawerOpen = await Spectra.get("~close-sidebar-btn").isDisplayed().catch(() => false);
|
|
29
|
+
if (!isDrawerOpen) {
|
|
30
|
+
await Spectra.get("~toggle-sidebar-btn").click();
|
|
31
|
+
await Spectra.get("~close-sidebar-btn").waitForElement(10000);
|
|
32
|
+
}
|
|
33
|
+
await Spectra.get("~nav-item-playground").click();
|
|
34
|
+
} catch {}
|
|
35
|
+
}
|
|
36
|
+
async fillCredentials(email = Fixture.playgroundData.defaultEmail, token = Fixture.playgroundData.defaultToken) {
|
|
37
|
+
await this.emailInput.type(email);
|
|
38
|
+
await this.tokenInput.type(token);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default new PlaygroundPage();
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
get visibleElement() { return Spectra.get("#demo-visible-el-pg"); }
|
|
3
|
-
get hiddenElement() { return Spectra.get("#demo-hidden-el-pg"); }
|
|
4
|
-
get existingElement() { return Spectra.get("#demo-existing-el-pg"); }
|
|
5
|
-
get removedElement() { return Spectra.get("#demo-removed-el-pg"); }
|
|
6
|
-
get enabledButton() { return Spectra.get("#demo-enabled-btn"); }
|
|
7
|
-
get disabledButton() { return Spectra.get("#demo-disabled-btn-pg"); }
|
|
8
|
-
get termsCheckbox() { return Spectra.get("#demo-terms-checkbox"); }
|
|
9
|
-
get modeRadio() { return Spectra.get("#demo-mode-radio"); }
|
|
10
|
-
get emailInput() { return Spectra.get("#demo-email-input-pg"); }
|
|
11
|
-
get tokenInput() { return Spectra.get("#demo-token-input-pg"); }
|
|
12
|
-
get exactText() { return Spectra.get("#demo-exact-text-pg"); }
|
|
13
|
-
get partialText() { return Spectra.get("#demo-partial-text-pg"); }
|
|
14
|
-
get activeTab() { return Spectra.get("#demo-active-tab-pg"); }
|
|
15
|
-
get navLink() { return Spectra.get("#demo-nav-link-pg"); }
|
|
16
|
-
get styledElement() { return Spectra.get("#demo-styled-el-pg"); }
|
|
17
|
-
get focusInput() { return Spectra.get("#demo-focus-input-pg"); }
|
|
18
|
-
get productItems() { return Spectra.getAll(".demo-product-item"); }
|
|
19
|
-
get emptyList() { return Spectra.getAll("#demo-empty-list-pg > *"); }
|
|
20
|
-
|
|
21
|
-
async open() {
|
|
22
|
-
await
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async fillCredentials(email = Fixture.playgroundData.defaultEmail, token = Fixture.playgroundData.defaultToken) {
|
|
26
|
-
await this.emailInput.type(email);
|
|
27
|
-
await this.tokenInput.type(token);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default new PlaygroundPage();
|
|
1
|
+
class PlaygroundPage {
|
|
2
|
+
get visibleElement() { return Spectra.get("#demo-visible-el-pg"); }
|
|
3
|
+
get hiddenElement() { return Spectra.get("#demo-hidden-el-pg"); }
|
|
4
|
+
get existingElement() { return Spectra.get("#demo-existing-el-pg"); }
|
|
5
|
+
get removedElement() { return Spectra.get("#demo-removed-el-pg"); }
|
|
6
|
+
get enabledButton() { return Spectra.get("#demo-enabled-btn"); }
|
|
7
|
+
get disabledButton() { return Spectra.get("#demo-disabled-btn-pg"); }
|
|
8
|
+
get termsCheckbox() { return Spectra.get("#demo-terms-checkbox"); }
|
|
9
|
+
get modeRadio() { return Spectra.get("#demo-mode-radio"); }
|
|
10
|
+
get emailInput() { return Spectra.get("#demo-email-input-pg"); }
|
|
11
|
+
get tokenInput() { return Spectra.get("#demo-token-input-pg"); }
|
|
12
|
+
get exactText() { return Spectra.get("#demo-exact-text-pg"); }
|
|
13
|
+
get partialText() { return Spectra.get("#demo-partial-text-pg"); }
|
|
14
|
+
get activeTab() { return Spectra.get("#demo-active-tab-pg"); }
|
|
15
|
+
get navLink() { return Spectra.get("#demo-nav-link-pg"); }
|
|
16
|
+
get styledElement() { return Spectra.get("#demo-styled-el-pg"); }
|
|
17
|
+
get focusInput() { return Spectra.get("#demo-focus-input-pg"); }
|
|
18
|
+
get productItems() { return Spectra.getAll(".demo-product-item"); }
|
|
19
|
+
get emptyList() { return Spectra.getAll("#demo-empty-list-pg > *"); }
|
|
20
|
+
|
|
21
|
+
async open() {
|
|
22
|
+
await Spectra.navigate("/#playground");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async fillCredentials(email = Fixture.playgroundData.defaultEmail, token = Fixture.playgroundData.defaultToken) {
|
|
26
|
+
await this.emailInput.type(email);
|
|
27
|
+
await this.tokenInput.type(token);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default new PlaygroundPage();
|
|
@@ -1,11 +1,53 @@
|
|
|
1
|
-
it("
|
|
2
|
-
// Navigate to API Fetch section
|
|
3
|
-
await MatchersPage.open("api-fetch");
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
it("Mock and assert GET API requests using browser.intercept", async () => {
|
|
2
|
+
// Navigate to API Fetch section
|
|
3
|
+
await MatchersPage.open("api-fetch");
|
|
4
|
+
|
|
5
|
+
// The app fetches the host demo server's self-hosted endpoint (http://localhost:5200/api/posts) —
|
|
6
|
+
// the device's global HTTP proxy (set up transparently at bootstrap) routes it through the
|
|
7
|
+
// worker's mock proxy without the app knowing or needing any special host/prefix, the same
|
|
8
|
+
// way the CDP web driver intercepts traffic for free. Clear any mock left registered by an
|
|
9
|
+
// earlier test in this same continuous session before adding this one.
|
|
10
|
+
Spectra.clearMocks();
|
|
11
|
+
const mock = await Spectra.intercept(
|
|
12
|
+
"api/posts",
|
|
13
|
+
"GET",
|
|
14
|
+
Fixture.apiData.mockPosts
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
// Trigger fetch button in mobile demo app
|
|
18
|
+
await MatchersPage.fetchApiButton.click();
|
|
19
|
+
|
|
20
|
+
// Assert status and mocked elements
|
|
21
|
+
await MatchersPage.fetchStatusBadge.shouldHaveText("200 OK");
|
|
22
|
+
await MatchersPage.fetchedItems.shouldHaveLength(Fixture.apiData.mockPosts.length);
|
|
23
|
+
await MatchersPage.fetchedItems.first().shouldContainText(Fixture.apiData.mockPosts[0].title);
|
|
24
|
+
|
|
25
|
+
// Dynamically update fixture response
|
|
26
|
+
await mock.respondWith([
|
|
27
|
+
{ id: 99, title: "Dynamic Updated Mock Title", body: "Updated on the fly" }
|
|
28
|
+
]);
|
|
29
|
+
await MatchersPage.fetchApiButton.click();
|
|
30
|
+
await MatchersPage.fetchedItems.shouldHaveLength(1);
|
|
31
|
+
await MatchersPage.fetchedItems.first().shouldContainText("Dynamic Updated Mock Title");
|
|
32
|
+
|
|
33
|
+
// Reset to the base mock and queue a single one-time response — asserts a transient state
|
|
34
|
+
// (e.g. one retry attempt) without disturbing what every other call returns.
|
|
35
|
+
Spectra.clearMocks();
|
|
36
|
+
const queuedMock = await Spectra.intercept(
|
|
37
|
+
"api/posts",
|
|
38
|
+
"GET",
|
|
39
|
+
Fixture.apiData.mockPosts
|
|
40
|
+
);
|
|
41
|
+
await queuedMock.respondOnce([
|
|
42
|
+
{ id: 777, title: "One-Time Queued Response", body: "Only served once" }
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
await MatchersPage.fetchApiButton.click();
|
|
46
|
+
await MatchersPage.fetchedItems.shouldHaveLength(1);
|
|
47
|
+
await MatchersPage.fetchedItems.first().shouldContainText("One-Time Queued Response");
|
|
48
|
+
|
|
49
|
+
// The queued response is consumed by the call above — this one reverts to the base rule.
|
|
50
|
+
await MatchersPage.fetchApiButton.click();
|
|
51
|
+
await MatchersPage.fetchedItems.shouldHaveLength(Fixture.apiData.mockPosts.length);
|
|
52
|
+
await MatchersPage.fetchedItems.first().shouldContainText(Fixture.apiData.mockPosts[0].title);
|
|
53
|
+
});
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
---
|
|
2
|
-
id: TC-0008-fetch-mocking
|
|
3
|
-
title: Mock and assert GET API requests using browser.intercept
|
|
4
|
-
priority: High
|
|
5
|
-
caseType: Positive
|
|
6
|
-
status: ready-for-automation
|
|
7
|
-
coverage:
|
|
8
|
-
web: automated
|
|
9
|
-
mobile: automated
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# Mock and assert GET API requests using browser.intercept
|
|
1
|
+
---
|
|
2
|
+
id: TC-0008-fetch-mocking
|
|
3
|
+
title: Mock and assert GET API requests using browser.intercept
|
|
4
|
+
priority: High
|
|
5
|
+
caseType: Positive
|
|
6
|
+
status: ready-for-automation
|
|
7
|
+
coverage:
|
|
8
|
+
web: automated
|
|
9
|
+
mobile: automated
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Mock and assert GET API requests using browser.intercept
|
|
13
|
+
|
|
14
|
+
## Test Steps
|
|
15
|
+
1. Open API fetch section in matchers page
|
|
16
|
+
2. Intercept GET /api/posts with mock posts fixture data
|
|
17
|
+
3. Click fetch API button
|
|
18
|
+
4. Assert status badge displays 200 OK and rendered items match fixture
|
|
19
|
+
5. Update mock response dynamically and verify updated items rendered
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
it("
|
|
2
|
-
// Navigate to API Fetch section
|
|
3
|
-
await MatchersPage.open("api-fetch");
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
await MatchersPage.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
await
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
await
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
it("Mock and assert GET API requests using browser.intercept", async () => {
|
|
2
|
+
// Navigate to API Fetch section
|
|
3
|
+
await MatchersPage.open("api-fetch");
|
|
4
|
+
|
|
5
|
+
// The app fetches the demo server's own self-hosted endpoint (/api/posts) — served by the
|
|
6
|
+
// built-in demo app (started with `--demo`), so no external network is involved. Clear any mock
|
|
7
|
+
// left registered by an earlier test in this same continuous session before adding this one,
|
|
8
|
+
// since rules aren't scoped per-test and the first matching rule wins.
|
|
9
|
+
Spectra.clearMocks();
|
|
10
|
+
const mock = await Spectra.intercept(
|
|
11
|
+
"api/posts",
|
|
12
|
+
"GET",
|
|
13
|
+
Fixture.apiData.mockPosts
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// Trigger fetch button
|
|
17
|
+
await MatchersPage.fetchApiButton.click();
|
|
18
|
+
|
|
19
|
+
// Assert status and mocked elements
|
|
20
|
+
await MatchersPage.fetchStatusBadge.shouldHaveText("200 OK");
|
|
21
|
+
await MatchersPage.fetchedItems.shouldHaveLength(Fixture.apiData.mockPosts.length);
|
|
22
|
+
await MatchersPage.fetchedItems.first().shouldContainText(Fixture.apiData.mockPosts[0].title);
|
|
23
|
+
|
|
24
|
+
// Dynamically update fixture response
|
|
25
|
+
await mock.respondWith([
|
|
26
|
+
{ id: 99, title: "Dynamic Updated Mock Title", body: "Updated on the fly" }
|
|
27
|
+
]);
|
|
28
|
+
await MatchersPage.fetchApiButton.click();
|
|
29
|
+
await MatchersPage.fetchedItems.shouldHaveLength(1);
|
|
30
|
+
await MatchersPage.fetchedItems.first().shouldContainText("Dynamic Updated Mock Title");
|
|
31
|
+
});
|
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
it("
|
|
2
|
-
// Navigate to API POST section
|
|
3
|
-
await MatchersPage.open("api-post");
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
it("Mock and assert POST API requests using browser.intercept", async () => {
|
|
2
|
+
// Navigate to API POST section
|
|
3
|
+
await MatchersPage.open("api-post");
|
|
4
|
+
|
|
5
|
+
// Setup POST API interception with status 201 — the app posts to the host demo server's
|
|
6
|
+
// self-hosted endpoint (http://localhost:5200/api/posts), transparently routed through the
|
|
7
|
+
// worker's mock proxy via the device's global HTTP proxy set up at bootstrap.
|
|
8
|
+
Spectra.clearMocks();
|
|
9
|
+
await Spectra.intercept(
|
|
10
|
+
"api/posts",
|
|
11
|
+
"POST",
|
|
12
|
+
Fixture.apiData.mockPostResponse,
|
|
13
|
+
{ statusCode: 201 }
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// Fill in form fields from Fixture
|
|
17
|
+
await MatchersPage.postTitleInput.type(Fixture.apiData.mockNewPost.title);
|
|
18
|
+
await MatchersPage.postBodyInput.type(Fixture.apiData.mockNewPost.body);
|
|
19
|
+
|
|
20
|
+
// Submit POST form
|
|
21
|
+
await MatchersPage.submitPostButton.click();
|
|
22
|
+
|
|
23
|
+
// Assert response elements and status
|
|
24
|
+
await MatchersPage.postStatusBadge.shouldHaveText("201 Created");
|
|
25
|
+
await MatchersPage.postSuccessBanner.shouldBeVisible();
|
|
26
|
+
await MatchersPage.postResponseJson.shouldContainText(Fixture.apiData.mockNewPost.title);
|
|
27
|
+
});
|