fix(e2e): stabilize initial board hydration

This commit is contained in:
Thomas Camlong committed 2026-08-09 01:11:38 +02:00
1 parent 48d8517ed1
commit 9d3d40d4bd
2 files changed
+7 -10

No files matched your search

+4 -1
View File
@@ -88,8 +88,11 @@ describe("lazy widget application graph", () => {
); );
await expect(clockWidget).toBeVisible({ timeout: 15_000 }); await expect(clockWidget).toBeVisible({ timeout: 15_000 });
await expect(page.locator("[data-homarr-dev-benchmark-spotlight-preloaded]")).toHaveCount(1, {
timeout: 15_000,
});
await page.keyboard.press("Control+K"); await page.keyboard.press("Control+K");
await expect(page.locator("[data-homarr-dev-benchmark-spotlight]")).toBeVisible(); await expect(page.locator("[data-homarr-dev-benchmark-spotlight]")).toBeVisible({ timeout: 15_000 });
await page.keyboard.press("Escape"); await page.keyboard.press("Escape");
await expect(page.locator("[data-homarr-dev-benchmark-spotlight]")).not.toBeVisible(); await expect(page.locator("[data-homarr-dev-benchmark-spotlight]")).not.toBeVisible();
+3 -9
View File
@@ -43,19 +43,13 @@ export default function ClockWidget({ options, width }: WidgetComponentProps<"cl
{options.customTitle} {options.customTitle}
</Text> </Text>
)} )}
<Title <Title className="clock-time-text" fw={700} order={sizing === "md" ? 2 : sizing === "sm" ? 4 : 6} lh="1">
className="clock-time-text"
fw={700}
order={sizing === "md" ? 2 : sizing === "sm" ? 4 : 6}
lh="1"
suppressHydrationWarning
>
{options.customTimeFormat {options.customTimeFormat
? dayjs(time).tz(timezone).format(customTimeFormat) ? dayjs(time).tz(timezone).format(customTimeFormat)
: dayjs(time).tz(timezone).format(timeFormat)} : dayjs(time).tz(timezone).format(timeFormat)}
</Title> </Title>
{options.showDate && ( {options.showDate && (
<Text className="clock-date-text" size={sizing} lineClamp={1} suppressHydrationWarning> <Text className="clock-date-text" size={sizing} lineClamp={1}>
{options.customDateFormat {options.customDateFormat
? dayjs(time).tz(timezone).format(customDateFormat) ? dayjs(time).tz(timezone).format(customDateFormat)
: dayjs(time).tz(timezone).format(dateFormat)} : dayjs(time).tz(timezone).format(dateFormat)}
@@ -96,7 +90,7 @@ interface UseCurrentTimeProps {
} }
const useCurrentTime = ({ showSeconds }: UseCurrentTimeProps) => { const useCurrentTime = ({ showSeconds }: UseCurrentTimeProps) => {
const [time, setTime] = useState(new Date()); const [time, setTime] = useState(() => new Date(0));
const timeoutRef = useRef<NodeJS.Timeout>(null); const timeoutRef = useRef<NodeJS.Timeout>(null);
const intervalRef = useRef<NodeJS.Timeout>(null); const intervalRef = useRef<NodeJS.Timeout>(null);
const intervalMultiplier = useMemo(() => (showSeconds ? 1 : 60), [showSeconds]); const intervalMultiplier = useMemo(() => (showSeconds ? 1 : 60), [showSeconds]);