@oracle/oraclejet-testing 17.1.4 → 18.0.1

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.
@@ -7,14 +7,14 @@ export interface TestDriver {
7
7
  * Click on the given TestElement
8
8
  * @param element The TestElement on which to click
9
9
  */
10
- click(element: TestElement): Promise<void>;
10
+ click(element: TestElement, options?: ClickOptions): Promise<void>;
11
11
  /**
12
12
  * Execute a script in the browser environment.
13
13
  * @param script The script to execute
14
14
  * @param args Any arguments to pass to the script. Access each argument through
15
15
  * the <code>arguments</code> array.
16
16
  */
17
- executeScript<T>(script: string, ...args: any): Promise<T>;
17
+ executeScript<T>(script: string | (() => T), ...args: any): Promise<T>;
18
18
  /**
19
19
  * Find an element in the browser environment that matches the given CSS query.
20
20
  * This method should throw an exception if no matching elements are found.
@@ -22,17 +22,18 @@ export interface TestDriver {
22
22
  */
23
23
  findElement(query: string): Promise<TestElement>;
24
24
  /**
25
- * Find elements in the browser environment matching the gven CSS query. If no
25
+ * Find elements in the browser environment matching the given CSS query. If no
26
26
  * matching elements are found, return a blank array.
27
27
  * @param query The CSS query to use in locating the elements.
28
28
  */
29
29
  findElements(query: string): Promise<TestElement[]>;
30
30
  /**
31
- *
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.
32
33
  * @param element The element to receive the keystrokes
33
- * @param text
34
+ * @param text The text value to send, or an array of KeyMap strings to send as a chord of keys
34
35
  */
35
- sendKeys(element: TestElement, text: string): Promise<void>;
36
+ sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;
36
37
  }
37
38
  /**
38
39
  * A TestElement represents the DOM element in the browser environment. This interface
@@ -42,7 +43,20 @@ export interface TestDriver {
42
43
  export interface TestElement {
43
44
  findElement(query: string): Promise<TestElement>;
44
45
  findElements(query: string): Promise<TestElement[]>;
46
+ getAttribute(attrName: string): Promise<string | null>;
45
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];
46
60
  /**
47
61
  * Set the TestDriver instance to be used for testing. This method should be called by
48
62
  * tests during setup, before calling any test adapter methods.
@@ -54,6 +68,6 @@ export declare function setDriver(driver: TestDriver): void;
54
68
  * Get the configured TestDriver instance to be used for testing. This method should
55
69
  * only be called by test adapters to interact with the browser environment.
56
70
  *
57
- * @returns {TestDriver} The TestDriver instance
71
+ * @returns The TestDriver instance
58
72
  */
59
73
  export declare function getDriver(): TestDriver;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Keys = exports.ModifierKeys = void 0;
