@ngneers/controls-playwright 0.0.1-next.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 +20 -0
- package/dist/components/accordion.d.ts +21 -0
- package/dist/components/accordion.d.ts.map +1 -0
- package/dist/components/accordion.js +42 -0
- package/dist/components/avatar.d.ts +9 -0
- package/dist/components/avatar.d.ts.map +1 -0
- package/dist/components/avatar.js +16 -0
- package/dist/components/breadcrumb.d.ts +20 -0
- package/dist/components/breadcrumb.d.ts.map +1 -0
- package/dist/components/breadcrumb.js +15 -0
- package/dist/components/button-group.d.ts +10 -0
- package/dist/components/button-group.d.ts.map +1 -0
- package/dist/components/button-group.js +16 -0
- package/dist/components/button.d.ts +6 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +6 -0
- package/dist/components/calendar.d.ts +101 -0
- package/dist/components/calendar.d.ts.map +1 -0
- package/dist/components/calendar.js +56 -0
- package/dist/components/chip.d.ts +15 -0
- package/dist/components/chip.d.ts.map +1 -0
- package/dist/components/chip.js +38 -0
- package/dist/components/edit-inplace.d.ts +18 -0
- package/dist/components/edit-inplace.d.ts.map +1 -0
- package/dist/components/edit-inplace.js +29 -0
- package/dist/components/filter.d.ts +186 -0
- package/dist/components/filter.d.ts.map +1 -0
- package/dist/components/filter.js +55 -0
- package/dist/components/hint.d.ts +10 -0
- package/dist/components/hint.d.ts.map +1 -0
- package/dist/components/hint.js +22 -0
- package/dist/components/index.d.ts +38 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +37 -0
- package/dist/components/inplace.d.ts +12 -0
- package/dist/components/inplace.d.ts.map +1 -0
- package/dist/components/inplace.js +29 -0
- package/dist/components/input-field.d.ts +12 -0
- package/dist/components/input-field.d.ts.map +1 -0
- package/dist/components/input-field.js +11 -0
- package/dist/components/input.d.ts +12 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +25 -0
- package/dist/components/item-view.d.ts +18 -0
- package/dist/components/item-view.d.ts.map +1 -0
- package/dist/components/item-view.js +39 -0
- package/dist/components/list-box.d.ts +20 -0
- package/dist/components/list-box.d.ts.map +1 -0
- package/dist/components/list-box.js +24 -0
- package/dist/components/mask-input.d.ts +62 -0
- package/dist/components/mask-input.d.ts.map +1 -0
- package/dist/components/mask-input.js +109 -0
- package/dist/components/menu.d.ts +16 -0
- package/dist/components/menu.d.ts.map +1 -0
- package/dist/components/menu.js +26 -0
- package/dist/components/message.d.ts +10 -0
- package/dist/components/message.d.ts.map +1 -0
- package/dist/components/message.js +22 -0
- package/dist/components/popover.d.ts +12 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/popover.js +33 -0
- package/dist/components/progress.d.ts +17 -0
- package/dist/components/progress.d.ts.map +1 -0
- package/dist/components/progress.js +46 -0
- package/dist/components/radio.d.ts +16 -0
- package/dist/components/radio.d.ts.map +1 -0
- package/dist/components/radio.js +35 -0
- package/dist/components/scroller.d.ts +20 -0
- package/dist/components/scroller.d.ts.map +1 -0
- package/dist/components/scroller.js +58 -0
- package/dist/components/select-button.d.ts +30 -0
- package/dist/components/select-button.d.ts.map +1 -0
- package/dist/components/select-button.js +46 -0
- package/dist/components/select.d.ts +46 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +74 -0
- package/dist/components/slider.d.ts +26 -0
- package/dist/components/slider.d.ts.map +1 -0
- package/dist/components/slider.js +73 -0
- package/dist/components/snackbar.d.ts +27 -0
- package/dist/components/snackbar.d.ts.map +1 -0
- package/dist/components/snackbar.js +70 -0
- package/dist/components/spinner.d.ts +11 -0
- package/dist/components/spinner.d.ts.map +1 -0
- package/dist/components/spinner.js +22 -0
- package/dist/components/state.d.ts +31 -0
- package/dist/components/state.d.ts.map +1 -0
- package/dist/components/state.js +31 -0
- package/dist/components/switch.d.ts +12 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/switch.js +39 -0
- package/dist/components/tabs.d.ts +22 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tabs.js +42 -0
- package/dist/components/tag.d.ts +10 -0
- package/dist/components/tag.d.ts.map +1 -0
- package/dist/components/tag.js +22 -0
- package/dist/components/toast.d.ts +27 -0
- package/dist/components/toast.d.ts.map +1 -0
- package/dist/components/toast.js +68 -0
- package/dist/components/toggle-button.d.ts +10 -0
- package/dist/components/toggle-button.d.ts.map +1 -0
- package/dist/components/toggle-button.js +29 -0
- package/dist/components/tooltip.d.ts +12 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +32 -0
- package/dist/components/tree.d.ts +47 -0
- package/dist/components/tree.d.ts.map +1 -0
- package/dist/components/tree.js +85 -0
- package/dist/components/upload.d.ts +27 -0
- package/dist/components/upload.d.ts.map +1 -0
- package/dist/components/upload.js +47 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/classes.d.ts +119 -0
- package/dist/utils/classes.d.ts.map +1 -0
- package/dist/utils/classes.js +31 -0
- package/dist/utils/theme.d.ts +3 -0
- package/dist/utils/theme.d.ts.map +1 -0
- package/dist/utils/theme.js +41 -0
- package/package.json +37 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type Locator } from '@playwright/test';
|
|
2
|
+
/**
|
|
3
|
+
* Playwright harness for `ngn-mask-input` (v2).
|
|
4
|
+
*
|
|
5
|
+
* ## Value assertion
|
|
6
|
+
* The control's `value` model (the serialized string, or `null` when incomplete)
|
|
7
|
+
* is NOT written into any DOM element — the proxy input stays empty at all times.
|
|
8
|
+
* E2E tests must assert the emitted value via a bound echo element rendered by the
|
|
9
|
+
* test component (e.g. `<span data-testid="value">{{ inputs().value }}</span>`).
|
|
10
|
+
* This harness intentionally does NOT expose an `expectValue` method.
|
|
11
|
+
*/
|
|
12
|
+
export declare class NgnMaskInputHarness {
|
|
13
|
+
private readonly locator;
|
|
14
|
+
readonly classes: import("@ngneers/controls-themes").ThemeClasses<import("@ngneers/controls-themes").ControlTemplate<"mask-input", ["root", "section", "section-active", "section-placeholder", "separator", "proxy", "sr-only"], readonly []>>;
|
|
15
|
+
/**
|
|
16
|
+
* The visually-hidden proxy input — this is the element that receives focus
|
|
17
|
+
* and keyboard events. All `press` / `pressSequentially` calls target it.
|
|
18
|
+
*/
|
|
19
|
+
readonly proxy: Locator;
|
|
20
|
+
/**
|
|
21
|
+
* All `[role="spinbutton"]` section spans (both filled and placeholder state).
|
|
22
|
+
*/
|
|
23
|
+
readonly sections: Locator;
|
|
24
|
+
constructor(locator: Locator);
|
|
25
|
+
/** Focus the proxy input so subsequent key events are delivered to the control. */
|
|
26
|
+
focus(): Promise<void>;
|
|
27
|
+
/** Press a single key on the proxy input (e.g. 'ArrowRight', 'Backspace', '1'). */
|
|
28
|
+
press(key: string): Promise<void>;
|
|
29
|
+
/** Type a string of characters into the proxy input one by one, with a small delay. */
|
|
30
|
+
pressSequentially(text: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Assert the visible rendered text of the control — the concatenation (with no
|
|
33
|
+
* separator) of all section, section-placeholder, and separator spans in DOM order.
|
|
34
|
+
* Screen-reader-only (`sr-only`) spans are excluded.
|
|
35
|
+
*
|
|
36
|
+
* Example: for a time mask `HH:MM:SS` with `12` entered in the first section
|
|
37
|
+
* the visible text is `'12:MM:SS'`.
|
|
38
|
+
*
|
|
39
|
+
* Uses Playwright's auto-retry (`expect.poll`) so it waits for Angular to render.
|
|
40
|
+
*/
|
|
41
|
+
expectText(visible: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the value of `aria-activedescendant` from the proxy input, which
|
|
44
|
+
* is the `id` of the currently focused section span. Returns `null` when the
|
|
45
|
+
* attribute is absent.
|
|
46
|
+
*/
|
|
47
|
+
activeDescendantId(): Promise<string | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Assert the innerText of the currently active section span.
|
|
50
|
+
* Useful for verifying which section is focused and what value it shows.
|
|
51
|
+
*/
|
|
52
|
+
expectActiveText(text: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Clear all sections by focusing the proxy, pressing Home to jump to the first
|
|
55
|
+
* section, then pressing Backspace twice per section (once to clear the value,
|
|
56
|
+
* once to step back if it was already empty — harmless no-op).
|
|
57
|
+
*
|
|
58
|
+
* This is intentionally blunt: it over-presses rather than inspecting state.
|
|
59
|
+
*/
|
|
60
|
+
clear(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=mask-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask-input.d.ts","sourceRoot":"","sources":["../../src/components/mask-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,kBAAkB,CAAC;AAIxD;;;;;;;;;GASG;AACH,qBAAa,mBAAmB;IAclB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAbpC,SAAgB,OAAO,gOAA0C;IAEjE;;;OAGG;IACH,SAAgB,KAAK,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,SAAgB,QAAQ,EAAE,OAAO,CAAC;gBAEL,OAAO,EAAE,OAAO;IAM7C,mFAAmF;IACtE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,mFAAmF;IACtE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9C,uFAAuF;IAC1E,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3D;;;;;;;;;OASG;IACI,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAejD;;;;OAIG;IACU,kBAAkB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKzD;;;OAGG;IACU,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS1D;;;;;;OAMG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAYpC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
import { themeClasses } from '../utils/theme';
|
|
3
|
+
import { maskInputControlTemplate } from '@ngneers/controls-themes/templates/mask-input';
|
|
4
|
+
/**
|
|
5
|
+
* Playwright harness for `ngn-mask-input` (v2).
|
|
6
|
+
*
|
|
7
|
+
* ## Value assertion
|
|
8
|
+
* The control's `value` model (the serialized string, or `null` when incomplete)
|
|
9
|
+
* is NOT written into any DOM element — the proxy input stays empty at all times.
|
|
10
|
+
* E2E tests must assert the emitted value via a bound echo element rendered by the
|
|
11
|
+
* test component (e.g. `<span data-testid="value">{{ inputs().value }}</span>`).
|
|
12
|
+
* This harness intentionally does NOT expose an `expectValue` method.
|
|
13
|
+
*/
|
|
14
|
+
export class NgnMaskInputHarness {
|
|
15
|
+
locator;
|
|
16
|
+
classes = themeClasses(maskInputControlTemplate);
|
|
17
|
+
/**
|
|
18
|
+
* The visually-hidden proxy input — this is the element that receives focus
|
|
19
|
+
* and keyboard events. All `press` / `pressSequentially` calls target it.
|
|
20
|
+
*/
|
|
21
|
+
proxy;
|
|
22
|
+
/**
|
|
23
|
+
* All `[role="spinbutton"]` section spans (both filled and placeholder state).
|
|
24
|
+
*/
|
|
25
|
+
sections;
|
|
26
|
+
constructor(locator) {
|
|
27
|
+
this.locator = locator;
|
|
28
|
+
// The proxy is the only <input> inside the control.
|
|
29
|
+
this.proxy = locator.locator('input').first();
|
|
30
|
+
this.sections = locator.locator('[role="spinbutton"]');
|
|
31
|
+
}
|
|
32
|
+
/** Focus the proxy input so subsequent key events are delivered to the control. */
|
|
33
|
+
async focus() {
|
|
34
|
+
await this.proxy.focus();
|
|
35
|
+
}
|
|
36
|
+
/** Press a single key on the proxy input (e.g. 'ArrowRight', 'Backspace', '1'). */
|
|
37
|
+
async press(key) {
|
|
38
|
+
await this.proxy.focus();
|
|
39
|
+
await this.proxy.press(key);
|
|
40
|
+
}
|
|
41
|
+
/** Type a string of characters into the proxy input one by one, with a small delay. */
|
|
42
|
+
async pressSequentially(text) {
|
|
43
|
+
await this.proxy.focus();
|
|
44
|
+
await this.proxy.pressSequentially(text, { delay: 5 });
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Assert the visible rendered text of the control — the concatenation (with no
|
|
48
|
+
* separator) of all section, section-placeholder, and separator spans in DOM order.
|
|
49
|
+
* Screen-reader-only (`sr-only`) spans are excluded.
|
|
50
|
+
*
|
|
51
|
+
* Example: for a time mask `HH:MM:SS` with `12` entered in the first section
|
|
52
|
+
* the visible text is `'12:MM:SS'`.
|
|
53
|
+
*
|
|
54
|
+
* Uses Playwright's auto-retry (`expect.poll`) so it waits for Angular to render.
|
|
55
|
+
*/
|
|
56
|
+
expectText(visible) {
|
|
57
|
+
const visibleSelector = [
|
|
58
|
+
this.classes['section'],
|
|
59
|
+
this.classes['section-placeholder'],
|
|
60
|
+
this.classes.separator,
|
|
61
|
+
].join(', ');
|
|
62
|
+
return expect
|
|
63
|
+
.poll(async () => {
|
|
64
|
+
const texts = await this.locator.locator(visibleSelector).allInnerTexts();
|
|
65
|
+
return texts.join('');
|
|
66
|
+
})
|
|
67
|
+
.toEqual(visible);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Returns the value of `aria-activedescendant` from the proxy input, which
|
|
71
|
+
* is the `id` of the currently focused section span. Returns `null` when the
|
|
72
|
+
* attribute is absent.
|
|
73
|
+
*/
|
|
74
|
+
async activeDescendantId() {
|
|
75
|
+
const val = await this.proxy.getAttribute('aria-activedescendant');
|
|
76
|
+
return val ?? null;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Assert the innerText of the currently active section span.
|
|
80
|
+
* Useful for verifying which section is focused and what value it shows.
|
|
81
|
+
*/
|
|
82
|
+
async expectActiveText(text) {
|
|
83
|
+
const id = await this.activeDescendantId();
|
|
84
|
+
if (id === null) {
|
|
85
|
+
throw new Error('No aria-activedescendant on proxy — no active section');
|
|
86
|
+
}
|
|
87
|
+
const activeSpan = this.locator.locator(`#${id}`);
|
|
88
|
+
await expect(activeSpan).toHaveText(text, { useInnerText: true });
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Clear all sections by focusing the proxy, pressing Home to jump to the first
|
|
92
|
+
* section, then pressing Backspace twice per section (once to clear the value,
|
|
93
|
+
* once to step back if it was already empty — harmless no-op).
|
|
94
|
+
*
|
|
95
|
+
* This is intentionally blunt: it over-presses rather than inspecting state.
|
|
96
|
+
*/
|
|
97
|
+
async clear() {
|
|
98
|
+
await this.proxy.focus();
|
|
99
|
+
// Start from the LAST section: Backspace clears the active section then steps
|
|
100
|
+
// to the previous one, so walking from the end clears every section. Starting
|
|
101
|
+
// from Home would get stuck on section 0 (Backspace there is a no-op).
|
|
102
|
+
await this.proxy.press('End');
|
|
103
|
+
const count = await this.sections.count();
|
|
104
|
+
for (let i = 0; i < count; i++) {
|
|
105
|
+
await this.proxy.press('Backspace');
|
|
106
|
+
await this.proxy.press('Backspace');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Locator } from '@playwright/test';
|
|
2
|
+
import { NgnPopoverHarness } from './popover';
|
|
3
|
+
export declare class NgnMenuHarness {
|
|
4
|
+
locator: Locator;
|
|
5
|
+
readonly classes: import("@ngneers/controls-themes").ThemeClasses<import("@ngneers/controls-themes").ControlTemplate<"menu", ["root", "submenu", "item", "item-opened", "icon-children", "separator"], readonly [{
|
|
6
|
+
readonly class: "popover";
|
|
7
|
+
readonly template: import("@ngneers/controls-themes").ControlTemplate<"popover", ["root", "content", "content-closing"], readonly []>;
|
|
8
|
+
}]>>;
|
|
9
|
+
readonly popover: NgnPopoverHarness;
|
|
10
|
+
readonly item: Locator;
|
|
11
|
+
constructor(locator: Locator);
|
|
12
|
+
expectItemCount(count: number): Promise<void>;
|
|
13
|
+
getItemByIndex(index: number): Promise<Locator>;
|
|
14
|
+
openChildMenuByIndex(index: number): Promise<NgnMenuHarness>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/components/menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,qBAAa,cAAc;IAKN,OAAO,EAAE,OAAO;IAJnC,SAAgB,OAAO;;;SAAqC;IAC5D,SAAgB,OAAO,EAAE,iBAAiB,CAAC;IAC3C,SAAgB,IAAI,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,OAAO;IAKtB,eAAe,CAAC,KAAK,EAAE,MAAM;IAI7B,cAAc,CAAC,KAAK,EAAE,MAAM;IAI5B,oBAAoB,CAAC,KAAK,EAAE,MAAM;CAKhD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
import { themeClasses } from '../utils/theme';
|
|
3
|
+
import { menuControlTemplate } from '@ngneers/controls-themes/templates/menu';
|
|
4
|
+
import { NgnPopoverHarness } from './popover';
|
|
5
|
+
export class NgnMenuHarness {
|
|
6
|
+
locator;
|
|
7
|
+
classes = themeClasses(menuControlTemplate);
|
|
8
|
+
popover;
|
|
9
|
+
item;
|
|
10
|
+
constructor(locator) {
|
|
11
|
+
this.locator = locator;
|
|
12
|
+
this.popover = new NgnPopoverHarness(locator.locator(this.classes['popover']['root']));
|
|
13
|
+
this.item = locator.locator(this.classes['item']);
|
|
14
|
+
}
|
|
15
|
+
async expectItemCount(count) {
|
|
16
|
+
await expect(this.item).toHaveCount(count);
|
|
17
|
+
}
|
|
18
|
+
async getItemByIndex(index) {
|
|
19
|
+
return this.item.nth(index);
|
|
20
|
+
}
|
|
21
|
+
async openChildMenuByIndex(index) {
|
|
22
|
+
const item = this.item.nth(index);
|
|
23
|
+
await item.click();
|
|
24
|
+
return new NgnMenuHarness(item.locator('ngn-menu').first());
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Locator } from '@playwright/test';
|
|
2
|
+
export declare class NgnMessageHarness {
|
|
3
|
+
readonly classes: import("@ngneers/controls-themes").ThemeClasses<import("@ngneers/controls-themes").ControlTemplate<"message", ["root", "content", "icon", `kind-${string}`, `color-${string}`], readonly []>>;
|
|
4
|
+
readonly locator: Locator;
|
|
5
|
+
readonly content: Locator;
|
|
6
|
+
readonly icon: Locator;
|
|
7
|
+
constructor(locator: Locator);
|
|
8
|
+
expectIcon(hasIcon: boolean): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/components/message.ts"],"names":[],"mappings":"AAEA,OAAa,EAAU,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE9D,qBAAa,iBAAiB;IAC5B,SAAgB,OAAO,gMAAwC;IAE/D,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,SAAgB,IAAI,EAAE,OAAO,CAAC;gBAElB,OAAO,EAAE,OAAO;IAMf,UAAU,CAAC,OAAO,EAAE,OAAO;CAOzC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { messageControlTemplate } from '@ngneers/controls-themes/templates/message';
|
|
2
|
+
import { themeClasses } from '../utils/theme';
|
|
3
|
+
import test, { expect } from '@playwright/test';
|
|
4
|
+
export class NgnMessageHarness {
|
|
5
|
+
classes = themeClasses(messageControlTemplate);
|
|
6
|
+
locator;
|
|
7
|
+
content;
|
|
8
|
+
icon;
|
|
9
|
+
constructor(locator) {
|
|
10
|
+
this.locator = locator;
|
|
11
|
+
this.content = locator.locator(this.classes.content);
|
|
12
|
+
this.icon = locator.locator(this.classes.icon);
|
|
13
|
+
}
|
|
14
|
+
async expectIcon(hasIcon) {
|
|
15
|
+
if (hasIcon) {
|
|
16
|
+
await expect(this.icon).toBeVisible();
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
await expect(this.icon).not.toBeVisible();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Locator } from '@playwright/test';
|
|
2
|
+
export declare class NgnPopoverHarness {
|
|
3
|
+
readonly classes: import("@ngneers/controls-themes").ThemeClasses<import("@ngneers/controls-themes").ControlTemplate<"popover", ["root", "content", "content-closing"], readonly []>>;
|
|
4
|
+
private readonly _ngnLazyCacher;
|
|
5
|
+
private readonly _contentWrapper;
|
|
6
|
+
private readonly _content;
|
|
7
|
+
constructor(locator: Locator);
|
|
8
|
+
get content(): Locator;
|
|
9
|
+
expectOpened(): Promise<void>;
|
|
10
|
+
expectRendered(rendered?: boolean): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/components/popover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,kBAAkB,CAAC;AAIxD,qBAAa,iBAAiB;IAC5B,SAAgB,OAAO,sKAAwC;IAE/D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IACzC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;gBAEvB,OAAO,EAAE,OAAO;IAM5B,IAAW,OAAO,IAAI,OAAO,CAE5B;IAEY,YAAY;IAIZ,cAAc,CAAC,QAAQ,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAa5D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
import { themeClasses } from '../utils/theme';
|
|
3
|
+
import { popoverControlTemplate } from '@ngneers/controls-themes/templates/popover';
|
|
4
|
+
export class NgnPopoverHarness {
|
|
5
|
+
classes = themeClasses(popoverControlTemplate);
|
|
6
|
+
_ngnLazyCacher;
|
|
7
|
+
_contentWrapper;
|
|
8
|
+
_content;
|
|
9
|
+
constructor(locator) {
|
|
10
|
+
this._ngnLazyCacher = locator.locator('ngn-defer');
|
|
11
|
+
this._contentWrapper = locator.locator(this.classes.content);
|
|
12
|
+
this._content = this._ngnLazyCacher.locator('> *');
|
|
13
|
+
}
|
|
14
|
+
get content() {
|
|
15
|
+
return this._content;
|
|
16
|
+
}
|
|
17
|
+
async expectOpened() {
|
|
18
|
+
await expect(this._contentWrapper).toBeVisible();
|
|
19
|
+
}
|
|
20
|
+
async expectRendered(rendered = true) {
|
|
21
|
+
await expect(this._ngnLazyCacher).toBeAttached();
|
|
22
|
+
await expect(async () => {
|
|
23
|
+
const el = await this._ngnLazyCacher.elementHandle();
|
|
24
|
+
const hasContent = !!(await el?.innerText()) || !!(await el?.evaluate(e => e.childElementCount));
|
|
25
|
+
if (rendered) {
|
|
26
|
+
expect(hasContent).toBeTruthy();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
expect(hasContent).toBeFalsy();
|
|
30
|
+
}
|
|
31
|
+
}).toPass({ timeout: 2000 });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Locator } from '@playwright/test';
|
|
2
|
+
export declare class NgnProgressHarness {
|
|
3
|
+
readonly classes: import("@ngneers/controls-themes").ThemeClasses<import("@ngneers/controls-themes").ControlTemplate<"progress", ["root", "svg", "track", "indeterminate", "circular", "fill", "fill2"], readonly []>>;
|
|
4
|
+
readonly locator: Locator;
|
|
5
|
+
readonly track: Locator;
|
|
6
|
+
readonly fill: Locator;
|
|
7
|
+
readonly fill2: Locator;
|
|
8
|
+
readonly svg: Locator;
|
|
9
|
+
constructor(locator: Locator);
|
|
10
|
+
expectValue(value: number): Promise<void>;
|
|
11
|
+
expectMin(min: number): Promise<void>;
|
|
12
|
+
expectMax(max: number): Promise<void>;
|
|
13
|
+
expectVisible(): Promise<void>;
|
|
14
|
+
expectIndeterminate(indeterminate: boolean): Promise<void>;
|
|
15
|
+
expectCircular(circular: boolean): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/components/progress.ts"],"names":[],"mappings":"AAEA,OAAa,EAAU,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE9D,qBAAa,kBAAkB;IAC7B,SAAgB,OAAO,uMAAyC;IAEhE,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,SAAgB,KAAK,EAAE,OAAO,CAAC;IAC/B,SAAgB,IAAI,EAAE,OAAO,CAAC;IAC9B,SAAgB,KAAK,EAAE,OAAO,CAAC;IAC/B,SAAgB,GAAG,EAAE,OAAO,CAAC;gBAEjB,OAAO,EAAE,OAAO;IAQf,WAAW,CAAC,KAAK,EAAE,MAAM;IAIzB,SAAS,CAAC,GAAG,EAAE,MAAM;IAIrB,SAAS,CAAC,GAAG,EAAE,MAAM;IAIrB,aAAa;IAIb,mBAAmB,CAAC,aAAa,EAAE,OAAO;IAQ1C,cAAc,CAAC,QAAQ,EAAE,OAAO;CAO9C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { progressControlTemplate } from '@ngneers/controls-themes/templates/progress';
|
|
2
|
+
import { themeClasses } from '../utils/theme';
|
|
3
|
+
import test, { expect } from '@playwright/test';
|
|
4
|
+
export class NgnProgressHarness {
|
|
5
|
+
classes = themeClasses(progressControlTemplate);
|
|
6
|
+
locator;
|
|
7
|
+
track;
|
|
8
|
+
fill;
|
|
9
|
+
fill2;
|
|
10
|
+
svg;
|
|
11
|
+
constructor(locator) {
|
|
12
|
+
this.locator = locator;
|
|
13
|
+
this.track = locator.locator(this.classes.track);
|
|
14
|
+
this.fill = locator.locator(this.classes.fill);
|
|
15
|
+
this.fill2 = locator.locator(this.classes.fill2);
|
|
16
|
+
this.svg = locator.locator(this.classes.svg);
|
|
17
|
+
}
|
|
18
|
+
async expectValue(value) {
|
|
19
|
+
await expect(this.locator).toHaveAttribute('aria-valuenow', value.toString());
|
|
20
|
+
}
|
|
21
|
+
async expectMin(min) {
|
|
22
|
+
await expect(this.locator).toHaveAttribute('aria-valuemin', min.toString());
|
|
23
|
+
}
|
|
24
|
+
async expectMax(max) {
|
|
25
|
+
await expect(this.locator).toHaveAttribute('aria-valuemax', max.toString());
|
|
26
|
+
}
|
|
27
|
+
async expectVisible() {
|
|
28
|
+
await expect(this.locator).toBeVisible();
|
|
29
|
+
}
|
|
30
|
+
async expectIndeterminate(indeterminate) {
|
|
31
|
+
if (indeterminate) {
|
|
32
|
+
await expect(this.fill2).toBeAttached();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
await expect(this.fill2).not.toBeAttached();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async expectCircular(circular) {
|
|
39
|
+
if (circular) {
|
|
40
|
+
await expect(this.svg).toBeVisible();
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
await expect(this.svg).not.toBeAttached();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Locator } from '@playwright/test';
|
|
2
|
+
export declare class NgnRadioGroupHarness {
|
|
3
|
+
readonly locator: Locator;
|
|
4
|
+
/** All radio options in the group, in DOM order. */
|
|
5
|
+
readonly radios: Locator;
|
|
6
|
+
constructor(locator: Locator);
|
|
7
|
+
radio(index: number): Locator;
|
|
8
|
+
/** Click the radio at `index` to select it. */
|
|
9
|
+
select(index: number, force?: boolean): Promise<void>;
|
|
10
|
+
expectSelected(index: number): Promise<void>;
|
|
11
|
+
expectNotSelected(index: number): Promise<void>;
|
|
12
|
+
expectDisabled(index: number, disabled?: boolean): Promise<void>;
|
|
13
|
+
/** Focus the currently active radio (the group's single tab stop). */
|
|
14
|
+
focusActive(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=radio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/components/radio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,kBAAkB,CAAC;AAExD,qBAAa,oBAAoB;IAC/B,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,oDAAoD;IACpD,SAAgB,MAAM,EAAE,OAAO,CAAC;gBAEpB,OAAO,EAAE,OAAO;IAKrB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIpC,+CAA+C;IAClC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,UAAQ;IAInC,cAAc,CAAC,KAAK,EAAE,MAAM;IAI5B,iBAAiB,CAAC,KAAK,EAAE,MAAM;IAI/B,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,UAAO;IAQ1D,sEAAsE;IACzD,WAAW;CAGzB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
export class NgnRadioGroupHarness {
|
|
3
|
+
locator;
|
|
4
|
+
/** All radio options in the group, in DOM order. */
|
|
5
|
+
radios;
|
|
6
|
+
constructor(locator) {
|
|
7
|
+
this.locator = locator;
|
|
8
|
+
this.radios = locator.locator('ngn-radio');
|
|
9
|
+
}
|
|
10
|
+
radio(index) {
|
|
11
|
+
return this.radios.nth(index);
|
|
12
|
+
}
|
|
13
|
+
/** Click the radio at `index` to select it. */
|
|
14
|
+
async select(index, force = false) {
|
|
15
|
+
await this.radio(index).click({ force });
|
|
16
|
+
}
|
|
17
|
+
async expectSelected(index) {
|
|
18
|
+
await expect(this.radio(index)).toHaveAttribute('aria-checked', 'true');
|
|
19
|
+
}
|
|
20
|
+
async expectNotSelected(index) {
|
|
21
|
+
await expect(this.radio(index)).toHaveAttribute('aria-checked', 'false');
|
|
22
|
+
}
|
|
23
|
+
async expectDisabled(index, disabled = true) {
|
|
24
|
+
if (disabled) {
|
|
25
|
+
await expect(this.radio(index)).toHaveAttribute('aria-disabled', 'true');
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
await expect(this.radio(index)).not.toHaveAttribute('aria-disabled', 'true');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Focus the currently active radio (the group's single tab stop). */
|
|
32
|
+
async focusActive() {
|
|
33
|
+
await this.locator.locator('ngn-radio[tabindex="0"]').focus();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Locator } from '@playwright/test';
|
|
2
|
+
export declare class NgnScrollerHarness {
|
|
3
|
+
locator: Locator;
|
|
4
|
+
readonly classes: import("@ngneers/controls-themes").ThemeClasses<import("@ngneers/controls-themes").ControlTemplate<"scroller", ["root", "virtual", "item", "item-sticky"], readonly []>>;
|
|
5
|
+
readonly scrollarea: Locator;
|
|
6
|
+
readonly item: Locator;
|
|
7
|
+
readonly itemSticky: Locator;
|
|
8
|
+
constructor(locator: Locator);
|
|
9
|
+
expectItemsCount(count: number): Promise<void>;
|
|
10
|
+
expectStickyItemsCount(count: number): Promise<void>;
|
|
11
|
+
expectItemsCountBetween(min: number, max: number): Promise<void>;
|
|
12
|
+
expectItemsTexts(texts: string[]): Promise<void>;
|
|
13
|
+
expectStickyItemsTexts(texts: string[]): Promise<void>;
|
|
14
|
+
clickItemByIndex(index: number): Promise<void>;
|
|
15
|
+
clickItemByText(text: string): Promise<void>;
|
|
16
|
+
getItemByIndex(index: number): Locator;
|
|
17
|
+
getItemByText(text: string): Locator;
|
|
18
|
+
scrollToIndex(index: number, itemHeight?: number): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=scroller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroller.d.ts","sourceRoot":"","sources":["../../src/components/scroller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAIxD,qBAAa,kBAAkB;IAMV,OAAO,EAAE,OAAO;IALnC,SAAgB,OAAO,2KAAyC;IAChE,SAAgB,UAAU,EAAE,OAAO,CAAC;IACpC,SAAgB,IAAI,EAAE,OAAO,CAAC;IAC9B,SAAgB,UAAU,EAAE,OAAO,CAAC;gBAEjB,OAAO,EAAE,OAAO;IAM5B,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAShE,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAItC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAU9E"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
import { themeClasses } from '../utils/theme';
|
|
3
|
+
import { scrollerControlTemplate } from '@ngneers/controls-themes/templates/scroller';
|
|
4
|
+
export class NgnScrollerHarness {
|
|
5
|
+
locator;
|
|
6
|
+
classes = themeClasses(scrollerControlTemplate);
|
|
7
|
+
scrollarea;
|
|
8
|
+
item;
|
|
9
|
+
itemSticky;
|
|
10
|
+
constructor(locator) {
|
|
11
|
+
this.locator = locator;
|
|
12
|
+
this.scrollarea = locator;
|
|
13
|
+
this.item = locator.locator(`> :not(${this.classes['item-sticky']})`);
|
|
14
|
+
this.itemSticky = locator.locator(this.classes['item-sticky']);
|
|
15
|
+
}
|
|
16
|
+
expectItemsCount(count) {
|
|
17
|
+
return expect(this.item).toHaveCount(count);
|
|
18
|
+
}
|
|
19
|
+
expectStickyItemsCount(count) {
|
|
20
|
+
return expect(this.itemSticky).toHaveCount(count);
|
|
21
|
+
}
|
|
22
|
+
expectItemsCountBetween(min, max) {
|
|
23
|
+
return expect(async () => {
|
|
24
|
+
const count = await this.item.count();
|
|
25
|
+
if (count < min || count > max) {
|
|
26
|
+
throw new Error(`Expected item count to be between ${min} and ${max}, but got ${count}`);
|
|
27
|
+
}
|
|
28
|
+
}).toPass();
|
|
29
|
+
}
|
|
30
|
+
expectItemsTexts(texts) {
|
|
31
|
+
return expect(this.item).toHaveText(texts);
|
|
32
|
+
}
|
|
33
|
+
expectStickyItemsTexts(texts) {
|
|
34
|
+
return expect(this.itemSticky).toHaveText(texts);
|
|
35
|
+
}
|
|
36
|
+
clickItemByIndex(index) {
|
|
37
|
+
return this.item.nth(index).click();
|
|
38
|
+
}
|
|
39
|
+
clickItemByText(text) {
|
|
40
|
+
return this.item.filter({ hasText: new RegExp(`^\\s*${text}\\s*$`, 'i') }).click();
|
|
41
|
+
}
|
|
42
|
+
getItemByIndex(index) {
|
|
43
|
+
return this.item.nth(index);
|
|
44
|
+
}
|
|
45
|
+
getItemByText(text) {
|
|
46
|
+
return this.item.filter({ hasText: new RegExp(`^\\s*${text}\\s*$`, 'i') });
|
|
47
|
+
}
|
|
48
|
+
async scrollToIndex(index, itemHeight) {
|
|
49
|
+
if (!itemHeight) {
|
|
50
|
+
await this.item.nth(index).scrollIntoViewIfNeeded();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const scrollAmount = index * itemHeight;
|
|
54
|
+
await this.scrollarea.evaluate((el, amount) => {
|
|
55
|
+
el.scrollTo({ top: amount });
|
|
56
|
+
}, scrollAmount);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Locator } from '@playwright/test';
|
|
2
|
+
import { NgnToggleButtonHarness } from './toggle-button';
|
|
3
|
+
export declare class NgnSelectButtonHarness {
|
|
4
|
+
readonly classes: import("@ngneers/controls-themes").ThemeClasses<import("@ngneers/controls-themes").ControlTemplate<"select-button", ["root", "invalid"], readonly [{
|
|
5
|
+
readonly class: "group";
|
|
6
|
+
readonly template: import("@ngneers/controls-themes").ControlTemplate<"button-group", ["root", "vertical", "horizontal"], readonly [{
|
|
7
|
+
readonly class: "button";
|
|
8
|
+
readonly template: import("@ngneers/controls-themes").ControlTemplate<"button", ["root", "inline", "loading", `kind-${string}`, `color-${string}`], readonly []>;
|
|
9
|
+
readonly projected: true;
|
|
10
|
+
}, {
|
|
11
|
+
readonly class: "toggle-button";
|
|
12
|
+
readonly template: import("@ngneers/controls-themes").ControlTemplate<"toggle-button", ["root", "invalid", "button", "label", "active", "placeholder", "placeholder-active"], readonly []>;
|
|
13
|
+
readonly projected: true;
|
|
14
|
+
}]>;
|
|
15
|
+
}, {
|
|
16
|
+
readonly class: "button";
|
|
17
|
+
readonly template: import("@ngneers/controls-themes").ControlTemplate<"toggle-button", ["root", "invalid", "button", "label", "active", "placeholder", "placeholder-active"], readonly []>;
|
|
18
|
+
}]>>;
|
|
19
|
+
readonly locator: Locator;
|
|
20
|
+
readonly buttons: Locator;
|
|
21
|
+
constructor(locator: Locator);
|
|
22
|
+
getButtonAt(index: number): NgnToggleButtonHarness;
|
|
23
|
+
getButtonByTestId(testId: string): NgnToggleButtonHarness;
|
|
24
|
+
clickButtonAt(index: number, force?: boolean): Promise<void>;
|
|
25
|
+
expectButtonCount(count: number): Promise<void>;
|
|
26
|
+
expectSelectedAt(index: number): Promise<void>;
|
|
27
|
+
expectNoneSelected(): Promise<void>;
|
|
28
|
+
expectDisabled(disabled: boolean): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=select-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-button.d.ts","sourceRoot":"","sources":["../../src/components/select-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,qBAAa,sBAAsB;IACjC,SAAgB,OAAO;;;;;;;;;;;;;;SAA6C;IAEpE,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,SAAgB,OAAO,EAAE,OAAO,CAAC;gBAErB,OAAO,EAAE,OAAO;IAKrB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,sBAAsB;IAIlD,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB;IAMnD,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,UAAQ;IAI1C,iBAAiB,CAAC,KAAK,EAAE,MAAM;IAI/B,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAI9B,kBAAkB;IAOlB,cAAc,CAAC,QAAQ,EAAE,OAAO;CAW9C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
import { themeClasses } from '../utils/theme';
|
|
3
|
+
import { selectButtonControlTemplate } from '@ngneers/controls-themes/templates/select-button';
|
|
4
|
+
import { NgnToggleButtonHarness } from './toggle-button';
|
|
5
|
+
export class NgnSelectButtonHarness {
|
|
6
|
+
classes = themeClasses(selectButtonControlTemplate);
|
|
7
|
+
locator;
|
|
8
|
+
buttons;
|
|
9
|
+
constructor(locator) {
|
|
10
|
+
this.locator = locator;
|
|
11
|
+
this.buttons = locator.locator('ngn-toggle-button');
|
|
12
|
+
}
|
|
13
|
+
getButtonAt(index) {
|
|
14
|
+
return new NgnToggleButtonHarness(this.buttons.nth(index));
|
|
15
|
+
}
|
|
16
|
+
getButtonByTestId(testId) {
|
|
17
|
+
return new NgnToggleButtonHarness(this.locator.locator(`ngn-toggle-button[data-testid="${testId}"]`));
|
|
18
|
+
}
|
|
19
|
+
async clickButtonAt(index, force = false) {
|
|
20
|
+
await this.getButtonAt(index).click(force);
|
|
21
|
+
}
|
|
22
|
+
async expectButtonCount(count) {
|
|
23
|
+
await expect(this.buttons).toHaveCount(count);
|
|
24
|
+
}
|
|
25
|
+
async expectSelectedAt(index) {
|
|
26
|
+
await this.getButtonAt(index).expectActive(true);
|
|
27
|
+
}
|
|
28
|
+
async expectNoneSelected() {
|
|
29
|
+
const count = await this.buttons.count();
|
|
30
|
+
for (let i = 0; i < count; i++) {
|
|
31
|
+
await this.getButtonAt(i).expectActive(false);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async expectDisabled(disabled) {
|
|
35
|
+
const innerButtons = this.locator.locator('button');
|
|
36
|
+
const count = await innerButtons.count();
|
|
37
|
+
for (let i = 0; i < count; i++) {
|
|
38
|
+
if (disabled) {
|
|
39
|
+
await expect(innerButtons.nth(i)).toBeDisabled();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
await expect(innerButtons.nth(i)).not.toBeDisabled();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|