Skip to content

Conversation

@Prithpal-Sooriya
Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Dec 15, 2025

Description

Dynamically format asset chart dates to omit the year for current year dates and include it for past/future years to improve readability.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: fix: chart history date label when older than current year

Related issues

Fixes: #38736 https://consensyssoftware.atlassian.net/browse/ASSETS-2116

Manual testing steps

See issue comment

Screenshots/Recordings

Before

After

https://www.loom.com/share/83ad9a83ccc9422cb24086452034ba6f

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Open in Cursor Open in Web


Note

Use a dynamic short date for chart labels (time for current year, year for other years) and add unit tests.

  • UI:
    • Update ui/pages/asset/components/chart/asset-chart-price.tsx to use getDynamicShortDate(date) for the hovered date label.
  • Utils:
    • Add getDynamicShortDate(date) in ui/pages/asset/util.ts to switch between getShortDateFormatter and getShortDateFormatterV2 based on year.
  • Tests:
    • Add tests in ui/pages/asset/util.test.ts covering multiple current/past/future year and timestamp scenarios for getDynamicShortDate.

Written by Cursor Bugbot for commit 8b363c9. This will update automatically on new commits. Configure here.

@cursor
Copy link

cursor bot commented Dec 15, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@cursor cursor bot force-pushed the cursor/asset-chart-date-formatting-380d branch from 3e9441a to 48c475c Compare December 15, 2025 11:32
@Prithpal-Sooriya Prithpal-Sooriya changed the title Asset chart date formatting fix: chart history date label when older than current year Dec 15, 2025
@cursor cursor bot force-pushed the cursor/asset-chart-date-formatting-380d branch from 48c475c to 46c212f Compare December 15, 2025 11:41
@Prithpal-Sooriya Prithpal-Sooriya marked this pull request as ready for review December 15, 2025 11:55
@Prithpal-Sooriya
Copy link
Contributor Author

@cursor can you resolve this comment please? I agree that to be safe we should use jest fake timers.
#38853 (comment)

@cursor
Copy link

cursor bot commented Dec 15, 2025

Done! I've updated the tests to use Jest fake timers to mock the system time, ensuring the tests won't become flaky after 2025.

Changes made:

  1. Added jest.useFakeTimers() - Mocks the system time to a fixed date (July 1, 2025)
  2. Added jest.setSystemTime(MOCKED_CURRENT_DATE) - Sets the mocked current date
  3. Added jest.useRealTimers() in afterAll - Restores real timers after tests complete
  4. Removed CURRENT_YEAR constant - Now using explicit year values since the system time is mocked

Updated test structure:

describe('getDynamicShortDate', () => {
  const originalNavigatorLanguage = navigator.language;
  // Use a fixed "current year" for testing - mock system time to ensure tests don't become flaky
  const MOCKED_CURRENT_DATE = new Date(2025, 6, 1, 12, 0, 0); // July 1, 2025

  beforeAll(() => {
    jest.useFakeTimers();
    jest.setSystemTime(MOCKED_CURRENT_DATE);
    Object.defineProperty(navigator, 'language', {
      value: 'en-US',
      configurable: true,
    });
  });

  afterAll(() => {
    jest.useRealTimers();
    Object.defineProperty(navigator, 'language', {
      value: originalNavigatorLanguage,
      configurable: true,
    });
  });

  // ... test cases
});

All 15 tests pass and TypeScript checks pass. The changes have been pushed to the branch.


Open in Cursor Open in Web

Learn more about Cursor Agents

@cursor cursor bot force-pushed the cursor/asset-chart-date-formatting-380d branch from 46c212f to 8b363c9 Compare December 15, 2025 11:59
@metamaskbot
Copy link
Collaborator

