-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: ui.datetime() rendering with empty initial value (#3249)
Fixes #3246 - Added test to verify datetime picker renders with empty initial value - Fixed DateTimePickerPlugin to handle undefined values properly Link to Devin run: https://app.devin.ai/sessions/47bc25251a1c4f8185891042b4964ebf Co-authored-by: Myles Scolnick <myles@marimo.io>
- Loading branch information
1 parent
e66f93b
commit 3b9cba1
Showing
10 changed files
with
80 additions
and
25 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
frontend/src/components/data-table/__tests__/data-table.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* Copyright 2024 Marimo. All rights reserved. */ | ||
import { useEffect, useRef } from "react"; | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
frontend/src/plugins/impl/__tests__/DateTimePickerPlugin.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* Copyright 2024 Marimo. All rights reserved. */ | ||
import { DateTimePickerPlugin } from "../DateTimePickerPlugin"; | ||
import { render } from "@testing-library/react"; | ||
import { expect, describe, it } from "vitest"; | ||
import type { IPluginProps } from "../../types"; | ||
|
||
interface DateTimeData { | ||
label: string | null; | ||
start: string; | ||
stop: string; | ||
fullWidth: boolean; | ||
} | ||
|
||
describe("DateTimePickerPlugin", () => { | ||
it("should render when initial value is not provided", () => { | ||
const plugin = new DateTimePickerPlugin(); | ||
// Create a host element as required by IPluginProps | ||
const host = document.createElement("div"); | ||
const props: IPluginProps<string, DateTimeData> = { | ||
host, | ||
value: "", // Empty string instead of undefined since type T = string | ||
setValue: (valueOrFn) => { | ||
// No-op function to satisfy lint requirements | ||
if (typeof valueOrFn === "function") { | ||
valueOrFn(""); | ||
} | ||
}, | ||
data: { | ||
label: null, | ||
start: "2024-01-01T00:00:00", | ||
stop: "2024-12-31T23:59:59", | ||
fullWidth: false, | ||
}, | ||
functions: {}, | ||
}; | ||
const { container } = render(plugin.render(props)); | ||
|
||
// Check if the component renders at all | ||
expect(container.innerHTML).not.toBe(""); | ||
// Check for the date picker group | ||
const datePicker = container.querySelector('[class*="group"]'); | ||
expect(datePicker).not.toBeNull(); | ||
}); | ||
}); |