Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

test(e2e): deflake toggle-cell-language spec (#9715)

Kiran Gadhave4703a9ab067a
diff --git a/frontend/e2e-tests/toggle-cell-language.spec.ts b/frontend/e2e-tests/toggle-cell-language.spec.ts
index b683aaa6c4..3380a05040 100644
--- a/frontend/e2e-tests/toggle-cell-language.spec.ts
+++ b/frontend/e2e-tests/toggle-cell-language.spec.ts
@@ -1,7 +1,7 @@
/* Copyright 2026 Marimo. All rights reserved. */
import { expect, test } from "@playwright/test";
import { getAppUrl, resetFile } from "../playwright.config";
-import { openCellActions } from "./helper";
+import { maybeRestartKernel, openCellActions } from "./helper";
const appUrl = getAppUrl("title.py");
@@ -10,6 +10,7 @@ test.beforeEach(async ({ page }, info) => {
if (info.retry) {
await page.reload();
}
+ await maybeRestartKernel(page);
});
test.afterEach(async () => {
@@ -28,6 +29,11 @@ test("change the cell to a markdown cell and toggle hide code", async ({
await page.getByText("Convert to Markdown").click();
await expect(title).toBeVisible();
+ // Code stays visible while the cell is focused; blur it so the markdown
+ // initial hide-code takes effect before asserting.
+ await page.keyboard.press("Escape");
+ await page.locator("body").click({ position: { x: 4, y: 4 } });
+
// Expect cell editor to be invisible at first (markdown initial hide code is true)
const cellEditor = page.getByTestId("cell-editor");
await expect(cellEditor).toBeHidden();