WFDASH-WEBAPP/src/components/data-table.test.tsx
SJCoetz 47b01bddfa feat: add picking slips, bulk print tracking, supplier map
- Add Supplier Map component to suppliers page and reorganize sidebar navigation
- Implement picking slip PDF generation with supplier per line item and picked-by signature footer
- Add invoice bulk print tracking API and view models to track printed invoice state
- Extend company search and form to support email/telephone fields and improve searchability
- Fix data table debounce race condition by using useRef for onSearch handler
- Fix supplier page fetch race condition with debounced timeout
- Reduce list page item counts to 10 per page for customers, companies, and suppliers
- Update company search filter to include email and telephone in search queries
- Add comprehensive test suite for new and existing components and APIs
- Add pdf-lib dependency for PDF generation and update related tooling
- Clean up unused code and fix minor linting issues
2026-07-10 10:47:11 +02:00

44 lines
1.2 KiB
TypeScript

import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { DataTable } from "./data-table";
describe("DataTable", () => {
it("does not re-fire search when only pagination props change", async () => {
const onSearch = vi.fn();
const columns = [{ key: "name", label: "Name" }];
const data = [{ id: "1", name: "Acme" }];
const { rerender } = render(
<DataTable
columns={columns}
data={data}
onSearch={onSearch}
page={1}
totalPages={3}
/>
);
const searchInput = screen.getByPlaceholderText("Search...");
fireEvent.change(searchInput, { target: { value: "acme" } });
await waitFor(() => {
expect(onSearch).toHaveBeenLastCalledWith("acme");
});
const callCountAfterTyping = onSearch.mock.calls.length;
rerender(
<DataTable
columns={columns}
data={data}
onSearch={onSearch}
page={2}
totalPages={3}
/>
);
await new Promise((resolve) => setTimeout(resolve, 350));
expect(onSearch).toHaveBeenCalledTimes(callCountAfterTyping);
});
});