From 594e23c43964448a4e90298344eb3ae7610ab1ef Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Mon, 25 Dec 2023 23:58:22 +0100 Subject: [PATCH] Fix broken tests --- playwright.config.ts | 2 +- tests/language-detection.spec.js | 12 ++++++------ tests/markdown.spec.js | 9 +++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 22c3505..d167fb1 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -41,7 +41,7 @@ export default defineConfig({ name: 'firefox', use: { ...devices['Desktop Firefox'] }, }, - + { name: 'webkit', use: { ...devices['Desktop Safari'] }, diff --git a/tests/language-detection.spec.js b/tests/language-detection.spec.js index 6581623..10503bf 100644 --- a/tests/language-detection.spec.js +++ b/tests/language-detection.spec.js @@ -11,11 +11,11 @@ test.beforeEach(async ({ page }) => { test("test valid JSON detection", async ({ page }) => { - page.locator("body").pressSequentially(` + await page.locator("body").pressSequentially(` {"test": 1, "key2": "hey!"} `) - await page.waitForTimeout(200); - expect(await page.locator("css=.status .status-block.lang")).toHaveText("JSON (auto)") + await page.waitForTimeout(1000); + await expect(page.locator("css=.status .status-block.lang")).toHaveText("JSON (auto)") const block = (await heynotePage.getBlocks())[0] expect(block.language.name).toBe("json") expect(block.language.auto).toBeTruthy() @@ -23,7 +23,7 @@ test("test valid JSON detection", async ({ page }) => { test("python detection", async ({ page }) => { - page.locator("body").pressSequentially(` + await page.locator("body").pressSequentially(` # import complex math module import cmath @@ -36,6 +36,6 @@ sol2 = (-b+cmath.sqrt(d))/(2*a) print('The solution are {0} and {1}'.format(sol1,sol2)) `) - await page.waitForTimeout(1000); - expect(await page.locator("css=.status .status-block.lang")).toHaveText("Python (auto)") + await page.waitForTimeout(3000); + await expect(page.locator("css=.status .status-block.lang")).toHaveText("Python (auto)") }) diff --git a/tests/markdown.spec.js b/tests/markdown.spec.js index e83528d..d174c13 100644 --- a/tests/markdown.spec.js +++ b/tests/markdown.spec.js @@ -10,24 +10,25 @@ test.beforeEach(async ({ page }) => { }); test("test markdown mode", async ({ page }) => { - heynotePage.setContent(` + await heynotePage.setContent(` ∞∞∞markdown # Markdown! - [ ] todo - [x] done `) + await page.waitForTimeout(200) //await page.locator("body").pressSequentially("test") - expect(await page.locator("css=.status .status-block.lang")).toHaveText("Markdown") + await expect(page.locator("css=.status .status-block.lang")).toHaveText("Markdown") }) test("checkbox toggle", async ({ page }) => { - heynotePage.setContent(` + await heynotePage.setContent(` ∞∞∞markdown - [ ] todo `) const checkbox = await page.locator("css=.cm-content input[type=checkbox]") - expect(checkbox).toHaveCount(1) + await expect(checkbox).toHaveCount(1) await checkbox.click() expect(await heynotePage.getBlockContent(0)).toBe("- [x] todo\n") await checkbox.click()