updates on the minor changes like zone updates and datepicker fix

This commit is contained in:
2026-09-28 15:36:59 +05:30
parent 3bde09839c
commit 5bf0104b61
8 changed files with 284 additions and 22 deletions

View File

@@ -347,10 +347,19 @@ describe('ZoneContext', () => {
expect(result.current.matchesZone({ milerprofileid: 11, hubid: '2' })).toBe(true);
});
it('should match a rider by their app location', () => {
it('should match a rider by their app location (city id against city id)', () => {
localStorage.setItem(ZONE_STORAGE_KEY, '2');
const { result } = setup();
expect(result.current.matchesZone({ milerprofileid: 11, applocationid: '2' })).toBe(true);
const { result } = setup({ hubs: [{ ...KORAMANGALA, applocationid: '3' }] });
expect(result.current.matchesZone({ milerprofileid: 11, applocationid: '3' })).toBe(true);
});
// Regression: a rider's applocationid (a CITY id) was also compared with the
// selected HUB id. Coimbatore Neptune Hub is hubid 2 in city 1, Hyderabad is
// city 2 — so every Hyderabad rider matched the Coimbatore zone.
it('should not match a rider whose city id merely equals the hub id', () => {
localStorage.setItem(ZONE_STORAGE_KEY, '2');
const { result } = setup({ hubs: [{ ...KORAMANGALA, applocationid: '1' }] });
expect(result.current.matchesZone({ milerprofileid: 11, applocationid: '2', hubid: null })).toBe(false);
});
it('should match a rider by city when they carry no hub id', () => {

View File

@@ -52,3 +52,33 @@ describe('toDateRange', () => {
expect(toDateRange(true)).toEqual({ from: '', to: '' });
});
});
describe('toReportRange — DatePicker value → report { from, to }', () => {
const { toReportRange } = require('@/lib/dateRange');
const dayjsLib = require('dayjs');
const todayStr = dayjsLib().format('YYYY-MM-DD');
const past = (n) => dayjsLib().subtract(n, 'day').format('YYYY-MM-DD');
const future = (n) => dayjsLib().add(n, 'day').format('YYYY-MM-DD');
it('turns a single day into a one-day range', () => {
expect(toReportRange(past(3))).toEqual({ from: past(3), to: past(3) });
});
it('keeps a valid range as it is', () => {
expect(toReportRange({ from: past(7), to: past(1) })).toEqual({ from: past(7), to: past(1) });
});
it('puts an inverted range in order', () => {
expect(toReportRange({ from: past(1), to: past(7) })).toEqual({ from: past(7), to: past(1) });
});
it('never goes past today', () => {
expect(toReportRange(future(2))).toEqual({ from: todayStr, to: todayStr });
expect(toReportRange({ from: past(2), to: future(5) })).toEqual({ from: past(2), to: todayStr });
});
it('falls back to today for "all" or nothing', () => {
expect(toReportRange('all')).toEqual({ from: todayStr, to: todayStr });
expect(toReportRange(undefined)).toEqual({ from: todayStr, to: todayStr });
});
});