fix(updates): compare prerelease versions correctly (#1220)
Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
eb3f0e7f72
commit
0cfa37932e
@@ -34,14 +34,16 @@ function createFetchMock() {
|
||||
|
||||
describe('checkForUpdates', () => {
|
||||
let fetchMock;
|
||||
let originalFetch;
|
||||
|
||||
beforeEach(() => {
|
||||
fetchMock = createFetchMock();
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
originalFetch = globalThis.fetch;
|
||||
globalThis.fetch = fetchMock;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
globalThis.fetch = originalFetch;
|
||||
});
|
||||
|
||||
// --- Scenario: API says update available, npm confirms ---
|
||||
@@ -98,6 +100,21 @@ describe('checkForUpdates', () => {
|
||||
expect(result.available).toBe(false);
|
||||
});
|
||||
|
||||
it('returns available=false when npm only has a prerelease of the current version', async () => {
|
||||
fetchMock
|
||||
.when('api.openchamber.dev', Promise.reject(new Error('Network error')))
|
||||
.when('registry.npmjs.org', {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
'dist-tags': { latest: '1.10.0-beta.1' },
|
||||
}),
|
||||
});
|
||||
|
||||
const result = await checkForUpdates({ currentVersion: '1.10.0' });
|
||||
|
||||
expect(result.available).toBe(false);
|
||||
});
|
||||
|
||||
it('does not cross-check desktop update claims against npm', async () => {
|
||||
fetchMock
|
||||
.when('api.openchamber.dev', {
|
||||
|
||||
Reference in New Issue
Block a user