Skip to content

🧪 Add edge case unit tests for dedupeEndpoints#564

Merged
sunnylqm merged 2 commits intomasterfrom
test-dedupe-endpoints-6072104238503552538
Apr 27, 2026
Merged

🧪 Add edge case unit tests for dedupeEndpoints#564
sunnylqm merged 2 commits intomasterfrom
test-dedupe-endpoints-6072104238503552538

Conversation

@sunnylqm
Copy link
Copy Markdown
Contributor

@sunnylqm sunnylqm commented Apr 27, 2026

🎯 What: Added missing edge case unit tests for dedupeEndpoints in src/__tests__/endpoint.test.ts.
📊 Coverage: The new tests cover regular deduplication, maintaining original insertion order for the first occurrence, filtering falsy values (like null, undefined, and ''), and correctly handling empty arrays.
Result: Test coverage for src/endpoint.ts has been improved, and the logic of dedupeEndpoints is now robustly verified.


PR created automatically by Jules for task 6072104238503552538 started by @sunnylqm

Summary by CodeRabbit

  • Tests
    • Added tests for endpoint deduplication that verify duplicate removal, order preservation, falsy-value filtering, and empty-array behavior.
    • Increased end-to-end test timeouts (reload and retryable reload) to allow longer waits during reload/verification steps.

Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

📝 Walkthrough

Walkthrough

Added tests for a dedupeEndpoints utility and increased timeouts in an end-to-end test, extending reload/wait durations.

Changes

Cohort / File(s) Summary
Unit tests
src/__tests__/endpoint.test.ts
Imported dedupeEndpoints and added tests verifying duplicate removal, first-occurrence order preservation, filtering of falsy values, and empty-array handling.
End-to-end test timeouts
Example/e2etest/e2e/local-merge.test.ts
Increased RELOAD_TIMEOUT from 180s to 300s and RETRYABLE_RELOAD_TIMEOUT from 45s to 90s; applied to .withTimeout(...) waits in reload/verification flows.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I’m a rabbit who hops through tests with delight,
Trimming duplicates clean in the soft morning light.
Timeouts stretched longer for slower day starts,
Order preserved, falsy bits depart.
Hooray for tidy lists and patient hearts! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title references adding edge case unit tests for dedupeEndpoints, which aligns with the main change shown in the raw summary - a new test suite for dedupeEndpoints in src/tests/endpoint.test.ts. However, the pull request also modifies timeout constants in a separate e2e test file (local-merge.test.ts), which is unrelated to the title's focus. Consider whether the timeout changes in local-merge.test.ts are intentional; if not, they should be removed or the title should be expanded to include both changes. If intentional, the title should mention both the unit tests and timeout adjustments.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-dedupe-endpoints-6072104238503552538

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/__tests__/endpoint.test.ts (1)

94-114: LGTM!

The new dedupeEndpoints test suite cleanly covers the documented behaviors of the implementation in src/endpoint.ts (dedup via Set, falsy filtering, first-occurrence ordering, empty input). Assertions match the implementation exactly.

One optional follow-up to consider (non-blocking): an additional case for input containing only falsy values (e.g. [null, undefined, ''][]) would tighten coverage of the falsy-filter branch when no truthy values are present.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/__tests__/endpoint.test.ts` around lines 94 - 114, Add a new unit test to
exercise the falsy-only input branch of dedupeEndpoints: create a test in the
same suite that calls dedupeEndpoints with an array of only falsy values (e.g.,
[null, undefined, '']) and assert it returns an empty array; reference the
existing test suite name 'dedupeEndpoints' and the function 'dedupeEndpoints' so
the new test mirrors the style and placement of the other cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/__tests__/endpoint.test.ts`:
- Around line 94-114: Add a new unit test to exercise the falsy-only input
branch of dedupeEndpoints: create a test in the same suite that calls
dedupeEndpoints with an array of only falsy values (e.g., [null, undefined, ''])
and assert it returns an empty array; reference the existing test suite name
'dedupeEndpoints' and the function 'dedupeEndpoints' so the new test mirrors the
style and placement of the other cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b1093088-3038-406d-be13-e6b0172d792b

📥 Commits

Reviewing files that changed from the base of the PR and between 2536854 and 96ed08d.

📒 Files selected for processing (1)
  • src/__tests__/endpoint.test.ts

Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
Example/e2etest/e2e/local-merge.test.ts (1)

8-8: Doubling RETRYABLE_RELOAD_TIMEOUT weakens the fast-retry path.

