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.

fix run buttons being flexed in compact mode (#7885)

Shahmir Varqha35b00c70e65b
diff --git a/frontend/AGENTS.md b/frontend/AGENTS.md
index d8331dae05..b07754447a 100644
--- a/frontend/AGENTS.md
+++ b/frontend/AGENTS.md
@@ -91,6 +91,8 @@ const form = useForm<z.infer<typeof schema>>({ resolver: zodResolver(schema) });
## Testing
+### Unit Tests
+
Tests live alongside source files or in `__tests__` directories.
```bash
@@ -98,11 +100,15 @@ pnpm --filter @marimo-team/frontend test # All tests
pnpm --filter @marimo-team/frontend test src/__tests__/lru.test.ts # Specific file
```
-Best practices
+Best practices:
- test edge cases
- use descriptive names
- group with `describe`
+### E2E Tests
+
+E2E tests use Playwright. See [e2e-tests/README.md](e2e-tests/README.md) for details.
+
## Type Patterns
```typescript
diff --git a/frontend/e2e-tests/README.md b/frontend/e2e-tests/README.md
new file mode 100644
index 0000000000..dce709022a
--- /dev/null
+++ b/frontend/e2e-tests/README.md
@@ -0,0 +1,20 @@
+# E2E Tests
+
+E2E tests use Playwright.
+
+## Running Tests
+
+```bash
+pnpm playwright test # Run all e2e tests
+pnpm playwright test e2e-tests/slides.spec.ts # Run specific test
+pnpm playwright test --ui # Interactive UI mode
+```
+
+## Rebuild Before Taking Screenshots
+
+Rebuild the frontend for tests that take screenshots to view the latest changes.
+
+```bash
+make fe
+pnpm playwright test
+```
diff --git a/frontend/e2e-tests/helper.ts b/frontend/e2e-tests/helper.ts
index 127dca8e5c..c7c996b785 100644
--- a/frontend/e2e-tests/helper.ts
+++ b/frontend/e2e-tests/helper.ts
@@ -167,14 +167,23 @@ export async function openCommandPalette(opts: {
}) {
const { page, command } = opts;
+ // Blur any active element first to avoid typing into cell editors
+ await page.evaluate(() => {
+ if (document.activeElement instanceof HTMLElement) {
+ document.activeElement.blur();
+ }
+ });
+
// Open command palette with Ctrl+K (or Cmd+K on Mac)
await pressShortcut(page, "global.commandPalette");
- // Wait for the command palette to be visible
- await expect(page.getByPlaceholder("Type to search")).toBeVisible();
+ // Wait for the command palette input to be visible
+ const commandInput = page.getByPlaceholder("Type to search...");
+ await expect(commandInput).toBeVisible();
- // Type the command
- await page.keyboard.type(command);
+ // Focus and wait for it to be ready
+ await commandInput.focus();
+ await commandInput.fill(command);
// Hit Enter to execute
await page.keyboard.press("Enter");
diff --git a/frontend/e2e-tests/py/layouts/slides.slides.json b/frontend/e2e-tests/py/layouts/slides.slides.json
new file mode 100644
index 0000000000..3bcd0f545a
--- /dev/null
+++ b/frontend/e2e-tests/py/layouts/slides.slides.json
@@ -0,0 +1,4 @@
+{
+ "type": "slides",
+ "data": {}
+}
diff --git a/frontend/e2e-tests/py/slides.py b/frontend/e2e-tests/py/slides.py
new file mode 100644
index 0000000000..b1d2740b49
--- /dev/null
+++ b/frontend/e2e-tests/py/slides.py
@@ -0,0 +1,35 @@
+# /// script
+# [tool.marimo.runtime]
+# auto_instantiate = true
+# ///
+
+import marimo
+
+__generated_with = "0.19.4"
+app = marimo.App(layout_file="layouts/slides.slides.json")
+
+
+def _():
+ import marimo as mo
+ return (mo,)
+
+
+def _(mo):
+ mo.md("""
+ # Slides!
+ """)
+ return
+
+
[email protected](hide_code=True)
+def _(mo):
+ mo.md(r"""
+ We all love slides don't we 🎀
+ """)
+ return
+
+
+if __name__ == "__main__":
+ app.run()
diff --git a/frontend/e2e-tests/screenshots/slides.0.png b/frontend/e2e-tests/screenshots/slides.0.png
new file mode 100644
index 0000000000..00979e6a03
Binary files /dev/null and b/frontend/e2e-tests/screenshots/slides.0.png differ
diff --git a/frontend/e2e-tests/screenshots/slides.1.png b/frontend/e2e-tests/screenshots/slides.1.png
new file mode 100644
index 0000000000..35e69e19fb
Binary files /dev/null and b/frontend/e2e-tests/screenshots/slides.1.png differ
diff --git a/frontend/e2e-tests/slides.spec.ts b/frontend/e2e-tests/slides.spec.ts
new file mode 100644
index 0000000000..78857a46de
--- /dev/null
+++ b/frontend/e2e-tests/slides.spec.ts
@@ -0,0 +1,79 @@
+/* Copyright 2026 Marimo. All rights reserved. */
+
+import { fileURLToPath } from "node:url";
+import { expect, test } from "@playwright/test";
+import { getAppUrl } from "../playwright.config";
+import { openCommandPalette, takeScreenshot } from "./helper";
+import { waitForMarimoApp } from "./test-utils";
+
+const __filename = fileURLToPath(import.meta.url);
+
+const appUrl = getAppUrl("slides.py");
+test.beforeEach(async ({ page }, info) => {
+ await page.goto(appUrl);
+ if (info.retry) {
+ await page.reload();
+ }
+
+ // Wait for cells to appear
+ await waitForMarimoApp(page);
+});
+
+test("slides", async ({ page }) => {
+ await expect(page.getByRole("heading", { name: "Slides!" })).toBeVisible();
+
+ await openCommandPalette({ page, command: "Present as Slides" });
+
+ // Wait for slides mode - Swiper adds .swiper class and component has .mo-slides-theme
+ const slidesContainer = page.locator(".swiper.mo-slides-theme");
+ await expect(slidesContainer).toBeVisible();
+
+ await takeScreenshot(page, __filename);
+
+ // Check pagination shows we're on first slide (bullet 1 is active)
+ // Use pagintion bullets instead of text because the library (Swiper) puts all elements in the viewport.
+ const paginationBullets = page.locator(".swiper-pagination-bullet");
+ await expect(paginationBullets.first()).toHaveClass(
+ /swiper-pagination-bullet-active/,
+ );
+
+ // Navigate to next slide using right arrow key
+ await page.keyboard.press("ArrowRight");
+
+ // Verify we moved to second slide via pagination
+ await expect(paginationBullets.nth(1)).toHaveClass(
+ /swiper-pagination-bullet-active/,
+ );
+
+ await takeScreenshot(page, __filename);
+
+ // Navigate back to first slide using left arrow key
+ await page.keyboard.press("ArrowLeft");
+
+ // Verify we're back on the first slide
+ await expect(paginationBullets.first()).toHaveClass(
+ /swiper-pagination-bullet-active/,
+ );
+});
+
+test("slides fullscreen", async ({ page }) => {
+ await openCommandPalette({ page, command: "Present as Slides" });
+
+ // Wait for slides mode - Swiper adds .swiper class and component has .mo-slides-theme
+ const slidesContainer = page.locator(".swiper.mo-slides-theme");
+ await expect(slidesContainer).toBeVisible();
+
+ // Test buttons
+ await expect(page.getByText("Fullscreen")).toBeVisible();
+ await page.getByText("Fullscreen").click();
+
+ await expect(page.getByText("Exit Fullscreen")).toBeVisible();
+ await page.getByText("Exit Fullscreen").click();
+
+ await expect(page.getByText("Fullscreen")).toBeVisible();
+ await page.getByText("Fullscreen").click();
+
+ // Test Escape key for exiting fullscreen
+ await page.keyboard.press("Escape");
+ await expect(page.getByText("Fullscreen")).toBeVisible();
+});
diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts
index dda6a82040..4c756033f4 100644
--- a/frontend/playwright.config.ts
+++ b/frontend/playwright.config.ts
@@ -42,6 +42,7 @@ const appToOptions = {
"layout_grid.py": { command: "edit" },
"stdin.py": { command: "edit" },
"layout_grid_with_sidebar.py": { command: "edit" },
+ "slides.py": { command: "edit" },
// Custom server for shutdown
"shutdown.py": { command: "edit", port: port() },
// Run
diff --git a/frontend/src/components/editor/controls/Controls.tsx b/frontend/src/components/editor/controls/Controls.tsx
index f72e1f6164..18beddd3b8 100644
--- a/frontend/src/components/editor/controls/Controls.tsx
+++ b/frontend/src/components/editor/controls/Controls.tsx
@@ -54,9 +54,7 @@ export const Controls = ({
onRun,
connectionState,
running,
- appConfig,
}: ControlsProps): JSX.Element => {
- const appWidth = appConfig.width;
const undoAvailable = useAtomValue(canUndoDeletesAtom);
const needsRun = useAtomValue(needsRunAtom);
const { undoDeleteCell } = useCellActions();
@@ -103,12 +101,7 @@ export const Controls = ({
</div>
)}
- <div
- className={cn(
- bottomRightControls,
- appWidth === "compact" && "xl:flex-row items-end",
- )}
- >
+ <div className={cn(bottomRightControls)}>
<HideInKioskMode>
<SaveComponent kioskMode={false} />
</HideInKioskMode>