Skip to content

fix(test): clear persisted history filters between tests (fix rc-red history suites)#1163

Merged
jSydorowicz21 merged 1 commit into
RunMaestro:rcfrom
jSydorowicz21:fix/history-test-isolation
Jul 5, 2026
Merged

fix(test): clear persisted history filters between tests (fix rc-red history suites)#1163
jSydorowicz21 merged 1 commit into
RunMaestro:rcfrom
jSydorowicz21:fix/history-test-isolation

Conversation

@jSydorowicz21

@jSydorowicz21 jSydorowicz21 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Problem

test CI has been red on rc (both runners) with 51 failures across two files:

  • src/__tests__/renderer/components/HistoryPanel.test.tsx (~49)
  • src/__tests__/renderer/components/DirectorNotes/UnifiedHistoryTab.test.tsx (2)

All failures were waitFor(() => getByText(<entry text>)) timeouts — entries never rendered.

Root cause

Test-isolation leak, not a product bug. Both HistoryPanel and the Director's Notes Unified History persist the source-type filter (USER/AUTO/CUE) to localStorage (historyPanel.filters / directorNotes.historyFilters) via savePersistedHistoryFilters, and rehydrate it on mount via resolveInitialHistoryFilters.

The suites toggle filters off in some tests but never cleared localStorage in beforeEach. jsdom's localStorage is shared across tests in a file, so once a test deselected a type, resolveInitialHistoryFilters restored that restrictive set for every subsequent test — entries of the hidden type never rendered, and all downstream entry-render assertions timed out. (Each test passed in isolation, which is why this only surfaced in full runs.)

Fix

Clear localStorage in each suite's beforeEach so filter state can't leak between tests. Test-only change (+10 lines, no product code touched).

Verification

  • HistoryPanel.test.tsx: 72/72 pass (was 49 failing)
  • UnifiedHistoryTab.test.tsx: 35/35 pass (was 2 failing)
  • Combined: 107 passed, exit 0
  • Prettier + ESLint clean on both files

Platform-independent (localStorage leak), so it fixes the same failures on the Windows runner as well.

Summary by CodeRabbit

  • Tests
    • Improved test reliability by resetting saved filter state before each test run.
    • Prevented leftover browser storage from affecting later test cases and causing inconsistent results.

HistoryPanel and UnifiedHistoryTab persist the source-type filter (USER/AUTO/CUE) to localStorage under historyPanel.filters / directorNotes.historyFilters. The suites toggle filters off but never cleared localStorage in beforeEach, so a deselection leaked into every later test in the file: resolveInitialHistoryFilters restored the restrictive set, entries of the hidden type never rendered, and all downstream entry-render assertions timed out. This was rc-red on both runners (51 failures across the two files). Clearing localStorage in each beforeEach isolates filter state; both files now pass (107 tests).
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 49339ab8-8525-4dee-8a04-5db7ac0f331b

📥 Commits

Reviewing files that changed from the base of the PR and between 067b068 and 9a22a6c.

📒 Files selected for processing (2)
  • src/__tests__/renderer/components/DirectorNotes/UnifiedHistoryTab.test.tsx
  • src/__tests__/renderer/components/HistoryPanel.test.tsx

📝 Walkthrough

Walkthrough

Two test files were modified to add localStorage.clear() calls within their beforeEach hooks, accompanied by explanatory comments, to prevent persisted filter state from one test leaking into subsequent tests.

Changes

Test Isolation via localStorage Clearing

Layer / File(s) Summary
Clear localStorage in beforeEach hooks
src/__tests__/renderer/components/DirectorNotes/UnifiedHistoryTab.test.tsx, src/__tests__/renderer/components/HistoryPanel.test.tsx
Added localStorage.clear() calls with explanatory comments in beforeEach hooks to prevent persisted filter state (UNIFIED_HISTORY_FILTERS_KEY, HISTORY_PANEL_FILTERS_KEY) from leaking between test cases.

