Skip to content

Commit 01fecda

Browse files
committed
test(device): submit the link popover by pressing the real Enter key
Two review questions shaped this. First: the old dispatched KeyboardEvent could never submit once the popovers moved to the form's submit event — synthetic events trigger no default action. Second: 'why not hit the Enter key?' — no reason not to, and the rig already knew how: on iOS, pressSoftKeyboardEnter taps the on-screen keyboard's actual return key (the RETURN_KEY_RATIOS offset ladder) — the real user gesture. On Android, where BrowserStack blocks native taps, a W3C protocol Enter is used instead: trusted input, so the browser runs its default action and the real path is exercised (key press -> implicit form submission -> the popover's submit handling). Only Gboard's own choice of *which* action its key performs stays out of reach, on the manual release checklist. Callers supply the verify script the iOS tap ladder needs.
1 parent d4f51ad commit 01fecda

2 files changed

Lines changed: 19 additions & 20 deletions

File tree

tests/device/formattingToolbar.device.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ for (const device of activeDevices()) {
139139
toolbar: true,
140140
});
141141

142-
await typeAndSubmit(session, `${LINK_POPOVER} input`, "example.com");
143-
144-
await session.waitFor(
145-
"link created and popover closed",
142+
await typeAndSubmit(
143+
session,
144+
`${LINK_POPOVER} input`,
145+
"example.com",
146146
`return {
147147
ok: !!document.querySelector('.bn-editor a[href="https://example.com"]')
148148
&& !document.querySelector(${JSON.stringify(LINK_POPOVER)}),

tests/device/linkPopover.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* use them, since only the link tests speak these concepts.
44
*/
55
import { MOBILE_TOOLBAR, PARAGRAPH, startEditing } from "./lib/editorPage.js";
6-
import { tapElement } from "./lib/gestures.js";
6+
import { pressSoftKeyboardEnter, tapElement } from "./lib/gestures.js";
77
import type { DeviceSession } from "./lib/webdriver.js";
88

99
export const LINK_BUTTON = `${MOBILE_TOOLBAR} [data-test="createLink"]`;
@@ -71,26 +71,25 @@ export async function openLinkPopover(session: DeviceSession): Promise<void> {
7171
}
7272

7373
/**
74-
* Types into a popover field and submits it the way the browser does:
75-
* `requestSubmit()` on the enclosing form, which runs the popover's real
76-
* `onSubmit` wiring. A dispatched Enter keydown cannot do this — synthetic
77-
* events trigger no default action, and the popovers commit through the
78-
* form's `submit` event rather than key handlers. Tapping the on-screen
79-
* keyboard's action key isn't an option either: no automation channel
80-
* reaches it (see the README) — which also means the IME's own choice of
81-
* action stays a manual release check.
74+
* Types into a popover field and submits it by pressing the Enter key.
75+
*
76+
* On iOS that is a native tap on the on-screen keyboard's actual return key
77+
* (the real user gesture — see `pressSoftKeyboardEnter`'s offset ladder). On
78+
* Android, where BrowserStack blocks native taps, it is a W3C protocol Enter:
79+
* trusted input, so the browser still runs its default action and the real
80+
* submission path is exercised (key press -> implicit form submission -> the
81+
* popover's `submit` handling). Only Gboard's own choice of *which* action
82+
* its key performs stays out of reach, and on the manual release checklist.
83+
*
84+
* `verify` is a page script returning `{ ok: boolean }` observing the
85+
* submission's effect — the iOS tap ladder needs it to know a tap landed.
8286
*/
8387
export async function typeAndSubmit(
8488
session: DeviceSession,
8589
css: string,
8690
text: string,
91+
verify: string,
8792
): Promise<void> {
8893
await session.elementValue(css, text);
89-
await session.exec(
90-
`const el = document.querySelector(arguments[0]);
91-
if (el && el.form) {
92-
el.form.requestSubmit();
93-
}`,
94-
[css],
95-
);
94+
await pressSoftKeyboardEnter(session, verify);
9695
}

0 commit comments

Comments
 (0)