RETRYABLE_RELOAD_TIMEOUT is used in tapCheckUpdateAndWaitForBundleLabel (Line 84) specifically for non-final attempts so the test can fail fast on a transient errorChecking and retry. Pushing it from 45s to 90s means each non-final attempt now blocks for up to 1.5 min before the retry path engages, doubling worst-case wall-clock time before the retry helps. If the goal was to reduce flakiness on the final attempt, consider raising only RELOAD_TIMEOUT and keeping the retryable budget tight (or making it a smaller fraction of RELOAD_TIMEOUT).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Example/e2etest/e2e/local-merge.test.ts` at line 8, The change doubled
RETRYABLE_RELOAD_TIMEOUT from 45s to 90s which weakens the fast-retry path used
by tapCheckUpdateAndWaitForBundleLabel; revert RETRYABLE_RELOAD_TIMEOUT to its
original tighter value (e.g. 45000) so non-final attempts can fail-fast and
retry, and if you need a longer final wait, increase RELOAD_TIMEOUT instead
while leaving RETRYABLE_RELOAD_TIMEOUT small.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Example/e2etest/e2e/local-merge.test.ts`:
- Around line 7-8: The E2E timeout changes to RELOAD_TIMEOUT and
RETRYABLE_RELOAD_TIMEOUT in local-merge.test.ts are unrelated to the
dedupeEndpoints unit test changes; either revert the edits to RELOAD_TIMEOUT
(300000) and RETRYABLE_RELOAD_TIMEOUT (90000) in local-merge.test.ts so the PR
only contains the unit-test changes, or move the timeout updates into a separate
PR and update this PR’s description to explicitly state the E2E timeout change
and rationale; locate the constants RELOAD_TIMEOUT and RETRYABLE_RELOAD_TIMEOUT
in local-merge.test.ts and either restore their original values or remove them
from this branch before merging.

---

Nitpick comments:
In `@Example/e2etest/e2e/local-merge.test.ts`:
- Line 8: The change doubled RETRYABLE_RELOAD_TIMEOUT from 45s to 90s which
weakens the fast-retry path used by tapCheckUpdateAndWaitForBundleLabel; revert
RETRYABLE_RELOAD_TIMEOUT to its original tighter value (e.g. 45000) so non-final
attempts can fail-fast and retry, and if you need a longer final wait, increase
RELOAD_TIMEOUT instead while leaving RETRYABLE_RELOAD_TIMEOUT small.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d79c78f2-eb31-457c-bfd7-eaf40e52bd5b

📥 Commits

Reviewing files that changed from the base of the PR and between 96ed08d and 31683c1.

📒 Files selected for processing (1)
  • Example/e2etest/e2e/local-merge.test.ts

Comment on lines +7 to +8
const RELOAD_TIMEOUT = 300000;
const RETRYABLE_RELOAD_TIMEOUT = 90000;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify what other files changed on this branch and whether endpoint.test.ts is actually modified.
git log --name-status -1 --format=
fd -H 'endpoint.test.ts'
rg -nP --type=ts '\bdedupeEndpoints\b' -C2

Repository: reactnativecn/react-native-update

Length of output: 28323


E2E timeout changes appear unrelated to unit tests PR.

The PR includes src/__tests__/endpoint.test.ts with tests for dedupeEndpoints, but this file also bundles unrelated timeout increases to the E2E suite (Example/e2etest/e2e/local-merge.test.ts: RELOAD_TIMEOUT 180s→300s, RETRYABLE_RELOAD_TIMEOUT 45s→90s). These timeout adjustments are not mentioned in the PR title or objective. Please clarify whether this was intentional or if the E2E changes should be split into a separate PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Example/e2etest/e2e/local-merge.test.ts` around lines 7 - 8, The E2E timeout
changes to RELOAD_TIMEOUT and RETRYABLE_RELOAD_TIMEOUT in local-merge.test.ts
are unrelated to the dedupeEndpoints unit test changes; either revert the edits
to RELOAD_TIMEOUT (300000) and RETRYABLE_RELOAD_TIMEOUT (90000) in
local-merge.test.ts so the PR only contains the unit-test changes, or move the
timeout updates into a separate PR and update this PR’s description to
explicitly state the E2E timeout change and rationale; locate the constants
RELOAD_TIMEOUT and RETRYABLE_RELOAD_TIMEOUT in local-merge.test.ts and either
restore their original values or remove them from this branch before merging.

@sunnylqm sunnylqm merged commit b5881f1 into master Apr 27, 2026
6 checks passed
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.

1 participant