This commit is contained in:
zhx 2026-06-08 13:15:35 +08:00
parent 66ffb3647c
commit 4b4054a4d0
3 changed files with 43 additions and 1 deletions

View File

@ -260,7 +260,12 @@ function RangeMenu({ activeValue, isOpen, onSelect, onToggle, range, timeZone })
};
const selectDate = (date) => {
setDraft((current) => ({ ...current, [activeField]: dateValue(date) }));
const selectedValue = dateValue(date);
setDraft((current) => ({ ...current, [activeField]: selectedValue }));
if (activeField === "start") {
setActiveField("end");
setViewMonth(monthDate(selectedValue));
}
setError("");
};

View File

@ -0,0 +1,36 @@
import { render, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { expect, test, vi } from "vitest";
import { DatabiHeader } from "./DatabiHeader.jsx";
const noop = vi.fn();
test("switches to end time after selecting a start date", async () => {
const user = userEvent.setup();
render(
<DatabiHeader
appCode="lalu"
appOptions={[{ code: "lalu", label: "Lalu", value: "lalu" }]}
countryId={0}
onAppChange={noop}
onCountryChange={noop}
onRangeChange={noop}
onRegionChange={noop}
onTimeZoneChange={noop}
range={{ end: "2026-06-08", endTime: "23:59:59", start: "2026-06-08", startTime: "00:00:00" }}
regionId="all"
timeZone="UTC"
/>
);
await user.click(screen.getByRole("button", { name: /2026-06-08\s*~\s*2026-06-08/ }));
const dialog = screen.getByRole("dialog");
const calendar = dialog.querySelector(".calendar-pane");
expect(within(dialog).getByRole("tab", { name: /开始时间/ })).toHaveAttribute("aria-selected", "true");
await user.click(within(calendar).getByRole("button", { name: "22" }));
expect(within(dialog).getByRole("tab", { name: /结束时间/ })).toHaveAttribute("aria-selected", "true");
});

View File

@ -48,6 +48,7 @@ const iconMap = {
dashboard: DashboardOutlined,
event_available: EventAvailableOutlined,
explore: MapOutlined,
favorite: FavoriteBorderOutlined,
flag: FlagOutlined,
gift: CardGiftcardOutlined,
inventory: Inventory2Outlined,