|
@@ -38,6 +38,7 @@ vi.mock("../../lib/api/bos", async (load) => ({
|
|
|
|
|
|
|
|
const dialogPrototype = HTMLDialogElement.prototype;
|
|
const dialogPrototype = HTMLDialogElement.prototype;
|
|
|
const { showModal, close } = dialogPrototype;
|
|
const { showModal, close } = dialogPrototype;
|
|
|
|
|
+const { hidePopover } = HTMLElement.prototype;
|
|
|
beforeEach(() => {
|
|
beforeEach(() => {
|
|
|
vi.clearAllMocks();
|
|
vi.clearAllMocks();
|
|
|
vi.stubGlobal("ResizeObserver", class {
|
|
vi.stubGlobal("ResizeObserver", class {
|
|
@@ -48,11 +49,13 @@ beforeEach(() => {
|
|
|
showModal(this: HTMLDialogElement) { this.open = true; },
|
|
showModal(this: HTMLDialogElement) { this.open = true; },
|
|
|
close(this: HTMLDialogElement) { this.open = false; },
|
|
close(this: HTMLDialogElement) { this.open = false; },
|
|
|
});
|
|
});
|
|
|
|
|
+ HTMLElement.prototype.hidePopover = vi.fn();
|
|
|
});
|
|
});
|
|
|
afterEach(() => {
|
|
afterEach(() => {
|
|
|
cleanup();
|
|
cleanup();
|
|
|
vi.unstubAllGlobals();
|
|
vi.unstubAllGlobals();
|
|
|
Object.assign(dialogPrototype, { showModal, close });
|
|
Object.assign(dialogPrototype, { showModal, close });
|
|
|
|
|
+ HTMLElement.prototype.hidePopover = hidePopover;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
function Destination() {
|
|
function Destination() {
|
|
@@ -96,19 +99,24 @@ it("从页头导出,表格分开展示两种状态,改筛选时返回第一
|
|
|
|
|
|
|
|
it.each(["", "?month=all"])("默认查询全部自然月并支持选月和重置(查询串 %j)", async (search) => {
|
|
it.each(["", "?month=all"])("默认查询全部自然月并支持选月和重置(查询串 %j)", async (search) => {
|
|
|
renderPage(search);
|
|
renderPage(search);
|
|
|
- const monthSelect = screen.getByRole<HTMLSelectElement>("combobox", { name: "自然月" });
|
|
|
|
|
- expect(monthSelect.selectedOptions[0].textContent).toBe("全部自然月");
|
|
|
|
|
|
|
+ const monthTrigger = screen.getByRole("button", { name: "自然月:全部自然月" });
|
|
|
await waitFor(() => expect(reconGetList).toHaveBeenLastCalledWith(expect.objectContaining({ period: undefined })));
|
|
await waitFor(() => expect(reconGetList).toHaveBeenLastCalledWith(expect.objectContaining({ period: undefined })));
|
|
|
await screen.findByRole("link", { name: "RECON-001" });
|
|
await screen.findByRole("link", { name: "RECON-001" });
|
|
|
fireEvent.click(screen.getByRole("button", { name: "导出当前结果" }));
|
|
fireEvent.click(screen.getByRole("button", { name: "导出当前结果" }));
|
|
|
await waitFor(() => expect(reconExportList).toHaveBeenCalledWith(expect.objectContaining({ period: undefined })));
|
|
await waitFor(() => expect(reconExportList).toHaveBeenCalledWith(expect.objectContaining({ period: undefined })));
|
|
|
|
|
|
|
|
- await screen.findByRole("option", { name: "2026-10" });
|
|
|
|
|
- fireEvent.change(monthSelect, { target: { value: "2026-10" } });
|
|
|
|
|
|
|
+ fireEvent.click(monthTrigger);
|
|
|
|
|
+ const calendar = within(screen.getByLabelText("选择自然月"));
|
|
|
|
|
+ expect(calendar.getByText("2026 年")).toBeTruthy();
|
|
|
|
|
+ expect(calendar.getByText<HTMLButtonElement>("11 月").disabled).toBe(true);
|
|
|
|
|
+ const october = calendar.getByText<HTMLButtonElement>("10 月");
|
|
|
|
|
+ expect(october.disabled).toBe(false);
|
|
|
|
|
+ fireEvent.click(october);
|
|
|
await waitFor(() => expect(reconGetList).toHaveBeenLastCalledWith(expect.objectContaining({ period: "2026-10" })));
|
|
await waitFor(() => expect(reconGetList).toHaveBeenLastCalledWith(expect.objectContaining({ period: "2026-10" })));
|
|
|
|
|
+ expect(screen.getByRole("button", { name: "自然月:2026-10" })).toBe(monthTrigger);
|
|
|
|
|
|
|
|
fireEvent.click(screen.getByRole("button", { name: "重置筛选" }));
|
|
fireEvent.click(screen.getByRole("button", { name: "重置筛选" }));
|
|
|
- expect(monthSelect.selectedOptions[0].textContent).toBe("全部自然月");
|
|
|
|
|
|
|
+ expect(screen.getByRole("button", { name: "自然月:全部自然月" })).toBe(monthTrigger);
|
|
|
await waitFor(() => expect(reconGetList).toHaveBeenLastCalledWith(expect.objectContaining({ period: undefined })));
|
|
await waitFor(() => expect(reconGetList).toHaveBeenLastCalledWith(expect.objectContaining({ period: undefined })));
|
|
|
});
|
|
});
|
|
|
|
|
|