cp功能
This commit is contained in:
parent
66ffb3647c
commit
4b4054a4d0
@ -260,7 +260,12 @@ function RangeMenu({ activeValue, isOpen, onSelect, onToggle, range, timeZone })
|
|||||||
};
|
};
|
||||||
|
|
||||||
const selectDate = (date) => {
|
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("");
|
setError("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
36
databi/src/components/DatabiHeader.test.jsx
Normal file
36
databi/src/components/DatabiHeader.test.jsx
Normal 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");
|
||||||
|
});
|
||||||
@ -48,6 +48,7 @@ const iconMap = {
|
|||||||
dashboard: DashboardOutlined,
|
dashboard: DashboardOutlined,
|
||||||
event_available: EventAvailableOutlined,
|
event_available: EventAvailableOutlined,
|
||||||
explore: MapOutlined,
|
explore: MapOutlined,
|
||||||
|
favorite: FavoriteBorderOutlined,
|
||||||
flag: FlagOutlined,
|
flag: FlagOutlined,
|
||||||
gift: CardGiftcardOutlined,
|
gift: CardGiftcardOutlined,
|
||||||
inventory: Inventory2Outlined,
|
inventory: Inventory2Outlined,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user