@badisi/wdio-harness 4.2.2 → 4.3.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.
- package/README.md +1 -0
- package/WebdriverIOHarnessEnvironment.d.ts +1 -1
- package/WebdriverIOHarnessEnvironment.js +1 -2
- package/WebdriverIOTestElement.d.ts +6 -1
- package/WebdriverIOTestElement.js +15 -3
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +2 -5
- package/utils.d.ts +3 -0
- package/utils.js +4 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentHarness, ComponentHarnessConstructor, HarnessEnvironment } from '@angular/cdk/testing';
|
|
1
|
+
import { type ComponentHarness, type ComponentHarnessConstructor, HarnessEnvironment } from '@angular/cdk/testing';
|
|
2
2
|
import { WebdriverIOTestElement } from './WebdriverIOTestElement.js';
|
|
3
3
|
/**
|
|
4
4
|
* A `HarnessEnvironment` implementation for WebdriverIO.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { HarnessEnvironment } from '@angular/cdk/testing';
|
|
2
2
|
import logger from '@wdio/logger';
|
|
3
3
|
import { WebdriverIOTestElement } from './WebdriverIOTestElement.js';
|
|
4
|
-
import
|
|
5
|
-
const { magenta, green } = colors;
|
|
4
|
+
import { green, magenta } from './utils';
|
|
6
5
|
/** Registers the environment logger. */
|
|
7
6
|
const log = logger('wdio-harness');
|
|
8
7
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementDimensions, EventData, ModifierKeys, TestElement, TestKey, TextOptions } from '@angular/cdk/testing';
|
|
1
|
+
import { type ElementDimensions, type EventData, type ModifierKeys, type TestElement, TestKey, type TextOptions } from '@angular/cdk/testing';
|
|
2
2
|
/** Module augmentation to expose the host element as a public api */
|
|
3
3
|
declare module '@angular/cdk/testing' {
|
|
4
4
|
interface ComponentHarness {
|
|
@@ -62,6 +62,11 @@ export declare class WebdriverIOTestElement implements TestElement {
|
|
|
62
62
|
sendKeys(modifiers: ModifierKeys, ...keys: (string | TestKey)[]): Promise<void>;
|
|
63
63
|
/** Gets the text from the element. */
|
|
64
64
|
text(options?: TextOptions): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Sets the value of a `contenteditable` element.
|
|
67
|
+
* @param value Value to be set on the element.
|
|
68
|
+
*/
|
|
69
|
+
setContenteditableValue(value: string): Promise<void>;
|
|
65
70
|
/** Gets the value for the given attribute from the element. */
|
|
66
71
|
getAttribute(name: string): Promise<string | null>;
|
|
67
72
|
/** Checks whether the element has the given class. */
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentHarness, TestKey } from '@angular/cdk/testing';
|
|
2
2
|
import { browser } from '@wdio/globals';
|
|
3
3
|
import logger from '@wdio/logger';
|
|
4
|
-
import
|
|
5
|
-
const { magenta, green } = colors;
|
|
4
|
+
import { green, magenta } from './utils';
|
|
6
5
|
var Button;
|
|
7
6
|
(function (Button) {
|
|
8
7
|
Button["LEFT"] = "left";
|
|
@@ -160,6 +159,19 @@ export class WebdriverIOTestElement {
|
|
|
160
159
|
// We don't go through WebdriverIO's `getText`, because it excludes text from hidden elements.
|
|
161
160
|
return browser.executeScript(`return (arguments[0].textContent ?? '').trim()`, [this.hostElement]);
|
|
162
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Sets the value of a `contenteditable` element.
|
|
164
|
+
* @param value Value to be set on the element.
|
|
165
|
+
*/
|
|
166
|
+
async setContenteditableValue(value) {
|
|
167
|
+
const contenteditableAttr = await this.getAttribute('contenteditable');
|
|
168
|
+
if (contenteditableAttr !== '' &&
|
|
169
|
+
contenteditableAttr !== 'true' &&
|
|
170
|
+
contenteditableAttr !== 'plaintext-only') {
|
|
171
|
+
throw new Error('setContenteditableValue can only be called on a `contenteditable` element.');
|
|
172
|
+
}
|
|
173
|
+
return browser.executeScript('arguments[0].textContent = arguments[1];', [this.hostElement, value]);
|
|
174
|
+
}
|
|
163
175
|
/** Gets the value for the given attribute from the element. */
|
|
164
176
|
async getAttribute(name) {
|
|
165
177
|
this.logAction('GET_ATTRIBUTE', name);
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentHarness, HarnessQuery } from '@angular/cdk/testing';
|
|
1
|
+
import type { ComponentHarness, HarnessQuery } from '@angular/cdk/testing';
|
|
2
2
|
import { WebdriverIOHarnessEnvironment } from './WebdriverIOHarnessEnvironment.js';
|
|
3
3
|
/**
|
|
4
4
|
* Searches for all instances of the component corresponding to the given harness type under the
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { browser
|
|
1
|
+
import { $, browser } from '@wdio/globals';
|
|
2
2
|
import { WebdriverIOHarnessEnvironment } from './WebdriverIOHarnessEnvironment.js';
|
|
3
3
|
/**
|
|
4
4
|
* Searches for all instances of the component corresponding to the given harness type under the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@badisi/wdio-harness",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "WebdriverIO support for Angular component test harnesses.",
|
|
5
5
|
"homepage": "https://github.com/Badisi/wdio-harness",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,11 +39,8 @@
|
|
|
39
39
|
"node": "^16.14.0 || >=18.10.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@angular/cdk": ">= 13 <
|
|
42
|
+
"@angular/cdk": ">= 13 < 22",
|
|
43
43
|
"@wdio/logger": ">= 9 < 10",
|
|
44
44
|
"webdriverio": ">= 9 < 10"
|
|
45
|
-
},
|
|
46
|
-
"dependencies": {
|
|
47
|
-
"@colors/colors": "^1.6.0"
|
|
48
45
|
}
|
|
49
46
|
}
|
package/utils.d.ts
ADDED
package/utils.js
ADDED