Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Avoid mock-heavy tests that verify implementation details rather than behavior.

- Prefer full-app stories (`App.stories.tsx`) to isolated component stories. This tests components in their real context with proper providers, state management, and styling.
- Use play functions with `@storybook/test` utilities (`within`, `userEvent`, `waitFor`) to interact with the UI and set up the desired visual state. Do not add props to production components solely for storybook convenience.
- Keep story data deterministic: avoid `Math.random()`, `Date.now()`, or other non-deterministic values in story setup. Pass explicit values when ordering or timing matters for visual stability.

### TDD Expectations

Expand Down
20 changes: 14 additions & 6 deletions src/browser/stories/App.reviews.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,50 +168,58 @@ export const BulkReviewActions: AppStory = {
setup={() => {
const workspaceId = "ws-bulk-reviews";

// Use deterministic timestamps so reviews render in stable order
const baseTime = 1700000000000;
setReviews(workspaceId, [
// Attached reviews - shown in ChatInput with "Clear all" button
createReview(
"review-attached-1",
"src/api/auth.ts",
"42-48",
"Consider using a constant for the token expiry",
"attached"
"attached",
baseTime + 1
),
createReview(
"review-attached-2",
"src/utils/helpers.ts",
"15-20",
"This function could be simplified using reduce",
"attached"
"attached",
baseTime + 2
),
createReview(
"review-attached-3",
"src/hooks/useAuth.ts",
"30-35",
"Missing error handling for network failures",
"attached"
"attached",
baseTime + 3
),
// Pending reviews - shown in banner with "Attach all to chat" button
createReview(
"review-pending-1",
"src/components/LoginForm.tsx",
"55-60",
"Add loading state while authenticating",
"pending"
"pending",
baseTime + 4
),
createReview(
"review-pending-2",
"src/services/api.ts",
"12-18",
"Consider adding retry logic for failed requests",
"pending"
"pending",
baseTime + 5
),
createReview(
"review-pending-3",
"src/types/user.ts",
"5-10",
"Make email field optional for guest users",
"pending"
"pending",
baseTime + 6
),
]);

Expand Down
5 changes: 3 additions & 2 deletions src/browser/stories/storyHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export function createReview(
filePath: string,
lineRange: string,
note: string,
status: "pending" | "attached" | "checked" = "pending"
status: "pending" | "attached" | "checked" = "pending",
createdAt?: number
): Review {
return {
id,
Expand All @@ -87,7 +88,7 @@ export function createReview(
userNote: note,
},
status,
createdAt: Date.now() - Math.random() * 3600000, // Random time in last hour
createdAt: createdAt ?? Date.now(),
statusChangedAt: status === "checked" ? Date.now() : undefined,
};
}
Expand Down