Add shareable invitation links II

This commit is contained in:
Schluffe committed 2026-10-19 23:09:18 +02:00
1 parent 43ee7f119f
commit 019267cc34
4 files changed
+92 -37

No files matched your search

+39
View File
@@ -151,12 +151,30 @@ const enableTurn = (session: string) => evaluate(session, () => {
const checkbox = window.__hellcon.element<HTMLInputElement>('.checkbox input');
if (!checkbox.checked) checkbox.click();
});
let checkedCodeLayout = false;
async function connect(sender: string, receiver: string, size: number, changedIdentity = false) {
await evaluate(sender, (size: number) => window.__hellcon.chooseFile(size, 'browser-test.bin'), size);
await input(sender, '#stun-provider', provider);
await input(receiver, '#stun-provider', provider);
if (turn) { await enableTurn(sender); await enableTurn(receiver); }
await click(sender, 'Create code'); await wait(sender, () => !!document.querySelector('#output-code'));
if (!checkedCodeLayout) {
const layout = await evaluate(sender, () => {
const details = window.__hellcon.element<HTMLDetailsElement>('.code-details');
const closedByDefault = !details.open;
details.open = true;
const code = window.__hellcon.element<HTMLTextAreaElement>('#output-code').getBoundingClientRect();
const copy = window.__hellcon.element<HTMLButtonElement>('.code-entry button').getBoundingClientRect();
const answer = window.__hellcon.element<HTMLTextAreaElement>('#answer-input').getBoundingClientRect();
const connect = window.__hellcon.element<HTMLButtonElement>('#answer-input + button').getBoundingClientRect();
details.open = false;
return { closedByDefault, codeGap: copy.top - code.bottom, answerGap: connect.top - answer.bottom, codeWidth: code.width, answerWidth: answer.width };
});
assert.equal(layout.closedByDefault, true, 'Code alternative starts collapsed');
assert.ok(Math.abs(layout.codeGap - layout.answerGap) < 1, 'Code and answer buttons have matching spacing');
assert.ok(Math.abs(layout.codeWidth - layout.answerWidth) < 1, 'Code and answer fields have matching width');
checkedCodeLayout = true;
}
const offer = await evaluate(sender, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
assert.ok(offer.startsWith(CODE_PREFIX));
await input(receiver, '#offer-input', 'invalid-code!');
@@ -227,6 +245,9 @@ try {
}, name);
await call('Emulation.setDeviceMetricsOverride', { width: 1440, height: 1000, deviceScaleFactor: 1, mobile: false }, sender);
assert.equal(await evaluate(sender, () => document.querySelector('.title-line h1')?.textContent), 'Con 1');
assert.deepEqual(await evaluate(sender, () => [...document.querySelectorAll<HTMLDetailsElement>('.config-details')].map(details => [details.querySelector('summary')?.textContent?.trim(), details.open])), [
['Remembered device', false], ['Network settings', false],
], 'Configuration panels start closed');
await checkAccessibility(sender, 'Connections desktop');
await screenshot(sender, 'connections-desktop');
await evaluate(sender, () => window.__hellcon.element<HTMLInputElement>('#connection-name').focus());
@@ -582,6 +603,24 @@ try {
await click(identitySender, 'Create code'); await wait(identitySender, () => !!document.querySelector('#output-code'));
const offer = await evaluate(identitySender, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
assert.ok((await decodeCode(offer)).identity);
// Another receiver tab whose current slot is a new one: the invitation still
// suggests the slot paired with the sender's device, and Open hands it there.
const invitedPaired = await page(receiverOrigin);
await click(invitedPaired, 'Add connection');
await wait(invitedPaired, () => document.querySelector('.title-line h1')?.textContent === 'Con 2');
await evaluate(invitedPaired, (code: string) => { location.hash = code; }, offer);
await wait(invitedPaired, () => document.querySelector('dialog[open]')?.textContent?.includes('Invitation to receive files'));
assert.match(await dialogText(invitedPaired), /matches the paired device of Con 1/);
assert.equal(await evaluate(invitedPaired, () => window.__hellcon.element<HTMLSelectElement>('#invitation-target').selectedOptions[0]?.textContent?.trim()), 'Con 1 · paired device');
await click(invitedPaired, 'Open'); await wait(invitedPaired, () => !document.querySelector('dialog[open]'));
assert.equal(await evaluate(invitedPaired, () => document.querySelector('.title-line h1')?.textContent), 'Con 1');
assert.equal(await evaluate(invitedPaired, () => window.__hellcon.element<HTMLTextAreaElement>('#offer-input').value), offer);
await evaluate(invitedPaired, () => [...document.querySelectorAll<HTMLButtonElement>('.connection-link')].find(item => item.querySelector('.connection-name')?.textContent === 'Con 2')?.click());
await wait(invitedPaired, () => document.querySelector('.title-line h1')?.textContent === 'Con 2');
await click(invitedPaired, 'Remove'); await click(invitedPaired, 'Remove connection');
await wait(invitedPaired, () => document.querySelectorAll('.connection-link').length === 1);
await closePage(invitedPaired);
console.log('PASS: an invitation from a paired device suggests its slot over the current one and hands the code to it.');
await input(identityReceiver, '#offer-input', offer); await click(identityReceiver, 'Accept & create answer');
await wait(identityReceiver, () => !!document.querySelector('#output-code'));
const answer = await evaluate(identityReceiver, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);