frontile 0.18.1 → 0.18.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/declarations/-private/get-config.d.ts.map +1 -1
- package/declarations/-private/timer.d.ts +3 -3
- package/declarations/-private/timer.d.ts.map +1 -1
- package/declarations/components/buttons/close-button.d.ts +2 -2
- package/declarations/components/buttons/close-button.d.ts.map +1 -1
- package/declarations/components/collections/calendar/calendar.d.ts +7 -1
- package/declarations/components/collections/calendar/calendar.d.ts.map +1 -1
- package/declarations/components/collections/calendar/header.d.ts +2 -0
- package/declarations/components/collections/calendar/header.d.ts.map +1 -1
- package/declarations/components/collections/calendar/types.d.ts +15 -0
- package/declarations/components/collections/calendar/types.d.ts.map +1 -1
- package/declarations/components/collections/calendar/year-grid.d.ts +2 -0
- package/declarations/components/collections/calendar/year-grid.d.ts.map +1 -1
- package/declarations/components/collections/listbox/item.d.ts +2 -2
- package/declarations/components/collections/listbox/item.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/column.d.ts +6 -0
- package/declarations/components/collections/simple-table/column.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/footer.d.ts +2 -1
- package/declarations/components/collections/simple-table/footer.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/header.d.ts +2 -1
- package/declarations/components/collections/simple-table/header.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/index.d.ts +1 -1
- package/declarations/components/collections/simple-table/index.d.ts.map +1 -1
- package/declarations/components/collections/table/checkbox.d.ts +1 -1
- package/declarations/components/collections/table/checkbox.d.ts.map +1 -1
- package/declarations/components/collections/table/column-visibility.d.ts +2 -2
- package/declarations/components/collections/table/column-visibility.d.ts.map +1 -1
- package/declarations/components/collections/table/table.d.ts +9 -7
- package/declarations/components/collections/table/table.d.ts.map +1 -1
- package/declarations/components/forms/checkbox.d.ts +2 -2
- package/declarations/components/forms/checkbox.d.ts.map +1 -1
- package/declarations/components/forms/date-input/clipboard.d.ts.map +1 -1
- package/declarations/components/forms/date-input/date-input.d.ts +5 -2
- package/declarations/components/forms/date-input/date-input.d.ts.map +1 -1
- package/declarations/components/forms/date-input/segment-group.d.ts +2 -0
- package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -1
- package/declarations/components/forms/date-input/segments.d.ts +30 -4
- package/declarations/components/forms/date-input/segments.d.ts.map +1 -1
- package/declarations/components/forms/date-input/types.d.ts +60 -5
- package/declarations/components/forms/date-input/types.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/date-picker.d.ts +19 -2
- package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/end-content.d.ts +3 -1
- package/declarations/components/forms/date-picker/end-content.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/types.d.ts +42 -4
- package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/value.d.ts +21 -5
- package/declarations/components/forms/date-picker/value.d.ts.map +1 -1
- package/declarations/components/forms/field.d.ts +4 -5
- package/declarations/components/forms/field.d.ts.map +1 -1
- package/declarations/components/forms/form.d.ts +5 -5
- package/declarations/components/forms/form.d.ts.map +1 -1
- package/declarations/components/forms/input-otp.d.ts +5 -5
- package/declarations/components/forms/input-otp.d.ts.map +1 -1
- package/declarations/components/forms/input.d.ts +4 -4
- package/declarations/components/forms/input.d.ts.map +1 -1
- package/declarations/components/forms/native-select.d.ts +2 -2
- package/declarations/components/forms/native-select.d.ts.map +1 -1
- package/declarations/components/forms/radio.d.ts +2 -2
- package/declarations/components/forms/radio.d.ts.map +1 -1
- package/declarations/components/forms/textarea.d.ts +3 -3
- package/declarations/components/forms/textarea.d.ts.map +1 -1
- package/declarations/components/navigation/pagination/pagination.d.ts +32 -1
- package/declarations/components/navigation/pagination/pagination.d.ts.map +1 -1
- package/declarations/components/overlays/overlay.d.ts +4 -4
- package/declarations/components/overlays/overlay.d.ts.map +1 -1
- package/declarations/components/utilities/avatar.d.ts +1 -1
- package/declarations/components/utilities/avatar.d.ts.map +1 -1
- package/declarations/components/utilities/collapsible.d.ts +16 -0
- package/declarations/components/utilities/collapsible.d.ts.map +1 -1
- package/declarations/utils/forms-utils-index.d.ts +1 -1
- package/declarations/utils/forms-utils-index.d.ts.map +1 -1
- package/declarations/utils/nested-data.d.ts +17 -0
- package/declarations/utils/nested-data.d.ts.map +1 -1
- package/dist/components/buttons/close-button.js +5 -12
- package/dist/components/buttons/close-button.js.map +1 -1
- package/dist/components/collections/calendar/calendar.js +13 -1
- package/dist/components/collections/calendar/calendar.js.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/calendar/header.js.map +1 -1
- package/dist/components/collections/calendar/year-grid.js +1 -1
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/collections/listbox/item.js +4 -11
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/simple-table/column.js +2 -2
- package/dist/components/collections/simple-table/column.js.map +1 -1
- package/dist/components/collections/simple-table/footer.js +1 -1
- package/dist/components/collections/simple-table/footer.js.map +1 -1
- package/dist/components/collections/simple-table/header.js +1 -1
- package/dist/components/collections/simple-table/header.js.map +1 -1
- package/dist/components/collections/simple-table/index.js +1 -1
- package/dist/components/collections/simple-table/index.js.map +1 -1
- package/dist/components/collections/table/checkbox.js +2 -7
- package/dist/components/collections/table/checkbox.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +2 -7
- package/dist/components/collections/table/column-visibility.js.map +1 -1
- package/dist/components/forms/checkbox.js +4 -12
- package/dist/components/forms/checkbox.js.map +1 -1
- package/dist/components/forms/date-input/clipboard.js +74 -5
- package/dist/components/forms/date-input/clipboard.js.map +1 -1
- package/dist/components/forms/date-input/date-input.js +24 -5
- package/dist/components/forms/date-input/date-input.js.map +1 -1
- package/dist/components/forms/date-input/segment-group.js +26 -5
- package/dist/components/forms/date-input/segment-group.js.map +1 -1
- package/dist/components/forms/date-input/segments.js +203 -20
- package/dist/components/forms/date-input/segments.js.map +1 -1
- package/dist/components/forms/date-input.js +1 -1
- package/dist/components/forms/date-picker/date-picker.js +76 -11
- package/dist/components/forms/date-picker/date-picker.js.map +1 -1
- package/dist/components/forms/date-picker/end-content.js +1 -3
- package/dist/components/forms/date-picker/end-content.js.map +1 -1
- package/dist/components/forms/date-picker/value.js +44 -6
- package/dist/components/forms/date-picker/value.js.map +1 -1
- package/dist/components/forms/field.js +8 -19
- package/dist/components/forms/field.js.map +1 -1
- package/dist/components/forms/form.js +11 -27
- package/dist/components/forms/form.js.map +1 -1
- package/dist/components/forms/index.js +3 -3
- package/dist/components/forms/input-otp.js +10 -26
- package/dist/components/forms/input-otp.js.map +1 -1
- package/dist/components/forms/input.js +9 -22
- package/dist/components/forms/input.js.map +1 -1
- package/dist/components/forms/native-select.js +5 -12
- package/dist/components/forms/native-select.js.map +1 -1
- package/dist/components/forms/radio.js +4 -12
- package/dist/components/forms/radio.js.map +1 -1
- package/dist/components/forms/textarea.js +6 -17
- package/dist/components/forms/textarea.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +18 -2
- package/dist/components/navigation/pagination/pagination.js.map +1 -1
- package/dist/components/notifications/index.js +1 -1
- package/dist/components/overlays/overlay.js +8 -21
- package/dist/components/overlays/overlay.js.map +1 -1
- package/dist/components/utilities/avatar.js +3 -7
- package/dist/components/utilities/avatar.js.map +1 -1
- package/dist/components/utilities/collapsible.js +47 -3
- package/dist/components/utilities/collapsible.js.map +1 -1
- package/dist/forms.js +3 -3
- package/dist/index.js +4 -4
- package/dist/{manager-jDaRVZ5o.js → manager-Dge4r8Vn.js} +9 -19
- package/dist/manager-Dge4r8Vn.js.map +1 -0
- package/dist/notifications.js +1 -1
- package/dist/services/notifications.js +1 -1
- package/dist/test-support.js +400 -365
- package/dist/test-support.js.map +1 -1
- package/dist/utils/forms-utils-index.js +1 -1
- package/dist/utils/forms-utils-index.js.map +1 -1
- package/dist/utils/nested-data.js +28 -1
- package/dist/utils/nested-data.js.map +1 -1
- package/package.json +10 -10
- package/dist/manager-jDaRVZ5o.js.map +0 -1
package/dist/test-support.js
CHANGED
|
@@ -1,192 +1,23 @@
|
|
|
1
|
-
import '@ember/application';
|
|
2
|
-
import { VERSION } from '@ember/version';
|
|
3
1
|
import { _backburner } from '@ember/runloop';
|
|
4
2
|
import EmberObject from '@ember/object';
|
|
3
|
+
import '@ember/application';
|
|
5
4
|
import '@ember/application/instance';
|
|
6
5
|
import '@ember/-internals/container';
|
|
7
6
|
import { RegistryProxyMixin, ContainerProxyMixin } from '@ember/-internals/runtime';
|
|
8
7
|
import { Test } from 'ember-testing';
|
|
9
8
|
import '@ember/-internals/error-handling';
|
|
10
9
|
import { registerDeprecationHandler, registerWarnHandler } from '@ember/debug';
|
|
10
|
+
import { VERSION } from '@ember/version';
|
|
11
11
|
import { getPendingWaiterState, hasPendingWaiters } from '@ember/test-waiters';
|
|
12
12
|
import '@ember/destroyable';
|
|
13
13
|
import '@ember/-internals/views';
|
|
14
14
|
import '@glimmer/manager';
|
|
15
|
+
import { macroCondition, appEmberSatisfies, importSync, dependencySatisfies } from '@embroider/macros';
|
|
15
16
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
16
|
-
import {
|
|
17
|
+
import { capabilities } from '@ember/component';
|
|
17
18
|
import { parseDate } from './components/forms/date-picker/value.js';
|
|
18
19
|
export { setPrefersReducedMotion } from './utils/prefers-reduced-motion.js';
|
|
19
20
|
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
Checks if the currently running Ember version is greater than or equal to the
|
|
24
|
-
specified major and minor version numbers.
|
|
25
|
-
|
|
26
|
-
@private
|
|
27
|
-
@param {number} major the major version number to compare
|
|
28
|
-
@param {number} minor the minor version number to compare
|
|
29
|
-
@returns {boolean} true if the Ember version is >= MAJOR.MINOR specified, false otherwise
|
|
30
|
-
*/
|
|
31
|
-
function hasEmberVersion(major, minor) {
|
|
32
|
-
const numbers = VERSION.split('-')[0]?.split('.');
|
|
33
|
-
if (!numbers || !numbers[0] || !numbers[1]) {
|
|
34
|
-
throw new Error('`Ember.VERSION` is not set.');
|
|
35
|
-
}
|
|
36
|
-
const actualMajor = parseInt(numbers[0], 10);
|
|
37
|
-
const actualMinor = parseInt(numbers[1], 10);
|
|
38
|
-
return actualMajor > major || actualMajor === major && actualMinor >= minor;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// NOTE: this is the same as what `EngineInstance`/`ApplicationInstance`
|
|
42
|
-
// implement, and is thus a superset of the `InternalOwner` contract from Ember
|
|
43
|
-
// itself.
|
|
44
|
-
|
|
45
|
-
EmberObject.extend(RegistryProxyMixin, ContainerProxyMixin, {
|
|
46
|
-
_emberTestHelpersMockOwner: true,
|
|
47
|
-
/* eslint-disable valid-jsdoc */
|
|
48
|
-
/**
|
|
49
|
-
* Unregister a factory and its instance.
|
|
50
|
-
*
|
|
51
|
-
* Overrides `RegistryProxy#unregister` in order to clear any cached instances
|
|
52
|
-
* of the unregistered factory.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} fullName Name of the factory to unregister.
|
|
55
|
-
*
|
|
56
|
-
* @see {@link https://github.com/emberjs/ember.js/pull/12680}
|
|
57
|
-
* @see {@link https://github.com/emberjs/ember.js/blob/v4.5.0-alpha.5/packages/%40ember/engine/instance.ts#L152-L167}
|
|
58
|
-
*/
|
|
59
|
-
/* eslint-enable valid-jsdoc */
|
|
60
|
-
unregister(fullName) {
|
|
61
|
-
// SAFETY: this is always present, but only the stable type definitions from
|
|
62
|
-
// Ember actually preserve it, since it is private API.
|
|
63
|
-
this['__container__'].reset(fullName);
|
|
64
|
-
|
|
65
|
-
// We overwrote this method from RegistryProxyMixin.
|
|
66
|
-
// SAFETY: this is always present, but only the stable type definitions from
|
|
67
|
-
// Ember actually preserve it, since it is private API.
|
|
68
|
-
this['__registry__'].unregister(fullName);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// eslint-disable-next-line require-jsdoc
|
|
73
|
-
function isElement(target) {
|
|
74
|
-
return target !== null && typeof target === 'object' && Reflect.get(target, 'nodeType') === Node.ELEMENT_NODE;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// eslint-disable-next-line require-jsdoc
|
|
78
|
-
function isWindow(target) {
|
|
79
|
-
return target instanceof Window;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// eslint-disable-next-line require-jsdoc
|
|
83
|
-
function isDocument(target) {
|
|
84
|
-
return target !== null && typeof target === 'object' && Reflect.get(target, 'nodeType') === Node.DOCUMENT_NODE;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// eslint-disable-next-line require-jsdoc
|
|
88
|
-
function isContentEditable(element) {
|
|
89
|
-
return 'isContentEditable' in element && element.isContentEditable;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const FORM_CONTROL_TAGS = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'];
|
|
93
|
-
/**
|
|
94
|
-
@private
|
|
95
|
-
@param {Element} element the element to check
|
|
96
|
-
@returns {boolean} `true` when the element is a form control, `false` otherwise
|
|
97
|
-
*/
|
|
98
|
-
function isFormControl(element) {
|
|
99
|
-
return !isWindow(element) && !isDocument(element) && FORM_CONTROL_TAGS.indexOf(element.tagName) > -1 && element.type !== 'hidden';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const futureTick = setTimeout;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
Returns whether the passed in string consists only of numeric characters.
|
|
106
|
-
|
|
107
|
-
@private
|
|
108
|
-
@param {string} n input string
|
|
109
|
-
@returns {boolean} whether the input string consists only of numeric characters
|
|
110
|
-
*/
|
|
111
|
-
function isNumeric(n) {
|
|
112
|
-
return !isNaN(parseFloat(n)) && isFinite(Number(n));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const TIMEOUTS = [0, 1, 2, 5, 7];
|
|
116
|
-
const MAX_TIMEOUT = 10;
|
|
117
|
-
/**
|
|
118
|
-
Wait for the provided callback to return a truthy value.
|
|
119
|
-
|
|
120
|
-
This does not leverage `settled()`, and as such can be used to manage async
|
|
121
|
-
while _not_ settled (e.g. "loading" or "pending" states).
|
|
122
|
-
|
|
123
|
-
@public
|
|
124
|
-
@param {Function} callback the callback to use for testing when waiting should stop
|
|
125
|
-
@param {Object} [options] options used to override defaults
|
|
126
|
-
@param {number} [options.timeout=1000] the maximum amount of time to wait
|
|
127
|
-
@param {string} [options.timeoutMessage='waitUntil timed out'] the message to use in the reject on timeout
|
|
128
|
-
@returns {Promise} resolves with the callback value when it returns a truthy value
|
|
129
|
-
|
|
130
|
-
@example
|
|
131
|
-
<caption>
|
|
132
|
-
Waiting until a selected element displays text:
|
|
133
|
-
</caption>
|
|
134
|
-
await waitUntil(function() {
|
|
135
|
-
return find('.my-selector').textContent.includes('something')
|
|
136
|
-
}, { timeout: 2000 })
|
|
137
|
-
*/
|
|
138
|
-
function waitUntil(callback, options = {}) {
|
|
139
|
-
const timeout = 'timeout' in options ? options.timeout : 1000;
|
|
140
|
-
const timeoutMessage = 'timeoutMessage' in options ? options.timeoutMessage : 'waitUntil timed out';
|
|
141
|
-
|
|
142
|
-
// creating this error eagerly so it has the proper invocation stack
|
|
143
|
-
const waitUntilTimedOut = new Error(timeoutMessage);
|
|
144
|
-
return new Promise(function (resolve, reject) {
|
|
145
|
-
let time = 0;
|
|
146
|
-
|
|
147
|
-
// eslint-disable-next-line require-jsdoc
|
|
148
|
-
function scheduleCheck(timeoutsIndex) {
|
|
149
|
-
const knownTimeout = TIMEOUTS[timeoutsIndex];
|
|
150
|
-
const interval = knownTimeout === undefined ? MAX_TIMEOUT : knownTimeout;
|
|
151
|
-
futureTick(function () {
|
|
152
|
-
time += interval;
|
|
153
|
-
let value;
|
|
154
|
-
try {
|
|
155
|
-
value = callback();
|
|
156
|
-
} catch (error) {
|
|
157
|
-
reject(error);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (value) {
|
|
161
|
-
resolve(value);
|
|
162
|
-
} else if (time < timeout) {
|
|
163
|
-
scheduleCheck(timeoutsIndex + 1);
|
|
164
|
-
} else {
|
|
165
|
-
reject(waitUntilTimedOut);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
}, interval);
|
|
169
|
-
}
|
|
170
|
-
scheduleCheck(0);
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/* globals global */
|
|
175
|
-
|
|
176
|
-
var global$1 = (() => {
|
|
177
|
-
if (typeof self !== 'undefined') {
|
|
178
|
-
return self;
|
|
179
|
-
} else if (typeof window !== 'undefined') {
|
|
180
|
-
return window;
|
|
181
|
-
// @ts-ignore -- global does not exist
|
|
182
|
-
} else if (typeof global !== 'undefined') {
|
|
183
|
-
// @ts-ignore -- global does not exist
|
|
184
|
-
return global;
|
|
185
|
-
} else {
|
|
186
|
-
return Function('return this')();
|
|
187
|
-
}
|
|
188
|
-
})();
|
|
189
|
-
|
|
190
21
|
const DEPRECATIONS = new WeakMap();
|
|
191
22
|
|
|
192
23
|
/**
|
|
@@ -293,79 +124,25 @@ if (typeof URLSearchParams !== 'undefined') {
|
|
|
293
124
|
}
|
|
294
125
|
}
|
|
295
126
|
|
|
296
|
-
|
|
127
|
+
// @ts-ignore
|
|
297
128
|
|
|
298
129
|
/**
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
* @param {string} label A label to help identify the hook.
|
|
302
|
-
* @returns {string} The compound key for the helper.
|
|
303
|
-
*/
|
|
304
|
-
function getHelperKey(helperName, label) {
|
|
305
|
-
return `${helperName}:${label}`;
|
|
306
|
-
}
|
|
130
|
+
Checks if the currently running Ember version is greater than or equal to the
|
|
131
|
+
specified major and minor version numbers.
|
|
307
132
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
* the helper invocation.
|
|
318
|
-
* @param {Function} hook The hook function to run when the test helper is invoked.
|
|
319
|
-
* @returns {HookUnregister} An object containing an `unregister` function that unregisters
|
|
320
|
-
* the specific hook initially registered to the helper.
|
|
321
|
-
* @example
|
|
322
|
-
* <caption>
|
|
323
|
-
* Registering a hook for the `end` point of the `click` test helper invocation
|
|
324
|
-
* </caption>
|
|
325
|
-
*
|
|
326
|
-
* const hook = registerHook('click', 'end', () => {
|
|
327
|
-
* console.log('Running `click:end` test helper hook');
|
|
328
|
-
* });
|
|
329
|
-
*
|
|
330
|
-
* // Unregister the hook at some later point in time
|
|
331
|
-
* hook.unregister();
|
|
332
|
-
*/
|
|
333
|
-
function registerHook(helperName, label, hook) {
|
|
334
|
-
const helperKey = getHelperKey(helperName, label);
|
|
335
|
-
let hooksForHelper = registeredHooks.get(helperKey);
|
|
336
|
-
if (hooksForHelper === undefined) {
|
|
337
|
-
hooksForHelper = new Set();
|
|
338
|
-
registeredHooks.set(helperKey, hooksForHelper);
|
|
133
|
+
@private
|
|
134
|
+
@param {number} major the major version number to compare
|
|
135
|
+
@param {number} minor the minor version number to compare
|
|
136
|
+
@returns {boolean} true if the Ember version is >= MAJOR.MINOR specified, false otherwise
|
|
137
|
+
*/
|
|
138
|
+
function hasEmberVersion(major, minor) {
|
|
139
|
+
const numbers = VERSION.split('-')[0]?.split('.');
|
|
140
|
+
if (!numbers || !numbers[0] || !numbers[1]) {
|
|
141
|
+
throw new Error('`Ember.VERSION` is not set.');
|
|
339
142
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
hooksForHelper.delete(hook);
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Runs all hooks registered for a specific test helper.
|
|
350
|
-
*
|
|
351
|
-
* @param {string} helperName The name of the test helper in which to run the hook.
|
|
352
|
-
* Test helper names include `blur`, `click`, `doubleClick`, `fillIn`,
|
|
353
|
-
* `fireEvent`, `focus`, `render`, `scrollTo`, `select`, `tab`, `tap`, `triggerEvent`,
|
|
354
|
-
* `triggerKeyEvent`, `typeIn`, and `visit`.
|
|
355
|
-
* @param {string} label A label to help identify the hook. Built-in labels include `start`, `end`,
|
|
356
|
-
* and `targetFound`, the former designating either the start or end of
|
|
357
|
-
* the helper invocation.
|
|
358
|
-
* @param {unknown[]} args Any arguments originally passed to the test helper.
|
|
359
|
-
* @returns {Promise<void>} A promise representing the serial invocation of the hooks.
|
|
360
|
-
*/
|
|
361
|
-
function runHooks(helperName, label, ...args) {
|
|
362
|
-
const hooks = registeredHooks.get(getHelperKey(helperName, label)) || new Set();
|
|
363
|
-
const promises = [];
|
|
364
|
-
hooks.forEach(hook => {
|
|
365
|
-
const hookResult = hook(...args);
|
|
366
|
-
promises.push(hookResult);
|
|
367
|
-
});
|
|
368
|
-
return Promise.all(promises).then(() => {});
|
|
143
|
+
const actualMajor = parseInt(numbers[0], 10);
|
|
144
|
+
const actualMinor = parseInt(numbers[1], 10);
|
|
145
|
+
return actualMajor > major || actualMajor === major && actualMinor >= minor;
|
|
369
146
|
}
|
|
370
147
|
|
|
371
148
|
const debugInfoHelpers = new Set();
|
|
@@ -514,7 +291,215 @@ class TestDebugInfo {
|
|
|
514
291
|
function isNotNullable(value) {
|
|
515
292
|
return value != null;
|
|
516
293
|
}
|
|
517
|
-
|
|
294
|
+
|
|
295
|
+
// NOTE: this is the same as what `EngineInstance`/`ApplicationInstance`
|
|
296
|
+
// implement, and is thus a superset of the `InternalOwner` contract from Ember
|
|
297
|
+
// itself.
|
|
298
|
+
// This is the same merging pattern Ember itself uses for `Engine` etc.: the
|
|
299
|
+
// interface reflects the mixins actually applied in the `extends` clause.
|
|
300
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
301
|
+
|
|
302
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
303
|
+
class Owner extends EmberObject.extend(RegistryProxyMixin, ContainerProxyMixin) {
|
|
304
|
+
_emberTestHelpersMockOwner = true;
|
|
305
|
+
|
|
306
|
+
/* eslint-disable valid-jsdoc */
|
|
307
|
+
/**
|
|
308
|
+
* Unregister a factory and its instance.
|
|
309
|
+
*
|
|
310
|
+
* Overrides `RegistryProxy#unregister` in order to clear any cached instances
|
|
311
|
+
* of the unregistered factory.
|
|
312
|
+
*
|
|
313
|
+
* @param {string} fullName Name of the factory to unregister.
|
|
314
|
+
*
|
|
315
|
+
* @see {@link https://github.com/emberjs/ember.js/pull/12680}
|
|
316
|
+
* @see {@link https://github.com/emberjs/ember.js/blob/v4.5.0-alpha.5/packages/%40ember/engine/instance.ts#L152-L167}
|
|
317
|
+
*/
|
|
318
|
+
/* eslint-enable valid-jsdoc */
|
|
319
|
+
unregister(fullName) {
|
|
320
|
+
// SAFETY: this is always present, but only the stable type definitions from
|
|
321
|
+
// Ember actually preserve it, since it is private API.
|
|
322
|
+
this['__container__'].reset(fullName);
|
|
323
|
+
|
|
324
|
+
// We overwrote this method from RegistryProxyMixin.
|
|
325
|
+
// SAFETY: this is always present, but only the stable type definitions from
|
|
326
|
+
// Ember actually preserve it, since it is private API.
|
|
327
|
+
this['__registry__'].unregister(fullName);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// eslint-disable-next-line require-jsdoc
|
|
332
|
+
function isElement(target) {
|
|
333
|
+
return target !== null && typeof target === 'object' && Reflect.get(target, 'nodeType') === Node.ELEMENT_NODE;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// eslint-disable-next-line require-jsdoc
|
|
337
|
+
function isWindow(target) {
|
|
338
|
+
return target instanceof Window;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// eslint-disable-next-line require-jsdoc
|
|
342
|
+
function isDocument(target) {
|
|
343
|
+
return target !== null && typeof target === 'object' && Reflect.get(target, 'nodeType') === Node.DOCUMENT_NODE;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// eslint-disable-next-line require-jsdoc
|
|
347
|
+
function isContentEditable(element) {
|
|
348
|
+
return 'isContentEditable' in element && element.isContentEditable;
|
|
349
|
+
}
|
|
350
|
+
const FORM_CONTROL_TAGS = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'];
|
|
351
|
+
/**
|
|
352
|
+
@private
|
|
353
|
+
@param {Element} element the element to check
|
|
354
|
+
@returns {boolean} `true` when the element is a form control, `false` otherwise
|
|
355
|
+
*/
|
|
356
|
+
function isFormControl(element) {
|
|
357
|
+
return !isWindow(element) && !isDocument(element) && FORM_CONTROL_TAGS.indexOf(element.tagName) > -1 && element.type !== 'hidden';
|
|
358
|
+
}
|
|
359
|
+
const futureTick = setTimeout;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
Returns whether the passed in string consists only of numeric characters.
|
|
363
|
+
|
|
364
|
+
@private
|
|
365
|
+
@param {string} n input string
|
|
366
|
+
@returns {boolean} whether the input string consists only of numeric characters
|
|
367
|
+
*/
|
|
368
|
+
function isNumeric(n) {
|
|
369
|
+
return !isNaN(parseFloat(n)) && isFinite(Number(n));
|
|
370
|
+
}
|
|
371
|
+
const TIMEOUTS = [0, 1, 2, 5, 7];
|
|
372
|
+
const MAX_TIMEOUT = 10;
|
|
373
|
+
/**
|
|
374
|
+
Wait for the provided callback to return a truthy value.
|
|
375
|
+
|
|
376
|
+
This does not leverage `settled()`, and as such can be used to manage async
|
|
377
|
+
while _not_ settled (e.g. "loading" or "pending" states).
|
|
378
|
+
|
|
379
|
+
@public
|
|
380
|
+
@param {Function} callback the callback to use for testing when waiting should stop
|
|
381
|
+
@param {Object} [options] options used to override defaults
|
|
382
|
+
@param {number} [options.timeout=1000] the maximum amount of time to wait
|
|
383
|
+
@param {string} [options.timeoutMessage='waitUntil timed out'] the message to use in the reject on timeout
|
|
384
|
+
@returns {Promise} resolves with the callback value when it returns a truthy value
|
|
385
|
+
|
|
386
|
+
@example
|
|
387
|
+
<caption>
|
|
388
|
+
Waiting until a selected element displays text:
|
|
389
|
+
</caption>
|
|
390
|
+
await waitUntil(function() {
|
|
391
|
+
return find('.my-selector').textContent.includes('something')
|
|
392
|
+
}, { timeout: 2000 })
|
|
393
|
+
*/
|
|
394
|
+
function waitUntil(callback, options = {}) {
|
|
395
|
+
const timeout = 'timeout' in options ? options.timeout : 1000;
|
|
396
|
+
const timeoutMessage = 'timeoutMessage' in options ? options.timeoutMessage : 'waitUntil timed out';
|
|
397
|
+
|
|
398
|
+
// creating this error eagerly so it has the proper invocation stack
|
|
399
|
+
const waitUntilTimedOut = new Error(timeoutMessage);
|
|
400
|
+
return new Promise(function (resolve, reject) {
|
|
401
|
+
let time = 0;
|
|
402
|
+
|
|
403
|
+
// eslint-disable-next-line require-jsdoc
|
|
404
|
+
function scheduleCheck(timeoutsIndex) {
|
|
405
|
+
const knownTimeout = TIMEOUTS[timeoutsIndex];
|
|
406
|
+
const interval = knownTimeout === undefined ? MAX_TIMEOUT : knownTimeout;
|
|
407
|
+
futureTick(function () {
|
|
408
|
+
time += interval;
|
|
409
|
+
let value;
|
|
410
|
+
try {
|
|
411
|
+
value = callback();
|
|
412
|
+
} catch (error) {
|
|
413
|
+
reject(error);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (value) {
|
|
417
|
+
resolve(value);
|
|
418
|
+
} else if (time < timeout) {
|
|
419
|
+
scheduleCheck(timeoutsIndex + 1);
|
|
420
|
+
} else {
|
|
421
|
+
reject(waitUntilTimedOut);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
}, interval);
|
|
425
|
+
}
|
|
426
|
+
scheduleCheck(0);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
const registeredHooks = new Map();
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* @private
|
|
433
|
+
* @param {string} helperName The name of the test helper in which to run the hook.
|
|
434
|
+
* @param {string} label A label to help identify the hook.
|
|
435
|
+
* @returns {string} The compound key for the helper.
|
|
436
|
+
*/
|
|
437
|
+
function getHelperKey(helperName, label) {
|
|
438
|
+
return `${helperName}:${label}`;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Registers a function to be run during the invocation of a test helper.
|
|
443
|
+
*
|
|
444
|
+
* @param {string} helperName The name of the test helper in which to run the hook.
|
|
445
|
+
* Test helper names include `blur`, `click`, `doubleClick`, `fillIn`,
|
|
446
|
+
* `fireEvent`, `focus`, `render`, `scrollTo`, `select`, `tab`, `tap`, `triggerEvent`,
|
|
447
|
+
* `triggerKeyEvent`, `typeIn`, and `visit`.
|
|
448
|
+
* @param {string} label A label to help identify the hook. Built-in labels include `start`, `end`,
|
|
449
|
+
* and `targetFound`, the former designating either the start or end of
|
|
450
|
+
* the helper invocation.
|
|
451
|
+
* @param {Function} hook The hook function to run when the test helper is invoked.
|
|
452
|
+
* @returns {HookUnregister} An object containing an `unregister` function that unregisters
|
|
453
|
+
* the specific hook initially registered to the helper.
|
|
454
|
+
* @example
|
|
455
|
+
* <caption>
|
|
456
|
+
* Registering a hook for the `end` point of the `click` test helper invocation
|
|
457
|
+
* </caption>
|
|
458
|
+
*
|
|
459
|
+
* const hook = registerHook('click', 'end', () => {
|
|
460
|
+
* console.log('Running `click:end` test helper hook');
|
|
461
|
+
* });
|
|
462
|
+
*
|
|
463
|
+
* // Unregister the hook at some later point in time
|
|
464
|
+
* hook.unregister();
|
|
465
|
+
*/
|
|
466
|
+
function registerHook(helperName, label, hook) {
|
|
467
|
+
const helperKey = getHelperKey(helperName, label);
|
|
468
|
+
let hooksForHelper = registeredHooks.get(helperKey);
|
|
469
|
+
if (hooksForHelper === undefined) {
|
|
470
|
+
hooksForHelper = new Set();
|
|
471
|
+
registeredHooks.set(helperKey, hooksForHelper);
|
|
472
|
+
}
|
|
473
|
+
hooksForHelper.add(hook);
|
|
474
|
+
return {
|
|
475
|
+
unregister() {
|
|
476
|
+
hooksForHelper.delete(hook);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Runs all hooks registered for a specific test helper.
|
|
483
|
+
*
|
|
484
|
+
* @param {string} helperName The name of the test helper in which to run the hook.
|
|
485
|
+
* Test helper names include `blur`, `click`, `doubleClick`, `fillIn`,
|
|
486
|
+
* `fireEvent`, `focus`, `render`, `scrollTo`, `select`, `tab`, `tap`, `triggerEvent`,
|
|
487
|
+
* `triggerKeyEvent`, `typeIn`, and `visit`.
|
|
488
|
+
* @param {string} label A label to help identify the hook. Built-in labels include `start`, `end`,
|
|
489
|
+
* and `targetFound`, the former designating either the start or end of
|
|
490
|
+
* the helper invocation.
|
|
491
|
+
* @param {unknown[]} args Any arguments originally passed to the test helper.
|
|
492
|
+
* @returns {Promise<void>} A promise representing the serial invocation of the hooks.
|
|
493
|
+
*/
|
|
494
|
+
function runHooks(helperName, label, ...args) {
|
|
495
|
+
const hooks = registeredHooks.get(getHelperKey(helperName, label)) || new Set();
|
|
496
|
+
const promises = [];
|
|
497
|
+
hooks.forEach(hook => {
|
|
498
|
+
const hookResult = hook(...args);
|
|
499
|
+
promises.push(hookResult);
|
|
500
|
+
});
|
|
501
|
+
return Promise.all(promises).then(() => {});
|
|
502
|
+
}
|
|
518
503
|
const CAN_USE_ROUTER_EVENTS = hasEmberVersion(3, 6);
|
|
519
504
|
let routerTransitionsPending = null;
|
|
520
505
|
const ROUTER = new WeakMap();
|
|
@@ -651,6 +636,22 @@ function settled() {
|
|
|
651
636
|
}).then(() => {});
|
|
652
637
|
}
|
|
653
638
|
|
|
639
|
+
/* globals global */
|
|
640
|
+
|
|
641
|
+
var global$1 = (() => {
|
|
642
|
+
if (typeof self !== 'undefined') {
|
|
643
|
+
return self;
|
|
644
|
+
} else if (typeof window !== 'undefined') {
|
|
645
|
+
return window;
|
|
646
|
+
// @ts-ignore -- global does not exist
|
|
647
|
+
} else if (typeof global !== 'undefined') {
|
|
648
|
+
// @ts-ignore -- global does not exist
|
|
649
|
+
return global;
|
|
650
|
+
} else {
|
|
651
|
+
return Function('return this')();
|
|
652
|
+
}
|
|
653
|
+
})();
|
|
654
|
+
|
|
654
655
|
// @ts-ignore: this is private API. This import will work Ember 5.1+ since it
|
|
655
656
|
// "provides" this public API, but does not for earlier versions. As a result,
|
|
656
657
|
// this type will be `any`.
|
|
@@ -725,67 +726,6 @@ function getContext() {
|
|
|
725
726
|
return globalObject.__test_context__;
|
|
726
727
|
}
|
|
727
728
|
|
|
728
|
-
/**
|
|
729
|
-
Get the root element of the application under test (usually `#ember-testing`)
|
|
730
|
-
|
|
731
|
-
@public
|
|
732
|
-
@returns {Element} the root element
|
|
733
|
-
|
|
734
|
-
@example
|
|
735
|
-
<caption>
|
|
736
|
-
Getting the root element of the application and checking that it is equal
|
|
737
|
-
to the element with id 'ember-testing'.
|
|
738
|
-
</caption>
|
|
739
|
-
assert.equal(getRootElement(), document.querySelector('#ember-testing'));
|
|
740
|
-
*/
|
|
741
|
-
function getRootElement() {
|
|
742
|
-
const context = getContext();
|
|
743
|
-
if (!context || !isTestContext(context) || !context.owner) {
|
|
744
|
-
throw new Error('Must setup rendering context before attempting to interact with elements.');
|
|
745
|
-
}
|
|
746
|
-
const owner = context.owner;
|
|
747
|
-
let rootElement;
|
|
748
|
-
// When the host app uses `setApplication` (instead of `setResolver`) the owner has
|
|
749
|
-
// a `rootElement` set on it with the element or id to be used
|
|
750
|
-
if (owner && owner._emberTestHelpersMockOwner === undefined) {
|
|
751
|
-
rootElement = owner.rootElement;
|
|
752
|
-
} else {
|
|
753
|
-
rootElement = '#ember-testing';
|
|
754
|
-
}
|
|
755
|
-
if (rootElement instanceof Window) {
|
|
756
|
-
rootElement = rootElement.document;
|
|
757
|
-
}
|
|
758
|
-
if (isElement(rootElement) || isDocument(rootElement)) {
|
|
759
|
-
return rootElement;
|
|
760
|
-
} else if (typeof rootElement === 'string') {
|
|
761
|
-
const _rootElement = document.querySelector(rootElement);
|
|
762
|
-
if (_rootElement) {
|
|
763
|
-
return _rootElement;
|
|
764
|
-
}
|
|
765
|
-
throw new Error(`Application.rootElement (${rootElement}) not found`);
|
|
766
|
-
} else {
|
|
767
|
-
throw new Error('Application.rootElement must be an element or a selector string');
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
precompileTemplate("{{outlet}}", {
|
|
772
|
-
strictMode: false
|
|
773
|
-
});
|
|
774
|
-
precompileTemplate("", {
|
|
775
|
-
strictMode: false
|
|
776
|
-
});
|
|
777
|
-
precompileTemplate("<this.ProvidedComponent />", {
|
|
778
|
-
strictMode: false
|
|
779
|
-
});
|
|
780
|
-
|
|
781
|
-
if (macroCondition(dependencySatisfies('ember-source', '>=4.5.0-beta.1'))) {
|
|
782
|
-
//@ts-ignore
|
|
783
|
-
importSync('@ember/renderer').renderSettled;
|
|
784
|
-
} else {
|
|
785
|
-
//@ts-ignore
|
|
786
|
-
importSync('@ember/-internals/glimmer').renderSettled;
|
|
787
|
-
}
|
|
788
|
-
|
|
789
729
|
const IS_DESCRIPTOR = '__dom_element_descriptor_is_descriptor__';
|
|
790
730
|
|
|
791
731
|
/**
|
|
@@ -847,52 +787,6 @@ function resolveDOMElement(target) {
|
|
|
847
787
|
}
|
|
848
788
|
}
|
|
849
789
|
|
|
850
|
-
/**
|
|
851
|
-
Used internally by the DOM interaction helpers to find one element.
|
|
852
|
-
|
|
853
|
-
@private
|
|
854
|
-
@param {string|Element} target the element or selector to retrieve
|
|
855
|
-
@returns {Element} the target or selector
|
|
856
|
-
*/
|
|
857
|
-
function getElement(target) {
|
|
858
|
-
if (typeof target === 'string') {
|
|
859
|
-
const rootElement = getRootElement();
|
|
860
|
-
return rootElement.querySelector(target);
|
|
861
|
-
} else if (isElement(target) || isDocument(target)) {
|
|
862
|
-
return target;
|
|
863
|
-
} else if (target instanceof Window) {
|
|
864
|
-
return target.document;
|
|
865
|
-
} else {
|
|
866
|
-
const descriptorData = lookupDescriptorData(target);
|
|
867
|
-
if (descriptorData) {
|
|
868
|
-
return resolveDOMElement(descriptorData);
|
|
869
|
-
} else {
|
|
870
|
-
throw new Error('Must use an element, selector string, or DOM element descriptor');
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
Used internally by the DOM interaction helpers to find either window or an element.
|
|
877
|
-
|
|
878
|
-
@private
|
|
879
|
-
@param {string|Element} target the window, an element or selector to retrieve
|
|
880
|
-
@returns {Element|Window} the target or selector
|
|
881
|
-
*/
|
|
882
|
-
function getWindowOrElement(target) {
|
|
883
|
-
if (isWindow(target)) {
|
|
884
|
-
return target;
|
|
885
|
-
}
|
|
886
|
-
return getElement(target);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
890
|
-
|
|
891
|
-
// eslint-disable-next-line require-jsdoc
|
|
892
|
-
function tuple(...args) {
|
|
893
|
-
return args;
|
|
894
|
-
}
|
|
895
|
-
|
|
896
790
|
/**
|
|
897
791
|
* Logs a debug message to the console if the `testHelperLogging` query
|
|
898
792
|
* parameter is set.
|
|
@@ -953,6 +847,127 @@ function elementToString(el) {
|
|
|
953
847
|
return desc;
|
|
954
848
|
}
|
|
955
849
|
|
|
850
|
+
/**
|
|
851
|
+
Get the root element of the application under test (usually `#ember-testing`)
|
|
852
|
+
|
|
853
|
+
@public
|
|
854
|
+
@returns {Element} the root element
|
|
855
|
+
|
|
856
|
+
@example
|
|
857
|
+
<caption>
|
|
858
|
+
Getting the root element of the application and checking that it is equal
|
|
859
|
+
to the element with id 'ember-testing'.
|
|
860
|
+
</caption>
|
|
861
|
+
assert.equal(getRootElement(), document.querySelector('#ember-testing'));
|
|
862
|
+
*/
|
|
863
|
+
function getRootElement() {
|
|
864
|
+
const context = getContext();
|
|
865
|
+
if (!context || !isTestContext(context) || !context.owner) {
|
|
866
|
+
throw new Error('Must setup rendering context before attempting to interact with elements.');
|
|
867
|
+
}
|
|
868
|
+
const owner = context.owner;
|
|
869
|
+
let rootElement;
|
|
870
|
+
// When the host app uses `setApplication` (instead of `setResolver`) the owner has
|
|
871
|
+
// a `rootElement` set on it with the element or id to be used
|
|
872
|
+
if (owner && owner._emberTestHelpersMockOwner === undefined) {
|
|
873
|
+
rootElement = owner.rootElement;
|
|
874
|
+
} else {
|
|
875
|
+
rootElement = '#ember-testing';
|
|
876
|
+
}
|
|
877
|
+
if (rootElement instanceof Window) {
|
|
878
|
+
rootElement = rootElement.document;
|
|
879
|
+
}
|
|
880
|
+
if (isElement(rootElement) || isDocument(rootElement)) {
|
|
881
|
+
return rootElement;
|
|
882
|
+
} else if (typeof rootElement === 'string') {
|
|
883
|
+
const _rootElement = document.querySelector(rootElement);
|
|
884
|
+
if (_rootElement) {
|
|
885
|
+
return _rootElement;
|
|
886
|
+
}
|
|
887
|
+
throw new Error(`Application.rootElement (${rootElement}) not found`);
|
|
888
|
+
} else {
|
|
889
|
+
throw new Error('Application.rootElement must be an element or a selector string');
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* while renderComponent landed in ember-source @ 6.8.0-alpha.1,
|
|
895
|
+
* it was not fully usable (in serious) until 6.12.0-alpha.4
|
|
896
|
+
* when https://github.com/emberjs/ember.js/pull/20996 was merged.
|
|
897
|
+
*
|
|
898
|
+
* ... but even then, we still needed a debugRenderTree fix,
|
|
899
|
+
* which didn't land until 6.12.1.
|
|
900
|
+
* https://github.com/emberjs/ember.js/pull/21623
|
|
901
|
+
*/
|
|
902
|
+
if (macroCondition(appEmberSatisfies('>=6.12.1'))) {
|
|
903
|
+
importSync('@ember/renderer').renderComponent;
|
|
904
|
+
}
|
|
905
|
+
precompileTemplate("{{outlet}}", {
|
|
906
|
+
strictMode: false
|
|
907
|
+
});
|
|
908
|
+
precompileTemplate("", {
|
|
909
|
+
strictMode: false
|
|
910
|
+
});
|
|
911
|
+
precompileTemplate("<this.ProvidedComponent />", {
|
|
912
|
+
strictMode: false
|
|
913
|
+
});
|
|
914
|
+
capabilities('3.13', {
|
|
915
|
+
destructor: false,
|
|
916
|
+
asyncLifecycleCallbacks: false
|
|
917
|
+
});
|
|
918
|
+
if (macroCondition(dependencySatisfies('ember-source', '>=4.5.0-beta.1'))) {
|
|
919
|
+
//@ts-ignore
|
|
920
|
+
importSync('@ember/renderer').renderSettled;
|
|
921
|
+
} else {
|
|
922
|
+
//@ts-ignore
|
|
923
|
+
importSync('@ember/-internals/glimmer').renderSettled;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
Used internally by the DOM interaction helpers to find one element.
|
|
928
|
+
|
|
929
|
+
@private
|
|
930
|
+
@param {string|Element} target the element or selector to retrieve
|
|
931
|
+
@returns {Element} the target or selector
|
|
932
|
+
*/
|
|
933
|
+
function getElement(target) {
|
|
934
|
+
if (typeof target === 'string') {
|
|
935
|
+
const rootElement = getRootElement();
|
|
936
|
+
return rootElement.querySelector(target);
|
|
937
|
+
} else if (isElement(target) || isDocument(target)) {
|
|
938
|
+
return target;
|
|
939
|
+
} else if (target instanceof Window) {
|
|
940
|
+
return target.document;
|
|
941
|
+
} else {
|
|
942
|
+
const descriptorData = lookupDescriptorData(target);
|
|
943
|
+
if (descriptorData) {
|
|
944
|
+
return resolveDOMElement(descriptorData);
|
|
945
|
+
} else {
|
|
946
|
+
throw new Error('Must use an element, selector string, or DOM element descriptor');
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
Used internally by the DOM interaction helpers to find either window or an element.
|
|
953
|
+
|
|
954
|
+
@private
|
|
955
|
+
@param {string|Element} target the window, an element or selector to retrieve
|
|
956
|
+
@returns {Element|Window} the target or selector
|
|
957
|
+
*/
|
|
958
|
+
function getWindowOrElement(target) {
|
|
959
|
+
if (isWindow(target)) {
|
|
960
|
+
return target;
|
|
961
|
+
}
|
|
962
|
+
return getElement(target);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
966
|
+
|
|
967
|
+
// eslint-disable-next-line require-jsdoc
|
|
968
|
+
function tuple(...args) {
|
|
969
|
+
return args;
|
|
970
|
+
}
|
|
956
971
|
registerHook('fireEvent', 'start', target => {
|
|
957
972
|
log('fireEvent', target);
|
|
958
973
|
});
|
|
@@ -1222,7 +1237,6 @@ function getDescription(target) {
|
|
|
1222
1237
|
return `${target}`;
|
|
1223
1238
|
}
|
|
1224
1239
|
}
|
|
1225
|
-
|
|
1226
1240
|
registerHook('blur', 'start', target => {
|
|
1227
1241
|
log('blur', target);
|
|
1228
1242
|
});
|
|
@@ -1256,7 +1270,6 @@ function __blur__(element, relatedTarget = null) {
|
|
|
1256
1270
|
...options
|
|
1257
1271
|
})).then(() => fireEvent(element, 'focusout', options)) : Promise.resolve();
|
|
1258
1272
|
}
|
|
1259
|
-
|
|
1260
1273
|
registerHook('focus', 'start', target => {
|
|
1261
1274
|
log('focus', target);
|
|
1262
1275
|
});
|
|
@@ -1374,23 +1387,18 @@ function focus(target) {
|
|
|
1374
1387
|
return __focus__(element).then(settled);
|
|
1375
1388
|
}).then(() => runHooks('focus', 'end', target));
|
|
1376
1389
|
}
|
|
1377
|
-
|
|
1378
1390
|
registerHook('click', 'start', target => {
|
|
1379
1391
|
log('click', target);
|
|
1380
1392
|
});
|
|
1381
|
-
|
|
1382
1393
|
registerHook('doubleClick', 'start', target => {
|
|
1383
1394
|
log('doubleClick', target);
|
|
1384
1395
|
});
|
|
1385
|
-
|
|
1386
1396
|
registerHook('tab', 'start', target => {
|
|
1387
1397
|
log('tab', target);
|
|
1388
1398
|
});
|
|
1389
|
-
|
|
1390
1399
|
registerHook('tap', 'start', target => {
|
|
1391
1400
|
log('tap', target);
|
|
1392
1401
|
});
|
|
1393
|
-
|
|
1394
1402
|
registerHook('triggerEvent', 'start', (target, eventType) => {
|
|
1395
1403
|
log('triggerEvent', target, eventType);
|
|
1396
1404
|
});
|
|
@@ -1459,7 +1467,6 @@ function triggerEvent(target, eventType, options, force = false) {
|
|
|
1459
1467
|
return runHooks('triggerEvent', 'end', target, eventType, options);
|
|
1460
1468
|
});
|
|
1461
1469
|
}
|
|
1462
|
-
|
|
1463
1470
|
registerHook('triggerKeyEvent', 'start', (target, eventType, key) => {
|
|
1464
1471
|
log('triggerKeyEvent', target, eventType, key);
|
|
1465
1472
|
});
|
|
@@ -1673,11 +1680,9 @@ function triggerKeyEvent(target, eventType, key, modifiers = DEFAULT_MODIFIERS)
|
|
|
1673
1680
|
return __triggerKeyEvent__(element, eventType, key, modifiers).then(settled);
|
|
1674
1681
|
}).then(() => runHooks('triggerKeyEvent', 'end', target, eventType, key));
|
|
1675
1682
|
}
|
|
1676
|
-
|
|
1677
1683
|
registerHook('fillIn', 'start', (target, text) => {
|
|
1678
1684
|
log('fillIn', target, text);
|
|
1679
1685
|
});
|
|
1680
|
-
|
|
1681
1686
|
registerHook('typeIn', 'start', (target, text) => {
|
|
1682
1687
|
log('typeIn', target, text);
|
|
1683
1688
|
});
|
|
@@ -1786,6 +1791,26 @@ async function fillDateRange(selector, start, end) {
|
|
|
1786
1791
|
await fillGroup('fillDateRange', selector, start, 0);
|
|
1787
1792
|
await fillGroup('fillDateRange', selector, end, 1);
|
|
1788
1793
|
}
|
|
1794
|
+
function clockHour(hours, segment) {
|
|
1795
|
+
const min = Number(segment.getAttribute('aria-valuemin'));
|
|
1796
|
+
const max = Number(segment.getAttribute('aria-valuemax'));
|
|
1797
|
+
if (max === 12) return hours % 12 || 12;
|
|
1798
|
+
if (max === 11) return hours % 12;
|
|
1799
|
+
if (min === 1) return hours || 24;
|
|
1800
|
+
return hours;
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
/**
|
|
1804
|
+
* AM/PM is typed by a letter that depends on the locale, so it is stepped
|
|
1805
|
+
* instead: ArrowUp fills an empty segment and toggles a filled one.
|
|
1806
|
+
*/
|
|
1807
|
+
async function setDayPeriod(segment, value) {
|
|
1808
|
+
await focus(segment);
|
|
1809
|
+
for (let i = 0; i < 2; i++) {
|
|
1810
|
+
if (segment.getAttribute('aria-valuenow') === String(value)) return;
|
|
1811
|
+
await triggerKeyEvent(segment, 'keydown', 'ArrowUp');
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1789
1814
|
|
|
1790
1815
|
/**
|
|
1791
1816
|
* Reuses the component's own parser rather than restating the wire format, so
|
|
@@ -1796,7 +1821,7 @@ async function fillDateRange(selector, start, end) {
|
|
|
1796
1821
|
function asDate(functionName, value) {
|
|
1797
1822
|
const parsed = parseDate(value);
|
|
1798
1823
|
if (!parsed) {
|
|
1799
|
-
throw new Error(`You called "${functionName}" with "${String(value)}", which is neither a Date nor a yyyy-MM-dd string.`);
|
|
1824
|
+
throw new Error(`You called "${functionName}" with "${String(value)}", which is neither a Date nor a yyyy-MM-dd or yyyy-MM-ddTHH:mm string.`);
|
|
1800
1825
|
}
|
|
1801
1826
|
return parsed;
|
|
1802
1827
|
}
|
|
@@ -1813,14 +1838,24 @@ async function fillGroup(functionName, selector, value, which) {
|
|
|
1813
1838
|
throw new Error(hasButtonTrigger ? `You called "${functionName}('${selector}', ...)" on a date field rendering its button trigger, which cannot be typed into. Drop @isEditable={{false}}, or click the trigger and pick from the calendar.` : `You called "${functionName}('${selector}', ...)" but found no date segments inside "${selector}".`);
|
|
1814
1839
|
}
|
|
1815
1840
|
const date = asDate(functionName, value);
|
|
1841
|
+
const pad = (n, width = 2) => String(n).padStart(width, '0');
|
|
1816
1842
|
const digits = {
|
|
1817
|
-
year:
|
|
1818
|
-
month:
|
|
1819
|
-
day:
|
|
1843
|
+
year: pad(date.getFullYear(), 4),
|
|
1844
|
+
month: pad(date.getMonth() + 1),
|
|
1845
|
+
day: pad(date.getDate()),
|
|
1846
|
+
minute: pad(date.getMinutes())
|
|
1820
1847
|
};
|
|
1821
1848
|
for (const segment of group.querySelectorAll('[data-part="segment"]')) {
|
|
1822
1849
|
const element = segment;
|
|
1823
|
-
const
|
|
1850
|
+
const type = element.dataset['type'];
|
|
1851
|
+
if (type === 'dayPeriod') {
|
|
1852
|
+
await setDayPeriod(element, date.getHours() < 12 ? 0 : 1);
|
|
1853
|
+
continue;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
// The hour goes in as the field's own clock counts it, which its
|
|
1857
|
+
// spinbutton bounds give away: 1-12 or 0-11 for AM/PM, 0-23 or 1-24 not.
|
|
1858
|
+
const run = type === 'hour' ? pad(clockHour(date.getHours(), element)) : type ? digits[type] : undefined;
|
|
1824
1859
|
if (!run) continue;
|
|
1825
1860
|
await focus(element);
|
|
1826
1861
|
for (const digit of run) {
|