4
+ exports.setDriver = setDriver;
5
+ exports.getDriver = getDriver;
6
+ // export const ModifierKeys: { [k: string]: KeyType } = {
7
+ exports.ModifierKeys = {
8
+ ALT: { key: 'ALT' },
9
+ CONTROL: { key: 'CONTROL' },
10
+ CONTROL_COMMAND: { key: 'CONTROL_COMMAND' },
11
+ SHIFT: { key: 'SHIFT' }
12
+ };
13
+ exports.Keys = {
14
+ ...exports.ModifierKeys,
15
+ BACKSPACE: { key: 'BACKSPACE' },
16
+ TAB: { key: 'TAB' },
17
+ ENTER: { key: 'ENTER' },
18
+ ESCAPE: { key: 'ESCAPE' },
19
+ PAGE_UP: { key: 'PAGE_UP' },
20
+ PAGE_DOWN: { key: 'PAGE_DOWN' },
21
+ END: { key: 'END' },
22
+ HOME: { key: 'HOME' },
23
+ ARROW_LEFT: { key: 'ARROW_LEFT' },
24
+ ARROW_UP: { key: 'ARROW_UP' },
25
+ ARROW_RIGHT: { key: 'ARROW_RIGHT' },
26
+ ARROW_DOWN: { key: 'ARROW_DOWN' },
27
+ DELETE: { key: 'DELETE' },
28
+ F1: { key: 'F1' },
29
+ F2: { key: 'F2' },
30
+ F3: { key: 'F3' },
31
+ F4: { key: 'F4' },
32
+ F5: { key: 'F5' },
33
+ F6: { key: 'F6' },
34
+ F7: { key: 'F7' },
35
+ F8: { key: 'F8' },
36
+ F9: { key: 'F9' },
37
+ F10: { key: 'F10' },
38
+ F11: { key: 'F11' },
39
+ F12: { key: 'F12' }
40
+ };
41
+ let _driver;
42
+ /**
43
+ * Set the TestDriver instance to be used for testing. This method should be called by
44
+ * tests during setup, before calling any test adapter methods.
45
+ *
46
+ * @param driver The TestDriver instance
47
+ */
48
+ function setDriver(driver) {
49
+ _driver = driver;
50
+ }
51
+ /**
52
+ * Get the configured TestDriver instance to be used for testing. This method should
53
+ * only be called by test adapters to interact with the browser environment.
54
+ *
55
+ * @returns The TestDriver instance
56
+ */
57
+ function getDriver() {
58
+ if (!_driver) {
59
+ throw Error('Driver has not been set. Call setDriver()');
60
+ }
61
+ return _driver;
62
+ }
@@ -0,0 +1 @@
1
+ export * from './Driver';
@@ -1,27 +1,17 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDriver = exports.setDriver = void 0;
4
- let _driver;
5
- /**
6
- * Set the TestDriver instance to be used for testing. This method should be called by
7
- * tests during setup, before calling any test adapter methods.
8
- *
9
- * @param driver The TestDriver instance
10
- */
11
- function setDriver(driver) {
12
- _driver = driver;
13
- }
14
- exports.setDriver = setDriver;
15
- /**
16
- * Get the configured TestDriver instance to be used for testing. This method should
17
- * only be called by test adapters to interact with the browser environment.
18
- *
19
- * @returns {TestDriver} The TestDriver instance
20
- */
21
- function getDriver() {
22
- if (!_driver) {
23
- throw Error('Driver has not been set. Call setDriver()');
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]; } };
24
7
  }
25
- return _driver;
26
- }
27
- exports.getDriver = getDriver;
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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getElement = exports.getByTestId = void 0;
3
+ exports.getByTestId = getByTestId;
4
+ exports.getElement = getElement;
4
5
  const UNSAFE_driver_1 = require("../UNSAFE_driver");
5
6
  /**
6
7
  * Create a locator that targets an element by its testId
@@ -12,7 +13,6 @@ function getByTestId(testId) {
12
13
  css: getTestIdQuery(testId)
13
14
  };
14
15
  }
15
- exports.getByTestId = getByTestId;
16
16
  function getTestIdQuery(testId) {
17
17
  return `[data-testid=${testId}]`;
18
18
  }
@@ -28,4 +28,3 @@ async function getElement(locator) {
28
28
  }
29
29
  return matches[0];
30
30
  }
31
- exports.getElement = getElement;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oracle/oraclejet-testing",
3
3
  "scripts": {
4
- "build": "yarn clean; tsc --outDir dist --declarationDir dist/types && yarn copy-files",
4
+ "build": "yarn clean; tsc --outDir dist && yarn copy-files",
5
5
  "clean": "rimraf dist",
6
6
  "copy-files": "mergeJson package.json src/package-overrides.json dist/package.json"
7
7
  },
@@ -9,7 +9,7 @@
9
9
  "@oracle/oraclejet-internal-ws-build": "workspace:^",
10
10
  "copyfiles": "2.4.1",
11
11
  "rimraf": "3.0.2",
12
- "typescript": "5.4.5"
12
+ "typescript": "5.7.2"
13
13
  },
14
14
  "exports": {
15
15
  "./*": "./*/index.js"
@@ -17,10 +17,10 @@
17
17
  "typesVersions": {
18
18
  "*": {
19
19
  "*": [
20
- "./types/*/index.d.ts"
20
+ "./*/index.d.ts"
21
21
  ]
22
22
  }
23
23
  },
24
24
  "dependencies": {},
25
- "version": "17.1.4"
25
+ "version": "18.0.1"
26
26
  }