@oracle/oraclejet-testing 18.1.5 → 19.0.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/README.md +1 -0
- package/UNSAFE_Driver/TestDriver.cjs +92 -0
- package/UNSAFE_Driver/TestDriver.cjs.map +1 -0
- package/UNSAFE_Driver/TestDriver.d.ts +226 -0
- package/{UNSAFE_driver/Driver.js → UNSAFE_Driver/TestDriver.mjs} +34 -12
- package/UNSAFE_Driver/TestDriver.mjs.map +1 -0
- package/UNSAFE_Driver/index.cjs +19 -0
- package/UNSAFE_Driver/index.cjs.map +1 -0
- package/UNSAFE_Driver/index.d.ts +3 -0
- package/UNSAFE_Driver/index.mjs +4 -0
- package/UNSAFE_Driver/index.mjs.map +1 -0
- package/UNSAFE_Driver/timeouts.cjs +48 -0
- package/UNSAFE_Driver/timeouts.cjs.map +1 -0
- package/UNSAFE_Driver/timeouts.d.ts +62 -0
- package/UNSAFE_Driver/timeouts.mjs +43 -0
- package/UNSAFE_Driver/timeouts.mjs.map +1 -0
- package/UNSAFE_Driver/waitFor.cjs +60 -0
- package/UNSAFE_Driver/waitFor.cjs.map +1 -0
- package/UNSAFE_Driver/waitFor.d.ts +19 -0
- package/UNSAFE_Driver/waitFor.mjs +55 -0
- package/UNSAFE_Driver/waitFor.mjs.map +1 -0
- package/UNSAFE_Locators/index.cjs +29 -0
- package/UNSAFE_Locators/index.cjs.map +1 -0
- package/UNSAFE_Locators/index.d.ts +15 -0
- package/UNSAFE_Locators/index.mjs +24 -0
- package/UNSAFE_Locators/index.mjs.map +1 -0
- package/UNSAFE_TestAdapter/TestAdapter.cjs +46 -0
- package/UNSAFE_TestAdapter/TestAdapter.cjs.map +1 -0
- package/UNSAFE_TestAdapter/TestAdapter.d.ts +27 -0
- package/UNSAFE_TestAdapter/TestAdapter.mjs +42 -0
- package/UNSAFE_TestAdapter/TestAdapter.mjs.map +1 -0
- package/UNSAFE_TestAdapter/index.cjs +10 -0
- package/UNSAFE_TestAdapter/index.cjs.map +1 -0
- package/UNSAFE_TestAdapter/index.d.ts +1 -0
- package/UNSAFE_TestAdapter/index.mjs +2 -0
- package/UNSAFE_TestAdapter/index.mjs.map +1 -0
- package/package.json +26 -5
- package/UNSAFE_driver/Driver.d.ts +0 -73
- package/UNSAFE_driver/index.d.ts +0 -1
- package/UNSAFE_driver/index.js +0 -17
- package/UNSAFE_locators/index.d.ts +0 -19
- package/UNSAFE_locators/index.js +0 -30
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# oraclejet-testing
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var waitFor = require('./waitFor.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A base class for implementing the TestDriver interface. Platform-specific TestDrivers should
|
|
9
|
+
* extend this class to inherit behavior for waiting on conditions.
|
|
10
|
+
*/
|
|
11
|
+
class TestDriverBase {
|
|
12
|
+
/**
|
|
13
|
+
* Wait for a condition to pass.
|
|
14
|
+
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
|
|
15
|
+
* the callback. The truthy return value of the callback will be returned to the caller.
|
|
16
|
+
* @param options Options for wait time/interval
|
|
17
|
+
* @returns A Promise resolving to the returned value from the callback
|
|
18
|
+
*/
|
|
19
|
+
async waitFor(callback, options) {
|
|
20
|
+
return waitFor.waitFor_internal(callback, options);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const ModifierKeys = {
|
|
24
|
+
ALT: { key: 'ALT' },
|
|
25
|
+
CONTROL: { key: 'CONTROL' },
|
|
26
|
+
CONTROL_COMMAND: { key: 'CONTROL_COMMAND' },
|
|
27
|
+
SHIFT: { key: 'SHIFT' }
|
|
28
|
+
};
|
|
29
|
+
const Keys = {
|
|
30
|
+
...ModifierKeys,
|
|
31
|
+
BACKSPACE: { key: 'BACKSPACE' },
|
|
32
|
+
TAB: { key: 'TAB' },
|
|
33
|
+
ENTER: { key: 'ENTER' },
|
|
34
|
+
ESCAPE: { key: 'ESCAPE' },
|
|
35
|
+
PAGE_UP: { key: 'PAGE_UP' },
|
|
36
|
+
PAGE_DOWN: { key: 'PAGE_DOWN' },
|
|
37
|
+
END: { key: 'END' },
|
|
38
|
+
HOME: { key: 'HOME' },
|
|
39
|
+
ARROW_LEFT: { key: 'ARROW_LEFT' },
|
|
40
|
+
ARROW_UP: { key: 'ARROW_UP' },
|
|
41
|
+
ARROW_RIGHT: { key: 'ARROW_RIGHT' },
|
|
42
|
+
ARROW_DOWN: { key: 'ARROW_DOWN' },
|
|
43
|
+
DELETE: { key: 'DELETE' },
|
|
44
|
+
F1: { key: 'F1' },
|
|
45
|
+
F2: { key: 'F2' },
|
|
46
|
+
F3: { key: 'F3' },
|
|
47
|
+
F4: { key: 'F4' },
|
|
48
|
+
F5: { key: 'F5' },
|
|
49
|
+
F6: { key: 'F6' },
|
|
50
|
+
F7: { key: 'F7' },
|
|
51
|
+
F8: { key: 'F8' },
|
|
52
|
+
F9: { key: 'F9' },
|
|
53
|
+
F10: { key: 'F10' },
|
|
54
|
+
F11: { key: 'F11' },
|
|
55
|
+
F12: { key: 'F12' }
|
|
56
|
+
};
|
|
57
|
+
let _driver;
|
|
58
|
+
/**
|
|
59
|
+
* Set the TestDriver instance to be used for testing. This method should be called by
|
|
60
|
+
* tests during setup, before calling any test adapter methods.
|
|
61
|
+
*
|
|
62
|
+
* @param driver The TestDriver instance
|
|
63
|
+
*/
|
|
64
|
+
function setTestDriver(driver) {
|
|
65
|
+
_driver = driver;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the configured TestDriver instance to be used for testing. This method should
|
|
69
|
+
* only be called by test adapters to interact with the browser environment.
|
|
70
|
+
*
|
|
71
|
+
* @returns The TestDriver instance
|
|
72
|
+
*/
|
|
73
|
+
function getTestDriver() {
|
|
74
|
+
if (!_driver) {
|
|
75
|
+
throw Error('Driver has not been set. Call setTestDriver()');
|
|
76
|
+
}
|
|
77
|
+
return _driver;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Unwrap the given TestElement into its driver-specific element
|
|
81
|
+
* @param element
|
|
82
|
+
*/
|
|
83
|
+
function unwrapElement(element) {
|
|
84
|
+
return getTestDriver().unwrapElement(element);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
exports.Keys = Keys;
|
|
88
|
+
exports.TestDriverBase = TestDriverBase;
|
|
89
|
+
exports.getTestDriver = getTestDriver;
|
|
90
|
+
exports.setTestDriver = setTestDriver;
|
|
91
|
+
exports.unwrapElement = unwrapElement;
|
|
92
|
+
//# sourceMappingURL=TestDriver.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestDriver.cjs","sources":["../../src/UNSAFE_Driver/TestDriver.ts"],"sourcesContent":["import { ElementLocator } from '../UNSAFE_Locators';\nimport { type WaitForOptions, waitFor_internal } from './waitFor';\n/**\n * A TestDriver implements the platform-specific commands needed for testing\n * with adapters.\n */\nexport interface TestDriver {\n /**\n * Click on the given TestElement\n * @param element The TestElement on which to click\n */\n click(element: TestElement, options?: ClickOptions): Promise<void>;\n /**\n * Execute a script in the browser environment.\n * Note that if passing a TestElement as an argument, you must first call {@link unwrapElement}\n * on it to pass the driver-specific element to the script.\n * @example\n * const testEl = await this.getElement();\n * await driver.executeScript<number>((el: HTMLElement) => el.clientHeight), unwrapElement(testEl));\n *\n * @param script The script to execute\n * @param args Any arguments to pass to the script. Access each argument through\n * the <code>arguments</code> array.\n */\n executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;\n /**\n * Find an element in the browser environment that matches the given ElementLocator.\n * If an element doesn't exist, this method will wait up to the timeout defined by\n * {@link getTimeouts().elementExistsTimeout}\n * This method throws an exception if no matching elements are found.\n * @param locator\n */\n waitForElement(locator: ElementLocator): Promise<TestElement>;\n /**\n * Find elements in the browser environment matching the given ElementLocator. If no\n * matching elements are found, return a blank array.\n * @param locator\n */\n waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n /**\n * Send text as keystrokes to the browser. If modifier keys are used, all key parameters in the\n * sequence will be combined into a single chord.\n * @param element The element to receive the keystrokes\n * @param text The text value to send, or an array of KeyMap strings to send as a chord of keys\n */\n sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;\n /**\n * Unwrap the given TestElement into its driver-specific element\n * @param element\n */\n unwrapElement<T>(element: TestElement): T;\n}\n\n/**\n * A base class for implementing the TestDriver interface. Platform-specific TestDrivers should\n * extend this class to inherit behavior for waiting on conditions.\n */\nexport abstract class TestDriverBase implements TestDriver {\n /**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @param options Options for wait time/interval\n * @returns A Promise resolving to the returned value from the callback\n */\n async waitFor<T>(callback: () => T | Promise<T>, options?: WaitForOptions) {\n return waitFor_internal(callback, options);\n }\n abstract click(element: TestElement, options?: ClickOptions): Promise<void>;\n abstract executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;\n abstract waitForElement(locator: ElementLocator): Promise<TestElement>;\n abstract waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n abstract sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;\n abstract unwrapElement<T>(element: TestElement): T;\n}\n\n/**\n * A TestElement represents the DOM element in the browser environment. This interface\n * is used by test adapters to work with elements without being bound to a specific\n * platform implementation.\n */\nexport interface TestElement {\n /**\n * Find an element in the browser environment that matches the given ElementLocator.\n * This method should throw an exception if no matching elements are found.\n * @param locator\n */\n waitForElement(locator: ElementLocator): Promise<TestElement>;\n /**\n * Find elements in the browser environment matching the given ElementLocator. If no\n * matching elements are found, return a blank array.\n * @param locator\n */\n waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n /**\n * Get the element's attribute value from the given attrName.\n * @param attrName\n */\n getAttribute(attrName: string): Promise<string | null>;\n}\n\nconst ModifierKeys = {\n ALT: { key: 'ALT' },\n CONTROL: { key: 'CONTROL' },\n CONTROL_COMMAND: { key: 'CONTROL_COMMAND' },\n SHIFT: { key: 'SHIFT' }\n} as const;\n\nexport type ClickOptions = {\n modifiers?: (typeof ModifierKeys)[keyof typeof ModifierKeys][];\n};\n\nexport const Keys = {\n ...ModifierKeys,\n BACKSPACE: { key: 'BACKSPACE' },\n TAB: { key: 'TAB' },\n ENTER: { key: 'ENTER' },\n ESCAPE: { key: 'ESCAPE' },\n PAGE_UP: { key: 'PAGE_UP' },\n PAGE_DOWN: { key: 'PAGE_DOWN' },\n END: { key: 'END' },\n HOME: { key: 'HOME' },\n ARROW_LEFT: { key: 'ARROW_LEFT' },\n ARROW_UP: { key: 'ARROW_UP' },\n ARROW_RIGHT: { key: 'ARROW_RIGHT' },\n ARROW_DOWN: { key: 'ARROW_DOWN' },\n DELETE: { key: 'DELETE' },\n\n F1: { key: 'F1' },\n F2: { key: 'F2' },\n F3: { key: 'F3' },\n F4: { key: 'F4' },\n F5: { key: 'F5' },\n F6: { key: 'F6' },\n F7: { key: 'F7' },\n F8: { key: 'F8' },\n F9: { key: 'F9' },\n F10: { key: 'F10' },\n F11: { key: 'F11' },\n F12: { key: 'F12' }\n} as const;\n\ntype KeysType = Record<keyof typeof Keys, { key: string }>;\nexport type KeyType = KeysType[keyof KeysType];\n\nlet _driver: TestDriver;\n\n/**\n * Set the TestDriver instance to be used for testing. This method should be called by\n * tests during setup, before calling any test adapter methods.\n *\n * @param driver The TestDriver instance\n */\nexport function setTestDriver(driver: TestDriver) {\n _driver = driver;\n}\n\n/**\n * Get the configured TestDriver instance to be used for testing. This method should\n * only be called by test adapters to interact with the browser environment.\n *\n * @returns The TestDriver instance\n */\nexport function getTestDriver() {\n if (!_driver) {\n throw Error('Driver has not been set. Call setTestDriver()');\n }\n return _driver;\n}\n\n/**\n * Unwrap the given TestElement into its driver-specific element\n * @param element\n */\nexport function unwrapElement(element: TestElement) {\n return getTestDriver().unwrapElement(element);\n}\n"],"names":["waitFor_internal"],"mappings":";;;;;;AAqDA;;;AAGG;MACmB,cAAc,CAAA;AAClC;;;;;;AAMG;AACH,IAAA,MAAM,OAAO,CAAI,QAA8B,EAAE,OAAwB,EAAA;AACvE,QAAA,OAAOA,wBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC5C;AAOF,CAAA;AA2BD,MAAM,YAAY,GAAG;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,OAAO,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;AAC3B,IAAA,eAAe,EAAE,EAAE,GAAG,EAAE,iBAAiB,EAAE;AAC3C,IAAA,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;CACf,CAAC;AAME,MAAA,IAAI,GAAG;AAClB,IAAA,GAAG,YAAY;AACf,IAAA,SAAS,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE;AAC/B,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;AACvB,IAAA,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;AACzB,IAAA,OAAO,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;AAC3B,IAAA,SAAS,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE;AAC/B,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;AACrB,IAAA,UAAU,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;AACjC,IAAA,QAAQ,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE;AAC7B,IAAA,WAAW,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE;AACnC,IAAA,UAAU,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;AACjC,IAAA,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;AAEzB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;EACV;AAKX,IAAI,OAAmB,CAAC;AAExB;;;;;AAKG;AACG,SAAU,aAAa,CAAC,MAAkB,EAAA;IAC9C,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAED;;;;;AAKG;SACa,aAAa,GAAA;IAC3B,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAC9D;AACD,IAAA,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;AAGG;AACG,SAAU,aAAa,CAAC,OAAoB,EAAA;AAChD,IAAA,OAAO,aAAa,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAChD;;;;;;;;"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { ElementLocator } from '../UNSAFE_Locators';
|
|
2
|
+
import { type WaitForOptions } from './waitFor';
|
|
3
|
+
/**
|
|
4
|
+
* A TestDriver implements the platform-specific commands needed for testing
|
|
5
|
+
* with adapters.
|
|
6
|
+
*/
|
|
7
|
+
export interface TestDriver {
|
|
8
|
+
/**
|
|
9
|
+
* Click on the given TestElement
|
|
10
|
+
* @param element The TestElement on which to click
|
|
11
|
+
*/
|
|
12
|
+
click(element: TestElement, options?: ClickOptions): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Execute a script in the browser environment.
|
|
15
|
+
* Note that if passing a TestElement as an argument, you must first call {@link unwrapElement}
|
|
16
|
+
* on it to pass the driver-specific element to the script.
|
|
17
|
+
* @example
|
|
18
|
+
* const testEl = await this.getElement();
|
|
19
|
+
* await driver.executeScript<number>((el: HTMLElement) => el.clientHeight), unwrapElement(testEl));
|
|
20
|
+
*
|
|
21
|
+
* @param script The script to execute
|
|
22
|
+
* @param args Any arguments to pass to the script. Access each argument through
|
|
23
|
+
* the <code>arguments</code> array.
|
|
24
|
+
*/
|
|
25
|
+
executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Find an element in the browser environment that matches the given ElementLocator.
|
|
28
|
+
* If an element doesn't exist, this method will wait up to the timeout defined by
|
|
29
|
+
* {@link getTimeouts().elementExistsTimeout}
|
|
30
|
+
* This method throws an exception if no matching elements are found.
|
|
31
|
+
* @param locator
|
|
32
|
+
*/
|
|
33
|
+
waitForElement(locator: ElementLocator): Promise<TestElement>;
|
|
34
|
+
/**
|
|
35
|
+
* Find elements in the browser environment matching the given ElementLocator. If no
|
|
36
|
+
* matching elements are found, return a blank array.
|
|
37
|
+
* @param locator
|
|
38
|
+
*/
|
|
39
|
+
waitForElements(locator: ElementLocator): Promise<TestElement[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Send text as keystrokes to the browser. If modifier keys are used, all key parameters in the
|
|
42
|
+
* sequence will be combined into a single chord.
|
|
43
|
+
* @param element The element to receive the keystrokes
|
|
44
|
+
* @param text The text value to send, or an array of KeyMap strings to send as a chord of keys
|
|
45
|
+
*/
|
|
46
|
+
sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Unwrap the given TestElement into its driver-specific element
|
|
49
|
+
* @param element
|
|
50
|
+
*/
|
|
51
|
+
unwrapElement<T>(element: TestElement): T;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A base class for implementing the TestDriver interface. Platform-specific TestDrivers should
|
|
55
|
+
* extend this class to inherit behavior for waiting on conditions.
|
|
56
|
+
*/
|
|
57
|
+
export declare abstract class TestDriverBase implements TestDriver {
|
|
58
|
+
/**
|
|
59
|
+
* Wait for a condition to pass.
|
|
60
|
+
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
|
|
61
|
+
* the callback. The truthy return value of the callback will be returned to the caller.
|
|
62
|
+
* @param options Options for wait time/interval
|
|
63
|
+
* @returns A Promise resolving to the returned value from the callback
|
|
64
|
+
*/
|
|
65
|
+
waitFor<T>(callback: () => T | Promise<T>, options?: WaitForOptions): Promise<T>;
|
|
66
|
+
abstract click(element: TestElement, options?: ClickOptions): Promise<void>;
|
|
67
|
+
abstract executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;
|
|
68
|
+
abstract waitForElement(locator: ElementLocator): Promise<TestElement>;
|
|
69
|
+
abstract waitForElements(locator: ElementLocator): Promise<TestElement[]>;
|
|
70
|
+
abstract sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;
|
|
71
|
+
abstract unwrapElement<T>(element: TestElement): T;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A TestElement represents the DOM element in the browser environment. This interface
|
|
75
|
+
* is used by test adapters to work with elements without being bound to a specific
|
|
76
|
+
* platform implementation.
|
|
77
|
+
*/
|
|
78
|
+
export interface TestElement {
|
|
79
|
+
/**
|
|
80
|
+
* Find an element in the browser environment that matches the given ElementLocator.
|
|
81
|
+
* This method should throw an exception if no matching elements are found.
|
|
82
|
+
* @param locator
|
|
83
|
+
*/
|
|
84
|
+
waitForElement(locator: ElementLocator): Promise<TestElement>;
|
|
85
|
+
/**
|
|
86
|
+
* Find elements in the browser environment matching the given ElementLocator. If no
|
|
87
|
+
* matching elements are found, return a blank array.
|
|
88
|
+
* @param locator
|
|
89
|
+
*/
|
|
90
|
+
waitForElements(locator: ElementLocator): Promise<TestElement[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Get the element's attribute value from the given attrName.
|
|
93
|
+
* @param attrName
|
|
94
|
+
*/
|
|
95
|
+
getAttribute(attrName: string): Promise<string | null>;
|
|
96
|
+
}
|
|
97
|
+
declare const ModifierKeys: {
|
|
98
|
+
readonly ALT: {
|
|
99
|
+
readonly key: "ALT";
|
|
100
|
+
};
|
|
101
|
+
readonly CONTROL: {
|
|
102
|
+
readonly key: "CONTROL";
|
|
103
|
+
};
|
|
104
|
+
readonly CONTROL_COMMAND: {
|
|
105
|
+
readonly key: "CONTROL_COMMAND";
|
|
106
|
+
};
|
|
107
|
+
readonly SHIFT: {
|
|
108
|
+
readonly key: "SHIFT";
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export type ClickOptions = {
|
|
112
|
+
modifiers?: (typeof ModifierKeys)[keyof typeof ModifierKeys][];
|
|
113
|
+
};
|
|
114
|
+
export declare const Keys: {
|
|
115
|
+
readonly BACKSPACE: {
|
|
116
|
+
readonly key: "BACKSPACE";
|
|
117
|
+
};
|
|
118
|
+
readonly TAB: {
|
|
119
|
+
readonly key: "TAB";
|
|
120
|
+
};
|
|
121
|
+
readonly ENTER: {
|
|
122
|
+
readonly key: "ENTER";
|
|
123
|
+
};
|
|
124
|
+
readonly ESCAPE: {
|
|
125
|
+
readonly key: "ESCAPE";
|
|
126
|
+
};
|
|
127
|
+
readonly PAGE_UP: {
|
|
128
|
+
readonly key: "PAGE_UP";
|
|
129
|
+
};
|
|
130
|
+
readonly PAGE_DOWN: {
|
|
131
|
+
readonly key: "PAGE_DOWN";
|
|
132
|
+
};
|
|
133
|
+
readonly END: {
|
|
134
|
+
readonly key: "END";
|
|
135
|
+
};
|
|
136
|
+
readonly HOME: {
|
|
137
|
+
readonly key: "HOME";
|
|
138
|
+
};
|
|
139
|
+
readonly ARROW_LEFT: {
|
|
140
|
+
readonly key: "ARROW_LEFT";
|
|
141
|
+
};
|
|
142
|
+
readonly ARROW_UP: {
|
|
143
|
+
readonly key: "ARROW_UP";
|
|
144
|
+
};
|
|
145
|
+
readonly ARROW_RIGHT: {
|
|
146
|
+
readonly key: "ARROW_RIGHT";
|
|
147
|
+
};
|
|
148
|
+
readonly ARROW_DOWN: {
|
|
149
|
+
readonly key: "ARROW_DOWN";
|
|
150
|
+
};
|
|
151
|
+
readonly DELETE: {
|
|
152
|
+
readonly key: "DELETE";
|
|
153
|
+
};
|
|
154
|
+
readonly F1: {
|
|
155
|
+
readonly key: "F1";
|
|
156
|
+
};
|
|
157
|
+
readonly F2: {
|
|
158
|
+
readonly key: "F2";
|
|
159
|
+
};
|
|
160
|
+
readonly F3: {
|
|
161
|
+
readonly key: "F3";
|
|
162
|
+
};
|
|
163
|
+
readonly F4: {
|
|
164
|
+
readonly key: "F4";
|
|
165
|
+
};
|
|
166
|
+
readonly F5: {
|
|
167
|
+
readonly key: "F5";
|
|
168
|
+
};
|
|
169
|
+
readonly F6: {
|
|
170
|
+
readonly key: "F6";
|
|
171
|
+
};
|
|
172
|
+
readonly F7: {
|
|
173
|
+
readonly key: "F7";
|
|
174
|
+
};
|
|
175
|
+
readonly F8: {
|
|
176
|
+
readonly key: "F8";
|
|
177
|
+
};
|
|
178
|
+
readonly F9: {
|
|
179
|
+
readonly key: "F9";
|
|
180
|
+
};
|
|
181
|
+
readonly F10: {
|
|
182
|
+
readonly key: "F10";
|
|
183
|
+
};
|
|
184
|
+
readonly F11: {
|
|
185
|
+
readonly key: "F11";
|
|
186
|
+
};
|
|
187
|
+
readonly F12: {
|
|
188
|
+
readonly key: "F12";
|
|
189
|
+
};
|
|
190
|
+
readonly ALT: {
|
|
191
|
+
readonly key: "ALT";
|
|
192
|
+
};
|
|
193
|
+
readonly CONTROL: {
|
|
194
|
+
readonly key: "CONTROL";
|
|
195
|
+
};
|
|
196
|
+
readonly CONTROL_COMMAND: {
|
|
197
|
+
readonly key: "CONTROL_COMMAND";
|
|
198
|
+
};
|
|
199
|
+
readonly SHIFT: {
|
|
200
|
+
readonly key: "SHIFT";
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
type KeysType = Record<keyof typeof Keys, {
|
|
204
|
+
key: string;
|
|
205
|
+
}>;
|
|
206
|
+
export type KeyType = KeysType[keyof KeysType];
|
|
207
|
+
/**
|
|
208
|
+
* Set the TestDriver instance to be used for testing. This method should be called by
|
|
209
|
+
* tests during setup, before calling any test adapter methods.
|
|
210
|
+
*
|
|
211
|
+
* @param driver The TestDriver instance
|
|
212
|
+
*/
|
|
213
|
+
export declare function setTestDriver(driver: TestDriver): void;
|
|
214
|
+
/**
|
|
215
|
+
* Get the configured TestDriver instance to be used for testing. This method should
|
|
216
|
+
* only be called by test adapters to interact with the browser environment.
|
|
217
|
+
*
|
|
218
|
+
* @returns The TestDriver instance
|
|
219
|
+
*/
|
|
220
|
+
export declare function getTestDriver(): TestDriver;
|
|
221
|
+
/**
|
|
222
|
+
* Unwrap the given TestElement into its driver-specific element
|
|
223
|
+
* @param element
|
|
224
|
+
*/
|
|
225
|
+
export declare function unwrapElement(element: TestElement): unknown;
|
|
226
|
+
export {};
|
|
@@ -1,17 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { waitFor_internal } from './waitFor.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A base class for implementing the TestDriver interface. Platform-specific TestDrivers should
|
|
5
|
+
* extend this class to inherit behavior for waiting on conditions.
|
|
6
|
+
*/
|
|
7
|
+
class TestDriverBase {
|
|
8
|
+
/**
|
|
9
|
+
* Wait for a condition to pass.
|
|
10
|
+
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
|
|
11
|
+
* the callback. The truthy return value of the callback will be returned to the caller.
|
|
12
|
+
* @param options Options for wait time/interval
|
|
13
|
+
* @returns A Promise resolving to the returned value from the callback
|
|
14
|
+
*/
|
|
15
|
+
async waitFor(callback, options) {
|
|
16
|
+
return waitFor_internal(callback, options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const ModifierKeys = {
|
|
8
20
|
ALT: { key: 'ALT' },
|
|
9
21
|
CONTROL: { key: 'CONTROL' },
|
|
10
22
|
CONTROL_COMMAND: { key: 'CONTROL_COMMAND' },
|
|
11
23
|
SHIFT: { key: 'SHIFT' }
|
|
12
24
|
};
|
|
13
|
-
|
|
14
|
-
...
|
|
25
|
+
const Keys = {
|
|
26
|
+
...ModifierKeys,
|
|
15
27
|
BACKSPACE: { key: 'BACKSPACE' },
|
|
16
28
|
TAB: { key: 'TAB' },
|
|
17
29
|
ENTER: { key: 'ENTER' },
|
|
@@ -45,7 +57,7 @@ let _driver;
|
|
|
45
57
|
*
|
|
46
58
|
* @param driver The TestDriver instance
|
|
47
59
|
*/
|
|
48
|
-
function
|
|
60
|
+
function setTestDriver(driver) {
|
|
49
61
|
_driver = driver;
|
|
50
62
|
}
|
|
51
63
|
/**
|
|
@@ -54,9 +66,19 @@ function setDriver(driver) {
|
|
|
54
66
|
*
|
|
55
67
|
* @returns The TestDriver instance
|
|
56
68
|
*/
|
|
57
|
-
function
|
|
69
|
+
function getTestDriver() {
|
|
58
70
|
if (!_driver) {
|
|
59
|
-
throw Error('Driver has not been set. Call
|
|
71
|
+
throw Error('Driver has not been set. Call setTestDriver()');
|
|
60
72
|
}
|
|
61
73
|
return _driver;
|
|
62
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Unwrap the given TestElement into its driver-specific element
|
|
77
|
+
* @param element
|
|
78
|
+
*/
|
|
79
|
+
function unwrapElement(element) {
|
|
80
|
+
return getTestDriver().unwrapElement(element);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { Keys, TestDriverBase, getTestDriver, setTestDriver, unwrapElement };
|
|
84
|
+
//# sourceMappingURL=TestDriver.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestDriver.mjs","sources":["../../src/UNSAFE_Driver/TestDriver.ts"],"sourcesContent":["import { ElementLocator } from '../UNSAFE_Locators';\nimport { type WaitForOptions, waitFor_internal } from './waitFor';\n/**\n * A TestDriver implements the platform-specific commands needed for testing\n * with adapters.\n */\nexport interface TestDriver {\n /**\n * Click on the given TestElement\n * @param element The TestElement on which to click\n */\n click(element: TestElement, options?: ClickOptions): Promise<void>;\n /**\n * Execute a script in the browser environment.\n * Note that if passing a TestElement as an argument, you must first call {@link unwrapElement}\n * on it to pass the driver-specific element to the script.\n * @example\n * const testEl = await this.getElement();\n * await driver.executeScript<number>((el: HTMLElement) => el.clientHeight), unwrapElement(testEl));\n *\n * @param script The script to execute\n * @param args Any arguments to pass to the script. Access each argument through\n * the <code>arguments</code> array.\n */\n executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;\n /**\n * Find an element in the browser environment that matches the given ElementLocator.\n * If an element doesn't exist, this method will wait up to the timeout defined by\n * {@link getTimeouts().elementExistsTimeout}\n * This method throws an exception if no matching elements are found.\n * @param locator\n */\n waitForElement(locator: ElementLocator): Promise<TestElement>;\n /**\n * Find elements in the browser environment matching the given ElementLocator. If no\n * matching elements are found, return a blank array.\n * @param locator\n */\n waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n /**\n * Send text as keystrokes to the browser. If modifier keys are used, all key parameters in the\n * sequence will be combined into a single chord.\n * @param element The element to receive the keystrokes\n * @param text The text value to send, or an array of KeyMap strings to send as a chord of keys\n */\n sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;\n /**\n * Unwrap the given TestElement into its driver-specific element\n * @param element\n */\n unwrapElement<T>(element: TestElement): T;\n}\n\n/**\n * A base class for implementing the TestDriver interface. Platform-specific TestDrivers should\n * extend this class to inherit behavior for waiting on conditions.\n */\nexport abstract class TestDriverBase implements TestDriver {\n /**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @param options Options for wait time/interval\n * @returns A Promise resolving to the returned value from the callback\n */\n async waitFor<T>(callback: () => T | Promise<T>, options?: WaitForOptions) {\n return waitFor_internal(callback, options);\n }\n abstract click(element: TestElement, options?: ClickOptions): Promise<void>;\n abstract executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;\n abstract waitForElement(locator: ElementLocator): Promise<TestElement>;\n abstract waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n abstract sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;\n abstract unwrapElement<T>(element: TestElement): T;\n}\n\n/**\n * A TestElement represents the DOM element in the browser environment. This interface\n * is used by test adapters to work with elements without being bound to a specific\n * platform implementation.\n */\nexport interface TestElement {\n /**\n * Find an element in the browser environment that matches the given ElementLocator.\n * This method should throw an exception if no matching elements are found.\n * @param locator\n */\n waitForElement(locator: ElementLocator): Promise<TestElement>;\n /**\n * Find elements in the browser environment matching the given ElementLocator. If no\n * matching elements are found, return a blank array.\n * @param locator\n */\n waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n /**\n * Get the element's attribute value from the given attrName.\n * @param attrName\n */\n getAttribute(attrName: string): Promise<string | null>;\n}\n\nconst ModifierKeys = {\n ALT: { key: 'ALT' },\n CONTROL: { key: 'CONTROL' },\n CONTROL_COMMAND: { key: 'CONTROL_COMMAND' },\n SHIFT: { key: 'SHIFT' }\n} as const;\n\nexport type ClickOptions = {\n modifiers?: (typeof ModifierKeys)[keyof typeof ModifierKeys][];\n};\n\nexport const Keys = {\n ...ModifierKeys,\n BACKSPACE: { key: 'BACKSPACE' },\n TAB: { key: 'TAB' },\n ENTER: { key: 'ENTER' },\n ESCAPE: { key: 'ESCAPE' },\n PAGE_UP: { key: 'PAGE_UP' },\n PAGE_DOWN: { key: 'PAGE_DOWN' },\n END: { key: 'END' },\n HOME: { key: 'HOME' },\n ARROW_LEFT: { key: 'ARROW_LEFT' },\n ARROW_UP: { key: 'ARROW_UP' },\n ARROW_RIGHT: { key: 'ARROW_RIGHT' },\n ARROW_DOWN: { key: 'ARROW_DOWN' },\n DELETE: { key: 'DELETE' },\n\n F1: { key: 'F1' },\n F2: { key: 'F2' },\n F3: { key: 'F3' },\n F4: { key: 'F4' },\n F5: { key: 'F5' },\n F6: { key: 'F6' },\n F7: { key: 'F7' },\n F8: { key: 'F8' },\n F9: { key: 'F9' },\n F10: { key: 'F10' },\n F11: { key: 'F11' },\n F12: { key: 'F12' }\n} as const;\n\ntype KeysType = Record<keyof typeof Keys, { key: string }>;\nexport type KeyType = KeysType[keyof KeysType];\n\nlet _driver: TestDriver;\n\n/**\n * Set the TestDriver instance to be used for testing. This method should be called by\n * tests during setup, before calling any test adapter methods.\n *\n * @param driver The TestDriver instance\n */\nexport function setTestDriver(driver: TestDriver) {\n _driver = driver;\n}\n\n/**\n * Get the configured TestDriver instance to be used for testing. This method should\n * only be called by test adapters to interact with the browser environment.\n *\n * @returns The TestDriver instance\n */\nexport function getTestDriver() {\n if (!_driver) {\n throw Error('Driver has not been set. Call setTestDriver()');\n }\n return _driver;\n}\n\n/**\n * Unwrap the given TestElement into its driver-specific element\n * @param element\n */\nexport function unwrapElement(element: TestElement) {\n return getTestDriver().unwrapElement(element);\n}\n"],"names":[],"mappings":";;AAqDA;;;AAGG;MACmB,cAAc,CAAA;AAClC;;;;;;AAMG;AACH,IAAA,MAAM,OAAO,CAAI,QAA8B,EAAE,OAAwB,EAAA;AACvE,QAAA,OAAO,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC5C;AAOF,CAAA;AA2BD,MAAM,YAAY,GAAG;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,OAAO,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;AAC3B,IAAA,eAAe,EAAE,EAAE,GAAG,EAAE,iBAAiB,EAAE;AAC3C,IAAA,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;CACf,CAAC;AAME,MAAA,IAAI,GAAG;AAClB,IAAA,GAAG,YAAY;AACf,IAAA,SAAS,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE;AAC/B,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;AACvB,IAAA,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;AACzB,IAAA,OAAO,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;AAC3B,IAAA,SAAS,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE;AAC/B,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;AACrB,IAAA,UAAU,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;AACjC,IAAA,QAAQ,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE;AAC7B,IAAA,WAAW,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE;AACnC,IAAA,UAAU,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;AACjC,IAAA,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;AAEzB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;EACV;AAKX,IAAI,OAAmB,CAAC;AAExB;;;;;AAKG;AACG,SAAU,aAAa,CAAC,MAAkB,EAAA;IAC9C,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAED;;;;;AAKG;SACa,aAAa,GAAA;IAC3B,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAC9D;AACD,IAAA,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;AAGG;AACG,SAAU,aAAa,CAAC,OAAoB,EAAA;AAChD,IAAA,OAAO,aAAa,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAChD;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var TestDriver = require('./TestDriver.cjs');
|
|
6
|
+
var timeouts = require('./timeouts.cjs');
|
|
7
|
+
var waitFor = require('./waitFor.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.Keys = TestDriver.Keys;
|
|
12
|
+
exports.TestDriverBase = TestDriver.TestDriverBase;
|
|
13
|
+
exports.getTestDriver = TestDriver.getTestDriver;
|
|
14
|
+
exports.setTestDriver = TestDriver.setTestDriver;
|
|
15
|
+
exports.unwrapElement = TestDriver.unwrapElement;
|
|
16
|
+
exports.getTimeouts = timeouts.getTimeouts;
|
|
17
|
+
exports.setTimeouts = timeouts.setTimeouts;
|
|
18
|
+
exports.waitFor = waitFor.waitFor;
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const _timeouts = {
|
|
6
|
+
/**
|
|
7
|
+
* The window of time to wait for an element to exist in the DOM.
|
|
8
|
+
* Set to 0 to wait indefinitely.
|
|
9
|
+
* Defaults to 1000
|
|
10
|
+
*/
|
|
11
|
+
elementExistsTimeout: 1000,
|
|
12
|
+
/**
|
|
13
|
+
* The window of time to wait for a remote script to complete execution.
|
|
14
|
+
* Set to 0 to wait indefinitely.
|
|
15
|
+
* Defaults to 30000
|
|
16
|
+
*/
|
|
17
|
+
scriptTimeout: 30 * 1000,
|
|
18
|
+
/**
|
|
19
|
+
* The window of time with which the waitFor() function will retry the callback.
|
|
20
|
+
* Set to 0 to wait indefinitely.
|
|
21
|
+
* Defaults to 30000
|
|
22
|
+
*/
|
|
23
|
+
waitForTimeout: 30 * 1000,
|
|
24
|
+
/**
|
|
25
|
+
* The delay between polling calls that waitFor() will wait before retrying the callback.
|
|
26
|
+
* Defaults to 100
|
|
27
|
+
*/
|
|
28
|
+
pollingInterval: 100
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Set the default timeouts for the TestDriver in milliseconds.
|
|
32
|
+
* Every property is optional, and can be partially set.
|
|
33
|
+
* @param timeouts
|
|
34
|
+
*/
|
|
35
|
+
function setTimeouts(timeouts) {
|
|
36
|
+
Object.assign(_timeouts, timeouts);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the default timeouts set for the TestDriver
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
function getTimeouts() {
|
|
43
|
+
return { ..._timeouts };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.getTimeouts = getTimeouts;
|
|
47
|
+
exports.setTimeouts = setTimeouts;
|
|
48
|
+
//# sourceMappingURL=timeouts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeouts.cjs","sources":["../../src/UNSAFE_Driver/timeouts.ts"],"sourcesContent":["const _timeouts = {\n /**\n * The window of time to wait for an element to exist in the DOM.\n * Set to 0 to wait indefinitely.\n * Defaults to 1000\n */\n elementExistsTimeout: 1000,\n /**\n * The window of time to wait for a remote script to complete execution.\n * Set to 0 to wait indefinitely.\n * Defaults to 30000\n */\n scriptTimeout: 30 * 1000,\n /**\n * The window of time with which the waitFor() function will retry the callback.\n * Set to 0 to wait indefinitely.\n * Defaults to 30000\n */\n waitForTimeout: 30 * 1000,\n /**\n * The delay between polling calls that waitFor() will wait before retrying the callback.\n * Defaults to 100\n */\n pollingInterval: 100\n};\n\nexport type TimeoutsType = typeof _timeouts;\n\n/**\n * Set the default timeouts for the TestDriver in milliseconds.\n * Every property is optional, and can be partially set.\n * @param timeouts\n */\nexport function setTimeouts(timeouts: Partial<TimeoutsType>) {\n Object.assign(_timeouts, timeouts);\n}\n\n/**\n * Get the default timeouts set for the TestDriver\n * @returns\n */\nexport function getTimeouts() {\n return { ..._timeouts };\n}\n"],"names":[],"mappings":";;;;AAAA,MAAM,SAAS,GAAG;AAChB;;;;AAIG;AACH,IAAA,oBAAoB,EAAE,IAAI;AAC1B;;;;AAIG;IACH,aAAa,EAAE,EAAE,GAAG,IAAI;AACxB;;;;AAIG;IACH,cAAc,EAAE,EAAE,GAAG,IAAI;AACzB;;;AAGG;AACH,IAAA,eAAe,EAAE,GAAG;CACrB,CAAC;AAIF;;;;AAIG;AACG,SAAU,WAAW,CAAC,QAA+B,EAAA;AACzD,IAAA,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED;;;AAGG;SACa,WAAW,GAAA;AACzB,IAAA,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;AAC1B;;;;;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
declare const _timeouts: {
|
|
2
|
+
/**
|
|
3
|
+
* The window of time to wait for an element to exist in the DOM.
|
|
4
|
+
* Set to 0 to wait indefinitely.
|
|
5
|
+
* Defaults to 1000
|
|
6
|
+
*/
|
|
7
|
+
elementExistsTimeout: number;
|
|
8
|
+
/**
|
|
9
|
+
* The window of time to wait for a remote script to complete execution.
|
|
10
|
+
* Set to 0 to wait indefinitely.
|
|
11
|
+
* Defaults to 30000
|
|
12
|
+
*/
|
|
13
|
+
scriptTimeout: number;
|
|
14
|
+
/**
|
|
15
|
+
* The window of time with which the waitFor() function will retry the callback.
|
|
16
|
+
* Set to 0 to wait indefinitely.
|
|
17
|
+
* Defaults to 30000
|
|
18
|
+
*/
|
|
19
|
+
waitForTimeout: number;
|
|
20
|
+
/**
|
|
21
|
+
* The delay between polling calls that waitFor() will wait before retrying the callback.
|
|
22
|
+
* Defaults to 100
|
|
23
|
+
*/
|
|
24
|
+
pollingInterval: number;
|
|
25
|
+
};
|
|
26
|
+
export type TimeoutsType = typeof _timeouts;
|
|
27
|
+
/**
|
|
28
|
+
* Set the default timeouts for the TestDriver in milliseconds.
|
|
29
|
+
* Every property is optional, and can be partially set.
|
|
30
|
+
* @param timeouts
|
|
31
|
+
*/
|
|
32
|
+
export declare function setTimeouts(timeouts: Partial<TimeoutsType>): void;
|
|
33
|
+
/**
|
|
34
|
+
* Get the default timeouts set for the TestDriver
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export declare function getTimeouts(): {
|
|
38
|
+
/**
|
|
39
|
+
* The window of time to wait for an element to exist in the DOM.
|
|
40
|
+
* Set to 0 to wait indefinitely.
|
|
41
|
+
* Defaults to 1000
|
|
42
|
+
*/
|
|
43
|
+
elementExistsTimeout: number;
|
|
44
|
+
/**
|
|
45
|
+
* The window of time to wait for a remote script to complete execution.
|
|
46
|
+
* Set to 0 to wait indefinitely.
|
|
47
|
+
* Defaults to 30000
|
|
48
|
+
*/
|
|
49
|
+
scriptTimeout: number;
|
|
50
|
+
/**
|
|
51
|
+
* The window of time with which the waitFor() function will retry the callback.
|
|
52
|
+
* Set to 0 to wait indefinitely.
|
|
53
|
+
* Defaults to 30000
|
|
54
|
+
*/
|
|
55
|
+
waitForTimeout: number;
|
|
56
|
+
/**
|
|
57
|
+
* The delay between polling calls that waitFor() will wait before retrying the callback.
|
|
58
|
+
* Defaults to 100
|
|
59
|
+
*/
|
|
60
|
+
pollingInterval: number;
|
|
61
|
+
};
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const _timeouts = {
|
|
2
|
+
/**
|
|
3
|
+
* The window of time to wait for an element to exist in the DOM.
|
|
4
|
+
* Set to 0 to wait indefinitely.
|
|
5
|
+
* Defaults to 1000
|
|
6
|
+
*/
|
|
7
|
+
elementExistsTimeout: 1000,
|
|
8
|
+
/**
|
|
9
|
+
* The window of time to wait for a remote script to complete execution.
|
|
10
|
+
* Set to 0 to wait indefinitely.
|
|
11
|
+
* Defaults to 30000
|
|
12
|
+
*/
|
|
13
|
+
scriptTimeout: 30 * 1000,
|
|
14
|
+
/**
|
|
15
|
+
* The window of time with which the waitFor() function will retry the callback.
|
|
16
|
+
* Set to 0 to wait indefinitely.
|
|
17
|
+
* Defaults to 30000
|
|
18
|
+
*/
|
|
19
|
+
waitForTimeout: 30 * 1000,
|
|
20
|
+
/**
|
|
21
|
+
* The delay between polling calls that waitFor() will wait before retrying the callback.
|
|
22
|
+
* Defaults to 100
|
|
23
|
+
*/
|
|
24
|
+
pollingInterval: 100
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Set the default timeouts for the TestDriver in milliseconds.
|
|
28
|
+
* Every property is optional, and can be partially set.
|
|
29
|
+
* @param timeouts
|
|
30
|
+
*/
|
|
31
|
+
function setTimeouts(timeouts) {
|
|
32
|
+
Object.assign(_timeouts, timeouts);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get the default timeouts set for the TestDriver
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
function getTimeouts() {
|
|
39
|
+
return { ..._timeouts };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { getTimeouts, setTimeouts };
|
|
43
|
+
//# sourceMappingURL=timeouts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeouts.mjs","sources":["../../src/UNSAFE_Driver/timeouts.ts"],"sourcesContent":["const _timeouts = {\n /**\n * The window of time to wait for an element to exist in the DOM.\n * Set to 0 to wait indefinitely.\n * Defaults to 1000\n */\n elementExistsTimeout: 1000,\n /**\n * The window of time to wait for a remote script to complete execution.\n * Set to 0 to wait indefinitely.\n * Defaults to 30000\n */\n scriptTimeout: 30 * 1000,\n /**\n * The window of time with which the waitFor() function will retry the callback.\n * Set to 0 to wait indefinitely.\n * Defaults to 30000\n */\n waitForTimeout: 30 * 1000,\n /**\n * The delay between polling calls that waitFor() will wait before retrying the callback.\n * Defaults to 100\n */\n pollingInterval: 100\n};\n\nexport type TimeoutsType = typeof _timeouts;\n\n/**\n * Set the default timeouts for the TestDriver in milliseconds.\n * Every property is optional, and can be partially set.\n * @param timeouts\n */\nexport function setTimeouts(timeouts: Partial<TimeoutsType>) {\n Object.assign(_timeouts, timeouts);\n}\n\n/**\n * Get the default timeouts set for the TestDriver\n * @returns\n */\nexport function getTimeouts() {\n return { ..._timeouts };\n}\n"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG;AAChB;;;;AAIG;AACH,IAAA,oBAAoB,EAAE,IAAI;AAC1B;;;;AAIG;IACH,aAAa,EAAE,EAAE,GAAG,IAAI;AACxB;;;;AAIG;IACH,cAAc,EAAE,EAAE,GAAG,IAAI;AACzB;;;AAGG;AACH,IAAA,eAAe,EAAE,GAAG;CACrB,CAAC;AAIF;;;;AAIG;AACG,SAAU,WAAW,CAAC,QAA+B,EAAA;AACzD,IAAA,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED;;;AAGG;SACa,WAAW,GAAA;AACzB,IAAA,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;AAC1B;;;;"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var timeouts = require('./timeouts.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Wait for a condition to pass.
|
|
9
|
+
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
|
|
10
|
+
* the callback. The truthy return value of the callback will be returned to the caller.
|
|
11
|
+
* @returns A Promise resolving to the returned value from the callback
|
|
12
|
+
*/
|
|
13
|
+
async function waitFor(callback) {
|
|
14
|
+
const { pollingInterval, waitForTimeout } = timeouts.getTimeouts();
|
|
15
|
+
return waitFor_internal(callback, { timeout: waitForTimeout, interval: pollingInterval });
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wait for a condition to pass.
|
|
19
|
+
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
|
|
20
|
+
* the callback. The truthy return value of the callback will be returned to the caller.
|
|
21
|
+
* @param options Options for wait time/interval
|
|
22
|
+
* @returns A Promise resolving to the returned value from the callback
|
|
23
|
+
*/
|
|
24
|
+
async function waitFor_internal(callback, options) {
|
|
25
|
+
const { waitForTimeout, pollingInterval } = timeouts.getTimeouts();
|
|
26
|
+
const timeout = options?.timeout ?? waitForTimeout;
|
|
27
|
+
const interval = options?.interval ?? pollingInterval;
|
|
28
|
+
const start = performance.now();
|
|
29
|
+
async function testCallback() {
|
|
30
|
+
try {
|
|
31
|
+
const result = await callback();
|
|
32
|
+
if (result) {
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
return retry();
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return retry();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function retry() {
|
|
42
|
+
const now = performance.now();
|
|
43
|
+
const elapsed = Math.round(now - start);
|
|
44
|
+
if (timeout && elapsed > timeout) {
|
|
45
|
+
return Promise.reject(new WaitForTimeoutError(elapsed));
|
|
46
|
+
}
|
|
47
|
+
return new Promise((accept, reject) => setTimeout(() => testCallback().then(accept).catch(reject), interval));
|
|
48
|
+
}
|
|
49
|
+
return testCallback();
|
|
50
|
+
}
|
|
51
|
+
class WaitForTimeoutError extends Error {
|
|
52
|
+
constructor(elapsed) {
|
|
53
|
+
super(`timed out after ${elapsed}ms`);
|
|
54
|
+
this.name = 'WaitForTimeoutError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exports.waitFor = waitFor;
|
|
59
|
+
exports.waitFor_internal = waitFor_internal;
|
|
60
|
+
//# sourceMappingURL=waitFor.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waitFor.cjs","sources":["../../src/UNSAFE_Driver/waitFor.ts"],"sourcesContent":["import { getTimeouts } from './timeouts';\n\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n};\n\n/**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @returns A Promise resolving to the returned value from the callback\n */\nexport async function waitFor<T>(callback: () => T | Promise<T>) {\n const { pollingInterval, waitForTimeout } = getTimeouts();\n return waitFor_internal(callback, { timeout: waitForTimeout, interval: pollingInterval });\n}\n\n/**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @param options Options for wait time/interval\n * @returns A Promise resolving to the returned value from the callback\n */\nexport async function waitFor_internal<T>(\n callback: () => T | Promise<T>,\n options?: WaitForOptions\n) {\n const { waitForTimeout, pollingInterval } = getTimeouts();\n const timeout = options?.timeout ?? waitForTimeout;\n const interval = options?.interval ?? pollingInterval;\n const start = performance.now();\n async function testCallback() {\n try {\n const result = await callback();\n if (result) {\n return result;\n }\n return retry();\n } catch {\n return retry();\n }\n }\n function retry(): T | Promise<T> {\n const now = performance.now();\n const elapsed = Math.round(now - start);\n if (timeout && elapsed > timeout) {\n return Promise.reject(new WaitForTimeoutError(elapsed));\n }\n return new Promise((accept, reject) =>\n setTimeout(() => testCallback().then(accept).catch(reject), interval)\n );\n }\n return testCallback();\n}\n\nclass WaitForTimeoutError extends Error {\n constructor(elapsed: number) {\n super(`timed out after ${elapsed}ms`);\n this.name = 'WaitForTimeoutError';\n }\n}\n"],"names":["getTimeouts"],"mappings":";;;;;;AAOA;;;;;AAKG;AACI,eAAe,OAAO,CAAI,QAA8B,EAAA;IAC7D,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,GAAGA,oBAAW,EAAE,CAAC;AAC1D,IAAA,OAAO,gBAAgB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED;;;;;;AAMG;AACI,eAAe,gBAAgB,CACpC,QAA8B,EAC9B,OAAwB,EAAA;IAExB,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,GAAGA,oBAAW,EAAE,CAAC;AAC1D,IAAA,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,cAAc,CAAC;AACnD,IAAA,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,eAAe,CAAC;AACtD,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;AAChC,IAAA,eAAe,YAAY,GAAA;AACzB,QAAA,IAAI;AACF,YAAA,MAAM,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAC;YAChC,IAAI,MAAM,EAAE;AACV,gBAAA,OAAO,MAAM,CAAC;aACf;YACD,OAAO,KAAK,EAAE,CAAC;SAChB;AAAC,QAAA,MAAM;YACN,OAAO,KAAK,EAAE,CAAC;SAChB;KACF;AACD,IAAA,SAAS,KAAK,GAAA;AACZ,QAAA,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;AACxC,QAAA,IAAI,OAAO,IAAI,OAAO,GAAG,OAAO,EAAE;YAChC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;SACzD;AACD,QAAA,OAAO,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,KAChC,UAAU,CAAC,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CACtE,CAAC;KACH;IACD,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,mBAAoB,SAAQ,KAAK,CAAA;AACrC,IAAA,WAAA,CAAY,OAAe,EAAA;AACzB,QAAA,KAAK,CAAC,CAAA,gBAAA,EAAmB,OAAO,CAAA,EAAA,CAAI,CAAC,CAAC;AACtC,QAAA,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;KACnC;AACF;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type WaitForOptions = {
|
|
2
|
+
timeout?: number;
|
|
3
|
+
interval?: number;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Wait for a condition to pass.
|
|
7
|
+
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
|
|
8
|
+
* the callback. The truthy return value of the callback will be returned to the caller.
|
|
9
|
+
* @returns A Promise resolving to the returned value from the callback
|
|
10
|
+
*/
|
|
11
|
+
export declare function waitFor<T>(callback: () => T | Promise<T>): Promise<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Wait for a condition to pass.
|
|
14
|
+
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
|
|
15
|
+
* the callback. The truthy return value of the callback will be returned to the caller.
|
|
16
|
+
* @param options Options for wait time/interval
|
|
17
|
+
* @returns A Promise resolving to the returned value from the callback
|
|
18
|
+
*/
|
|
19
|
+
export declare function waitFor_internal<T>(callback: () => T | Promise<T>, options?: WaitForOptions): Promise<T>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getTimeouts } from './timeouts.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wait for a condition to pass.
|
|
5
|
+
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
|
|
6
|
+
* the callback. The truthy return value of the callback will be returned to the caller.
|
|
7
|
+
* @returns A Promise resolving to the returned value from the callback
|
|
8
|
+
*/
|
|
9
|
+
async function waitFor(callback) {
|
|
10
|
+
const { pollingInterval, waitForTimeout } = getTimeouts();
|
|
11
|
+
return waitFor_internal(callback, { timeout: waitForTimeout, interval: pollingInterval });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Wait for a condition to pass.
|
|
15
|
+
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
|
|
16
|
+
* the callback. The truthy return value of the callback will be returned to the caller.
|
|
17
|
+
* @param options Options for wait time/interval
|
|
18
|
+
* @returns A Promise resolving to the returned value from the callback
|
|
19
|
+
*/
|
|
20
|
+
async function waitFor_internal(callback, options) {
|
|
21
|
+
const { waitForTimeout, pollingInterval } = getTimeouts();
|
|
22
|
+
const timeout = options?.timeout ?? waitForTimeout;
|
|
23
|
+
const interval = options?.interval ?? pollingInterval;
|
|
24
|
+
const start = performance.now();
|
|
25
|
+
async function testCallback() {
|
|
26
|
+
try {
|
|
27
|
+
const result = await callback();
|
|
28
|
+
if (result) {
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
return retry();
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return retry();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function retry() {
|
|
38
|
+
const now = performance.now();
|
|
39
|
+
const elapsed = Math.round(now - start);
|
|
40
|
+
if (timeout && elapsed > timeout) {
|
|
41
|
+
return Promise.reject(new WaitForTimeoutError(elapsed));
|
|
42
|
+
}
|
|
43
|
+
return new Promise((accept, reject) => setTimeout(() => testCallback().then(accept).catch(reject), interval));
|
|
44
|
+
}
|
|
45
|
+
return testCallback();
|
|
46
|
+
}
|
|
47
|
+
class WaitForTimeoutError extends Error {
|
|
48
|
+
constructor(elapsed) {
|
|
49
|
+
super(`timed out after ${elapsed}ms`);
|
|
50
|
+
this.name = 'WaitForTimeoutError';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { waitFor, waitFor_internal };
|
|
55
|
+
//# sourceMappingURL=waitFor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waitFor.mjs","sources":["../../src/UNSAFE_Driver/waitFor.ts"],"sourcesContent":["import { getTimeouts } from './timeouts';\n\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n};\n\n/**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @returns A Promise resolving to the returned value from the callback\n */\nexport async function waitFor<T>(callback: () => T | Promise<T>) {\n const { pollingInterval, waitForTimeout } = getTimeouts();\n return waitFor_internal(callback, { timeout: waitForTimeout, interval: pollingInterval });\n}\n\n/**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @param options Options for wait time/interval\n * @returns A Promise resolving to the returned value from the callback\n */\nexport async function waitFor_internal<T>(\n callback: () => T | Promise<T>,\n options?: WaitForOptions\n) {\n const { waitForTimeout, pollingInterval } = getTimeouts();\n const timeout = options?.timeout ?? waitForTimeout;\n const interval = options?.interval ?? pollingInterval;\n const start = performance.now();\n async function testCallback() {\n try {\n const result = await callback();\n if (result) {\n return result;\n }\n return retry();\n } catch {\n return retry();\n }\n }\n function retry(): T | Promise<T> {\n const now = performance.now();\n const elapsed = Math.round(now - start);\n if (timeout && elapsed > timeout) {\n return Promise.reject(new WaitForTimeoutError(elapsed));\n }\n return new Promise((accept, reject) =>\n setTimeout(() => testCallback().then(accept).catch(reject), interval)\n );\n }\n return testCallback();\n}\n\nclass WaitForTimeoutError extends Error {\n constructor(elapsed: number) {\n super(`timed out after ${elapsed}ms`);\n this.name = 'WaitForTimeoutError';\n }\n}\n"],"names":[],"mappings":";;AAOA;;;;;AAKG;AACI,eAAe,OAAO,CAAI,QAA8B,EAAA;IAC7D,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,WAAW,EAAE,CAAC;AAC1D,IAAA,OAAO,gBAAgB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED;;;;;;AAMG;AACI,eAAe,gBAAgB,CACpC,QAA8B,EAC9B,OAAwB,EAAA;IAExB,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,WAAW,EAAE,CAAC;AAC1D,IAAA,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,cAAc,CAAC;AACnD,IAAA,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,eAAe,CAAC;AACtD,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;AAChC,IAAA,eAAe,YAAY,GAAA;AACzB,QAAA,IAAI;AACF,YAAA,MAAM,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAC;YAChC,IAAI,MAAM,EAAE;AACV,gBAAA,OAAO,MAAM,CAAC;aACf;YACD,OAAO,KAAK,EAAE,CAAC;SAChB;AAAC,QAAA,MAAM;YACN,OAAO,KAAK,EAAE,CAAC;SAChB;KACF;AACD,IAAA,SAAS,KAAK,GAAA;AACZ,QAAA,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;AACxC,QAAA,IAAI,OAAO,IAAI,OAAO,GAAG,OAAO,EAAE;YAChC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;SACzD;AACD,QAAA,OAAO,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,KAChC,UAAU,CAAC,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CACtE,CAAC;KACH;IACD,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,mBAAoB,SAAQ,KAAK,CAAA;AACrC,IAAA,WAAA,CAAY,OAAe,EAAA;AACzB,QAAA,KAAK,CAAC,CAAA,gBAAA,EAAmB,OAAO,CAAA,EAAA,CAAI,CAAC,CAAC;AACtC,QAAA,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;KACnC;AACF;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create a locator that targets an element by its testId
|
|
7
|
+
* @param testId
|
|
8
|
+
* @returns The ElementLocator for the given testId
|
|
9
|
+
*/
|
|
10
|
+
function byTestId(testId) {
|
|
11
|
+
return byCss(getTestIdCss(testId));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a locator that targets an element by CSS selector
|
|
15
|
+
* @param css
|
|
16
|
+
* @returns The ElementLocator matching the CSS selector
|
|
17
|
+
*/
|
|
18
|
+
function byCss(css) {
|
|
19
|
+
return {
|
|
20
|
+
css
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function getTestIdCss(testId) {
|
|
24
|
+
return `[data-testid=${testId}]`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.byCss = byCss;
|
|
28
|
+
exports.byTestId = byTestId;
|
|
29
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/UNSAFE_Locators/index.ts"],"sourcesContent":["export interface ElementLocator {\n css: string;\n}\n\n/**\n * Create a locator that targets an element by its testId\n * @param testId\n * @returns The ElementLocator for the given testId\n */\nexport function byTestId(testId: string): ElementLocator {\n return byCss(getTestIdCss(testId));\n}\n\n/**\n * Create a locator that targets an element by CSS selector\n * @param css\n * @returns The ElementLocator matching the CSS selector\n */\nexport function byCss(css: string): ElementLocator {\n return {\n css\n };\n}\n\nfunction getTestIdCss(testId: string) {\n return `[data-testid=${testId}]`;\n}\n"],"names":[],"mappings":";;;;AAIA;;;;AAIG;AACG,SAAU,QAAQ,CAAC,MAAc,EAAA;AACrC,IAAA,OAAO,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;AAIG;AACG,SAAU,KAAK,CAAC,GAAW,EAAA;IAC/B,OAAO;QACL,GAAG;KACJ,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,MAAc,EAAA;IAClC,OAAO,CAAA,aAAA,EAAgB,MAAM,CAAA,CAAA,CAAG,CAAC;AACnC;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ElementLocator {
|
|
2
|
+
css: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Create a locator that targets an element by its testId
|
|
6
|
+
* @param testId
|
|
7
|
+
* @returns The ElementLocator for the given testId
|
|
8
|
+
*/
|
|
9
|
+
export declare function byTestId(testId: string): ElementLocator;
|
|
10
|
+
/**
|
|
11
|
+
* Create a locator that targets an element by CSS selector
|
|
12
|
+
* @param css
|
|
13
|
+
* @returns The ElementLocator matching the CSS selector
|
|
14
|
+
*/
|
|
15
|
+
export declare function byCss(css: string): ElementLocator;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a locator that targets an element by its testId
|
|
3
|
+
* @param testId
|
|
4
|
+
* @returns The ElementLocator for the given testId
|
|
5
|
+
*/
|
|
6
|
+
function byTestId(testId) {
|
|
7
|
+
return byCss(getTestIdCss(testId));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a locator that targets an element by CSS selector
|
|
11
|
+
* @param css
|
|
12
|
+
* @returns The ElementLocator matching the CSS selector
|
|
13
|
+
*/
|
|
14
|
+
function byCss(css) {
|
|
15
|
+
return {
|
|
16
|
+
css
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function getTestIdCss(testId) {
|
|
20
|
+
return `[data-testid=${testId}]`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { byCss, byTestId };
|
|
24
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/UNSAFE_Locators/index.ts"],"sourcesContent":["export interface ElementLocator {\n css: string;\n}\n\n/**\n * Create a locator that targets an element by its testId\n * @param testId\n * @returns The ElementLocator for the given testId\n */\nexport function byTestId(testId: string): ElementLocator {\n return byCss(getTestIdCss(testId));\n}\n\n/**\n * Create a locator that targets an element by CSS selector\n * @param css\n * @returns The ElementLocator matching the CSS selector\n */\nexport function byCss(css: string): ElementLocator {\n return {\n css\n };\n}\n\nfunction getTestIdCss(testId: string) {\n return `[data-testid=${testId}]`;\n}\n"],"names":[],"mappings":"AAIA;;;;AAIG;AACG,SAAU,QAAQ,CAAC,MAAc,EAAA;AACrC,IAAA,OAAO,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;AAIG;AACG,SAAU,KAAK,CAAC,GAAW,EAAA;IAC/B,OAAO;QACL,GAAG;KACJ,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,MAAc,EAAA;IAClC,OAAO,CAAA,aAAA,EAAgB,MAAM,CAAA,CAAA,CAAG,CAAC;AACnC;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var TestDriver = require('../UNSAFE_Driver/TestDriver.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The base class for portable test adapters. Test adapters should extend this
|
|
9
|
+
* class to provide uniform construction.
|
|
10
|
+
*/
|
|
11
|
+
class TestAdapter {
|
|
12
|
+
/**
|
|
13
|
+
* Create the test adapter from the locator and optional TestDriver or TestElement.
|
|
14
|
+
* If a driverOrElement is given, the locator will be searched from there.
|
|
15
|
+
* @param locator The ElementLocator used to search for the component
|
|
16
|
+
* @param driverOrElement The optional TestDriver or TestElement from which to search. If
|
|
17
|
+
* TestElement is given, locator will search underneath that element. If TestDriver is given
|
|
18
|
+
* or the parameter is undefined, the DOM is searched globally.
|
|
19
|
+
*/
|
|
20
|
+
constructor(locator, driverOrElement) {
|
|
21
|
+
this._elementQuery = () => {
|
|
22
|
+
if (driverOrElement) {
|
|
23
|
+
return driverOrElement.waitForElement(locator);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return TestDriver.getTestDriver().waitForElement(locator);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the TestElement for the root DOM of this component. This method will query the DOM environment
|
|
32
|
+
* for the matching element each time it's calld. Do not store the reference to the returned element.
|
|
33
|
+
* It's recommended that this method be called each time element is needed, to avoid the chance that
|
|
34
|
+
* the reference may become stale due to a rerender.
|
|
35
|
+
* @returns Promise resolving to the TestElement for this adapter
|
|
36
|
+
*/
|
|
37
|
+
getElement() {
|
|
38
|
+
return this._elementQuery();
|
|
39
|
+
}
|
|
40
|
+
getTestDriver() {
|
|
41
|
+
return TestDriver.getTestDriver();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.TestAdapter = TestAdapter;
|
|
46
|
+
//# sourceMappingURL=TestAdapter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestAdapter.cjs","sources":["../../src/UNSAFE_TestAdapter/TestAdapter.ts"],"sourcesContent":["import { TestDriver, TestElement, getTestDriver } from '../UNSAFE_Driver';\nimport { ElementLocator } from '../UNSAFE_Locators';\n\n/**\n * The base class for portable test adapters. Test adapters should extend this\n * class to provide uniform construction.\n */\nexport class TestAdapter {\n private _elementQuery: () => Promise<TestElement>;\n\n /**\n * Create the test adapter from the locator and optional TestDriver or TestElement.\n * If a driverOrElement is given, the locator will be searched from there.\n * @param locator The ElementLocator used to search for the component\n * @param driverOrElement The optional TestDriver or TestElement from which to search. If\n * TestElement is given, locator will search underneath that element. If TestDriver is given\n * or the parameter is undefined, the DOM is searched globally.\n */\n constructor(locator: ElementLocator, driverOrElement?: TestDriver | TestElement) {\n this._elementQuery = () => {\n if (driverOrElement) {\n return driverOrElement.waitForElement(locator);\n } else {\n return getTestDriver().waitForElement(locator);\n }\n };\n }\n\n /**\n * Get the TestElement for the root DOM of this component. This method will query the DOM environment\n * for the matching element each time it's calld. Do not store the reference to the returned element.\n * It's recommended that this method be called each time element is needed, to avoid the chance that\n * the reference may become stale due to a rerender.\n * @returns Promise resolving to the TestElement for this adapter\n */\n protected getElement() {\n return this._elementQuery();\n }\n\n protected getTestDriver() {\n return getTestDriver();\n }\n}\n"],"names":["getTestDriver"],"mappings":";;;;;;AAGA;;;AAGG;MACU,WAAW,CAAA;AAGtB;;;;;;;AAOG;IACH,WAAY,CAAA,OAAuB,EAAE,eAA0C,EAAA;AAC7E,QAAA,IAAI,CAAC,aAAa,GAAG,MAAK;YACxB,IAAI,eAAe,EAAE;AACnB,gBAAA,OAAO,eAAe,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAChD;iBAAM;AACL,gBAAA,OAAOA,wBAAa,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAChD;AACH,SAAC,CAAC;KACH;AAED;;;;;;AAMG;IACO,UAAU,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;KAC7B;IAES,aAAa,GAAA;QACrB,OAAOA,wBAAa,EAAE,CAAC;KACxB;AACF;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TestDriver, TestElement } from '../UNSAFE_Driver';
|
|
2
|
+
import { ElementLocator } from '../UNSAFE_Locators';
|
|
3
|
+
/**
|
|
4
|
+
* The base class for portable test adapters. Test adapters should extend this
|
|
5
|
+
* class to provide uniform construction.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TestAdapter {
|
|
8
|
+
private _elementQuery;
|
|
9
|
+
/**
|
|
10
|
+
* Create the test adapter from the locator and optional TestDriver or TestElement.
|
|
11
|
+
* If a driverOrElement is given, the locator will be searched from there.
|
|
12
|
+
* @param locator The ElementLocator used to search for the component
|
|
13
|
+
* @param driverOrElement The optional TestDriver or TestElement from which to search. If
|
|
14
|
+
* TestElement is given, locator will search underneath that element. If TestDriver is given
|
|
15
|
+
* or the parameter is undefined, the DOM is searched globally.
|
|
16
|
+
*/
|
|
17
|
+
constructor(locator: ElementLocator, driverOrElement?: TestDriver | TestElement);
|
|
18
|
+
/**
|
|
19
|
+
* Get the TestElement for the root DOM of this component. This method will query the DOM environment
|
|
20
|
+
* for the matching element each time it's calld. Do not store the reference to the returned element.
|
|
21
|
+
* It's recommended that this method be called each time element is needed, to avoid the chance that
|
|
22
|
+
* the reference may become stale due to a rerender.
|
|
23
|
+
* @returns Promise resolving to the TestElement for this adapter
|
|
24
|
+
*/
|
|
25
|
+
protected getElement(): Promise<TestElement>;
|
|
26
|
+
protected getTestDriver(): TestDriver;
|
|
27
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getTestDriver } from '../UNSAFE_Driver/TestDriver.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The base class for portable test adapters. Test adapters should extend this
|
|
5
|
+
* class to provide uniform construction.
|
|
6
|
+
*/
|
|
7
|
+
class TestAdapter {
|
|
8
|
+
/**
|
|
9
|
+
* Create the test adapter from the locator and optional TestDriver or TestElement.
|
|
10
|
+
* If a driverOrElement is given, the locator will be searched from there.
|
|
11
|
+
* @param locator The ElementLocator used to search for the component
|
|
12
|
+
* @param driverOrElement The optional TestDriver or TestElement from which to search. If
|
|
13
|
+
* TestElement is given, locator will search underneath that element. If TestDriver is given
|
|
14
|
+
* or the parameter is undefined, the DOM is searched globally.
|
|
15
|
+
*/
|
|
16
|
+
constructor(locator, driverOrElement) {
|
|
17
|
+
this._elementQuery = () => {
|
|
18
|
+
if (driverOrElement) {
|
|
19
|
+
return driverOrElement.waitForElement(locator);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return getTestDriver().waitForElement(locator);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get the TestElement for the root DOM of this component. This method will query the DOM environment
|
|
28
|
+
* for the matching element each time it's calld. Do not store the reference to the returned element.
|
|
29
|
+
* It's recommended that this method be called each time element is needed, to avoid the chance that
|
|
30
|
+
* the reference may become stale due to a rerender.
|
|
31
|
+
* @returns Promise resolving to the TestElement for this adapter
|
|
32
|
+
*/
|
|
33
|
+
getElement() {
|
|
34
|
+
return this._elementQuery();
|
|
35
|
+
}
|
|
36
|
+
getTestDriver() {
|
|
37
|
+
return getTestDriver();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { TestAdapter };
|
|
42
|
+
//# sourceMappingURL=TestAdapter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestAdapter.mjs","sources":["../../src/UNSAFE_TestAdapter/TestAdapter.ts"],"sourcesContent":["import { TestDriver, TestElement, getTestDriver } from '../UNSAFE_Driver';\nimport { ElementLocator } from '../UNSAFE_Locators';\n\n/**\n * The base class for portable test adapters. Test adapters should extend this\n * class to provide uniform construction.\n */\nexport class TestAdapter {\n private _elementQuery: () => Promise<TestElement>;\n\n /**\n * Create the test adapter from the locator and optional TestDriver or TestElement.\n * If a driverOrElement is given, the locator will be searched from there.\n * @param locator The ElementLocator used to search for the component\n * @param driverOrElement The optional TestDriver or TestElement from which to search. If\n * TestElement is given, locator will search underneath that element. If TestDriver is given\n * or the parameter is undefined, the DOM is searched globally.\n */\n constructor(locator: ElementLocator, driverOrElement?: TestDriver | TestElement) {\n this._elementQuery = () => {\n if (driverOrElement) {\n return driverOrElement.waitForElement(locator);\n } else {\n return getTestDriver().waitForElement(locator);\n }\n };\n }\n\n /**\n * Get the TestElement for the root DOM of this component. This method will query the DOM environment\n * for the matching element each time it's calld. Do not store the reference to the returned element.\n * It's recommended that this method be called each time element is needed, to avoid the chance that\n * the reference may become stale due to a rerender.\n * @returns Promise resolving to the TestElement for this adapter\n */\n protected getElement() {\n return this._elementQuery();\n }\n\n protected getTestDriver() {\n return getTestDriver();\n }\n}\n"],"names":[],"mappings":";;AAGA;;;AAGG;MACU,WAAW,CAAA;AAGtB;;;;;;;AAOG;IACH,WAAY,CAAA,OAAuB,EAAE,eAA0C,EAAA;AAC7E,QAAA,IAAI,CAAC,aAAa,GAAG,MAAK;YACxB,IAAI,eAAe,EAAE;AACnB,gBAAA,OAAO,eAAe,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAChD;iBAAM;AACL,gBAAA,OAAO,aAAa,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAChD;AACH,SAAC,CAAC;KACH;AAED;;;;;;AAMG;IACO,UAAU,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;KAC7B;IAES,aAAa,GAAA;QACrB,OAAO,aAAa,EAAE,CAAC;KACxB;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TestAdapter } from './TestAdapter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,18 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oracle/oraclejet-testing",
|
|
3
3
|
"scripts": {
|
|
4
|
-
"build": "
|
|
4
|
+
"build": "turbo run-build --filter=@oracle/oraclejet-testing",
|
|
5
5
|
"clean": "rimraf dist",
|
|
6
|
-
"
|
|
6
|
+
"check-types": "turbo run-check-types --filter=@oracle/oraclejet-testing -- ",
|
|
7
|
+
"copy-files": "mergeJson package.json src/package-overrides.json dist/package.json; copyfiles -f README.md dist",
|
|
8
|
+
"lint": "turbo run-lint --filter=@oracle/oraclejet-testing -- ",
|
|
9
|
+
"run-build": "rollup -c rollup.config.mjs && yarn copy-files",
|
|
10
|
+
"run-check-types": "tsc --noEmit",
|
|
11
|
+
"run-lint": "eslint",
|
|
12
|
+
"test": "jest -c test/jest.config.js",
|
|
13
|
+
"test-ci-headless": "yarn test"
|
|
7
14
|
},
|
|
8
15
|
"devDependencies": {
|
|
16
|
+
"@jest/globals": "29.6.2",
|
|
17
|
+
"@oracle/oraclejet-config-eslint": "workspace:*",
|
|
18
|
+
"@oracle/oraclejet-config-jest": "workspace:*",
|
|
19
|
+
"@oracle/oraclejet-config-typescript": "workspace:*",
|
|
9
20
|
"@oracle/oraclejet-internal-ws-build": "workspace:^",
|
|
10
21
|
"copyfiles": "2.4.1",
|
|
22
|
+
"eslint": "9.2.0",
|
|
23
|
+
"jest": "29.6.2",
|
|
11
24
|
"rimraf": "3.0.2",
|
|
12
|
-
"
|
|
25
|
+
"rollup": "2.70.2",
|
|
26
|
+
"ts-jest": "29.1.0",
|
|
27
|
+
"turbo": "2.3.3",
|
|
28
|
+
"typescript": "5.8.3",
|
|
29
|
+
"typescript-eslint": "8.29.1"
|
|
13
30
|
},
|
|
14
31
|
"exports": {
|
|
15
|
-
"./*":
|
|
32
|
+
"./*": {
|
|
33
|
+
"types": "./*/index.d.ts",
|
|
34
|
+
"require": "./*/index.cjs",
|
|
35
|
+
"import": "./*/index.mjs"
|
|
36
|
+
}
|
|
16
37
|
},
|
|
17
38
|
"typesVersions": {
|
|
18
39
|
"*": {
|
|
@@ -22,5 +43,5 @@
|
|
|
22
43
|
}
|
|
23
44
|
},
|
|
24
45
|
"dependencies": {},
|
|
25
|
-
"version": "
|
|
46
|
+
"version": "19.0.0"
|
|
26
47
|
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A TestDriver implements the platform-specific commands needed for testing
|
|
3
|
-
* with adapters.
|
|
4
|
-
*/
|
|
5
|
-
export interface TestDriver {
|
|
6
|
-
/**
|
|
7
|
-
* Click on the given TestElement
|
|
8
|
-
* @param element The TestElement on which to click
|
|
9
|
-
*/
|
|
10
|
-
click(element: TestElement, options?: ClickOptions): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* Execute a script in the browser environment.
|
|
13
|
-
* @param script The script to execute
|
|
14
|
-
* @param args Any arguments to pass to the script. Access each argument through
|
|
15
|
-
* the <code>arguments</code> array.
|
|
16
|
-
*/
|
|
17
|
-
executeScript<T>(script: string | (() => T), ...args: any): Promise<T>;
|
|
18
|
-
/**
|
|
19
|
-
* Find an element in the browser environment that matches the given CSS query.
|
|
20
|
-
* This method should throw an exception if no matching elements are found.
|
|
21
|
-
* @param query The CSS query to use in locate the element
|
|
22
|
-
*/
|
|
23
|
-
findElement(query: string): Promise<TestElement>;
|
|
24
|
-
/**
|
|
25
|
-
* Find elements in the browser environment matching the given CSS query. If no
|
|
26
|
-
* matching elements are found, return a blank array.
|
|
27
|
-
* @param query The CSS query to use in locating the elements.
|
|
28
|
-
*/
|
|
29
|
-
findElements(query: string): Promise<TestElement[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Send text as keystrokes to the browser. If modifier keys are used, all key parameters in the
|
|
32
|
-
* sequence will be combined into a single chord.
|
|
33
|
-
* @param element The element to receive the keystrokes
|
|
34
|
-
* @param text The text value to send, or an array of KeyMap strings to send as a chord of keys
|
|
35
|
-
*/
|
|
36
|
-
sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* A TestElement represents the DOM element in the browser environment. This interface
|
|
40
|
-
* is used by test adapters to work with elements without being bound to a specific
|
|
41
|
-
* platform implementation.
|
|
42
|
-
*/
|
|
43
|
-
export interface TestElement {
|
|
44
|
-
findElement(query: string): Promise<TestElement>;
|
|
45
|
-
findElements(query: string): Promise<TestElement[]>;
|
|
46
|
-
getAttribute(attrName: string): Promise<string | null>;
|
|
47
|
-
}
|
|
48
|
-
export declare const ModifierKeys: {
|
|
49
|
-
[key: string]: KeyType;
|
|
50
|
-
};
|
|
51
|
-
export type ClickOptions = {
|
|
52
|
-
modifiers?: (typeof ModifierKeys)[keyof typeof ModifierKeys][];
|
|
53
|
-
};
|
|
54
|
-
export declare const Keys: {
|
|
55
|
-
[key: string]: {
|
|
56
|
-
key: string;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
export type KeyType = (typeof Keys)[keyof typeof Keys];
|
|
60
|
-
/**
|
|
61
|
-
* Set the TestDriver instance to be used for testing. This method should be called by
|
|
62
|
-
* tests during setup, before calling any test adapter methods.
|
|
63
|
-
*
|
|
64
|
-
* @param driver The TestDriver instance
|
|
65
|
-
*/
|
|
66
|
-
export declare function setDriver(driver: TestDriver): void;
|
|
67
|
-
/**
|
|
68
|
-
* Get the configured TestDriver instance to be used for testing. This method should
|
|
69
|
-
* only be called by test adapters to interact with the browser environment.
|
|
70
|
-
*
|
|
71
|
-
* @returns The TestDriver instance
|
|
72
|
-
*/
|
|
73
|
-
export declare function getDriver(): TestDriver;
|
package/UNSAFE_driver/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Driver';
|
package/UNSAFE_driver/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Driver"), exports);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type TestElement } from '../UNSAFE_driver';
|
|
2
|
-
interface ElementLocator {
|
|
3
|
-
css: string;
|
|
4
|
-
}
|
|
5
|
-
export interface TestIdLocator extends ElementLocator {
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Create a locator that targets an element by its testId
|
|
9
|
-
* @param testId
|
|
10
|
-
* @returns The ElementLocator for the given testId
|
|
11
|
-
*/
|
|
12
|
-
export declare function getByTestId(testId: string): TestIdLocator;
|
|
13
|
-
/**
|
|
14
|
-
* Perform an element search on the driver using the given ElementLocator
|
|
15
|
-
* @param locator
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
export declare function getElement(locator: ElementLocator): Promise<TestElement>;
|
|
19
|
-
export {};
|
package/UNSAFE_locators/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getByTestId = getByTestId;
|
|
4
|
-
exports.getElement = getElement;
|
|
5
|
-
const UNSAFE_driver_1 = require("../UNSAFE_driver");
|
|
6
|
-
/**
|
|
7
|
-
* Create a locator that targets an element by its testId
|
|
8
|
-
* @param testId
|
|
9
|
-
* @returns The ElementLocator for the given testId
|
|
10
|
-
*/
|
|
11
|
-
function getByTestId(testId) {
|
|
12
|
-
return {
|
|
13
|
-
css: getTestIdQuery(testId)
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function getTestIdQuery(testId) {
|
|
17
|
-
return `[data-testid=${testId}]`;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Perform an element search on the driver using the given ElementLocator
|
|
21
|
-
* @param locator
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
async function getElement(locator) {
|
|
25
|
-
const matches = await (0, UNSAFE_driver_1.getDriver)().findElements(locator.css);
|
|
26
|
-
if (!matches.length) {
|
|
27
|
-
throw Error(`No matches found for "${locator.css}"`);
|
|
28
|
-
}
|
|
29
|
-
return matches[0];
|
|
30
|
-
}
|