@ember-joinery/test-support 1.0.1 → 1.1.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/CHANGELOG.md +24 -0
- package/dist/app-shell.d.ts +43 -0
- package/dist/app-shell.d.ts.map +1 -0
- package/dist/app-shell.js +78 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/inspector.d.ts +47 -0
- package/dist/inspector.d.ts.map +1 -0
- package/dist/inspector.js +97 -0
- package/dist/navigation-bar.d.ts +30 -0
- package/dist/navigation-bar.d.ts.map +1 -0
- package/dist/navigation-bar.js +52 -0
- package/dist/navigation-stack.d.ts +36 -0
- package/dist/navigation-stack.d.ts.map +1 -0
- package/dist/navigation-stack.js +67 -0
- package/dist/page.d.ts +38 -0
- package/dist/page.d.ts.map +1 -0
- package/dist/page.js +68 -0
- package/dist/pull-to-refresh.d.ts +40 -0
- package/dist/pull-to-refresh.d.ts.map +1 -0
- package/dist/pull-to-refresh.js +65 -0
- package/dist/split-view.d.ts +77 -0
- package/dist/split-view.d.ts.map +1 -0
- package/dist/split-view.js +145 -0
- package/dist/status-bar.d.ts +25 -0
- package/dist/status-bar.d.ts.map +1 -0
- package/dist/status-bar.js +42 -0
- package/dist/tab-bar.d.ts +38 -0
- package/dist/tab-bar.d.ts.map +1 -0
- package/dist/tab-bar.js +78 -0
- package/dist/title-bar.d.ts +43 -0
- package/dist/title-bar.d.ts.map +1 -0
- package/dist/title-bar.js +74 -0
- package/dist/toolbar.d.ts +40 -0
- package/dist/toolbar.d.ts.map +1 -0
- package/dist/toolbar.js +67 -0
- package/dist/window-frame.d.ts +40 -0
- package/dist/window-frame.d.ts.map +1 -0
- package/dist/window-frame.js +66 -0
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Reads a `<TitleBar>` from `@ember-joinery/ember`: its title, how it is laid out, and its
|
|
4
|
+
* parts.
|
|
5
|
+
*
|
|
6
|
+
* const bar = new TitleBarHarness('main') // <TitleBar @name="main">
|
|
7
|
+
* assert.strictEqual(bar.title, 'Inbox')
|
|
8
|
+
* assert.strictEqual(bar.variant, 'unified')
|
|
9
|
+
* assert.false(bar.isInactive)
|
|
10
|
+
*
|
|
11
|
+
* The bar wraps the app's controls, so its own parts are found by their `data-jn-title-bar-*`
|
|
12
|
+
* attributes. A component in one of its parts has a harness of its own:
|
|
13
|
+
* `bar.find(ToolbarHarness)`.
|
|
14
|
+
*/
|
|
15
|
+
export declare class TitleBarHarness extends Harness {
|
|
16
|
+
#private;
|
|
17
|
+
static component: string;
|
|
18
|
+
/** The title's text, or `''` when it has none. */
|
|
19
|
+
get title(): string;
|
|
20
|
+
/** The subtitle's text, or `''` when it has none. */
|
|
21
|
+
get subtitle(): string;
|
|
22
|
+
/** Its `@variant`: `unified`, `unified-compact` or `expanded`. */
|
|
23
|
+
get variant(): string | null;
|
|
24
|
+
/** Its `@controls`: `none`, `start` or `overlay`. */
|
|
25
|
+
get controls(): string | null;
|
|
26
|
+
/** Whether it has the inactive look: the window has no focus, or `@inactive`. */
|
|
27
|
+
get isInactive(): boolean;
|
|
28
|
+
/** Whether it is a drag region. */
|
|
29
|
+
get isDraggable(): boolean;
|
|
30
|
+
/** The title's element. Throws when it has none. */
|
|
31
|
+
get titleElement(): HTMLElement;
|
|
32
|
+
/** The `Leading` part, or `null`. */
|
|
33
|
+
get leading(): HTMLElement | null;
|
|
34
|
+
/** The `Center` part, or `null`. */
|
|
35
|
+
get center(): HTMLElement | null;
|
|
36
|
+
/** The `Trailing` part, or `null`. */
|
|
37
|
+
get trailing(): HTMLElement | null;
|
|
38
|
+
/** The `Toolbar` row part, or `null`. */
|
|
39
|
+
get toolbar(): HTMLElement | null;
|
|
40
|
+
/** The `TrafficLights` part, or `null`. */
|
|
41
|
+
get trafficLights(): HTMLElement | null;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=title-bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"title-bar.d.ts","sourceRoot":"","sources":["../src/title-bar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAgB,SAAQ,OAAO;;IAC1C,OAAgB,SAAS,SAAc;IAMvC,kDAAkD;IAClD,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,qDAAqD;IACrD,IAAI,QAAQ,IAAI,MAAM,CAGrB;IAED,kEAAkE;IAClE,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,qDAAqD;IACrD,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAE5B;IAED,iFAAiF;IACjF,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,mCAAmC;IACnC,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,oDAAoD;IACpD,IAAI,YAAY,IAAI,WAAW,CAI9B;IAED,qCAAqC;IACrC,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,oCAAoC;IACpC,IAAI,MAAM,IAAI,WAAW,GAAG,IAAI,CAE/B;IAED,sCAAsC;IACtC,IAAI,QAAQ,IAAI,WAAW,GAAG,IAAI,CAEjC;IAED,yCAAyC;IACzC,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,2CAA2C;IAC3C,IAAI,aAAa,IAAI,WAAW,GAAG,IAAI,CAEtC;CACF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Harness } from "./harness.js";
|
|
2
|
+
import { textOf } from "./-private/checkable.js";
|
|
3
|
+
/**
|
|
4
|
+
* Reads a `<TitleBar>` from `@ember-joinery/ember`: its title, how it is laid out, and its
|
|
5
|
+
* parts.
|
|
6
|
+
*
|
|
7
|
+
* const bar = new TitleBarHarness('main') // <TitleBar @name="main">
|
|
8
|
+
* assert.strictEqual(bar.title, 'Inbox')
|
|
9
|
+
* assert.strictEqual(bar.variant, 'unified')
|
|
10
|
+
* assert.false(bar.isInactive)
|
|
11
|
+
*
|
|
12
|
+
* The bar wraps the app's controls, so its own parts are found by their `data-jn-title-bar-*`
|
|
13
|
+
* attributes. A component in one of its parts has a harness of its own:
|
|
14
|
+
* `bar.find(ToolbarHarness)`.
|
|
15
|
+
*/
|
|
16
|
+
export class TitleBarHarness extends Harness {
|
|
17
|
+
static component = 'title-bar';
|
|
18
|
+
#query(part) {
|
|
19
|
+
return this.element.querySelector(`[data-jn-title-bar-${part}]`);
|
|
20
|
+
}
|
|
21
|
+
/** The title's text, or `''` when it has none. */
|
|
22
|
+
get title() {
|
|
23
|
+
const title = this.#query('title');
|
|
24
|
+
return title ? textOf(title) : '';
|
|
25
|
+
}
|
|
26
|
+
/** The subtitle's text, or `''` when it has none. */
|
|
27
|
+
get subtitle() {
|
|
28
|
+
const subtitle = this.#query('subtitle');
|
|
29
|
+
return subtitle ? textOf(subtitle) : '';
|
|
30
|
+
}
|
|
31
|
+
/** Its `@variant`: `unified`, `unified-compact` or `expanded`. */
|
|
32
|
+
get variant() {
|
|
33
|
+
return this.element.getAttribute('data-variant');
|
|
34
|
+
}
|
|
35
|
+
/** Its `@controls`: `none`, `start` or `overlay`. */
|
|
36
|
+
get controls() {
|
|
37
|
+
return this.element.getAttribute('data-controls');
|
|
38
|
+
}
|
|
39
|
+
/** Whether it has the inactive look: the window has no focus, or `@inactive`. */
|
|
40
|
+
get isInactive() {
|
|
41
|
+
return this.element.hasAttribute('data-inactive');
|
|
42
|
+
}
|
|
43
|
+
/** Whether it is a drag region. */
|
|
44
|
+
get isDraggable() {
|
|
45
|
+
return this.element.hasAttribute('data-draggable');
|
|
46
|
+
}
|
|
47
|
+
/** The title's element. Throws when it has none. */
|
|
48
|
+
get titleElement() {
|
|
49
|
+
const title = this.#query('title');
|
|
50
|
+
if (!title)
|
|
51
|
+
throw new Error(`Joinery harness: no title in ${this}`);
|
|
52
|
+
return title;
|
|
53
|
+
}
|
|
54
|
+
/** The `Leading` part, or `null`. */
|
|
55
|
+
get leading() {
|
|
56
|
+
return this.#query('leading');
|
|
57
|
+
}
|
|
58
|
+
/** The `Center` part, or `null`. */
|
|
59
|
+
get center() {
|
|
60
|
+
return this.#query('center');
|
|
61
|
+
}
|
|
62
|
+
/** The `Trailing` part, or `null`. */
|
|
63
|
+
get trailing() {
|
|
64
|
+
return this.#query('trailing');
|
|
65
|
+
}
|
|
66
|
+
/** The `Toolbar` row part, or `null`. */
|
|
67
|
+
get toolbar() {
|
|
68
|
+
return this.#query('toolbar');
|
|
69
|
+
}
|
|
70
|
+
/** The `TrafficLights` part, or `null`. */
|
|
71
|
+
get trafficLights() {
|
|
72
|
+
return this.#query('traffic-lights');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
import { type KeyModifiers } from './focus.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Drives a `<Toolbar>` from `@ember-joinery/ember`: its controls (each element with the
|
|
5
|
+
* toolbar's `item` modifier), which one Tab stops on, and the keys that move between them.
|
|
6
|
+
*
|
|
7
|
+
* const toolbar = new ToolbarHarness('format') // <Toolbar @name="format">
|
|
8
|
+
* assert.deepEqual(toolbar.labels, ['Bold', 'Italic', 'Share'])
|
|
9
|
+
* await toolbar.focus()
|
|
10
|
+
* await toolbar.press('ArrowRight')
|
|
11
|
+
* assert.strictEqual(toolbar.focusedLabel, 'Italic')
|
|
12
|
+
*/
|
|
13
|
+
export declare class ToolbarHarness extends Harness {
|
|
14
|
+
static component: string;
|
|
15
|
+
/** Its accessible name: `aria-label` or `aria-labelledby`. */
|
|
16
|
+
get label(): string;
|
|
17
|
+
/** Its orientation (`aria-orientation`): `horizontal` or `vertical`. */
|
|
18
|
+
get orientation(): string | null;
|
|
19
|
+
/** Its `@size`: `sm`, `default` or `lg`. */
|
|
20
|
+
get size(): string | null;
|
|
21
|
+
/** Its controls, in order: every element with the toolbar's `item` modifier. */
|
|
22
|
+
get controls(): HTMLElement[];
|
|
23
|
+
/** Each control's accessible name, in order. */
|
|
24
|
+
get labels(): string[];
|
|
25
|
+
/** The control Tab enters the toolbar on, or `null` before any has had focus. */
|
|
26
|
+
get tabStop(): HTMLElement | null;
|
|
27
|
+
/** The control with focus, or `null`. */
|
|
28
|
+
get focused(): HTMLElement | null;
|
|
29
|
+
/** The accessible name of the control with focus, or `''`. */
|
|
30
|
+
get focusedLabel(): string;
|
|
31
|
+
/** Its groups, in order. */
|
|
32
|
+
get groups(): HTMLElement[];
|
|
33
|
+
/** Its separators, in order. */
|
|
34
|
+
get separators(): HTMLElement[];
|
|
35
|
+
/** Focuses the toolbar as Tab does: the control last focused, or the first. */
|
|
36
|
+
focus(): Promise<void>;
|
|
37
|
+
/** Presses a key on the focused control: an arrow, Home or End moves focus. */
|
|
38
|
+
press(key: string, modifiers?: KeyModifiers): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=toolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../src/toolbar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA;AAGxD;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,OAAO;IACzC,OAAgB,SAAS,SAAY;IAErC,8DAA8D;IAC9D,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,wEAAwE;IACxE,IAAI,WAAW,IAAI,MAAM,GAAG,IAAI,CAE/B;IAED,4CAA4C;IAC5C,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,gFAAgF;IAChF,IAAI,QAAQ,IAAI,WAAW,EAAE,CAI5B;IAED,gDAAgD;IAChD,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED,iFAAiF;IACjF,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,yCAAyC;IACzC,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAGhC;IAED,8DAA8D;IAC9D,IAAI,YAAY,IAAI,MAAM,CAGzB;IAED,4BAA4B;IAC5B,IAAI,MAAM,IAAI,WAAW,EAAE,CAE1B;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,WAAW,EAAE,CAE9B;IAED,+EAA+E;IACzE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,+EAA+E;IACzE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtE"}
|
package/dist/toolbar.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { focus } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { pressKey } from "./focus.js";
|
|
4
|
+
import { accessibleName } from "./-private/checkable.js";
|
|
5
|
+
/**
|
|
6
|
+
* Drives a `<Toolbar>` from `@ember-joinery/ember`: its controls (each element with the
|
|
7
|
+
* toolbar's `item` modifier), which one Tab stops on, and the keys that move between them.
|
|
8
|
+
*
|
|
9
|
+
* const toolbar = new ToolbarHarness('format') // <Toolbar @name="format">
|
|
10
|
+
* assert.deepEqual(toolbar.labels, ['Bold', 'Italic', 'Share'])
|
|
11
|
+
* await toolbar.focus()
|
|
12
|
+
* await toolbar.press('ArrowRight')
|
|
13
|
+
* assert.strictEqual(toolbar.focusedLabel, 'Italic')
|
|
14
|
+
*/
|
|
15
|
+
export class ToolbarHarness extends Harness {
|
|
16
|
+
static component = 'toolbar';
|
|
17
|
+
/** Its accessible name: `aria-label` or `aria-labelledby`. */
|
|
18
|
+
get label() {
|
|
19
|
+
return accessibleName(this.element);
|
|
20
|
+
}
|
|
21
|
+
/** Its orientation (`aria-orientation`): `horizontal` or `vertical`. */
|
|
22
|
+
get orientation() {
|
|
23
|
+
return this.element.getAttribute('aria-orientation');
|
|
24
|
+
}
|
|
25
|
+
/** Its `@size`: `sm`, `default` or `lg`. */
|
|
26
|
+
get size() {
|
|
27
|
+
return this.element.getAttribute('data-size');
|
|
28
|
+
}
|
|
29
|
+
/** Its controls, in order: every element with the toolbar's `item` modifier. */
|
|
30
|
+
get controls() {
|
|
31
|
+
return [...this.element.querySelectorAll('[tabindex]')].filter(control => control !== this.element);
|
|
32
|
+
}
|
|
33
|
+
/** Each control's accessible name, in order. */
|
|
34
|
+
get labels() {
|
|
35
|
+
return this.controls.map(control => accessibleName(control));
|
|
36
|
+
}
|
|
37
|
+
/** The control Tab enters the toolbar on, or `null` before any has had focus. */
|
|
38
|
+
get tabStop() {
|
|
39
|
+
return this.controls.find(control => control.getAttribute('tabindex') === '0') ?? null;
|
|
40
|
+
}
|
|
41
|
+
/** The control with focus, or `null`. */
|
|
42
|
+
get focused() {
|
|
43
|
+
const active = this.element.ownerDocument.activeElement;
|
|
44
|
+
return this.controls.find(control => control === active) ?? null;
|
|
45
|
+
}
|
|
46
|
+
/** The accessible name of the control with focus, or `''`. */
|
|
47
|
+
get focusedLabel() {
|
|
48
|
+
const focused = this.focused;
|
|
49
|
+
return focused ? accessibleName(focused) : '';
|
|
50
|
+
}
|
|
51
|
+
/** Its groups, in order. */
|
|
52
|
+
get groups() {
|
|
53
|
+
return this.parts('group');
|
|
54
|
+
}
|
|
55
|
+
/** Its separators, in order. */
|
|
56
|
+
get separators() {
|
|
57
|
+
return this.parts('separator');
|
|
58
|
+
}
|
|
59
|
+
/** Focuses the toolbar as Tab does: the control last focused, or the first. */
|
|
60
|
+
async focus() {
|
|
61
|
+
await focus(this.tabStop ?? this.controls[0]);
|
|
62
|
+
}
|
|
63
|
+
/** Presses a key on the focused control: an arrow, Home or End moves focus. */
|
|
64
|
+
async press(key, modifiers = {}) {
|
|
65
|
+
await pressKey(key, modifiers);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
type Region = 'title-bar' | 'sidebar' | 'body' | 'status-bar';
|
|
3
|
+
/**
|
|
4
|
+
* Reads a `<WindowFrame>` from `@ember-joinery/ember`: what kind of window it is, and its
|
|
5
|
+
* regions.
|
|
6
|
+
*
|
|
7
|
+
* const frame = new WindowFrameHarness('mail') // <WindowFrame @name="mail">
|
|
8
|
+
* assert.strictEqual(frame.label, 'Mail')
|
|
9
|
+
* assert.strictEqual(frame.find(TitleBarHarness).title, 'Mail')
|
|
10
|
+
*
|
|
11
|
+
* The frame wraps the app, so the parts inside it still belong to the components around them;
|
|
12
|
+
* its own regions are found by their `data-jn-window-frame-*` attributes. A page object can
|
|
13
|
+
* extend this class and declare the app's components with `@child`.
|
|
14
|
+
*/
|
|
15
|
+
export declare class WindowFrameHarness extends Harness {
|
|
16
|
+
#private;
|
|
17
|
+
static component: string;
|
|
18
|
+
/** Its accessible name: the title (`aria-labelledby`), or its `aria-label`. */
|
|
19
|
+
get label(): string;
|
|
20
|
+
/** Its `@variant`: `window`, `settings`, `panel` or `hud`. */
|
|
21
|
+
get variant(): string | null;
|
|
22
|
+
/** Whether it fills the viewport, as the root of an app. */
|
|
23
|
+
get isFill(): boolean;
|
|
24
|
+
/** Whether it has the inactive look. */
|
|
25
|
+
get isInactive(): boolean;
|
|
26
|
+
/** Whether the sidebar runs the full height, beside the title bar. */
|
|
27
|
+
get hasFullHeightSidebar(): boolean;
|
|
28
|
+
/** The title bar region. Throws when it has none. */
|
|
29
|
+
get titleBar(): HTMLElement;
|
|
30
|
+
/** The sidebar region. Throws when it has none. */
|
|
31
|
+
get sidebar(): HTMLElement;
|
|
32
|
+
/** The body. Throws when it has none. */
|
|
33
|
+
get body(): HTMLElement;
|
|
34
|
+
/** The status bar region. Throws when it has none. */
|
|
35
|
+
get statusBar(): HTMLElement;
|
|
36
|
+
/** Whether it has the region: `title-bar`, `sidebar`, `body` or `status-bar`. */
|
|
37
|
+
has(region: Region): boolean;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=window-frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window-frame.d.ts","sourceRoot":"","sources":["../src/window-frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,KAAK,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,YAAY,CAAA;AAE7D;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAmB,SAAQ,OAAO;;IAC7C,OAAgB,SAAS,SAAiB;IAY1C,+EAA+E;IAC/E,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,8DAA8D;IAC9D,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,4DAA4D;IAC5D,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,wCAAwC;IACxC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,sEAAsE;IACtE,IAAI,oBAAoB,IAAI,OAAO,CAElC;IAED,qDAAqD;IACrD,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED,mDAAmD;IACnD,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,yCAAyC;IACzC,IAAI,IAAI,IAAI,WAAW,CAEtB;IAED,sDAAsD;IACtD,IAAI,SAAS,IAAI,WAAW,CAE3B;IAED,iFAAiF;IACjF,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAG7B"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Harness } from "./harness.js";
|
|
2
|
+
import { accessibleName } from "./-private/checkable.js";
|
|
3
|
+
/**
|
|
4
|
+
* Reads a `<WindowFrame>` from `@ember-joinery/ember`: what kind of window it is, and its
|
|
5
|
+
* regions.
|
|
6
|
+
*
|
|
7
|
+
* const frame = new WindowFrameHarness('mail') // <WindowFrame @name="mail">
|
|
8
|
+
* assert.strictEqual(frame.label, 'Mail')
|
|
9
|
+
* assert.strictEqual(frame.find(TitleBarHarness).title, 'Mail')
|
|
10
|
+
*
|
|
11
|
+
* The frame wraps the app, so the parts inside it still belong to the components around them;
|
|
12
|
+
* its own regions are found by their `data-jn-window-frame-*` attributes. A page object can
|
|
13
|
+
* extend this class and declare the app's components with `@child`.
|
|
14
|
+
*/
|
|
15
|
+
export class WindowFrameHarness extends Harness {
|
|
16
|
+
static component = 'window-frame';
|
|
17
|
+
#query(region) {
|
|
18
|
+
return this.element.querySelector(`:scope > [data-jn-window-frame-${region}]`);
|
|
19
|
+
}
|
|
20
|
+
#region(region) {
|
|
21
|
+
const element = this.#query(region);
|
|
22
|
+
if (!element)
|
|
23
|
+
throw new Error(`Joinery harness: no ${region} in ${this}`);
|
|
24
|
+
return element;
|
|
25
|
+
}
|
|
26
|
+
/** Its accessible name: the title (`aria-labelledby`), or its `aria-label`. */
|
|
27
|
+
get label() {
|
|
28
|
+
return accessibleName(this.element);
|
|
29
|
+
}
|
|
30
|
+
/** Its `@variant`: `window`, `settings`, `panel` or `hud`. */
|
|
31
|
+
get variant() {
|
|
32
|
+
return this.element.getAttribute('data-variant');
|
|
33
|
+
}
|
|
34
|
+
/** Whether it fills the viewport, as the root of an app. */
|
|
35
|
+
get isFill() {
|
|
36
|
+
return this.element.hasAttribute('data-fill');
|
|
37
|
+
}
|
|
38
|
+
/** Whether it has the inactive look. */
|
|
39
|
+
get isInactive() {
|
|
40
|
+
return this.element.hasAttribute('data-inactive');
|
|
41
|
+
}
|
|
42
|
+
/** Whether the sidebar runs the full height, beside the title bar. */
|
|
43
|
+
get hasFullHeightSidebar() {
|
|
44
|
+
return this.element.hasAttribute('data-full-height-sidebar');
|
|
45
|
+
}
|
|
46
|
+
/** The title bar region. Throws when it has none. */
|
|
47
|
+
get titleBar() {
|
|
48
|
+
return this.#region('title-bar');
|
|
49
|
+
}
|
|
50
|
+
/** The sidebar region. Throws when it has none. */
|
|
51
|
+
get sidebar() {
|
|
52
|
+
return this.#region('sidebar');
|
|
53
|
+
}
|
|
54
|
+
/** The body. Throws when it has none. */
|
|
55
|
+
get body() {
|
|
56
|
+
return this.#region('body');
|
|
57
|
+
}
|
|
58
|
+
/** The status bar region. Throws when it has none. */
|
|
59
|
+
get statusBar() {
|
|
60
|
+
return this.#region('status-bar');
|
|
61
|
+
}
|
|
62
|
+
/** Whether it has the region: `title-bar`, `sidebar`, `body` or `status-bar`. */
|
|
63
|
+
has(region) {
|
|
64
|
+
return this.#query(region) !== null;
|
|
65
|
+
}
|
|
66
|
+
}
|
package/package.json
CHANGED