Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example/e2etest/e2e/local-merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
LOCAL_UPDATE_LABELS,
} from './localUpdateConfig.ts';

const RELOAD_TIMEOUT = 180000;
const RETRYABLE_RELOAD_TIMEOUT = 45000;
const RELOAD_TIMEOUT = 300000;
const RETRYABLE_RELOAD_TIMEOUT = 90000;
Comment on lines +7 to +8
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.

const MARK_SUCCESS_TIMEOUT = 30000;
const MARK_SUCCESS_SETTLE_MS = 1500;
const DOWNLOAD_SUCCESS_TIMEOUT = 120000;
Expand Down
24 changes: 23 additions & 1 deletion src/__tests__/endpoint.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, mock, test } from 'bun:test';
import { executeEndpointFallback } from '../endpoint';
import { executeEndpointFallback, dedupeEndpoints } from '../endpoint';

const delay = (ms: number) =>
new Promise<void>(resolve => {
Expand Down Expand Up @@ -90,3 +90,25 @@ describe('executeEndpointFallback', () => {
expect(tryEndpoint.mock.calls.map(call => call[0])).toEqual(['a', 'b', 'c']);
});
});

describe('dedupeEndpoints', () => {
test('removes duplicate endpoints', () => {
const result = dedupeEndpoints(['a', 'b', 'a', 'c', 'b']);
expect(result).toEqual(['a', 'b', 'c']);
});

test('preserves the original order of the first occurrence', () => {
const result = dedupeEndpoints(['c', 'b', 'a', 'c', 'd', 'b']);
expect(result).toEqual(['c', 'b', 'a', 'd']);
});

test('filters out falsy values', () => {
const result = dedupeEndpoints(['a', null, 'b', undefined, '', 'c']);
expect(result).toEqual(['a', 'b', 'c']);
});

test('returns an empty array when given an empty array', () => {
const result = dedupeEndpoints([]);
expect(result).toEqual([]);
});
});