Skip to content

Conversation

@Lee-WonJun
Copy link
Contributor

@Lee-WonJun Lee-WonJun commented Jun 17, 2025

Description

Extract the client-environment check into a new, exported isClientEnvironment() helper so tests can mock it directly, without changing any runtime behavior or throwing errors.

As this is not intended as a patch but rather a small enhancement, I avoided adding any breaking behaviors like throwing errors to ensure full backward compatibility.

Related Issue: #178

Changes

  • Add and export isClientEnvironment() util
  • Have useClientLayoutEffect call it and return early when false (non-changed behavior)
  • No other logic or error-throwing changes—existing behavior is untouched

Motivation and Context

// jest.setup.js
global.navigator = { product: 'ReactNative' };

Patching global.navigator in jest.setup.js is a pretty good workable solution, but it feels a bit weird and like a global workaround.

By extracting and exporting the check, we enable targeted jest.mock()/jest.spyOn() of exactly that function (and it makes the [overlay-kit] repo itself more testable)

While I’m not primarily a frontend engineer and may not be fully familiar with the canonical idioms, I believe this small suggestion maintains full backward compatibility, introduces no runtime changes, and allows for more flexible testing.

How Has This Been Tested?

I didn’t find dedicated tests for this hook, so I’ll check the CI test results after opening the PR.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have performed a self-review of my own code.
  • My code is commented, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

Further Comments

@Lee-WonJun Lee-WonJun requested a review from jungpaeng as a code owner June 17, 2025 14:52
@changeset-bot
Copy link

changeset-bot bot commented Jun 17, 2025

🦋 Changeset detected

Latest commit: 2c7a142

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
overlay-kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jun 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
overlay-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2025 2:53pm

@vercel
Copy link

vercel bot commented Oct 12, 2025

@jungpaeng is attempting to deploy a commit to the Toss Team on Vercel.

A member of the Team first needs to authorize it.

@codecov-commenter
Copy link

codecov-commenter commented Oct 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.85%. Comparing base (6d35a52) to head (2c7a142).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #179   +/-   ##
=======================================
  Coverage   99.85%   99.85%           
=======================================
  Files          15       15           
  Lines        1337     1340    +3     
  Branches      260      262    +2     
=======================================
+ Hits         1335     1338    +3     
  Misses          2        2           
Components Coverage Δ
overlay-kit 99.85% <100.00%> (+<0.01%) ⬆️
🚀 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
Member

@jungpaeng jungpaeng left a comment

Choose a reason for hiding this comment

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

Thank you for your suggestion.
However, since this PR does not completely resolve the issue, I’ve updated the description to ensure the issue is not closed.

@jungpaeng jungpaeng changed the title Small suggestion about #178 feat: Export isClientEnvironment function Oct 12, 2025
@jungpaeng jungpaeng merged commit 6a96688 into toss:main Oct 12, 2025
9 of 10 checks passed
@Lee-WonJun
Copy link
Contributor Author

Understood. Thanks for updating it directly.

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.

3 participants