From b8fde03cf896519e0249c2f0b0b36c8d483e245e Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 19 Sep 2026 23:37:45 -0700 Subject: [PATCH] test(e2e): retry rich selection before clipboard assertions --- tests/e2e/markdown-copy-formatting.spec.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/e2e/markdown-copy-formatting.spec.ts b/tests/e2e/markdown-copy-formatting.spec.ts index 57caacde2c5..b24db46a319 100644 --- a/tests/e2e/markdown-copy-formatting.spec.ts +++ b/tests/e2e/markdown-copy-formatting.spec.ts @@ -23,14 +23,12 @@ test('copying a rich selection preserves Markdown formatting', async ({ orcaPage await openMarkdownFixture(orcaPage, context, filePath) const editor = await waitForRichMarkdownEditor(orcaPage) await expect(editor.locator('strong')).toHaveText('bold') - await editor.locator('p').selectText() await expect - .poll(() => orcaPage.evaluate(() => window.getSelection()?.toString())) + .poll(async () => { + await editor.locator('p').selectText() + return orcaPage.evaluate(() => window.getSelection()?.toString()) + }) .toBe('A bold paragraph with a link.') - await testInfo.attach('formatted-selection', { - body: await orcaPage.screenshot({ path: testInfo.outputPath('formatted-selection.png') }), - contentType: 'image/png' - }) const copied = await editor.evaluate((element) => { // Keep this check isolated from the user's system clipboard. const clipboardData = new DataTransfer() @@ -44,11 +42,17 @@ test('copying a rich selection preserves Markdown formatting', async ({ orcaPage expect(copied.text).not.toContain('# Copy formatting') expect(copied.html).toContain('bold') await expect(editor.locator('p')).toHaveText('A bold paragraph with a link.') + await testInfo.attach('formatted-selection', { + body: await orcaPage.screenshot({ path: testInfo.outputPath('formatted-selection.png') }), + contentType: 'image/png' + }) await testInfo.attach('copied-markdown', { body: copied.text, contentType: 'text/markdown' }) - await editor.selectText() await expect - .poll(() => orcaPage.evaluate(() => window.getSelection()?.toString())) + .poll(async () => { + await editor.selectText() + return orcaPage.evaluate(() => window.getSelection()?.toString()) + }) .toContain('Copy formatting') const copiedBlocks = await editor.evaluate((element) => { const clipboardData = new DataTransfer()