Skip to content

Commit 7640948

Browse files
authored
fix(validations): hide_background=1 now works correctly (JhaSourav07#1636)
## Description Fixes JhaSourav07#1631 ## Pillar - [ ] 🎨 Pillar 1 β€” New Theme Design - [ ] πŸ“ Pillar 2 β€” Geometric SVG Improvement - [ ] πŸ• Pillar 3 β€” Timezone Logic Optimization - [x] πŸ› οΈ Other (Bug fix, refactoring, docs) ## Visual Preview N/A β€” validation logic change, no visual diff. ## Checklist before requesting a review: - [x] I have read the CONTRIBUTING.md file. - [x] I have tested these changes locally. - [x] My commit follows the Conventional Commits format. - [ ] I have updated README.md (not needed). - [x] I have starred the repo. - [x] I have made sure I have only one commit.
2 parents cb47e46 + 549b924 commit 7640948

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

β€Žlib/validations.test.tsβ€Ž

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,16 +552,15 @@ describe('streakParamsSchema β€” boolean transform fields', () => {
552552
});
553553

554554
// ── hide_background ────────────────────────────────────────────────────────
555-
// Stricter than hide_title/hide_stats β€” only exact 'true' is accepted,
556-
// '1' does NOT enable it.
555+
// Same dual-value rule as hide_title/hide_stats: 'true' and '1' are both truthy.
557556

558557
describe('hide_background', () => {
559558
it('returns true when hide_background="true"', () => {
560559
expect(parse({ hide_background: 'true' }).hide_background).toBe(true);
561560
});
562561

563-
it('returns false when hide_background="1" (only exact "true" accepted)', () => {
564-
expect(parse({ hide_background: '1' }).hide_background).toBe(false);
562+
it('returns true when hide_background="1" (both "true" and "1" accepted)', () => {
563+
expect(parse({ hide_background: '1' }).hide_background).toBe(true);
565564
});
566565

567566
it('returns false when hide_background="false"', () => {

β€Žlib/validations.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export const streakParamsSchema = z.object({
171171
),
172172
refresh: z.string().optional().transform(toRefreshFlag),
173173
hide_title: z.string().optional().transform(toBooleanFlag),
174-
hide_background: z.string().optional().transform(toRefreshFlag),
174+
hide_background: z.string().optional().transform(toBooleanFlag),
175175
hide_stats: z.string().optional().transform(toBooleanFlag),
176176
lang: z.string().optional().default('en'),
177177
// Unknown view values fall back to the default dashboard view.

β€Žutils/tracking.test.tsβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,18 @@ describe('trackUser', () => {
8989

9090
it('handles empty username without crashing', () => {
9191
const sendBeaconMock = vi.fn().mockReturnValue(true);
92+
const fetchMock = vi.fn();
9293

9394
Object.defineProperty(navigator, 'sendBeacon', {
9495
value: sendBeaconMock,
9596
configurable: true,
9697
});
9798

99+
vi.stubGlobal('fetch', fetchMock);
100+
98101
expect(() => trackUser('')).not.toThrow();
99102
expect(sendBeaconMock).not.toHaveBeenCalled();
103+
expect(fetchMock).not.toHaveBeenCalled();
100104
});
101105

102106
it('falls back to fetch when sendBeacon returns false', () => {

0 commit comments

Comments
Β (0)