Skip to content

Commit f095a34

Browse files
authored
fix(e2e): restore the keyboard-only markdown selection and wait for it to apply (#10265)
1 parent 2edb436 commit f095a34

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

‎apps/sim/scripts/test-markdown-viewer-e2e.ts‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -376,22 +376,18 @@ async function editLastCell(page: Page, marker: string) {
376376
timeout: 120_000,
377377
})
378378
await page.bringToFront()
379-
const bold = page.locator('.rich-markdown-prose strong').filter({ hasText: /^bold$/ })
380-
await bold.click()
379+
await page
380+
.locator('.rich-markdown-prose strong')
381+
.filter({ hasText: /^bold$/ })
382+
.click()
381383
await expect(page.locator('.rich-markdown-prose[contenteditable="true"]')).toBeFocused()
382-
// A click can land the caret at the word's edge, where one step left crosses the space before it
383-
// and Shift+ArrowRight selects only that space. Start inside the word: "bo|ld".
384-
await bold.evaluate((element) => {
385-
const text = element.firstChild
386-
if (text?.nodeType !== Node.TEXT_NODE) throw new Error('The bold mark has no text node')
387-
getSelection()?.collapse(text, 2)
388-
})
384+
await page.keyboard.press('ArrowLeft')
389385
await page.keyboard.press('Shift+ArrowRight')
390386
await expect
391-
.poll(() => page.evaluate(() => getSelection()?.toString() ?? ''), {
387+
.poll(() => page.evaluate(() => getSelection()?.toString().trim() ?? ''), {
392388
message: 'Keyboard selection did not select text',
393389
})
394-
.toBe('l')
390+
.not.toBe('')
395391
await proveToolbar(page, page.getByRole('toolbar', { name: 'Text formatting' }))
396392
await page.keyboard.press('ArrowRight')
397393
}

0 commit comments

Comments
 (0)