@blotch/angular-lynx-testing-library 22.2.25 → 22.2.27
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 +3 -3
- package/dist/fire-event.d.ts +15 -0
- package/dist/fire-event.d.ts.map +1 -1
- package/dist/fire-event.js +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/linking.d.ts +31 -4
- package/dist/linking.d.ts.map +1 -1
- package/dist/linking.js +61 -5
- package/dist/render.d.ts +12 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +36 -1
- package/dist/role-queries.d.ts +6 -1
- package/dist/role-queries.d.ts.map +1 -1
- package/dist/role-queries.js +61 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -209,12 +209,12 @@ expect(getByRole('button', { name: 'Week', selected: true })).toBeTruthy();
|
|
|
209
209
|
| `adjustable` | `slider` |
|
|
210
210
|
| `tabbar` | `tablist` |
|
|
211
211
|
|
|
212
|
-
- **Role**: from each trait in the table. An `<image>` is an `img` unless it sets `accessibility-traits`.
|
|
212
|
+
- **Role**: from each trait in the table. An `<image>` is an `img` unless it sets `accessibility-traits`. `accessibility-heading` adds `heading`, and an `accessibility-role-description` of `button`, `switch`, `checkbox`, `image` or `progressbar` adds that role (`image` is `img`), as Android reads them.
|
|
213
213
|
- **Reachable**: a screen reader reaches `<text>`, `<image>`, and other elements with `accessibility-element="true"`, outside `accessibility-elements-hidden`. A `tabbar` is read from the container around the tabs, so it needs no `accessibility-element`. Others match only with `hidden: true`.
|
|
214
|
-
- **`name`**: the `accessibility-label`, or a `<text>`'s own text. A `<view>` gets no name from the text inside it, since iOS doesn't read it.
|
|
214
|
+
- **`name`**: the `accessibility-label`, or a `<text>`'s own text. A `<view>` gets no name from the text inside it, since iOS doesn't read it. An `accessibility-status` comes first, as iOS and Android read it: `'Unread, Inbox'`.
|
|
215
215
|
- **`selected`**: the `selected` trait, as in `accessibility-traits="button,selected"`, which an active `routerLinkActive` element gets, and which `[lynxAccessibilityTraits]="{ selected: true }"` adds. iOS reads a comma-separated list. Android reads one trait (`button` or `image`) and treats a list as `none`.
|
|
216
216
|
- **`value: { text }`**: the `accessibility-value`.
|
|
217
|
-
- **Other ARIA states** (`checked`, `pressed`, `expanded`, `level`, …) have no Lynx attribute, so Lynx elements never match them.
|
|
217
|
+
- **Other ARIA states** (`checked`, `pressed`, `expanded`, `level`, …) have no Lynx attribute, so Lynx elements never match them, a `switch` or `checkbox` from a role description included.
|
|
218
218
|
|
|
219
219
|
### `screen`, `within()` and `getQueriesForElement()`
|
|
220
220
|
|
package/dist/fire-event.d.ts
CHANGED
|
@@ -106,6 +106,12 @@ export declare const eventMap: {
|
|
|
106
106
|
bubbles: boolean;
|
|
107
107
|
};
|
|
108
108
|
};
|
|
109
|
+
mouseenter: {
|
|
110
|
+
defaultInit: {};
|
|
111
|
+
};
|
|
112
|
+
mouseleave: {
|
|
113
|
+
defaultInit: {};
|
|
114
|
+
};
|
|
109
115
|
scroll: {
|
|
110
116
|
defaultInit: {};
|
|
111
117
|
};
|
|
@@ -148,6 +154,15 @@ export declare const eventMap: {
|
|
|
148
154
|
confirm: {
|
|
149
155
|
defaultInit: {};
|
|
150
156
|
};
|
|
157
|
+
keyboardheightchange: {
|
|
158
|
+
defaultInit: {};
|
|
159
|
+
};
|
|
160
|
+
accessibilityaction: {
|
|
161
|
+
defaultInit: {};
|
|
162
|
+
};
|
|
163
|
+
requestclose: {
|
|
164
|
+
defaultInit: {};
|
|
165
|
+
};
|
|
151
166
|
layoutchange: {
|
|
152
167
|
defaultInit: {};
|
|
153
168
|
};
|
package/dist/fire-event.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fire-event.d.ts","sourceRoot":"","sources":["../src/fire-event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAoBH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"fire-event.d.ts","sourceRoot":"","sources":["../src/fire-event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAoBH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEpB,CAAC;AAEF,KAAK,SAAS,GAAG,MAAM,OAAO,QAAQ,CAAC;AACvC,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;AAC/E,KAAK,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,GAAG;KAC3D,CAAC,IAAI,SAAS,GAAG,YAAY;CAC/B,CAAC;AAsLF,eAAO,MAAM,SAAS,EAAE,SAET,CAAC"}
|
package/dist/fire-event.js
CHANGED
|
@@ -57,6 +57,12 @@ export const eventMap = {
|
|
|
57
57
|
mousedblclick: { defaultInit: { bubbles: true } },
|
|
58
58
|
mouselongpress: { defaultInit: { bubbles: true } },
|
|
59
59
|
wheel: { defaultInit: { bubbles: true } },
|
|
60
|
+
// The pointer moving onto and off an element. They stay on it, as on the
|
|
61
|
+
// web: Lynx's desktop engine sends them outside HandleBubbleEvent, and Lynx
|
|
62
|
+
// for Web forwards the DOM's mouseenter and mouseleave, which don't bubble.
|
|
63
|
+
// A component clears a pressed state on mouseleave.
|
|
64
|
+
mouseenter: { defaultInit: {} },
|
|
65
|
+
mouseleave: { defaultInit: {} },
|
|
60
66
|
// Scroll / viewport
|
|
61
67
|
scroll: { defaultInit: {} },
|
|
62
68
|
scrollend: { defaultInit: {} },
|
|
@@ -76,6 +82,14 @@ export const eventMap = {
|
|
|
76
82
|
blur: { defaultInit: {} },
|
|
77
83
|
input: { defaultInit: {} },
|
|
78
84
|
confirm: { defaultInit: {} },
|
|
85
|
+
// An <input> or <textarea> with focus reporting the keyboard's height as it
|
|
86
|
+
// shows, changes size and hides (`detail.height`, 0 once it's gone).
|
|
87
|
+
keyboardheightchange: { defaultInit: {} },
|
|
88
|
+
// Accessibility: a screen reader running one of the element's
|
|
89
|
+
// `accessibility-actions`, named in `detail.name`.
|
|
90
|
+
accessibilityaction: { defaultInit: {} },
|
|
91
|
+
// Overlays: Android's back button asking an <overlay> to close.
|
|
92
|
+
requestclose: { defaultInit: {} },
|
|
79
93
|
// Layout / loading. `load` is an <image>, <svg>, <frame> or <webview>
|
|
80
94
|
// reporting its content arrived, and `error` an <image>, <video>,
|
|
81
95
|
// <webview> or <overlay> reporting it didn't. A device sends both to the
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { render, cleanup, waitForUpdate } from './render.js';
|
|
|
2
2
|
export type { RenderInputs, RenderOptions, RenderResult } from './render.js';
|
|
3
3
|
export type { ComponentRef } from '@angular/core';
|
|
4
4
|
export { fireEvent, eventMap } from './fire-event.js';
|
|
5
|
-
export { openedURLs } from './linking.js';
|
|
5
|
+
export { openedURLs, openLink } from './linking.js';
|
|
6
6
|
export type { OpenedURL } from './linking.js';
|
|
7
7
|
export { runShortcut } from './shortcuts.js';
|
|
8
8
|
export { screen, within, getQueriesForElement, queries } from './queries.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7E,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7E,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC7E,YAAY,EACV,8BAA8B,EAC9B,gBAAgB,EAChB,WAAW,EACX,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,EACvB,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,GACX,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { render, cleanup, waitForUpdate } from './render.js';
|
|
2
2
|
export { fireEvent, eventMap } from './fire-event.js';
|
|
3
|
-
export { openedURLs } from './linking.js';
|
|
3
|
+
export { openedURLs, openLink } from './linking.js';
|
|
4
4
|
export { runShortcut } from './shortcuts.js';
|
|
5
5
|
export { screen, within, getQueriesForElement, queries } from './queries.js';
|
|
6
6
|
export { queryAllByAccessibilityLabel, queryByAccessibilityLabel, getAllByAccessibilityLabel, getByAccessibilityLabel, findAllByAccessibilityLabel, findByAccessibilityLabel, } from './accessibility-label-queries.js';
|
package/dist/linking.d.ts
CHANGED
|
@@ -13,13 +13,16 @@ export type OpenedURL = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Gives the environment's background thread an `AngularLynxLinking` module,
|
|
15
15
|
* as the apps `ng build --platform` makes have, which records each URL rather
|
|
16
|
-
* than opening it
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* than opening it, and keeps the links to the app {@link openLink} sends
|
|
17
|
+
* until `LynxLinking` takes them. `LynxLinking` reaches it through the
|
|
18
|
+
* background thread, as it reaches the shells' module, so specs see the
|
|
19
|
+
* runtime's own behavior: `openURL()` and `openInApp()` resolve, and
|
|
20
|
+
* `canOpenURL()` resolves `true`.
|
|
19
21
|
*
|
|
20
22
|
* It runs each time the environment injects the background thread's globals:
|
|
21
23
|
* when it's created, and on the reset after each test, so each test starts
|
|
22
|
-
* with no URLs recorded
|
|
24
|
+
* with no URLs recorded and no link waiting. Only
|
|
25
|
+
* `NativeModules.AngularLynxLinking` is added:
|
|
23
26
|
* every other module stays missing, as in Lynx Explorer.
|
|
24
27
|
*/
|
|
25
28
|
export declare const installLinkingModule: (threadGlobals: {
|
|
@@ -39,4 +42,28 @@ export declare const installLinkingModule: (threadGlobals: {
|
|
|
39
42
|
* ```
|
|
40
43
|
*/
|
|
41
44
|
export declare const openedURLs: () => readonly OpenedURL[];
|
|
45
|
+
/**
|
|
46
|
+
* Opens the app with a link, as the person does by tapping a link with one of
|
|
47
|
+
* angular.json's `deepLinkSchemes` while the app is open, so a spec can check
|
|
48
|
+
* where it leads. With `provideRouter()`, the router navigates to the link's
|
|
49
|
+
* route, and each `LynxLinking.onURL()` handler is called with the URL.
|
|
50
|
+
*
|
|
51
|
+
* The link reaches the app as it does on a phone, through the background
|
|
52
|
+
* thread: wait for it with `waitForUpdate()`. Sent before the app listens,
|
|
53
|
+
* it waits for the first handler, as a link that arrives while an app is
|
|
54
|
+
* starting does. It's never the link that started the app:
|
|
55
|
+
* `LynxLinking.getInitialURL()` stays `null`. Give that one to `render()` as
|
|
56
|
+
* its `initialURL` option.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* await render(App, { providers: [provideRouter(routes)] });
|
|
61
|
+
* openLink('myapp://orders/42');
|
|
62
|
+
* await waitForUpdate();
|
|
63
|
+
* expect(screen.getByText('Order 42')).toBeInTheDocument();
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param url - The whole URL, such as `myapp://orders/42?tab=items`.
|
|
67
|
+
*/
|
|
68
|
+
export declare const openLink: (url: string) => void;
|
|
42
69
|
//# sourceMappingURL=linking.d.ts.map
|
package/dist/linking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../src/linking.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,mCAAmC;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,CAAC;
|
|
1
|
+
{"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../src/linking.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,mCAAmC;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,CAAC;AAmCF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAAI,eAAe;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC,KAAG,IAqBH,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,QAAO,SAAS,SAAS,EAM/C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,KAAG,IA2BtC,CAAC"}
|
package/dist/linking.js
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* What `LynxLinking` calls and hears, named as the shells name their module
|
|
3
|
+
* and global event.
|
|
4
|
+
*/
|
|
2
5
|
const MODULE = 'AngularLynxLinking';
|
|
6
|
+
const EVENT = 'angularLynxURL';
|
|
3
7
|
/**
|
|
4
8
|
* Gives the environment's background thread an `AngularLynxLinking` module,
|
|
5
9
|
* as the apps `ng build --platform` makes have, which records each URL rather
|
|
6
|
-
* than opening it
|
|
7
|
-
*
|
|
8
|
-
*
|
|
10
|
+
* than opening it, and keeps the links to the app {@link openLink} sends
|
|
11
|
+
* until `LynxLinking` takes them. `LynxLinking` reaches it through the
|
|
12
|
+
* background thread, as it reaches the shells' module, so specs see the
|
|
13
|
+
* runtime's own behavior: `openURL()` and `openInApp()` resolve, and
|
|
14
|
+
* `canOpenURL()` resolves `true`.
|
|
9
15
|
*
|
|
10
16
|
* It runs each time the environment injects the background thread's globals:
|
|
11
17
|
* when it's created, and on the reset after each test, so each test starts
|
|
12
|
-
* with no URLs recorded
|
|
18
|
+
* with no URLs recorded and no link waiting. Only
|
|
19
|
+
* `NativeModules.AngularLynxLinking` is added:
|
|
13
20
|
* every other module stays missing, as in Lynx Explorer.
|
|
14
21
|
*/
|
|
15
22
|
export const installLinkingModule = (threadGlobals) => {
|
|
16
23
|
const opened = [];
|
|
24
|
+
const waiting = [];
|
|
17
25
|
const module = {
|
|
18
26
|
opened,
|
|
27
|
+
waiting,
|
|
19
28
|
openURL: (url, done) => {
|
|
20
29
|
opened.push({ url, inApp: false });
|
|
21
30
|
done({});
|
|
@@ -25,6 +34,7 @@ export const installLinkingModule = (threadGlobals) => {
|
|
|
25
34
|
done({});
|
|
26
35
|
},
|
|
27
36
|
canOpenURL: (_url, done) => done({ value: true }),
|
|
37
|
+
takeURLs: (done) => done({ urls: waiting.splice(0) }),
|
|
28
38
|
};
|
|
29
39
|
threadGlobals.NativeModules = {
|
|
30
40
|
...threadGlobals.NativeModules,
|
|
@@ -51,3 +61,49 @@ export const openedURLs = () => {
|
|
|
51
61
|
.NativeModules?.[MODULE];
|
|
52
62
|
return [...(module?.opened ?? [])];
|
|
53
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Opens the app with a link, as the person does by tapping a link with one of
|
|
66
|
+
* angular.json's `deepLinkSchemes` while the app is open, so a spec can check
|
|
67
|
+
* where it leads. With `provideRouter()`, the router navigates to the link's
|
|
68
|
+
* route, and each `LynxLinking.onURL()` handler is called with the URL.
|
|
69
|
+
*
|
|
70
|
+
* The link reaches the app as it does on a phone, through the background
|
|
71
|
+
* thread: wait for it with `waitForUpdate()`. Sent before the app listens,
|
|
72
|
+
* it waits for the first handler, as a link that arrives while an app is
|
|
73
|
+
* starting does. It's never the link that started the app:
|
|
74
|
+
* `LynxLinking.getInitialURL()` stays `null`. Give that one to `render()` as
|
|
75
|
+
* its `initialURL` option.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* await render(App, { providers: [provideRouter(routes)] });
|
|
80
|
+
* openLink('myapp://orders/42');
|
|
81
|
+
* await waitForUpdate();
|
|
82
|
+
* expect(screen.getByText('Order 42')).toBeInTheDocument();
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @param url - The whole URL, such as `myapp://orders/42?tab=items`.
|
|
86
|
+
*/
|
|
87
|
+
export const openLink = (url) => {
|
|
88
|
+
// Read through the environment rather than kept here: under `ng test`, the
|
|
89
|
+
// setup file and the specs can load different copies of this module.
|
|
90
|
+
const env = globalThis.lynxTestingEnv;
|
|
91
|
+
const background = env?.backgroundThread.globalThis;
|
|
92
|
+
const module = background?.NativeModules?.[MODULE];
|
|
93
|
+
if (!env || !module) {
|
|
94
|
+
throw new Error("openLink() needs the testing library's environment, which its setup file installs.");
|
|
95
|
+
}
|
|
96
|
+
module.waiting.push(url);
|
|
97
|
+
// What the shells send when a link arrives: LynxLinking answers by taking
|
|
98
|
+
// the ones waiting. A global event arrives on the background thread, and
|
|
99
|
+
// the listener there calls the app's on the main thread through that
|
|
100
|
+
// thread's `lynx`, so the event is sent from it. Specs run on the main
|
|
101
|
+
// thread, which comes back afterwards.
|
|
102
|
+
env.switchToBackgroundThread();
|
|
103
|
+
try {
|
|
104
|
+
background?.lynx?.getJSModule?.('GlobalEventEmitter')?.emit(EVENT);
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
env.switchToMainThread();
|
|
108
|
+
}
|
|
109
|
+
};
|
package/dist/render.d.ts
CHANGED
|
@@ -57,6 +57,18 @@ export type RenderOptions<Q extends Queries = LynxQueries, C = unknown> = {
|
|
|
57
57
|
* sees `@Input()` and `inputs` metadata, but not `input()` or `model()`.
|
|
58
58
|
*/
|
|
59
59
|
inputs?: RenderInputs<C>;
|
|
60
|
+
/**
|
|
61
|
+
* The link that started the app, such as `myapp://orders/42`, as when the
|
|
62
|
+
* person opens the app from a link with one of angular.json's
|
|
63
|
+
* `deepLinkSchemes` while it's closed.
|
|
64
|
+
*
|
|
65
|
+
* `LynxLinking.getInitialURL()` returns it, and with `provideRouter()` the
|
|
66
|
+
* app's first screen is the link's route, with nothing under it to go back
|
|
67
|
+
* to. A link whose route the router can't find starts the app at `/`
|
|
68
|
+
* instead. Left out, the app starts from its icon: `getInitialURL()` is
|
|
69
|
+
* `null`. A link that arrives while the app is open is `openLink()`'s.
|
|
70
|
+
*/
|
|
71
|
+
initialURL?: string;
|
|
60
72
|
};
|
|
61
73
|
export type RenderResult<Q extends Queries = LynxQueries, C = unknown> = {
|
|
62
74
|
/**
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,QAAQ,EAKb,KAAK,IAAI,EACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,OAAO,EAEb,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,QAAQ,EAKb,KAAK,IAAI,EACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,OAAO,EAEb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAW,MAAM,cAAc,CAAC;AAEhF;;;;GAIG;AACH,KAAK,UAAU,CAAC,CAAC,IAIf,CAAC,SAAS,wBAAwB,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI;KACrC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,OAAO,GAAG,WAAW,EAAE,CAAC,GAAG,OAAO,IAAI;IACxE,SAAS,CAAC,EAAE,CAAC,QAAQ,GAAG,oBAAoB,CAAC,EAAE,CAAC;IAChD;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACzB;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAiCF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,WAAW,EAAE,CAAC,GAAG,OAAO,IAAI;IACvE;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3E;;;OAGG;IACH,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EACzC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,EAClB,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GACrC,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/B;;OAEG;IACH,UAAU,EAAE,MAAM,gBAAgB,CAAC;IACnC;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CAC/B,GAAG,gBAAgB,GAClB,cAAc,CAAC,CAAC,CAAC,CAAC;AAIpB,eAAO,MAAM,OAAO,QAAO,IAM1B,CAAC;AAmFF;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAU,CAAC,SAAS,OAAO,GAAG,WAAW,EAAE,CAAC,GAAG,OAAO,EACvE,eAAe,IAAI,CAAC,CAAC,CAAC,EACtB,UAAS,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAM,KACzC,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAuH5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,IAAI,CAKlD,CAAC"}
|
package/dist/render.js
CHANGED
|
@@ -17,8 +17,36 @@
|
|
|
17
17
|
import { inputBinding, provideZonelessChangeDetection, reflectComponentType, signal, } from '@angular/core';
|
|
18
18
|
import { createApplication } from '@angular/platform-browser';
|
|
19
19
|
import { getQueriesForElement, } from '@testing-library/dom';
|
|
20
|
-
import { provideRenderer } from '@blotch/angular-lynx';
|
|
20
|
+
import { provideRenderer, ɵhideSplashScreenUnlessProvided, } from '@blotch/angular-lynx';
|
|
21
21
|
import { queries } from './queries.js';
|
|
22
|
+
/**
|
|
23
|
+
* The global prop the shells hand the link that started the app in, which
|
|
24
|
+
* `LynxLinking.getInitialURL()` reads (see the runtime's linking.ts).
|
|
25
|
+
*/
|
|
26
|
+
const INITIAL_URL_PROP = 'initialURL';
|
|
27
|
+
/**
|
|
28
|
+
* Hands the app the link that started it, or none, as the shells do: in the
|
|
29
|
+
* global props, on both threads, before the app's code runs.
|
|
30
|
+
*
|
|
31
|
+
* Each render() sets it or clears it, so a rerender() with another component
|
|
32
|
+
* starts the app the way its own options say rather than with the last
|
|
33
|
+
* render's link. The environment's reset after each test gives each thread a
|
|
34
|
+
* new `lynx`, so nothing carries over to the next test either.
|
|
35
|
+
*/
|
|
36
|
+
const setInitialURL = (env, url) => {
|
|
37
|
+
// The environment gives both threads a `lynx`, but no global props: the
|
|
38
|
+
// first render() of a test creates them.
|
|
39
|
+
for (const thread of [env.mainThread, env.backgroundThread]) {
|
|
40
|
+
const props = (thread.globalThis.lynx.__globalProps ??=
|
|
41
|
+
{});
|
|
42
|
+
if (url === undefined) {
|
|
43
|
+
delete props[INITIAL_URL_PROP];
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
props[INITIAL_URL_PROP] = url;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
22
50
|
let currentAppRef = null;
|
|
23
51
|
export const cleanup = () => {
|
|
24
52
|
if (currentAppRef) {
|
|
@@ -105,6 +133,9 @@ export const render = async (rootComponent, options = {}) => {
|
|
|
105
133
|
// are available as globals. LynxDocument requires them to create elements.
|
|
106
134
|
const env = globalThis.lynxTestingEnv;
|
|
107
135
|
env.switchToMainThread();
|
|
136
|
+
// Before createApplication(): provideRouter() reads the link while the
|
|
137
|
+
// app's providers start, to pick the router's first route.
|
|
138
|
+
setInitialURL(env, options.initialURL);
|
|
108
139
|
// Clear JSDOM body so previous render's elements are gone.
|
|
109
140
|
const doc = globalThis.document;
|
|
110
141
|
doc.body.innerHTML = '';
|
|
@@ -133,6 +164,10 @@ export const render = async (rootComponent, options = {}) => {
|
|
|
133
164
|
// LynxDocument.createRootElement() runs during bootstrap, calling
|
|
134
165
|
// __CreatePage which appends the <page> element to document.body.
|
|
135
166
|
const componentRef = appRef.bootstrap(rootComponent, { bindings });
|
|
167
|
+
// What bootstrapApplication() does next: the splash screen goes at the
|
|
168
|
+
// first frame, unless the app's provideSplashScreen() says when. A spec
|
|
169
|
+
// reads LynxSplashScreen.visible() to see that it went.
|
|
170
|
+
ɵhideSplashScreenUnlessProvided(appRef);
|
|
136
171
|
// Force a synchronous CD cycle so signal-initialized state is reflected in
|
|
137
172
|
// the DOM before we return. bootstrap already triggers one CD, but work it
|
|
138
173
|
// starts may defer follow-up updates to a microtask: ngModel writes its
|
package/dist/role-queries.d.ts
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* - Role: each trait in `accessibility-traits` that names a kind of element
|
|
13
13
|
* (`TRAIT_ROLES`), or the element's own default: an `<image>` is an image.
|
|
14
|
+
* `accessibility-heading` makes it a heading, and an
|
|
15
|
+
* `accessibility-role-description` that names a kind of control makes it
|
|
16
|
+
* that control (`ROLE_DESCRIPTION_ROLES`), as Android reads them.
|
|
14
17
|
* - Exposed: a screen reader reaches an element only when it's an
|
|
15
18
|
* accessibility element. `<text>` and `<image>` are by default; anything
|
|
16
19
|
* else needs `accessibility-element="true"`. The exception is a tab bar,
|
|
@@ -20,7 +23,9 @@
|
|
|
20
23
|
* Library leaves out what's off the accessibility tree.
|
|
21
24
|
* - Name: `accessibility-label`, or a `<text>`'s own text when it has none.
|
|
22
25
|
* Lynx gives no other element a name from the text inside it: iOS reads an
|
|
23
|
-
* accessibility element's label and skips its children.
|
|
26
|
+
* accessibility element's label and skips its children. An
|
|
27
|
+
* `accessibility-status` comes first, as iOS and Android read it:
|
|
28
|
+
* `"Unread, Inbox"`.
|
|
24
29
|
* - State: the `selected` trait is `selected: true`, and `accessibility-value`
|
|
25
30
|
* is `value: { text }`. Lynx has no other ARIA state.
|
|
26
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-queries.d.ts","sourceRoot":"","sources":["../src/role-queries.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"role-queries.d.ts","sourceRoot":"","sources":["../src/role-queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAQL,OAAO,IAAI,UAAU,EACtB,MAAM,sBAAsB,CAAC;AA0Z9B,QAAA,MAAM,QAAQ,EAAqB,OAAO,UAAU,CAAC,cAAc,CAAC;AACpE,QAAA,MAAM,KAAK,EAAc,OAAO,UAAU,CAAC,WAAW,CAAC;AACvD,QAAA,MAAM,MAAM,EAAe,OAAO,UAAU,CAAC,YAAY,CAAC;AAC1D,QAAA,MAAM,GAAG,EAAY,OAAO,UAAU,CAAC,SAAS,CAAC;AACjD,QAAA,MAAM,OAAO,EAAgB,OAAO,UAAU,CAAC,aAAa,CAAC;AAC7D,QAAA,MAAM,IAAI,EAAa,OAAO,UAAU,CAAC,UAAU,CAAC;AAEpD,OAAO,EACL,QAAQ,IAAI,cAAc,EAC1B,KAAK,IAAI,WAAW,EACpB,MAAM,IAAI,YAAY,EACtB,GAAG,IAAI,SAAS,EAChB,OAAO,IAAI,aAAa,EACxB,IAAI,IAAI,UAAU,GACnB,CAAC"}
|
package/dist/role-queries.js
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* - Role: each trait in `accessibility-traits` that names a kind of element
|
|
13
13
|
* (`TRAIT_ROLES`), or the element's own default: an `<image>` is an image.
|
|
14
|
+
* `accessibility-heading` makes it a heading, and an
|
|
15
|
+
* `accessibility-role-description` that names a kind of control makes it
|
|
16
|
+
* that control (`ROLE_DESCRIPTION_ROLES`), as Android reads them.
|
|
14
17
|
* - Exposed: a screen reader reaches an element only when it's an
|
|
15
18
|
* accessibility element. `<text>` and `<image>` are by default; anything
|
|
16
19
|
* else needs `accessibility-element="true"`. The exception is a tab bar,
|
|
@@ -20,7 +23,9 @@
|
|
|
20
23
|
* Library leaves out what's off the accessibility tree.
|
|
21
24
|
* - Name: `accessibility-label`, or a `<text>`'s own text when it has none.
|
|
22
25
|
* Lynx gives no other element a name from the text inside it: iOS reads an
|
|
23
|
-
* accessibility element's label and skips its children.
|
|
26
|
+
* accessibility element's label and skips its children. An
|
|
27
|
+
* `accessibility-status` comes first, as iOS and Android read it:
|
|
28
|
+
* `"Unread, Inbox"`.
|
|
24
29
|
* - State: the `selected` trait is `selected: true`, and `accessibility-value`
|
|
25
30
|
* is `value: { text }`. Lynx has no other ARIA state.
|
|
26
31
|
*
|
|
@@ -46,6 +51,20 @@ const TRAIT_ROLES = new Map([
|
|
|
46
51
|
['adjustable', 'slider'],
|
|
47
52
|
['tabbar', 'tablist'],
|
|
48
53
|
]);
|
|
54
|
+
/**
|
|
55
|
+
* The ARIA role of each `accessibility-role-description` Android turns into
|
|
56
|
+
* a kind of control: it gives the node that control's class (a Switch, a
|
|
57
|
+
* CheckBox), and TalkBack names the control as it would a native one
|
|
58
|
+
* (`CustomAccessibilityDelegateCompat`). Any other description is read as
|
|
59
|
+
* it is, and gives no role.
|
|
60
|
+
*/
|
|
61
|
+
const ROLE_DESCRIPTION_ROLES = new Map([
|
|
62
|
+
['button', 'button'],
|
|
63
|
+
['switch', 'switch'],
|
|
64
|
+
['checkbox', 'checkbox'],
|
|
65
|
+
['image', 'img'],
|
|
66
|
+
['progressbar', 'progressbar'],
|
|
67
|
+
]);
|
|
49
68
|
/**
|
|
50
69
|
* The roles a screen reader reads from a container, not from an
|
|
51
70
|
* accessibility element. VoiceOver reads the tab bar trait from the view
|
|
@@ -90,21 +109,36 @@ const matchesText = (text, element, matcher) => {
|
|
|
90
109
|
const traitsOf = (element) => element.getAttribute('accessibility-traits')?.split(',') ??
|
|
91
110
|
(element.localName === 'image' ? ['image'] : []);
|
|
92
111
|
/**
|
|
93
|
-
* The
|
|
112
|
+
* Whether a true/false attribute is on. The attribute holds a string, so any
|
|
113
|
+
* value but "false" is true, as the element directives' boolean inputs read
|
|
114
|
+
* it.
|
|
94
115
|
*/
|
|
95
|
-
const
|
|
116
|
+
const isOn = (flag) => flag !== null && flag !== 'false';
|
|
117
|
+
/**
|
|
118
|
+
* The ARIA roles Lynx gives the element: its traits', a heading's, and its
|
|
119
|
+
* role description's.
|
|
120
|
+
*/
|
|
121
|
+
const lynxRolesOf = (element) => {
|
|
122
|
+
const roles = traitsOf(element).flatMap((trait) => TRAIT_ROLES.get(trait) ?? []);
|
|
123
|
+
if (isOn(element.getAttribute('accessibility-heading'))) {
|
|
124
|
+
roles.push('heading');
|
|
125
|
+
}
|
|
126
|
+
const described = ROLE_DESCRIPTION_ROLES.get(element.getAttribute('accessibility-role-description') ?? '');
|
|
127
|
+
if (described !== undefined)
|
|
128
|
+
roles.push(described);
|
|
129
|
+
return roles;
|
|
130
|
+
};
|
|
96
131
|
/**
|
|
97
132
|
* Whether the element is an accessibility element, one stop for a screen
|
|
98
133
|
* reader. Lynx makes `<text>` and `<image>` accessibility elements by default
|
|
99
134
|
* and nothing else, so a `<view>` is one only with
|
|
100
|
-
* `accessibility-element="true"`.
|
|
101
|
-
* but "false" is true, as the element directives' boolean inputs read it.
|
|
135
|
+
* `accessibility-element="true"`.
|
|
102
136
|
*/
|
|
103
137
|
const isAccessibilityElement = (element) => {
|
|
104
138
|
const flag = element.getAttribute('accessibility-element');
|
|
105
139
|
return flag === null
|
|
106
140
|
? element.localName === 'text' || element.localName === 'image'
|
|
107
|
-
: flag
|
|
141
|
+
: isOn(flag);
|
|
108
142
|
};
|
|
109
143
|
/**
|
|
110
144
|
* Whether a screen reader reads `role` on the element: from an accessibility
|
|
@@ -116,25 +150,37 @@ const exposesRole = (element, role) => (isAccessibilityElement(element) || CONTA
|
|
|
116
150
|
// Testing Library's own check catches what Lynx doesn't draw either, such
|
|
117
151
|
// as an element styled display: none.
|
|
118
152
|
!isInaccessible(element);
|
|
153
|
+
/**
|
|
154
|
+
* `name` as a screen reader reads it, after the element's
|
|
155
|
+
* `accessibility-status`: iOS and Android join the two with a comma
|
|
156
|
+
* (`concatA11yStatus` in `LynxUI.m`, `concatA11yStatusAndLabel` on
|
|
157
|
+
* Android). A `<text>` with a status and no label is named by its text
|
|
158
|
+
* after the status, as Android reads it; iOS reads only the status then, as
|
|
159
|
+
* a status stops it reading the text, which a label avoids.
|
|
160
|
+
*/
|
|
161
|
+
const withStatus = (element, name) => [element.getAttribute('accessibility-status'), name]
|
|
162
|
+
.filter(Boolean)
|
|
163
|
+
.join(', ');
|
|
119
164
|
/**
|
|
120
165
|
* What a screen reader reads as the element's name: its
|
|
121
166
|
* `accessibility-label`, or for a `<text>`, the text it shows (iOS and
|
|
122
|
-
* Android read that when the label is missing or empty).
|
|
167
|
+
* Android read that when the label is missing or empty), after its status.
|
|
123
168
|
*/
|
|
124
|
-
const lynxNameOf = (element) => element.getAttribute('accessibility-label') ||
|
|
169
|
+
const lynxNameOf = (element) => withStatus(element, element.getAttribute('accessibility-label') ||
|
|
125
170
|
(element.localName === 'text'
|
|
126
171
|
? element.textContent.replace(/\s+/g, ' ').trim()
|
|
127
|
-
: '');
|
|
172
|
+
: ''));
|
|
128
173
|
/**
|
|
129
174
|
* Whether the element is in the states `options` asks for. Lynx has two:
|
|
130
175
|
* the `selected` trait, and the value in `accessibility-value`. For the rest
|
|
131
176
|
* it answers as Testing Library does for an element without the `aria-*`
|
|
132
|
-
* attribute: not busy and not current, and never
|
|
133
|
-
* level or at a number.
|
|
134
|
-
*
|
|
177
|
+
* attribute: not busy and not current, and never checked, pressed,
|
|
178
|
+
* expanded, at a level or at a number. A role description makes a switch or
|
|
179
|
+
* a checkbox, but Lynx has no checked state to give it.
|
|
135
180
|
*/
|
|
136
|
-
const matchesState = (element, traits, { selected, busy, pressed, current, expanded, level, value = {}, }) => (selected === undefined || selected === traits.includes('selected')) &&
|
|
181
|
+
const matchesState = (element, traits, { selected, busy, checked, pressed, current, expanded, level, value = {}, }) => (selected === undefined || selected === traits.includes('selected')) &&
|
|
137
182
|
!busy &&
|
|
183
|
+
!checked &&
|
|
138
184
|
(current === undefined || current === false) &&
|
|
139
185
|
pressed === undefined &&
|
|
140
186
|
expanded === undefined &&
|
|
@@ -151,7 +197,7 @@ const queryAllByLynxRole = (container, role, options) => {
|
|
|
151
197
|
const { hidden = getConfig().defaultHidden, name, description } = options;
|
|
152
198
|
return Array.from(container.querySelectorAll('*')).filter((element) => {
|
|
153
199
|
const traits = traitsOf(element);
|
|
154
|
-
return (
|
|
200
|
+
return (lynxRolesOf(element).includes(role) &&
|
|
155
201
|
(hidden || exposesRole(element, role)) &&
|
|
156
202
|
matchesState(element, traits, options) &&
|
|
157
203
|
(name === undefined ||
|
|
@@ -172,7 +218,7 @@ const queryAllByAriaRole = (container, role, options) => {
|
|
|
172
218
|
...options,
|
|
173
219
|
name: name === undefined
|
|
174
220
|
? undefined
|
|
175
|
-
: (accessibleName, element) => matchesText(element.getAttribute('accessibility-label') || accessibleName, element, name),
|
|
221
|
+
: (accessibleName, element) => matchesText(withStatus(element, element.getAttribute('accessibility-label') || accessibleName), element, name),
|
|
176
222
|
});
|
|
177
223
|
}
|
|
178
224
|
catch (error) {
|
package/package.json
CHANGED