mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 10:23:11 +00:00
fix(work-orders): clarify search scope with advanced filters
This commit is contained in:
parent
dace388633
commit
2b2b24f2e3
4 changed files with 24 additions and 5 deletions
|
|
@ -13,6 +13,8 @@ type WorkOrdersListHeaderProps = {
|
|||
/** Omit until wizard shell slice mounts New WO. */
|
||||
onNewWorkOrder?: () => void;
|
||||
activeFilterCount: number;
|
||||
/** True while Advanced Filters are applied; results are global and the keyword box is inert. */
|
||||
advancedFiltersActive?: boolean;
|
||||
isFetching?: boolean;
|
||||
};
|
||||
|
||||
|
|
@ -23,6 +25,7 @@ export function WorkOrdersListHeader({
|
|||
onOpenAdvancedFilters,
|
||||
onNewWorkOrder,
|
||||
activeFilterCount,
|
||||
advancedFiltersActive = false,
|
||||
isFetching = false,
|
||||
}: WorkOrdersListHeaderProps) {
|
||||
return (
|
||||
|
|
@ -34,8 +37,8 @@ export function WorkOrdersListHeader({
|
|||
placeholder="Search this week…"
|
||||
aria-label="Search work orders"
|
||||
/>
|
||||
{/* SH-194: keyword search is scoped to the active week; make that scope visible. */}
|
||||
{search.trim() !== "" && Boolean(weekLabel) && (
|
||||
{/* Keyword search is scoped to the active week; make that scope visible. */}
|
||||
{!advancedFiltersActive && search.trim() !== "" && Boolean(weekLabel) && (
|
||||
<span
|
||||
role="status"
|
||||
className="absolute left-0 whitespace-nowrap"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export function useWorkOrdersBoardSource(filters: FiltersReturn): WorkOrdersBoar
|
|||
() =>
|
||||
buildResolvedBoardSearchParams({
|
||||
advApplied: filters.advApplied,
|
||||
// SH-194: Advanced Filters are global by design; the week-scoped keyword box has no effect.
|
||||
// Advanced Filters are global by design; the week-scoped keyword box has no effect.
|
||||
search: "",
|
||||
page: filters.page,
|
||||
pageSize: filters.pageSize,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ export default function WorkOrdersListPage() {
|
|||
onOpenAdvancedFilters={() => filters.setAdvOpen(true)}
|
||||
onNewWorkOrder={() => page.setWizardOpen(true)}
|
||||
activeFilterCount={filters.activeFilterCount}
|
||||
advancedFiltersActive={filters.advApplied != null}
|
||||
isFetching={tableData.isFetching && !tableData.isLoading}
|
||||
/>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ function renderBoardSource() {
|
|||
return renderHook(() => useBoardWithFilters(), { wrapper });
|
||||
}
|
||||
|
||||
describe("SH-194 keyword search scope indicator", () => {
|
||||
describe("keyword search scope indicator", () => {
|
||||
it("shows no scope badge while the search box is empty", () => {
|
||||
renderWithProviders(
|
||||
<WorkOrdersListHeader
|
||||
|
|
@ -75,9 +75,24 @@ describe("SH-194 keyword search scope indicator", () => {
|
|||
|
||||
expect(screen.getByText("Searching within 5/4–5/8")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("hides the scope label while Advanced Filters are active", () => {
|
||||
renderWithProviders(
|
||||
<WorkOrdersListHeader
|
||||
search="hvac"
|
||||
weekLabel="5/4–5/8"
|
||||
onSearchChange={vi.fn()}
|
||||
activeFilterCount={1}
|
||||
advancedFiltersActive
|
||||
/>,
|
||||
{ withAuth: false },
|
||||
);
|
||||
|
||||
expect(screen.queryByText(/searching within/i)).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("SH-194 keyword search vs Advanced Filters scope", () => {
|
||||
describe("keyword search vs Advanced Filters scope", () => {
|
||||
beforeEach(() => {
|
||||
searchBoard.mockReset().mockResolvedValue(EMPTY_RESULT);
|
||||
getBoard.mockReset().mockResolvedValue(EMPTY_RESULT);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue