fix(18): WR-01 treat empty/blank TZ as unset in household timezone fallback
The D-06 fallback used row?.value ?? process.env.TZ ?? Intl..., but ??
only short-circuits on null/undefined. A set-but-empty TZ ('' or ' ')
leaked through and yielded an invalid IANA zone that throws inside
Intl.DateTimeFormat({ timeZone }) downstream, silently dropping the
all-day reminder. Extract resolveHouseholdTimezone() which trims and
treats empty/whitespace candidate values (stored value and TZ) as
absent so they fall through to the Intl resolved zone. Adds RED->GREEN
unit tests for empty and whitespace-only TZ.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
ea93089b74
commit
d168da71cf
@@ -97,6 +97,24 @@ describe('getHouseholdTimezone', () => {
|
||||
const result = await getHouseholdTimezone(mockDb as never);
|
||||
expect(result).toBe('Europe/London');
|
||||
});
|
||||
|
||||
it('treats an empty process.env.TZ as unset and falls through to the Intl zone (WR-01)', async () => {
|
||||
mockDb.select.mockReturnValue(makeSelectChain([]));
|
||||
process.env.TZ = '';
|
||||
|
||||
const expected = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
const result = await getHouseholdTimezone(mockDb as never);
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
|
||||
it('treats a whitespace-only process.env.TZ as unset and falls through to the Intl zone (WR-01)', async () => {
|
||||
mockDb.select.mockReturnValue(makeSelectChain([]));
|
||||
process.env.TZ = ' ';
|
||||
|
||||
const expected = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
const result = await getHouseholdTimezone(mockDb as never);
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isValidIanaTimezone', () => {
|
||||
|
||||
Reference in New Issue
Block a user