Refine subscription import and refresh flow
This commit is contained in:
@@ -4,7 +4,6 @@ import test from 'node:test';
|
||||
import {
|
||||
HarborApiError,
|
||||
request,
|
||||
validationStatusForError,
|
||||
} from '../../src/web/api.js';
|
||||
|
||||
const response = (status, error) => ({
|
||||
@@ -54,8 +53,3 @@ test('local unknown errors get a safe message and diagnostic reference', () => {
|
||||
assert.equal(typeof error.correlationId, 'string');
|
||||
assert.ok(error.correlationId.length >= 8);
|
||||
});
|
||||
|
||||
test('subscription validation distinguishes bad input from provider outage', () => {
|
||||
assert.equal(validationStatusForError({ code: 'SUBSCRIPTION_INVALID' }), 'invalid');
|
||||
assert.equal(validationStatusForError({ code: 'PROVIDER_UNAVAILABLE' }), 'unavailable');
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
copyText,
|
||||
formatConnectionDuration,
|
||||
formatConnectionDurationWords,
|
||||
isSubscriptionUrlValid,
|
||||
localProxyUrls,
|
||||
subscriptionDomain,
|
||||
subscriptionDaysLeft,
|
||||
@@ -44,6 +45,13 @@ test('saved subscription is reduced to its public domain', () => {
|
||||
assert.equal(subscriptionDomain(''), '');
|
||||
});
|
||||
|
||||
test('subscription URL is validated locally by shape', () => {
|
||||
assert.equal(isSubscriptionUrlValid(' https://sub.example/token '), true);
|
||||
assert.equal(isSubscriptionUrlValid('http://127.0.0.1/subscription'), true);
|
||||
assert.equal(isSubscriptionUrlValid('ftp://sub.example/token'), false);
|
||||
assert.equal(isSubscriptionUrlValid('not-a-url'), false);
|
||||
});
|
||||
|
||||
test('local proxy exposes both supported URLs', () => {
|
||||
assert.deepEqual(localProxyUrls(18080), {
|
||||
socks5: 'socks5://127.0.0.1:18080',
|
||||
|
||||
@@ -3,7 +3,6 @@ import http from 'node:http';
|
||||
import test from 'node:test';
|
||||
|
||||
import {
|
||||
createLatestRequest,
|
||||
createOperationRegistry,
|
||||
OPERATION_CONFLICTS,
|
||||
operationBlocked,
|
||||
@@ -72,22 +71,3 @@ test('a conflicting operation is rejected before its action starts', async () =>
|
||||
connection.resolve(true);
|
||||
await running;
|
||||
});
|
||||
|
||||
test('latest request cancels and ignores a stale validation result', async () => {
|
||||
const latest = createLatestRequest();
|
||||
const oldResult = deferred();
|
||||
const newResult = deferred();
|
||||
let oldSignal;
|
||||
|
||||
const oldRequest = latest.run((signal) => {
|
||||
oldSignal = signal;
|
||||
return oldResult.promise;
|
||||
});
|
||||
const newRequest = latest.run(() => newResult.promise);
|
||||
oldResult.resolve('old');
|
||||
newResult.resolve('new');
|
||||
|
||||
assert.equal(await oldRequest, undefined);
|
||||
assert.equal(await newRequest, 'new');
|
||||
assert.equal(oldSignal.aborted, true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user