mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 05:43:12 +00:00
fix(workorders): match a range on the board the same way the search does (SH-391)
A week-only row that still carries a scheduled date outside the range passed the board search (its target week overlaps) but failed the on-page filter, which judged it by the date alone. Both now accept a row dated in the range or a week-only row whose target week overlaps it.
This commit is contained in:
parent
0d6af0da59
commit
f69c8a04eb
2 changed files with 39 additions and 4 deletions
|
|
@ -16,10 +16,9 @@ const matchesDateRange: AdvancedFilterPredicate = (row, filters) => {
|
||||||
const range = dateRangeFor(filters);
|
const range = dateRangeFor(filters);
|
||||||
if (!range) return true;
|
if (!range) return true;
|
||||||
const [from, to] = range;
|
const [from, to] = range;
|
||||||
if (row.scheduledOn) {
|
if (row.scheduledOn && row.scheduledOn >= from && row.scheduledOn <= to) return true;
|
||||||
return row.scheduledOn >= from && row.scheduledOn <= to;
|
// Week-only rows also match when their target week overlaps the range, the
|
||||||
}
|
// same rule as the board search (SH-391).
|
||||||
// Week-only rows match when their target week overlaps the range (SH-391).
|
|
||||||
return (
|
return (
|
||||||
row.scheduleWeekOnly &&
|
row.scheduleWeekOnly &&
|
||||||
Boolean(row.targetWeek) &&
|
Boolean(row.targetWeek) &&
|
||||||
|
|
|
||||||
|
|
@ -454,6 +454,42 @@ describe("matchesAdvancedFilters", () => {
|
||||||
expect(matchesAdvancedFilters(weekOnly, filters)).toBe(true);
|
expect(matchesAdvancedFilters(weekOnly, filters)).toBe(true);
|
||||||
expect(matchesAdvancedFilters(undatedAssigned, filters)).toBe(true);
|
expect(matchesAdvancedFilters(undatedAssigned, filters)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("matches a range the same way the board search does (SH-391)", () => {
|
||||||
|
const filters = {
|
||||||
|
...EMPTY_ADVANCED_FILTERS,
|
||||||
|
dateRange: "custom" as const,
|
||||||
|
customFrom: "2026-09-23",
|
||||||
|
customTo: "2026-09-25",
|
||||||
|
};
|
||||||
|
|
||||||
|
// Week-only: a target week overlapping the range matches, whatever date the
|
||||||
|
// row still carries.
|
||||||
|
const weekOnlyStaleDate = makeRow({
|
||||||
|
scheduledOn: "2026-10-02",
|
||||||
|
targetWeek: "2026-09-21",
|
||||||
|
scheduleWeekOnly: true,
|
||||||
|
});
|
||||||
|
const weekOnlyPreviousWeek = makeRow({
|
||||||
|
scheduledOn: "",
|
||||||
|
targetWeek: "2026-09-14",
|
||||||
|
scheduleWeekOnly: true,
|
||||||
|
});
|
||||||
|
const weekOnlyOutside = makeRow({
|
||||||
|
scheduledOn: "",
|
||||||
|
targetWeek: "2026-09-28",
|
||||||
|
scheduleWeekOnly: true,
|
||||||
|
});
|
||||||
|
const datedOutsideWithWeek = makeRow({ scheduledOn: "2026-10-02", targetWeek: "2026-09-21" });
|
||||||
|
const undated = makeRow({ scheduledOn: "", targetWeek: "" });
|
||||||
|
|
||||||
|
expect(matchesAdvancedFilters(weekOnlyStaleDate, filters)).toBe(true);
|
||||||
|
expect(matchesAdvancedFilters(weekOnlyPreviousWeek, filters)).toBe(false);
|
||||||
|
expect(matchesAdvancedFilters(weekOnlyOutside, filters)).toBe(false);
|
||||||
|
expect(matchesAdvancedFilters(datedOutsideWithWeek, filters)).toBe(false);
|
||||||
|
expect(matchesAdvancedFilters(undated, filters)).toBe(false);
|
||||||
|
expect(matchesAdvancedFilters(undated, { ...filters, dateRange: null })).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("computeIsPastDue", () => {
|
describe("computeIsPastDue", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue