|
1 | | -# SourceValue Race Condition Test Documentation |
2 | | - |
3 | | -## Overview |
| 1 | +# Onyx sourceValue issues |
4 | 2 |
|
5 | 3 | These tests demonstrate and prove multiple issues with Onyx sourceValue handling: |
6 | 4 | 1. **Race Condition**: Multiple discrete updates batched → only first `sourceValue` visible |
7 | 5 | 2. **Logic Bug**: `useSidebarOrderedReports` conditional logic ignores available `sourceValues` |
8 | | -3. **Compound Issue**: Both problems occurring simultaneously for maximum impact |
| 6 | +3. **Stale sourceValues**: `sourceValue` preserves the keys of the latest onyx update during unrelated rerenders |
| 7 | + |
| 8 | +See the thread in [#quality](https://expensify.slack.com/archives/C05LX9D6E07/p1755792968968239?thread_ts=1755543034.080259&cid=C05LX9D6E07) for more info |
9 | 9 |
|
10 | 10 | ## Test Files |
11 | 11 |
|
12 | 12 | **`simpleSourceValueRaceConditionDemo.ts`** - Pure race condition test proving batching loses intermediate `sourceValues` |
13 | 13 | **`useSidebarOrderedReportsVulnerability.ts`** - Logic bug and compound issue tests replicating production patterns |
| 14 | +**`staleSourceValueTest`** - Test demonstrating that sourceValue persists during unrelated renders, leading to unnecessary cache busing |
14 | 15 |
|
15 | 16 | ## How to Run the Tests |
16 | 17 |
|
17 | 18 | ```bash |
18 | 19 | # Run the race condition test |
19 | 20 | npm test -- tests/unit/simpleSourceValueRaceConditionDemo.ts |
20 | 21 |
|
21 | | -# Run the useSidebarOrderedReports vulnerability tests |
22 | | -npm test -- tests/unit/useSidebarOrderedReportsVulnerability.ts |
| 22 | +# Run the useSidebarOrderedReports display bug tests |
| 23 | +npm test -- tests/unit/useSidebarOrderedReportsDisplayBug.ts |
23 | 24 |
|
24 | | -# Or run both test files |
25 | | -npm test -- tests/unit/simpleSourceValueRaceConditionDemo.ts tests/unit/useSidebarOrderedReportsVulnerability.ts |
| 25 | +# Run the staleSourceValueTest tests |
| 26 | +npm test -- tests/unit/staleSourceValueTest.ts |
26 | 27 |
|
27 | | -# Run with verbose output to see detailed logging |
28 | | -npm test -- tests/unit/simpleSourceValueRaceConditionDemo.ts --verbose |
| 28 | +# Or run all 3 at once |
| 29 | +npm test -- tests/unit/simpleSourceValueRaceConditionDemo.ts tests/unit/useSidebarOrderedReportsDisplayBug.ts tests/unit/staleSourceValueTest.ts |
29 | 30 | ``` |
30 | 31 |
|
31 | | -## What the Test Proves |
| 32 | +# The race condition test and what it proves |
32 | 33 |
|
33 | 34 | ### The Race Condition Mechanism |
34 | 35 |
|
|
0 commit comments