Add subscription info refresh endpoint and UI stats

This commit is contained in:
2026-07-11 09:49:55 +03:00
parent 6bc7840fb1
commit 99f7f58fcb
8 changed files with 521 additions and 40 deletions

View File

@@ -6,6 +6,8 @@ import {
formatConnectionDuration,
localProxyUrls,
subscriptionDomain,
subscriptionDaysLeft,
subscriptionUsage,
} from '../../src/web/utils/clientControls.js';
test('connection button chooses the only valid client action', () => {
@@ -44,3 +46,21 @@ test('local proxy defaults to the macOS client port', () => {
http: 'http://127.0.0.1:8082',
});
});
test('subscription usage combines traffic and caps progress', () => {
assert.deepEqual(subscriptionUsage({ upload: 30, download: 80, total: 100, expire: 2 }), {
upload: 30,
download: 80,
total: 100,
used: 110,
percent: 100,
expiresAt: new Date(2000),
});
});
test('subscription expiry uses Russian day forms', () => {
const now = Date.parse('2026-07-11T00:00:00Z');
assert.equal(subscriptionDaysLeft(new Date('2026-07-12T00:00:00Z'), now), 'остался 1 день');
assert.equal(subscriptionDaysLeft(new Date('2026-07-13T00:00:00Z'), now), 'осталось 2 дня');
assert.equal(subscriptionDaysLeft(new Date('2026-07-16T00:00:00Z'), now), 'осталось 5 дней');
});