Skip to content

Commit 5ac2a94

Browse files
🤖 fix: deterministic timestamps for review stories (#1061)
Reviews were rendering in non-deterministic order because `createReview` defaulted to `Date.now()` for timestamps. When multiple calls happened in the same millisecond, the sort became unstable. Added explicit `baseTime + N` timestamps to affected stories: - ReviewsBanner - AllReviewsChecked - ManyReviews This fixes chromatic flakes where review order would vary between runs. _Generated with `mux`_
1 parent 4f167ab commit 5ac2a94

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

src/browser/stories/App.reviews.stories.tsx

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,32 @@ export const ReviewsBanner: AppStory = {
2222
setup={() => {
2323
const workspaceId = "ws-reviews";
2424

25-
// Set up reviews
25+
// Use deterministic timestamps so reviews render in stable order
26+
const baseTime = 1700000000000;
2627
setReviews(workspaceId, [
2728
createReview(
2829
"review-1",
2930
"src/api/auth.ts",
3031
"42-48",
3132
"Consider using a constant for the token expiry",
32-
"pending"
33+
"pending",
34+
baseTime + 1
3335
),
3436
createReview(
3537
"review-2",
3638
"src/utils/helpers.ts",
3739
"15",
3840
"This function could be simplified",
39-
"pending"
41+
"pending",
42+
baseTime + 2
4043
),
4144
createReview(
4245
"review-3",
4346
"src/components/Button.tsx",
4447
"23-25",
4548
"Already addressed in another PR",
46-
"checked"
49+
"checked",
50+
baseTime + 3
4751
),
4852
]);
4953

@@ -95,9 +99,25 @@ export const AllReviewsChecked: AppStory = {
9599
setup={() => {
96100
const workspaceId = "ws-all-checked";
97101

102+
// Use deterministic timestamps so reviews render in stable order
103+
const baseTime = 1700000000000;
98104
setReviews(workspaceId, [
99-
createReview("review-1", "src/api/users.ts", "10-15", "Fixed the null check", "checked"),
100-
createReview("review-2", "src/utils/format.ts", "42", "Added error handling", "checked"),
105+
createReview(
106+
"review-1",
107+
"src/api/users.ts",
108+
"10-15",
109+
"Fixed the null check",
110+
"checked",
111+
baseTime + 1
112+
),
113+
createReview(
114+
"review-2",
115+
"src/utils/format.ts",
116+
"42",
117+
"Added error handling",
118+
"checked",
119+
baseTime + 2
120+
),
101121
]);
102122

103123
return setupSimpleChatStory({
@@ -126,13 +146,16 @@ export const ManyReviews: AppStory = {
126146
const workspaceId = "ws-many-reviews";
127147

128148
// Create many reviews to test scroll behavior
149+
// Use deterministic timestamps so reviews render in stable order
150+
const baseTime = 1700000000000;
129151
const reviewItems = Array.from({ length: 10 }, (_, i) =>
130152
createReview(
131153
`review-${i + 1}`,
132154
`src/components/Feature${i + 1}.tsx`,
133155
`${10 + i * 5}-${15 + i * 5}`,
134156
`Review comment ${i + 1}: This needs attention`,
135-
i < 7 ? "pending" : "checked"
157+
i < 7 ? "pending" : "checked",
158+
baseTime + i + 1
136159
)
137160
);
138161

0 commit comments

Comments
 (0)