Update VPN proxy client behavior
Build and Deploy Gateway / build-and-push (push) Successful in 18s
Build and Deploy Gateway / deploy (push) Successful in 13s

This commit is contained in:
2026-08-09 11:55:02 +03:00
parent 71ede44be0
commit 90433d7cd8
27 changed files with 770 additions and 254 deletions
+68
View File
@@ -93,6 +93,74 @@ test('copy uses the synchronous native path available on gateway HTTP', async ()
assert.equal(textarea.removed, true);
});
test('copy prefers the Clipboard API when it is available', async () => {
const writes = [];
let legacyCalls = 0;
await copyText('socks5://127.0.0.1:8082', {
clipboard: { writeText: async (text) => writes.push(text) },
documentRef: { execCommand: () => { legacyCalls += 1; } },
});
assert.deepEqual(writes, ['socks5://127.0.0.1:8082']);
assert.equal(legacyCalls, 0);
});
test('copy falls back after the Clipboard API rejects', async () => {
const textarea = {
style: {},
setAttribute() {},
select() {},
remove() { this.removed = true; },
};
const documentRef = {
body: { append() {} },
createElement: () => textarea,
execCommand: () => true,
};
await copyText('192.168.50.111', {
clipboard: { writeText: async () => { throw new Error('denied'); } },
documentRef,
});
assert.equal(textarea.removed, true);
});
test('copy rejects and removes the temporary textarea when the fallback fails', async () => {
const textarea = {
style: {},
setAttribute() {},
select() {},
remove() { this.removed = true; },
};
const documentRef = {
body: { append() {} },
createElement: () => textarea,
execCommand: () => false,
};
await assert.rejects(copyText('192.168.50.111', { documentRef }), /Copy failed/);
assert.equal(textarea.removed, true);
});
test('copy removes the temporary textarea when the fallback throws', async () => {
const textarea = {
style: {},
setAttribute() {},
select() {},
remove() { this.removed = true; },
};
const documentRef = {
body: { append() {} },
createElement: () => textarea,
execCommand: () => { throw new Error('legacy failed'); },
};
await assert.rejects(copyText('192.168.50.111', { documentRef }), /legacy failed/);
assert.equal(textarea.removed, true);
});
test('subscription usage combines traffic and caps progress', () => {
assert.deepEqual(subscriptionUsage({ upload: 30, download: 80, total: 100, expire: 2 }), {
upload: 30,