Estimated code review effort: 1 (Trivial) | ~3 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jSydorowicz21 jSydorowicz21 merged commit 7856f1a into RunMaestro:rc Jul 5, 2026
3 of 5 checks passed
@greptile-apps

greptile-apps Bot commented Jul 5, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes 51 test failures on the rc branch caused by localStorage filter state leaking between tests in HistoryPanel and UnifiedHistoryTab suites. Adding localStorage.clear() to each suite's beforeEach ensures resolveInitialHistoryFilters always starts from a clean slate, so a filter toggle in one test can't hide entries in later tests.

  • HistoryPanel.test.tsx: localStorage.clear() added inside the describe('HistoryPanel') beforeEach, targeting HISTORY_PANEL_FILTERS_KEY leakage — restores 72/72 passing.
  • UnifiedHistoryTab.test.tsx: localStorage.clear() added to the top-level beforeEach, targeting UNIFIED_HISTORY_FILTERS_KEY leakage — restores 35/35 passing.
  • No product code was modified; the fix is entirely test-infrastructure scoped.

Confidence Score: 5/5

Safe to merge — test-only change with no product code touched.

Both files receive a single-line localStorage.clear() call in beforeEach. The fix directly addresses a well-understood jsdom shared-state leak, restores all 107 previously-broken tests, and introduces no risk to any runtime behaviour.

No files require special attention.

Important Files Changed

Filename Overview
src/tests/renderer/components/HistoryPanel.test.tsx Adds localStorage.clear() in beforeEach inside the describe('HistoryPanel') block to prevent filter state leaked by one test from hiding entries in subsequent tests.
src/tests/renderer/components/DirectorNotes/UnifiedHistoryTab.test.tsx Adds localStorage.clear() in the top-level beforeEach to clear UNIFIED_HISTORY_FILTERS_KEY state between tests, fixing the 2 previously failing entry-render assertions.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant T1 as Test N (toggles filter off)
    participant LS as jsdom localStorage
    participant T2 as Test N+1 (expects entries)
    participant RHF as resolveInitialHistoryFilters

    Note over T1,RHF: BEFORE fix — leak scenario
    T1->>LS: "savePersistedHistoryFilters(key, {USER})"
    T1->>T1: passes ✓
    T2->>RHF: called on mount
    RHF->>LS: getItem(key) → ["USER"]
    RHF-->>T2: "Set{USER} (AUTO hidden)"
    T2->>T2: waitFor(AUTO entry) → timeout ✗

    Note over T1,RHF: AFTER fix — localStorage.clear() in beforeEach
    T1->>LS: "savePersistedHistoryFilters(key, {USER})"
    T1->>T1: passes ✓
    LS->>LS: localStorage.clear() [beforeEach]
    T2->>RHF: called on mount
    RHF->>LS: getItem(key) → null
    RHF-->>T2: "Set{USER, AUTO} (defaults)"
    T2->>T2: waitFor(AUTO entry) → renders ✓
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant T1 as Test N (toggles filter off)
    participant LS as jsdom localStorage
    participant T2 as Test N+1 (expects entries)
    participant RHF as resolveInitialHistoryFilters

    Note over T1,RHF: BEFORE fix — leak scenario
    T1->>LS: "savePersistedHistoryFilters(key, {USER})"
    T1->>T1: passes ✓
    T2->>RHF: called on mount
    RHF->>LS: getItem(key) → ["USER"]
    RHF-->>T2: "Set{USER} (AUTO hidden)"
    T2->>T2: waitFor(AUTO entry) → timeout ✗

    Note over T1,RHF: AFTER fix — localStorage.clear() in beforeEach
    T1->>LS: "savePersistedHistoryFilters(key, {USER})"
    T1->>T1: passes ✓
    LS->>LS: localStorage.clear() [beforeEach]
    T2->>RHF: called on mount
    RHF->>LS: getItem(key) → null
    RHF-->>T2: "Set{USER, AUTO} (defaults)"
    T2->>T2: waitFor(AUTO entry) → renders ✓
Loading

Reviews (1): Last reviewed commit: "fix(test): clear persisted history filte..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant