-
Notifications
You must be signed in to change notification settings - Fork 4
feat(earn): add history chart hover details #573
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/widget/tests/pages-dashboard/history-chart.browser.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { type DateTime, Schema } from "effect"; | ||
| import { I18nextProvider } from "react-i18next"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { userEvent } from "vitest/browser"; | ||
| import { render } from "vitest-browser-react"; | ||
| import { UtcDateTimeFromString } from "../../src/domain/finance/scalars"; | ||
| import type { HistoryPoint } from "../../src/domain/portfolio/models"; | ||
| import { HistoryChart } from "../../src/features/earn/ui/dashboard/earn-details/reward-rate-chart"; | ||
| import { createWidgetI18nInstance } from "../../src/services/translation/widget-translation"; | ||
|
|
||
| const i18nInstance = createWidgetI18nInstance(); | ||
|
|
||
| const parseDate = (iso: string): DateTime.Utc => | ||
| Schema.decodeSync(UtcDateTimeFromString)(iso); | ||
|
|
||
| const samplePoints: ReadonlyArray<HistoryPoint> = [ | ||
| { | ||
| timestamp: parseDate("2026-06-01T00:00:00.000Z"), | ||
| value: 6.5, | ||
| }, | ||
| { | ||
| timestamp: parseDate("2026-06-15T00:00:00.000Z"), | ||
| value: 6.85, | ||
| }, | ||
| { | ||
| timestamp: parseDate("2026-07-01T00:00:00.000Z"), | ||
| value: 7.19, | ||
| }, | ||
| ]; | ||
|
|
||
| describe("HistoryChart browser interactions", () => { | ||
| it("displays hover container with point details and active dot on mouse move", async () => { | ||
| const screen = await render( | ||
| <I18nextProvider i18n={i18nInstance}> | ||
| <div style={{ width: 400, height: 200 }}> | ||
| <HistoryChart | ||
| chartId="reward-rate" | ||
| data={samplePoints} | ||
| isLoading={false} | ||
| isRefreshing={false} | ||
| refreshKey="30d" | ||
| tickFormatter={(val) => `${val.toFixed(2)}%`} | ||
| /> | ||
| </div> | ||
| </I18nextProvider> | ||
| ); | ||
|
|
||
| const surface = screen.container.querySelector("svg.recharts-surface"); | ||
| expect(surface).toBeTruthy(); | ||
|
|
||
| if (!surface) return; | ||
| // Hover over the chart surface | ||
| await userEvent.hover(surface); | ||
| const tooltip = screen.getByTestId("reward-rate-tooltip"); | ||
| await expect.element(tooltip).toBeVisible(); | ||
| await expect.element(tooltip.getByText("6.85%")).toBeVisible(); | ||
| await expect.element(tooltip.getByText("Jun 15, 2026")).toBeVisible(); | ||
|
|
||
| const activeDot = screen.container.querySelector( | ||
| 'g[key*="reward-rate-active-dot"], circle[r="3.5"]' | ||
| ); | ||
| expect(activeDot).toBeTruthy(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hover date shifts by timezone
Medium Severity
DateTime.formatLocalconverts each history timestamp into the viewer's local timezone. Chart points are UTC midnight daily snapshots, so users west of UTC see the previous calendar day on hover instead of the recorded date. Locale still applies if the UTC calendar day is formatted instead.Reviewed by Cursor Bugbot for commit 7c05eae. Configure here.
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.
Fixed in c0b9cc6. Snapshot dates now use
DateTime.formatUtc, with a regression test forced toAmerica/Los_Angelesthat previously rendered the prior calendar day.