Builds ready [8b363c9]
UI Startup Metrics (1290 ± 101 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12901044148310113611461
load107688612749411441241
domContentLoaded106988212639411371226
domInteractive261691192185
firstPaint4658112763979301173
backgroundConnect21419725910218232
firstReactRender453284114875
getState4216122175074
initialActions109112
loadScripts8626671061939341018
setupStore1265561318
numNetworkReqs181177181169
BrowserifyPower User HomeuiStartup19181627233315119902208
load1088887146012111701287
domContentLoaded1077878145412011621275
domInteractive3116173242890
firstPaint53293136541610101254
backgroundConnect24919757987233535
firstReactRender50398885264
getState217146762120211685
initialActions103112
loadScripts86468312381189461067
setupStore1665681531
numNetworkReqs67551932263122
WebpackStandard HomeuiStartup8726841254999321051
load67857899084730860
domContentLoaded67257298184722855
domInteractive2617127212284
firstPaint25079818180233681
backgroundConnect237165262879
firstReactRender66352825363208
getState3216152184162
initialActions106113
loadScripts66956997283720852
setupStore12788101327
numNetworkReqs181177181174
WebpackPower User HomeuiStartup13571035183720014351763
load692586106787705886
domContentLoaded685580106187699881
domInteractive29161092324102
firstPaint27391794192275698
backgroundConnect83765815190552
firstReactRender49407365159
getState191141725103180280
initialActions103112
loadScripts682578105386697872
setupStore1476281334
numNetworkReqs67522152762127
FirefoxBrowserifyStandard HomeuiStartup13951077195018415261723
load1101896152513211841374
domContentLoaded1101895152513211831374
domInteractive67302184091149
firstPaint------
backgroundConnect55222063976135
firstReactRender403086104165
getState137139161033
initialActions103122
loadScripts1068879144211411431310
setupStore13586111234
numNetworkReqs19987191375
BrowserifyPower User HomeuiStartup25951570351454330483327
load1566984258849520242354
domContentLoaded1565984258849520242353
domInteractive1603198226896942
firstPaint------
backgroundConnect177201180230179944
firstReactRender5336103125780
getState1336732146161221
initialActions2139523
loadScripts1476961255646619152323
setupStore464102711140173
numNetworkReqs70481372367128
WebpackStandard HomeuiStartup15941296256020516691997
load13151099226716013921528
domContentLoaded13151099226716013911528
domInteractive70282013892133
firstPaint------
backgroundConnect68222334298153
firstReactRender42338984456
getState147120131531
initialActions102022
loadScripts12821084224015113521460
setupStore16599171457
numNetworkReqs19990201476
WebpackPower User HomeuiStartup26751775580159131253530
load18591106471057723152659
domContentLoaded18591100471057823152659
domInteractive2463033004471571000
firstPaint------
backgroundConnect163261085215194940
firstReactRender5937108126679
getState1387642958175249
initialActions3133426
loadScripts17721090453555322412580
setupStore4553967750311
numNetworkReqs71521402370122
📊 Page Load Benchmark Results

Current Commit: 8b363c9 | Date: 12/15/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±39ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 728ms (±36ms) 🟢 | historical mean value: 732ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±9ms) 🟢 | historical mean value: 78ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 39ms 1.02s 1.33s 1.06s 1.33s
domContentLoaded 728ms 36ms 703ms 1.00s 747ms 1.00s
firstPaint 78ms 9ms 60ms 152ms 88ms 152ms
firstContentfulPaint 78ms 9ms 60ms 152ms 88ms 152ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 158 Bytes (0%)
  • common: 20 Bytes (0%)

@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Dec 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 16, 2025
@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Dec 16, 2025
Merged via the queue into main with commit c57c0c0 Dec 16, 2025
333 of 335 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the cursor/asset-chart-date-formatting-380d branch December 16, 2025 10:48
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2025
@metamaskbot metamaskbot added the release-13.14.0 Issue or pull request that will be included in release 13.14.0 label Dec 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.14.0 Issue or pull request that will be included in release 13.14.0 size-S team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: All chart does not show the year field

5 participants