Skip to content

Conversation

@just-boris
Copy link
Member

@just-boris just-boris commented Aug 5, 2025

Issue #, if available:

Description of changes:

There are only two hard things in Computer Science: cache invalidation and naming things.

In this PR we got incorrect caching.

This affects our useMobile hook. Example:

test('first', () => {
  globalThis[forceMobileModeSymbol] = false;
  render(<AppLayout />); // I see desktop view

  // resize to mobile
  act(() => {
    globalThis[forceMobileModeSymbol] = true;
    window.dispatchEvent(new CustomEvent('resize'));
  });

  // clean up flag to its original state
  globalThis[forceMobileModeSymbol] = undefined;
});

test('second', () => {
  // no overrides in this test, it should be desktop by default, but the mobile size is leaked from the previous test
  render(<AppLayout />);
});

With the fix the "second" test will work as expected

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@just-boris just-boris requested a review from a team as a code owner August 5, 2025 19:47
@just-boris just-boris requested review from teodoranemes and removed request for a team August 5, 2025 19:47
@codecov
Copy link

codecov bot commented Aug 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.39%. Comparing base (dca1353) to head (4d52cc5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
- Coverage   99.39%   99.39%   -0.01%     
==========================================
  Files          33       33              
  Lines         833      830       -3     
  Branches      234      224      -10     
==========================================
- Hits          828      825       -3     
  Misses          5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@teodoranemes teodoranemes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liked the CS quote from the Description

@just-boris just-boris added this pull request to the merge queue Aug 6, 2025
Merged via the queue into main with commit dfbb81d Aug 6, 2025
38 checks passed
@just-boris just-boris deleted the fix-singleton-state branch August 6, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants