@testra-studio/kit 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/actions.d.ts +18 -2
- package/dist/actions.js +30 -4
- package/dist/plain.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ A major version (or, before 1.0, a minor one) changes a format or a
|
|
|
5
5
|
variable e2e Studio and the project share; the Studio's project check names
|
|
6
6
|
the oldest kit it works with.
|
|
7
7
|
|
|
8
|
+
## 0.4.1
|
|
9
|
+
|
|
10
|
+
- A recorded Tab on a combobox waits until its list has closed before the
|
|
11
|
+
next action: a lookup checks its value with the app after Tab, and a Save
|
|
12
|
+
pressed meanwhile was lost. One still open after 10 s is warned of, and
|
|
13
|
+
the run goes on.
|
|
14
|
+
|
|
15
|
+
What a project does: nothing.
|
|
16
|
+
|
|
8
17
|
## 0.4.0
|
|
9
18
|
|
|
10
19
|
- A Do step with actions may say what shows when it is done, in a Check's
|
package/dist/actions.d.ts
CHANGED
|
@@ -127,8 +127,18 @@ export declare function actionValue(action: StepAction): string | undefined;
|
|
|
127
127
|
export declare function locate(target: StepTarget, screen: ScreenLike, browser: BrowserLike | undefined): LocatorLike;
|
|
128
128
|
/** How long one recorded action waits for its element before the step falls back to its sentence. */
|
|
129
129
|
export declare const ACTION_TIMEOUT = 15000;
|
|
130
|
-
/**
|
|
131
|
-
export declare
|
|
130
|
+
/** How long a combobox left with Tab is waited for to check its value, before the run goes on and says so. */
|
|
131
|
+
export declare const LOOKUP_TIMEOUT = 10000;
|
|
132
|
+
/**
|
|
133
|
+
* Does one recorded action, its value with the run's values in place of `{…}` (`value`).
|
|
134
|
+
*
|
|
135
|
+
* A combobox left with Tab checks its value with the app (a lookup: its list
|
|
136
|
+
* stays open until the value is found), and what is pressed meanwhile may be
|
|
137
|
+
* lost, as a Save is. So with the framework's `expect`, Tab on a combobox
|
|
138
|
+
* waits until its list has closed; one still open after `LOOKUP_TIMEOUT` is
|
|
139
|
+
* said, and the run goes on. Kit 0.4.1.
|
|
140
|
+
*/
|
|
141
|
+
export declare function perform(action: StepAction, screen: ScreenLike, browser: BrowserLike | undefined, value: (text: string) => string, app?: AppLike, expect?: ExpectLike): Promise<void>;
|
|
132
142
|
/** The matchers an expectation may use, as the framework's `expect` names them. */
|
|
133
143
|
export declare const MATCHERS: readonly ['toBeVisible', 'toHaveText', 'toContainText', 'toHaveValue'];
|
|
134
144
|
/**
|
|
@@ -161,6 +171,12 @@ export type ExpectLike = (locator: LocatorLike) => {
|
|
|
161
171
|
toHaveValue(value: string, options?: {
|
|
162
172
|
timeout?: number;
|
|
163
173
|
}): Promise<unknown>;
|
|
174
|
+
/** Where the framework has it: what says a combobox left with Tab has closed its list. Kit 0.4.1. */
|
|
175
|
+
readonly not?: {
|
|
176
|
+
toBeExpanded?(options?: {
|
|
177
|
+
timeout?: number;
|
|
178
|
+
}): Promise<unknown>;
|
|
179
|
+
};
|
|
164
180
|
};
|
|
165
181
|
/** Why `value` is no expectation, or nothing when it is one. */
|
|
166
182
|
export declare function expectationProblem(value: unknown): string | undefined;
|
package/dist/actions.js
CHANGED
|
@@ -159,8 +159,18 @@ function matching(target, screen, browser) {
|
|
|
159
159
|
const AMBIGUOUS = /LOCATOR_AMBIGUOUS|matched \d+ (?:nodes|elements), expected exactly one/;
|
|
160
160
|
/** How long one recorded action waits for its element before the step falls back to its sentence. */
|
|
161
161
|
export const ACTION_TIMEOUT = 15_000;
|
|
162
|
-
/**
|
|
163
|
-
export
|
|
162
|
+
/** How long a combobox left with Tab is waited for to check its value, before the run goes on and says so. */
|
|
163
|
+
export const LOOKUP_TIMEOUT = 10_000;
|
|
164
|
+
/**
|
|
165
|
+
* Does one recorded action, its value with the run's values in place of `{…}` (`value`).
|
|
166
|
+
*
|
|
167
|
+
* A combobox left with Tab checks its value with the app (a lookup: its list
|
|
168
|
+
* stays open until the value is found), and what is pressed meanwhile may be
|
|
169
|
+
* lost, as a Save is. So with the framework's `expect`, Tab on a combobox
|
|
170
|
+
* waits until its list has closed; one still open after `LOOKUP_TIMEOUT` is
|
|
171
|
+
* said, and the run goes on. Kit 0.4.1.
|
|
172
|
+
*/
|
|
173
|
+
export async function perform(action, screen, browser, value, app, expect) {
|
|
164
174
|
if ('open' in action)
|
|
165
175
|
return void (await need(app, 'opening a page', 'app').open(action.open));
|
|
166
176
|
const timeout = { timeout: ACTION_TIMEOUT };
|
|
@@ -197,10 +207,26 @@ export async function perform(action, screen, browser, value, app) {
|
|
|
197
207
|
return on(action.check, (e) => e.check(timeout));
|
|
198
208
|
if ('uncheck' in action)
|
|
199
209
|
return on(action.uncheck, (e) => e.uncheck(timeout));
|
|
200
|
-
if ('press' in action)
|
|
201
|
-
|
|
210
|
+
if ('press' in action) {
|
|
211
|
+
await on(action.press, (e) => e.press(action.key, timeout));
|
|
212
|
+
if (action.key === 'Tab' && action.press.role === 'combobox')
|
|
213
|
+
await closed(action.press, screen, browser, expect);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
202
216
|
await need(browser, 'a key on whatever has focus').keyboard.press(action.key);
|
|
203
217
|
}
|
|
218
|
+
/** Waits until a combobox left with Tab has closed its list: its value is checked. Never fails the action. */
|
|
219
|
+
async function closed(target, screen, browser, expect) {
|
|
220
|
+
if (!expect)
|
|
221
|
+
return;
|
|
222
|
+
try {
|
|
223
|
+
const found = await element(target, screen, browser);
|
|
224
|
+
await expect(found).not?.toBeExpanded?.({ timeout: LOOKUP_TIMEOUT });
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
console.warn(`${describe(target)} still has its list open ${LOOKUP_TIMEOUT / 1000} s after Tab; the run goes on without waiting for it`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
204
230
|
function need(value, what, fixture = 'browser') {
|
|
205
231
|
if (value === undefined)
|
|
206
232
|
throw new Error(`${what} needs the ${fixture} fixture, which the runner did not pass`);
|
package/dist/plain.js
CHANGED
|
@@ -333,7 +333,7 @@ export async function runSteps(fixtures, test, options = {}) {
|
|
|
333
333
|
let done = false;
|
|
334
334
|
try {
|
|
335
335
|
for (const action of step.actions)
|
|
336
|
-
await perform(action, screen, browser, text, app);
|
|
336
|
+
await perform(action, screen, browser, text, app, expect);
|
|
337
337
|
done = true;
|
|
338
338
|
}
|
|
339
339
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testra-studio/kit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "What a test project on the e2e framework needs to run under e2e Studio: its browser and devices, plain-English steps files, and basic data.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|