From 5163f7f532c603ca82cbe6383ac8da21c541be2f Mon Sep 17 00:00:00 2001 From: YERRAGUNTA AJAY KUMAR Date: Sat, 30 May 2026 15:28:54 +0530 Subject: [PATCH 1/7] test(utils): check boundary robustness of date range formatter --- lib/validations.test.ts | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lib/validations.test.ts b/lib/validations.test.ts index 1e41c328..a0f05a6a 100644 --- a/lib/validations.test.ts +++ b/lib/validations.test.ts @@ -647,3 +647,45 @@ describe('streakParamsSchema — view fallback behavior', () => { expect(parse({}).view).toBe('default'); }); }); + +/* ========================================================================== + * DATE RANGE BOUNDARY ROBUSTNESS (VARIATION 1) + * ========================================================================== */ + +describe('streakParamsSchema — Date Range Boundary Robustness (Variation 1)', () => { + it('should process validation safely and fallback when partial or missing year parameters are passed', () => { + // Arrange: Provide a mock payload missing a full YYYY format sequence + const partialYearPayload = { + user: 'octocat', + from: '05-12', + to: '05-30', + }; + + // Act: Pass the object through the validator schema matrix + const result = streakParamsSchema.safeParse(partialYearPayload); + + // Assert: The validator handles it safely using implicit date engine fallbacks + expect(result.success).toBe(true); + if (result.success) { + expect(result.data.from).toBeDefined(); + expect(result.data.to).toBeDefined(); + } + }); + + it('should pass cleanly and fallback to default ranges when date bounds are completely omitted', () => { + // Arrange: Pass only the bare minimum required parameters + const minimalPayload = { + user: 'octocat' + }; + + // Act + const result = streakParamsSchema.safeParse(minimalPayload); + + // Assert: Verify that omitted range options return undefined to use downstream defaults smoothly + expect(result.success).toBe(true); + if (result.success) { + expect(result.data.from).toBeUndefined(); + expect(result.data.to).toBeUndefined(); + } + }); +}); \ No newline at end of file From fd2a3be57c4903799ca36c86a29c374821b9299e Mon Sep 17 00:00:00 2001 From: YERRAGUNTA AJAY KUMAR Date: Sat, 30 May 2026 15:36:45 +0530 Subject: [PATCH 2/7] test(validations): fix formatting alignment for date robustness tests --- lib/validations.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/validations.test.ts b/lib/validations.test.ts index a67d4db2..39797593 100644 --- a/lib/validations.test.ts +++ b/lib/validations.test.ts @@ -656,7 +656,7 @@ describe('streakParamsSchema — Date Range Boundary Robustness (Variation 1)', // Arrange: Provide a mock payload missing a full YYYY format sequence const partialYearPayload = { user: 'octocat', - from: '05-12', + from: '05-12', to: '05-30', }; @@ -674,7 +674,7 @@ describe('streakParamsSchema — Date Range Boundary Robustness (Variation 1)', it('should pass cleanly and fallback to default ranges when date bounds are completely omitted', () => { // Arrange: Pass only the bare minimum required parameters const minimalPayload = { - user: 'octocat' + user: 'octocat', }; // Act @@ -687,4 +687,4 @@ describe('streakParamsSchema — Date Range Boundary Robustness (Variation 1)', expect(result.data.to).toBeUndefined(); } }); -}); \ No newline at end of file +}); From 78411f3c7e626bcee2438cd1bcf844c616c3a909 Mon Sep 17 00:00:00 2001 From: YERRAGUNTA AJAY KUMAR Date: Sun, 31 May 2026 08:41:56 +0530 Subject: [PATCH 3/7] test(utils): check boundary robustness of time normalization (#1549) --- utils/time.test.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/utils/time.test.ts b/utils/time.test.ts index 0ac26c67..3ce850bd 100644 --- a/utils/time.test.ts +++ b/utils/time.test.ts @@ -204,6 +204,38 @@ describe('getSecondsUntilMidnightInTimezone', () => { expect(secondsUTC).toBe(86400); expect(secondsLondon).toBe(86400); }); + + it('should handle extreme negative timezone offset boundary (-12:00)', () => { + // Arrange: Etc/GMT+12 is UTC-12 (Baker Island / Howland Island). + // When UTC is Jan 1, 11:59:50, Baker Island is Dec 31, 23:59:50 (10 seconds to midnight) + const boundaryTime = new Date(Date.UTC(2024, 0, 1, 11, 59, 50)); + vi.setSystemTime(boundaryTime); + + // Act + const seconds = getSecondsUntilMidnightInTimezone('Etc/GMT+12'); + + // Assert: Should correctly calculate 10 seconds without calendar shifting + expect(seconds).toBe(10); + }); + + it('should handle extreme timezone offsets without calendar date shifting', () => { + // Arrange: Test the most extreme offsets to ensure no calendar date shifting occurs + const extremeOffsets = [ + { tz: 'Etc/GMT+12', offset: -12, utcHour: 12, expectedLocalHour: 0 }, // UTC-12 + { tz: 'Etc/GMT-14', offset: 14, utcHour: 10, expectedLocalHour: 0 }, // UTC+14 + ]; + + for (const { tz, utcHour, expectedLocalHour } of extremeOffsets) { + // Set UTC time such that local time is exactly midnight + vi.setSystemTime(new Date(Date.UTC(2024, 6, 15, utcHour, 0, 0))); + + // Act: Get seconds until midnight in this timezone + const seconds = getSecondsUntilMidnightInTimezone(tz); + + // Assert: At local midnight, should return exactly 86400 seconds (full day) + expect(seconds).toBe(86400); + } + }); }); describe('getSecondsUntilUTCMidnight — sliding window boundary robustness', () => { From b29a6963d1faafcc309c7197d3d106dbe088df5e Mon Sep 17 00:00:00 2001 From: YERRAGUNTA AJAY KUMAR Date: Sun, 31 May 2026 09:09:14 +0530 Subject: [PATCH 4/7] fix: remove leftover merge conflict marker --- lib/validations.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/validations.test.ts b/lib/validations.test.ts index a33dab01..90425d13 100644 --- a/lib/validations.test.ts +++ b/lib/validations.test.ts @@ -724,7 +724,7 @@ describe('streakParamsSchema — view fallback behavior', () => { describe('streakParamsSchema — Date Range Boundary Robustness (Variation 1)', () => { it('should process validation safely and fallback when partial or missing year parameters are passed', () => { // Arrange: Provide a mock payload missing a full YYYY format sequence -======= + describe('streakParamsSchema — accent parameter HEX color validation', () => { it('rejects an invalid hex color like "#ZZZZZZZ" for accent', () => { // #ZZZZZZZ contains non-hex characters — must fail schema validation From 1f475dc0e12bae11571aff17bafdb7773708633b Mon Sep 17 00:00:00 2001 From: YERRAGUNTA AJAY KUMAR Date: Sun, 31 May 2026 09:14:06 +0530 Subject: [PATCH 5/7] fix: add missing closing brace --- lib/validations.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/validations.test.ts b/lib/validations.test.ts index 90425d13..ee8c199e 100644 --- a/lib/validations.test.ts +++ b/lib/validations.test.ts @@ -816,5 +816,4 @@ describe('streakParamsSchema — tz IANA timezone validation (Variation 4)', () expect(result.error.issues[0]?.message).toContain('Invalid timezone'); } }); -}); - +}); From 1a40a3d38970539f9f77e30ef1d090c34e0731a9 Mon Sep 17 00:00:00 2001 From: YERRAGUNTA AJAY KUMAR Date: Sun, 31 May 2026 09:18:53 +0530 Subject: [PATCH 6/7] fix: add missing closing brace back --- lib/validations.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/validations.test.ts b/lib/validations.test.ts index ee8c199e..3506e152 100644 --- a/lib/validations.test.ts +++ b/lib/validations.test.ts @@ -812,8 +812,9 @@ describe('streakParamsSchema — tz IANA timezone validation (Variation 4)', () }); expect(result.success).toBe(false); - if (!result.success) { - expect(result.error.issues[0]?.message).toContain('Invalid timezone'); - } + if (!result.success) { + expect(result.error.issues[0]?.message).toContain('Invalid timezone'); + } + }); }); }); From 1ac4e5368a9f9749dcf6c94b641ff442ad2f9f41 Mon Sep 17 00:00:00 2001 From: YERRAGUNTA AJAY KUMAR Date: Sun, 31 May 2026 09:25:09 +0530 Subject: [PATCH 7/7] fix: resolve remaining syntax errors --- lib/validations.test.ts | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/lib/validations.test.ts b/lib/validations.test.ts index 3506e152..8d406b16 100644 --- a/lib/validations.test.ts +++ b/lib/validations.test.ts @@ -26,6 +26,7 @@ describe('streakParamsSchema — grace fallback behavior', () => { expect(parse({}).grace).toBe(1); }); }); + describe('githubParamsSchema', () => { it('should pass when username is valid', () => { const result = githubParamsSchema.safeParse({ @@ -76,6 +77,7 @@ describe('githubParamsSchema', () => { } }); }); + describe('streakParamsSchema user validation', () => { it('should pass when user is valid', () => { const result = streakParamsSchema.safeParse({ @@ -295,6 +297,7 @@ describe('streakParamsSchema', () => { expect(result.error.issues[0]?.message).toBe('Invalid GitHub username'); } }); + it('should accept delta_format percent', () => { const result = streakParamsSchema.safeParse({ user: 'octocat', @@ -450,6 +453,7 @@ describe('streakParamsSchema — size fallback behavior', () => { it('falls back to "medium" for empty string', () => { expect(parse({ size: '' }).size).toBe('medium'); }); + it('should accept org parameter when provided', () => { const result = streakParamsSchema.safeParse({ user: 'octocat', @@ -716,15 +720,6 @@ describe('streakParamsSchema — view fallback behavior', () => { }); }); - -/* ========================================================================== - * DATE RANGE BOUNDARY ROBUSTNESS (VARIATION 1) - * ========================================================================== */ - -describe('streakParamsSchema — Date Range Boundary Robustness (Variation 1)', () => { - it('should process validation safely and fallback when partial or missing year parameters are passed', () => { - // Arrange: Provide a mock payload missing a full YYYY format sequence - describe('streakParamsSchema — accent parameter HEX color validation', () => { it('rejects an invalid hex color like "#ZZZZZZZ" for accent', () => { // #ZZZZZZZ contains non-hex characters — must fail schema validation @@ -746,24 +741,23 @@ describe('streakParamsSchema — accent parameter HEX color validation', () => { }); }); +/* ========================================================================== + * DATE RANGE BOUNDARY ROBUSTNESS (VARIATION 1) + * ========================================================================== */ + describe('streakParamsSchema — Date Range Boundary Robustness (Variation 1)', () => { it('should process validation safely and fallback when partial or missing year parameters are passed', () => { - + // Arrange: Provide a mock payload missing a full YYYY format sequence const partialYearPayload = { user: 'octocat', from: '05-12', to: '05-30', }; - // Act: Pass the object through the validator schema matrix const result = streakParamsSchema.safeParse(partialYearPayload); // Assert: The validator handles it safely using implicit date engine fallbacks - - const result = streakParamsSchema.safeParse(partialYearPayload); - - expect(result.success).toBe(true); if (result.success) { expect(result.data.from).toBeDefined(); @@ -772,22 +766,15 @@ describe('streakParamsSchema — Date Range Boundary Robustness (Variation 1)', }); it('should pass cleanly and fallback to default ranges when date bounds are completely omitted', () => { - // Arrange: Pass only the bare minimum required parameters - const minimalPayload = { user: 'octocat', }; - // Act const result = streakParamsSchema.safeParse(minimalPayload); // Assert: Verify that omitted range options return undefined to use downstream defaults smoothly - - const result = streakParamsSchema.safeParse(minimalPayload); - - expect(result.success).toBe(true); if (result.success) { expect(result.data.from).toBeUndefined(); @@ -796,7 +783,6 @@ describe('streakParamsSchema — Date Range Boundary Robustness (Variation 1)', }); }); - /* ========================================================================== * TZ PARAMETER — IANA TIMEZONE VALIDATION (VARIATION 4) * ========================================================================== */ @@ -812,9 +798,8 @@ describe('streakParamsSchema — tz IANA timezone validation (Variation 4)', () }); expect(result.success).toBe(false); - if (!result.success) { - expect(result.error.issues[0]?.message).toContain('Invalid timezone'); - } - }); + if (!result.success) { + expect(result.error.issues[0]?.message).toContain('Invalid timezone'); + } }); -}); +});