@testspectra/plugin-demo 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +48 -0
- package/dist/ButtonHandle.d.ts +10 -0
- package/dist/ButtonHandle.js +14 -0
- package/dist/ComponentHandle.d.ts +21 -0
- package/dist/ComponentHandle.js +34 -0
- package/dist/common.d.ts +15 -0
- package/dist/common.js +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +39 -0
- package/dist/web.d.ts +12 -0
- package/dist/web.js +1 -0
- package/package.json +49 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# TestSpectra Commercial Software License Agreement
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TestSpectra. All rights reserved.
|
|
4
|
+
|
|
5
|
+
IMPORTANT NOTICE: This software is NOT open-source. Although distribution archives,
|
|
6
|
+
npm packages, and editor extensions are publicly downloadable, installation,
|
|
7
|
+
execution, and use of the Software are strictly conditioned upon obtaining a valid
|
|
8
|
+
Commercial License or an authorized Evaluation/Trial License from TestSpectra.
|
|
9
|
+
|
|
10
|
+
1. GRANT OF LICENSE
|
|
11
|
+
Subject to payment of applicable license fees or an active authorized evaluation
|
|
12
|
+
period, TestSpectra grants you a non-exclusive, non-transferable, revocable license
|
|
13
|
+
to install and execute the Software solely for authoring, debugging, and executing
|
|
14
|
+
automated software tests.
|
|
15
|
+
|
|
16
|
+
2. LICENSE ACTIVATION & ENFORCEMENT
|
|
17
|
+
- Use of the Software requires activation via a valid License Key, authorized CI token,
|
|
18
|
+
or active TestSpectra Cloud account.
|
|
19
|
+
- Any attempt to circumvent, disable, modify, reverse engineer, or tamper with the
|
|
20
|
+
license verification mechanisms, cryptographic signatures, or binary checks is
|
|
21
|
+
a material breach of this Agreement and automatically terminates your license.
|
|
22
|
+
|
|
23
|
+
3. RESTRICTIONS
|
|
24
|
+
You shall not, and shall not permit any third party to:
|
|
25
|
+
- Decompile, disassemble, reverse engineer, or derive source code from the binaries,
|
|
26
|
+
compiled scripts, or libraries of the Software.
|
|
27
|
+
- Sublicense, sell, rent, lease, distribute, or host the Software as a service for third parties.
|
|
28
|
+
- Re-brand, white-label, or package the Software or any of its components as part of a
|
|
29
|
+
competing commercial QA, testing, or developer tooling product.
|
|
30
|
+
- Modify, alter, or remove any proprietary notices, copyright labels, or license headers.
|
|
31
|
+
|
|
32
|
+
4. INTELLECTUAL PROPERTY
|
|
33
|
+
The Software, including its source code, architecture, Rust core engine, algorithms,
|
|
34
|
+
matchers, extensions, interfaces, and documentation, represents valuable intellectual
|
|
35
|
+
property and trade secrets of TestSpectra.
|
|
36
|
+
|
|
37
|
+
5. TERMINATION
|
|
38
|
+
This license is effective until terminated. Your rights under this license will terminate
|
|
39
|
+
automatically without notice if you fail to comply with any of its terms, or upon expiration
|
|
40
|
+
of your active subscription or trial term. Upon termination, you must cease all use of
|
|
41
|
+
the Software and delete all copies in your possession.
|
|
42
|
+
|
|
43
|
+
6. DISCLAIMER OF WARRANTY & LIMITATION OF LIABILITY
|
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
45
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
46
|
+
PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
47
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
48
|
+
ARISING FROM THE USE OF OR INABILITY TO USE THE SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentHandle } from './ComponentHandle.js';
|
|
2
|
+
/**
|
|
3
|
+
* Button-specific handle returned by the demo plugin's `Spectra.findButton()` command.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ButtonHandle extends ComponentHandle {
|
|
6
|
+
/** Activates the button (aliases `click()` with button-oriented intent). */
|
|
7
|
+
press(): Promise<void>;
|
|
8
|
+
/** Asserts the button's accessible/label text. */
|
|
9
|
+
assertLabel(expected: string | RegExp): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentHandle } from './ComponentHandle.js';
|
|
2
|
+
/**
|
|
3
|
+
* Button-specific handle returned by the demo plugin's `Spectra.findButton()` command.
|
|
4
|
+
*/
|
|
5
|
+
export class ButtonHandle extends ComponentHandle {
|
|
6
|
+
/** Activates the button (aliases `click()` with button-oriented intent). */
|
|
7
|
+
async press() {
|
|
8
|
+
await this.element.click();
|
|
9
|
+
}
|
|
10
|
+
/** Asserts the button's accessible/label text. */
|
|
11
|
+
async assertLabel(expected) {
|
|
12
|
+
await this.element.shouldHaveText(expected);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SingleElementProxy } from '@testspectra/matchers';
|
|
2
|
+
/**
|
|
3
|
+
* Universal wrapper around a single resolved element, exposing a small fluent surface that plugin
|
|
4
|
+
* commands can return. Kept generic on purpose so the plugin is not tied to any one widget type.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ComponentHandle {
|
|
7
|
+
protected readonly element: SingleElementProxy;
|
|
8
|
+
constructor(element: SingleElementProxy);
|
|
9
|
+
/** The underlying Spectra element proxy, for escape-hatch access. */
|
|
10
|
+
get el(): SingleElementProxy;
|
|
11
|
+
/** Clicks the wrapped element. */
|
|
12
|
+
click(): Promise<void>;
|
|
13
|
+
/** Returns the wrapped element's text content. */
|
|
14
|
+
getText(): Promise<string>;
|
|
15
|
+
/** Asserts the wrapped element's text matches `expected`. */
|
|
16
|
+
shouldHaveText(expected: string | RegExp): Promise<void>;
|
|
17
|
+
/** Asserts the wrapped element is visible. */
|
|
18
|
+
shouldBeVisible(): Promise<void>;
|
|
19
|
+
/** Asserts the wrapped element exists in the DOM. */
|
|
20
|
+
shouldExist(): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal wrapper around a single resolved element, exposing a small fluent surface that plugin
|
|
3
|
+
* commands can return. Kept generic on purpose so the plugin is not tied to any one widget type.
|
|
4
|
+
*/
|
|
5
|
+
export class ComponentHandle {
|
|
6
|
+
element;
|
|
7
|
+
constructor(element) {
|
|
8
|
+
this.element = element;
|
|
9
|
+
}
|
|
10
|
+
/** The underlying Spectra element proxy, for escape-hatch access. */
|
|
11
|
+
get el() {
|
|
12
|
+
return this.element;
|
|
13
|
+
}
|
|
14
|
+
/** Clicks the wrapped element. */
|
|
15
|
+
async click() {
|
|
16
|
+
await this.element.click();
|
|
17
|
+
}
|
|
18
|
+
/** Returns the wrapped element's text content. */
|
|
19
|
+
async getText() {
|
|
20
|
+
return await this.element.getText();
|
|
21
|
+
}
|
|
22
|
+
/** Asserts the wrapped element's text matches `expected`. */
|
|
23
|
+
async shouldHaveText(expected) {
|
|
24
|
+
await this.element.shouldHaveText(expected);
|
|
25
|
+
}
|
|
26
|
+
/** Asserts the wrapped element is visible. */
|
|
27
|
+
async shouldBeVisible() {
|
|
28
|
+
await this.element.shouldBeVisible();
|
|
29
|
+
}
|
|
30
|
+
/** Asserts the wrapped element exists in the DOM. */
|
|
31
|
+
async shouldExist() {
|
|
32
|
+
await this.element.shouldExist();
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ButtonHandle } from './ButtonHandle.js';
|
|
2
|
+
import type { ComponentHandle } from './ComponentHandle.js';
|
|
3
|
+
/**
|
|
4
|
+
* Platform-common command types — declared in the `common` stem, so the generator wires them into
|
|
5
|
+
* every platform's ambient declarations (web, android, ios, mobile, common). A command must be
|
|
6
|
+
* declared in exactly one stem file that covers the platforms it supports.
|
|
7
|
+
*/
|
|
8
|
+
declare module '@testspectra/matchers' {
|
|
9
|
+
interface SpectraStatic {
|
|
10
|
+
/** Finds a generic component by selector and returns a universal handle. */
|
|
11
|
+
findComponent(selector: string): ComponentHandle;
|
|
12
|
+
/** Finds a button by selector and returns a button-specific handle. */
|
|
13
|
+
findButton(selector: string): ButtonHandle;
|
|
14
|
+
}
|
|
15
|
+
}
|
package/dist/common.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* # @testspectra/plugin-demo
|
|
4
|
+
*
|
|
5
|
+
* Demo TestSpectra plugin. It is intentionally universal — a small component-interaction kit —
|
|
6
|
+
* and registers `Spectra` commands via `Spectra.registerCommand()`:
|
|
7
|
+
*
|
|
8
|
+
* - `Spectra.findComponent(selector)` → `ComponentHandle` (common: web + android + ios)
|
|
9
|
+
* - `Spectra.findButton(selector)` → `ButtonHandle` (common, the button-specific command)
|
|
10
|
+
* - `Spectra.findByCss(cssSelector)` → `ComponentHandle` (web only)
|
|
11
|
+
*
|
|
12
|
+
* Types are shipped as per-platform-stem subpath entries (`./common`, `./web`) which the type
|
|
13
|
+
* generator wires into the matching platform ambient declarations.
|
|
14
|
+
*
|
|
15
|
+
* Declare it in `spectra.config.ts`:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* executionConfig: { plugins: ['@testspectra/plugin-demo'] }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import type { SpectraPlugin } from '@testspectra/matchers';
|
|
22
|
+
declare const plugin: SpectraPlugin;
|
|
23
|
+
export default plugin;
|
|
24
|
+
export { ButtonHandle } from './ButtonHandle.js';
|
|
25
|
+
export { ComponentHandle } from './ComponentHandle.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* # @testspectra/plugin-demo
|
|
4
|
+
*
|
|
5
|
+
* Demo TestSpectra plugin. It is intentionally universal — a small component-interaction kit —
|
|
6
|
+
* and registers `Spectra` commands via `Spectra.registerCommand()`:
|
|
7
|
+
*
|
|
8
|
+
* - `Spectra.findComponent(selector)` → `ComponentHandle` (common: web + android + ios)
|
|
9
|
+
* - `Spectra.findButton(selector)` → `ButtonHandle` (common, the button-specific command)
|
|
10
|
+
* - `Spectra.findByCss(cssSelector)` → `ComponentHandle` (web only)
|
|
11
|
+
*
|
|
12
|
+
* Types are shipped as per-platform-stem subpath entries (`./common`, `./web`) which the type
|
|
13
|
+
* generator wires into the matching platform ambient declarations.
|
|
14
|
+
*
|
|
15
|
+
* Declare it in `spectra.config.ts`:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* executionConfig: { plugins: ['@testspectra/plugin-demo'] }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { ButtonHandle } from './ButtonHandle.js';
|
|
22
|
+
import { ComponentHandle } from './ComponentHandle.js';
|
|
23
|
+
const plugin = {
|
|
24
|
+
name: '@testspectra/plugin-demo',
|
|
25
|
+
setup(spectra, { platform }) {
|
|
26
|
+
// Common commands: available on every platform.
|
|
27
|
+
spectra.registerCommands({
|
|
28
|
+
findComponent: (selector) => new ComponentHandle(spectra.get(selector)),
|
|
29
|
+
findButton: (selector) => new ButtonHandle(spectra.get(selector)),
|
|
30
|
+
});
|
|
31
|
+
// Web-only command: registered only when running against the web target.
|
|
32
|
+
if (platform === 'web') {
|
|
33
|
+
spectra.registerCommand('findByCss', (cssSelector) => new ComponentHandle(spectra.get(cssSelector)));
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
export default plugin;
|
|
38
|
+
export { ButtonHandle } from './ButtonHandle.js';
|
|
39
|
+
export { ComponentHandle } from './ComponentHandle.js';
|
package/dist/web.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentHandle } from './ComponentHandle.js';
|
|
2
|
+
/**
|
|
3
|
+
* Web-only command types — declared in the `web` stem, so `Spectra.findByCss` is only typed on the
|
|
4
|
+
* web platform (CSS selectors have no meaning on Android/iOS). The command is likewise registered
|
|
5
|
+
* only when the active platform is `web` (see `index.ts`).
|
|
6
|
+
*/
|
|
7
|
+
declare module '@testspectra/matchers' {
|
|
8
|
+
interface SpectraStatic {
|
|
9
|
+
/** Finds a component by raw CSS selector (web only). */
|
|
10
|
+
findByCss(cssSelector: string): ComponentHandle;
|
|
11
|
+
}
|
|
12
|
+
}
|
package/dist/web.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@testspectra/plugin-demo",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Demo TestSpectra plugin — a universal component-interaction kit that registers Spectra commands, including a button-specific one",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"testspectra",
|
|
7
|
+
"spectra",
|
|
8
|
+
"plugin",
|
|
9
|
+
"component-testing"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/TestSpectra/testspectra-source",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/TestSpectra/testspectra-source.git",
|
|
15
|
+
"directory": "tools/plugin-demo"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./common": {
|
|
27
|
+
"types": "./dist/common.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./web": {
|
|
30
|
+
"types": "./dist/web.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@testspectra/matchers": "1.2.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^20.14.0",
|
|
42
|
+
"typescript": "^5.6.3"
|
|
43
|
+
},
|
|
44
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc",
|
|
47
|
+
"typecheck": "tsc --noEmit"
|
|
48
|
+
}
|
|
49
|
+
}
|