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
/* Copyright 2026 Marimo. All rights reserved. */
import { describe, expect, test } from "vitest";
import type { UserConfig } from "@/core/config/config-schema";
import { applyManualInjections, getDirtyValues } from "../get-dirty-values";
describe("getDirtyValues", () => {
test("extracts only dirty fields", () => {
const values = {
display: { theme: "dark", fontSize: 14 },
runtime: { dotenv: [".env.dev"], auto_reload: "lazy" },
};
const dirtyFields = {
display: { theme: true },
};
const result = getDirtyValues(values, dirtyFields);
expect(result).toEqual({ display: { theme: "dark" } });
expect(result).not.toHaveProperty("runtime");
});
test("returns empty object when nothing is dirty", () => {
const values = { display: { theme: "dark" } };
const dirtyFields = {};
const result = getDirtyValues(values, dirtyFields);
expect(result).toEqual({});
});
test("handles nested dirty fields", () => {
const values = {
runtime: { auto_reload: "lazy", dotenv: [".env"] },
display: { theme: "dark" },
};
const dirtyFields = {
runtime: { auto_reload: true },
};
const result = getDirtyValues(values, dirtyFields);
expect(result).toEqual({ runtime: { auto_reload: "lazy" } });
expect(result.runtime).not.toHaveProperty("dotenv");
});
test("handles multiple dirty fields at same level", () => {
const values = {
display: { theme: "dark", fontSize: 16, width: "full" },
};
const dirtyFields = {
display: { theme: true, fontSize: true },
};
const result = getDirtyValues(values, dirtyFields);
expect(result).toEqual({ display: { theme: "dark", fontSize: 16 } });
expect(result.display).not.toHaveProperty("width");
});
test("preserves unmodified runtime settings like dotenv", () => {
const values = {
display: { theme: "dark" },
runtime: { dotenv: [".env.local"], pythonpath: ["/custom/path"] },
};
const dirtyFields = {
display: { theme: true },
};
const result = getDirtyValues(values, dirtyFields);
expect(result).toEqual({ display: { theme: "dark" } });
expect(result).not.toHaveProperty("runtime");
});
test("applyManualInjections injects touched ai model fields", () => {
const values = {
ai: {
models: {
displayed_models: ["openai/gpt-4"],
custom_models: ["openai/custom-model"],
},
},
} as UserConfig;
const dirtyValues: Partial<UserConfig> = {};
const touchedFields = {
ai: { models: { displayed_models: true } },
};
applyManualInjections({ values, dirtyValues, touchedFields });
expect(dirtyValues).toEqual({
ai: {
models: {
displayed_models: ["openai/gpt-4"],
custom_models: ["openai/custom-model"],
},
},
});
});
test("applyManualInjections skips when field not touched", () => {
const values = {
ai: {
models: {
displayed_models: ["openai/gpt-4"],
custom_models: ["openai/custom-model"],
},
},
} as UserConfig;
const dirtyValues: Partial<UserConfig> = {};
const touchedFields = {
ai: { models: { displayed_models: false } },
};
applyManualInjections({ values, dirtyValues, touchedFields });
expect(dirtyValues).toEqual({});
});
});