mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-07-17 16:47:05 +00:00
test: focus the editor before typing in three specs
These three Playwright tests started failing after the autofocus removal inef95498because they reached for keyboard input without first clicking into the editor: - enter.spec.ts: `lastLine.focus()` is a no-op on a <div> (not natively focusable), so Enter went to <body> instead of the contenteditable. Replaced with `.click()`. - indentation.spec.ts: `selectText()` triple-clicks but the focus event didn't reliably reach the inner contenteditable in CI; added an explicit `.click()` first. - collab_client.spec.ts: each test opens its own browser contexts via goToPad, which does not click into the editor; selectText() in replaceLineText was the only thing landing focus, and that proved flaky. Added `body.click()` at the top of replaceLineText. All three previously relied on the page-load auto-focus thatef95498removed. The new pattern (click first, then type) is what writeToPad and clearPadContent already do — these specs now match. Refs #7255 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ef95498249
commit
e65e86fd94
3 changed files with 14 additions and 1 deletions
|
|
@ -30,6 +30,11 @@ test.describe('Messages in the COLLABROOM', function () {
|
|||
|
||||
const div = body.locator('div').nth(lineNumber)
|
||||
|
||||
// Click into the editor before keypresses. Each test opens its own
|
||||
// browser contexts via goToPad, which does not click — previously the
|
||||
// page-load auto-focus put the editor in focus regardless, but that
|
||||
// was removed in #7255 so the skip link could be Tab-reachable.
|
||||
await body.click();
|
||||
// simulate key presses to delete content
|
||||
await div.locator('span').selectText() // select all
|
||||
await page.keyboard.press('Backspace') // clear the first line
|
||||
|
|
|
|||
|
|
@ -49,7 +49,11 @@ test.describe('enter keystroke', function () {
|
|||
for (let i = 0; i < numberOfLines; i++) {
|
||||
const expectedCount = originalLength + i + 1;
|
||||
const lastLine = padBody.locator('div').last();
|
||||
await lastLine.focus();
|
||||
// `.focus()` is a no-op on a <div> (not natively focusable), so click
|
||||
// the line to put the caret in the editor. Previously the editor was
|
||||
// auto-focused on page load and this still happened to work; removing
|
||||
// that auto-focus (#7255) makes the click explicit.
|
||||
await lastLine.click();
|
||||
await page.keyboard.press('End');
|
||||
await page.keyboard.press('Enter');
|
||||
await expect(padBody.locator('div')).toHaveCount(expectedCount);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ test.describe('indentation button', function () {
|
|||
// get the first text element out of the inner iframe
|
||||
const $firstTextElement = padBody.locator('div').first();
|
||||
|
||||
// Click first to land focus inside the editor iframe; the load-time
|
||||
// auto-focus that previously did this was removed in #7255 so Tab
|
||||
// could reach the skip-to-content link.
|
||||
await $firstTextElement.click();
|
||||
// select this text element
|
||||
await $firstTextElement.selectText()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue