-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: clean up task list in HistoryPreview and History components #6687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b86602b
3f688ea
0ef9c9a
cffc22e
8f54d78
8be6dd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,47 +74,33 @@ describe("TaskItem", () => { | |
| expect(screen.getByTestId("export")).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it("displays cache information when present", () => { | ||
| const mockTaskWithCache = { | ||
| ...mockTask, | ||
| cacheReads: 10, | ||
| cacheWrites: 5, | ||
| } | ||
|
|
||
| it("displays time ago information", () => { | ||
| render( | ||
| <TaskItem | ||
| item={mockTaskWithCache} | ||
| item={mockTask} | ||
| variant="full" | ||
| isSelected={false} | ||
| onToggleSelection={vi.fn()} | ||
| isSelectionMode={false} | ||
| />, | ||
| ) | ||
|
|
||
| // Should display cache information in the footer | ||
| expect(screen.getByTestId("cache-compact")).toBeInTheDocument() | ||
| expect(screen.getByText("5")).toBeInTheDocument() // cache writes | ||
| expect(screen.getByText("10")).toBeInTheDocument() // cache reads | ||
| // Should display time ago format | ||
| expect(screen.getByText(/ago/)).toBeInTheDocument() | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be helpful to add more specific test cases for edge cases? For example:
This would ensure the time formatting works correctly across all scenarios.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be testing the library, I don't think it's necessary. |
||
| }) | ||
|
|
||
| it("does not display cache information when not present", () => { | ||
| const mockTaskWithoutCache = { | ||
| ...mockTask, | ||
| cacheReads: 0, | ||
| cacheWrites: 0, | ||
| } | ||
|
|
||
| it("applies hover effect class", () => { | ||
| render( | ||
| <TaskItem | ||
| item={mockTaskWithoutCache} | ||
| item={mockTask} | ||
| variant="full" | ||
| isSelected={false} | ||
| onToggleSelection={vi.fn()} | ||
| isSelectionMode={false} | ||
| />, | ||
| ) | ||
|
|
||
| // Cache section should not be present | ||
| expect(screen.queryByTestId("cache-compact")).not.toBeInTheDocument() | ||
| const taskItem = screen.getByTestId("task-item-1") | ||
| expect(taskItem).toHaveClass("hover:bg-vscode-list-hoverBackground") | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import i18next from "i18next" | ||
| import { formatDistanceToNow } from "date-fns" | ||
|
|
||
| export function formatLargeNumber(num: number): string { | ||
| if (num >= 1e9) { | ||
|
|
@@ -33,3 +34,7 @@ export const formatDate = (timestamp: number) => { | |
|
|
||
| return dateStr.toUpperCase() | ||
| } | ||
|
|
||
| export const formatTimeAgo = (timestamp: number) => { | ||
| return formatDistanceToNow(new Date(timestamp), { addSuffix: true }) | ||
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hover effect looks good! Could we verify that the contrast ratio between text and meets WCAG accessibility standards? This would ensure the UI remains accessible for users with visual impairments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, thanks for the consideration.