diff --git a/databi/src/components/DatabiHeader.jsx b/databi/src/components/DatabiHeader.jsx index 86eac9c..cb06a5d 100644 --- a/databi/src/components/DatabiHeader.jsx +++ b/databi/src/components/DatabiHeader.jsx @@ -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(""); }; diff --git a/databi/src/components/DatabiHeader.test.jsx b/databi/src/components/DatabiHeader.test.jsx new file mode 100644 index 0000000..d47601a --- /dev/null +++ b/databi/src/components/DatabiHeader.test.jsx @@ -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( + + ); + + 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"); +}); diff --git a/src/app/navigation/menu.js b/src/app/navigation/menu.js index 81ad9f5..9ea63a7 100644 --- a/src/app/navigation/menu.js +++ b/src/app/navigation/menu.js @@ -48,6 +48,7 @@ const iconMap = { dashboard: DashboardOutlined, event_available: EventAvailableOutlined, explore: MapOutlined, + favorite: FavoriteBorderOutlined, flag: FlagOutlined, gift: CardGiftcardOutlined, inventory: Inventory2Outlined,