@blotch/angular-lynx-testing-library 22.3.2 → 22.3.3
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/dist/app-state.d.ts.map +1 -1
- package/dist/app-state.js +2 -26
- package/dist/audio-recorder.d.ts +95 -0
- package/dist/audio-recorder.d.ts.map +1 -0
- package/dist/audio-recorder.js +250 -0
- package/dist/fire-event.d.ts.map +1 -1
- package/dist/fire-event.js +58 -8
- package/dist/geolocation.d.ts +94 -0
- package/dist/geolocation.d.ts.map +1 -0
- package/dist/geolocation.js +255 -0
- package/dist/global-props.d.ts +17 -0
- package/dist/global-props.d.ts.map +1 -0
- package/dist/global-props.js +35 -0
- package/dist/image-picker.d.ts +84 -0
- package/dist/image-picker.d.ts.map +1 -0
- package/dist/image-picker.js +140 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/network.d.ts +26 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +31 -0
- package/dist/setup.js +27 -7
- package/package.json +2 -2
package/dist/network.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { setGlobalProp } from './global-props.js';
|
|
2
|
+
/**
|
|
3
|
+
* The global prop the shells send the connection in (see the runtime's
|
|
4
|
+
* `LynxNetwork`).
|
|
5
|
+
*/
|
|
6
|
+
const ONLINE_PROP = 'online';
|
|
7
|
+
/**
|
|
8
|
+
* Takes the phone offline, or brings it back online, so a spec can check what
|
|
9
|
+
* the app shows without a connection and what it does once it's back.
|
|
10
|
+
* `LynxNetwork.online()` becomes `online`.
|
|
11
|
+
*
|
|
12
|
+
* It reaches the app as it does on a phone, as a change to the host's global
|
|
13
|
+
* props: change detection runs on its own, so wait for it with
|
|
14
|
+
* `waitForUpdate()`. Wait between two changes too: an `effect()` runs once
|
|
15
|
+
* for both otherwise, and never sees the phone go offline. Each test starts
|
|
16
|
+
* online.
|
|
17
|
+
*
|
|
18
|
+
* It changes only what `LynxNetwork` reports: requests go on as the spec's
|
|
19
|
+
* fakes answer them.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* await render(Orders);
|
|
24
|
+
* setOnline(false);
|
|
25
|
+
* await waitForUpdate();
|
|
26
|
+
* expect(screen.getByText('An internet connection is required')).toBeTruthy();
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param online - `false` to take the phone offline, `true` to bring it back.
|
|
30
|
+
*/
|
|
31
|
+
export const setOnline = (online) => setGlobalProp(ONLINE_PROP, online, 'setOnline');
|
package/dist/setup.js
CHANGED
|
@@ -25,6 +25,8 @@ import { LynxTestingEnv } from '@lynx-js/testing-environment';
|
|
|
25
25
|
import { installShellModule } from './back-button.js';
|
|
26
26
|
import { installBiometricsModule } from './biometrics.js';
|
|
27
27
|
import { installFilePickerModule } from './file-picker.js';
|
|
28
|
+
import { installImagePickerModule } from './image-picker.js';
|
|
29
|
+
import { installAudioRecorderModule } from './audio-recorder.js';
|
|
28
30
|
import { installBarcodeScannerModule } from './barcode-scanner.js';
|
|
29
31
|
import { installBluetoothModule } from './bluetooth.js';
|
|
30
32
|
import { installCalendarModule } from './calendar.js';
|
|
@@ -37,6 +39,7 @@ import { installStoreReviewModule } from './store-review.js';
|
|
|
37
39
|
import { answerAppleSignInButtonOnMainThread, installAppleSignInModule, } from './apple-sign-in.js';
|
|
38
40
|
import { installTrackingModule } from './tracking.js';
|
|
39
41
|
import { installWifiModule } from './wifi.js';
|
|
42
|
+
import { installGeolocationModule } from './geolocation.js';
|
|
40
43
|
import { installMotionModule } from './motion.js';
|
|
41
44
|
// ─── CSS fetch intercept ─────────────────────────────────────────────────────
|
|
42
45
|
/**
|
|
@@ -133,6 +136,10 @@ globalThis.onInjectBackgroundThreadGlobals = (threadGlobals) => {
|
|
|
133
136
|
// LynxNfc's sessions, which tapNfcTag() brings tags to and nfcWrites()
|
|
134
137
|
// lists the writes of (see nfc.ts).
|
|
135
138
|
installNfcModule(threadGlobals);
|
|
139
|
+
// LynxAudioRecorder's recordings, which setMicrophonePermission() and
|
|
140
|
+
// setRecordedAudio() steer and emitAudioLevel() meters (see
|
|
141
|
+
// audio-recorder.ts).
|
|
142
|
+
installAudioRecorderModule(threadGlobals);
|
|
136
143
|
// LynxWifi's network and joins, which setWifiNetwork() and
|
|
137
144
|
// queueWifiJoinResult() steer and wifiJoins() lists (see wifi.ts).
|
|
138
145
|
installWifiModule(threadGlobals);
|
|
@@ -154,9 +161,15 @@ globalThis.onInjectBackgroundThreadGlobals = (threadGlobals) => {
|
|
|
154
161
|
// LynxBluetooth finds the devices addBluetoothDevice() adds (see
|
|
155
162
|
// bluetooth.ts).
|
|
156
163
|
installBluetoothModule(threadGlobals);
|
|
164
|
+
// LynxGeolocation finds the phone where setLocation() puts it, with the
|
|
165
|
+
// permission setLocationPermission() sets (see geolocation.ts).
|
|
166
|
+
installGeolocationModule(threadGlobals);
|
|
157
167
|
// LynxFilePicker's picks and saves, which setPickedFiles(),
|
|
158
168
|
// setFilePickerCanceled() and savedFiles() steer (see file-picker.ts).
|
|
159
169
|
installFilePickerModule(threadGlobals);
|
|
170
|
+
// LynxImagePicker's library and camera, which setPickedImage(),
|
|
171
|
+
// setTakenPhoto() and failImagePicker() steer (see image-picker.ts).
|
|
172
|
+
installImagePickerModule(threadGlobals);
|
|
160
173
|
};
|
|
161
174
|
// ─── Install LynxTestingEnv ──────────────────────────────────────────────────
|
|
162
175
|
/**
|
|
@@ -212,12 +225,10 @@ lynxTestingEnv.switchToMainThread();
|
|
|
212
225
|
// __AddEvent in the testing environment calls runWorklet(handler, [event]) when
|
|
213
226
|
// an event handler is registered as type:'worklet'. AngularLynx registers all
|
|
214
227
|
// event handlers this way (see LynxElement.addEventListener). runWorklet simply
|
|
215
|
-
// invokes the callback
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
};
|
|
228
|
+
// invokes the callback and returns its result, as the polyfill in
|
|
229
|
+
// global-callbacks.ts does on a device, where Lynx reads the stop bits a
|
|
230
|
+
// listener's stopPropagation() sets from it (see fire-event.ts's deliver()).
|
|
231
|
+
globalThis.runWorklet = (value, params) => typeof value === 'function' ? value(...params) : undefined;
|
|
221
232
|
// ─── Missing PAPI polyfills ──────────────────────────────────────────────────
|
|
222
233
|
// The testing-environment's ElementPAPI uses real JSDOM HTMLElements as the
|
|
223
234
|
// native element representation. So DOM traversal methods work natively on them.
|
|
@@ -292,13 +303,22 @@ const isTextField = (element) => /^(input|textarea)$/i.test(element?.tagName ??
|
|
|
292
303
|
* text in the JSDOM field's `value`, where a test reads it (`input.value`,
|
|
293
304
|
* `toHaveValue`), and `getValue` reads it back: the runtime shows a bound
|
|
294
305
|
* value with setValue (see LynxElement's setProperty), so a field shows on
|
|
295
|
-
* screen what it reads here.
|
|
306
|
+
* screen what it reads here. `focus` and `blur` move JSDOM's focus. Other
|
|
307
|
+
* methods do nothing. Each answers at once
|
|
296
308
|
* that it ran, as a device answers for an element whose UI it has made.
|
|
297
309
|
*/
|
|
298
310
|
globalThis.__InvokeUIMethod = (element, methodName, params, callback) => {
|
|
299
311
|
if (isTextField(element) && methodName === 'setValue') {
|
|
300
312
|
element.value = String(params?.value ?? '');
|
|
301
313
|
}
|
|
314
|
+
// A field's focus and blur move JSDOM's focus, so a test can read which
|
|
315
|
+
// field has it (`document.activeElement`, `toHaveFocus()`), as after a
|
|
316
|
+
// form's focusBoundControl(). They don't fire bindfocus or bindblur, which
|
|
317
|
+
// fireEvent.focus and fireEvent.blur do.
|
|
318
|
+
if (isTextField(element) && methodName === 'focus')
|
|
319
|
+
element.focus();
|
|
320
|
+
if (isTextField(element) && methodName === 'blur')
|
|
321
|
+
element.blur();
|
|
302
322
|
if (isTextField(element) && methodName === 'getValue') {
|
|
303
323
|
callback?.({
|
|
304
324
|
code: 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blotch/angular-lynx-testing-library",
|
|
3
|
-
"version": "22.3.
|
|
3
|
+
"version": "22.3.3",
|
|
4
4
|
"description": "Testing utilities for AngularLynx apps",
|
|
5
5
|
"homepage": "https://github.com/Blotch-Smart-Frames/AngularLynx#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@angular/compiler": "^22.3.0",
|
|
60
60
|
"@angular/core": "^22.3.0",
|
|
61
61
|
"@angular/platform-browser": "^22.3.0",
|
|
62
|
-
"@blotch/angular-lynx": "^22.3.
|
|
62
|
+
"@blotch/angular-lynx": "^22.3.3"
|
|
63
63
|
},
|
|
64
64
|
"ng-update": {
|
|
65
65
|
"packageGroup": [
|