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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fixes for fe-tests (#7607)
Shahmir Varqha9681726d6218
diff --git a/frontend/src/core/codemirror/language/__tests__/markdown.test.ts b/frontend/src/core/codemirror/language/__tests__/markdown.test.tsindex b1c4216753..d22f3478a4 100644--- a/frontend/src/core/codemirror/language/__tests__/markdown.test.ts+++ b/frontend/src/core/codemirror/language/__tests__/markdown.test.ts@@ -25,14 +25,7 @@ describe("MarkdownLanguageAdapter", () => {expect(innerCode).toBe("");expect(offset).toBe(0);const out = adapter.transformOut(innerCode, metadata);- expect(out).toMatchInlineSnapshot(`- [- "mo.md(r"""-- """)",- 12,- ]- `);+ expect(out).toEqual([`mo.md(r"""\n \n""")`, 12]);});it("should extract inner Markdown from triple double-quoted strings", () => {@@ -229,9 +222,8 @@ describe("MarkdownLanguageAdapter", () => {it("empty string", () => {const code = "";const [wrappedCode, offset] = adapter.transformOut(code, metadata);- expect(wrappedCode).toBe(`mo.md("""--""")`);+ // Empty strings get a space to avoid 6 consecutive quotes+ expect(wrappedCode).toBe(`mo.md("""\n \n""")`);expect(offset).toBe(11);});diff --git a/frontend/src/core/codemirror/reactive-references/__tests__/analyzer.test.ts b/frontend/src/core/codemirror/reactive-references/__tests__/analyzer.test.tsindex 859da57120..bce4597af2 100644--- a/frontend/src/core/codemirror/reactive-references/__tests__/analyzer.test.ts+++ b/frontend/src/core/codemirror/reactive-references/__tests__/analyzer.test.ts@@ -311,7 +311,7 @@ def outer():return a + b + z # highlight: b^return inner()-+${" ".repeat(8)}"`);});diff --git a/frontend/src/hooks/__tests__/usePackageMetadata.test.tsx b/frontend/src/hooks/__tests__/usePackageMetadata.test.tsxindex e1d3cb3550..654b3d164e 100644--- a/frontend/src/hooks/__tests__/usePackageMetadata.test.tsx+++ b/frontend/src/hooks/__tests__/usePackageMetadata.test.tsx@@ -1,5 +1,31 @@/* Copyright 2026 Marimo. All rights reserved. */+import { vi } from "vitest";++// MSW 2.x requires localStorage for cookie persistence.+// vi.hoisted runs before all imports, so localStorage is available when MSW loads.+vi.hoisted(() => {+ const store: Record<string, string> = {};+ globalThis.localStorage = {+ getItem: (key: string) => store[key] ?? null,+ setItem: (key: string, value: string) => {+ store[key] = value;+ },+ removeItem: (key: string) => {+ Reflect.deleteProperty(store, key);+ },+ clear: () => {+ for (const key of Object.keys(store)) {+ Reflect.deleteProperty(store, key);+ }+ },+ key: (index: number) => Object.keys(store)[index] ?? null,+ get length() {+ return Object.keys(store).length;+ },+ };+});+import { renderHook, waitFor } from "@testing-library/react";import * as msw from "msw";import { setupServer } from "msw/node";@@ -33,6 +59,8 @@ describe("usePackageMetadata", () => {afterEach(() => {// Remove any handlers you may have added in individual tests (runtime handlers).server.resetHandlers();+ // Clear localStorage to prevent state leakage between tests.+ localStorage.clear();});afterAll(() => {diff --git a/frontend/src/utils/__tests__/capabilities.test.ts b/frontend/src/utils/__tests__/capabilities.test.tsindex bf32d5616b..ba5d9ebef9 100644--- a/frontend/src/utils/__tests__/capabilities.test.ts+++ b/frontend/src/utils/__tests__/capabilities.test.ts@@ -325,11 +325,6 @@ describe("capabilities", () => {describe("complete capability detection scenarios", () => {it("should handle fully sandboxed iframe", async () => {- const mockWindow = {- ...window,- parent: {} as Window,- };-const mockStorage: Partial<Storage> = {setItem: vi.fn(() => {throw new Error("blocked");@@ -338,6 +333,13 @@ describe("capabilities", () => {removeItem: vi.fn(),};+ const mockWindow = {+ ...window,+ parent: {} as Window,+ localStorage: mockStorage,+ sessionStorage: mockStorage,+ };+vi.stubGlobal("window", mockWindow);vi.stubGlobal("localStorage", mockStorage);vi.stubGlobal("sessionStorage", mockStorage);