From 464084ebf4d7f24a368cc8074e6aac3b7d3ad9c8 Mon Sep 17 00:00:00 2001 From: Jin <22962980+JYC333@users.noreply.github.com> Date: Tue, 18 Mar 2025 14:15:42 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Improve=20e2e=20test?= =?UTF-8?q?=20stability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e2e/note_types/text.spec.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/e2e/note_types/text.spec.ts b/e2e/note_types/text.spec.ts index 71e2da2cc..328a43d17 100644 --- a/e2e/note_types/text.spec.ts +++ b/e2e/note_types/text.spec.ts @@ -61,8 +61,24 @@ test("Displays math popup", async ({ page, context }) => { const mathForm = page.locator(".ck-math-form"); await expect(mathForm).toBeVisible(); - await mathForm.locator(".ck-input").first().fill("e=mc^2"); + const input = mathForm.locator(".ck-input").first(); + await input.click(); + await input.fill("e=mc^2"); + await page.waitForTimeout(100); const preview = page.locator('[id^="math-preview"]'); + await preview.waitFor({ + state: 'visible', + timeout: 5000 + }); + + await page.waitForFunction((): boolean => { + const preview = document.querySelector('[id^="math-preview"]'); + if (!preview) return false; + const katex = preview.querySelector('.katex'); + return !!katex && window.getComputedStyle(preview).display !== 'none'; + }, { timeout: 5000 }); + + await expect(preview.locator('.katex')).toBeVisible(); await expect(preview).toMatchAriaSnapshot("- math: e = m c 2"); });