WIP improve UX [snapshot task 2]

This commit is contained in:
Schluffe committed 2026-10-16 15:39:31 +02:00
1 parent 3ae47dde8e
commit cd66321ea6
13 files changed
+703 -87

No files matched your search

+60 -8
View File
@@ -167,11 +167,14 @@ try {
const downloads = join(profile, 'downloads');
await mkdir(downloads);
await call('Browser.setDownloadBehavior', { behavior: 'allow', downloadPath: downloads });
const sender = await page();
const sender = await page(), receiver = await page();
await click(receiver, 'Receive');
for (const size of [0, 1024 * 1024 + 7, 120 * 1024 * 1024]) {
const receiver = await page();
await click(receiver, 'Receive');
await connect(sender, receiver, size);
if (size === 0) await connect(sender, receiver, size);
else {
await evaluate(sender, (size: number) => window.__hellcon.chooseFile(size, 'browser-test.bin'), size);
await wait(receiver, () => !!document.querySelector('.incoming'));
}
assert.equal(await evaluate(receiver, () => typeof window.showSaveFilePicker), 'undefined');
await click(receiver, `Receive as download (${size === 0 ? '0 B' : (size / 1024 ** 2).toFixed(1) + ' MiB'})`);
await wait(sender, () => window.__hellcon.element('[role=status]').textContent?.includes('confirmed the complete file'));
@@ -190,7 +193,6 @@ try {
}
assert.equal(bytes, size);
await rm(destination);
await click(sender, 'Reset');
console.log(`PASS: hosted app streams ${size} bytes to a real browser download without the native save picker; exact file bytes verified.`);
}
assert.deepEqual(browserErrors, []);
@@ -246,6 +248,53 @@ try {
assert.doesNotMatch(diagnostics, /browser-test\.bin|a=candidate:|a=ice-pwd:|a=fingerprint:|\.local\b/);
console.log('PASS: real two-page WebRTC flow; full fingerprints; no metadata before both confirmations; exact file and receipt.');
console.log('PASS: invalid offers can be replaced; invalid answers can be corrected without losing the live offer.');
const originalFingerprints = await evaluate(sender, () => [...document.querySelectorAll('.fp-row code')].map(e => e.textContent));
for (const size of [0, 4097]) {
const previousDownload = await evaluate(receiver, () => window.__hellcon.element<HTMLAnchorElement>('a.download').href);
await evaluate(sender, (size: number) => window.__hellcon.chooseFile(size, 'another.bin'), size);
await wait(receiver, () => !!document.querySelector('.incoming'));
assert.equal(await evaluate(receiver, () => window.__hellcon.element<HTMLAnchorElement>('a.download').href), previousDownload);
assert.equal(await evaluate(sender, () => window.__hellcon.element('[role=status]').textContent), 'Waiting for the receiver to accept the file…');
assert.deepEqual(await evaluate(sender, () => [...document.querySelectorAll('.fp-row code')].map(e => e.textContent)), originalFingerprints);
await click(receiver, 'Receive in memory (up to 64 MiB)');
await wait(sender, () => window.__hellcon.element('[role=status]').textContent?.includes('confirmed the complete file'));
const next = await evaluate(receiver, async () => {
const link = window.__hellcon.element<HTMLAnchorElement>('a.download');
const bytes = new Uint8Array(await (await fetch(link.href)).arrayBuffer());
return { name: link.download, length: bytes.length, valid: bytes.every(byte => byte === 123) };
});
assert.deepEqual(next, { name: 'another.bin', length: size, valid: true });
}
console.log('PASS: consecutive files including an empty file reuse fingerprints, require acceptance, and preserve the previous download until acceptance.');
// Queue two files and send back simultaneously, on the same peer connection.
await evaluate(sender, () => {
const input = window.__hellcon.element<HTMLInputElement>('#file-input');
const files = new DataTransfer();
for (const name of ['decline-me.bin', 'queued.bin', 'remove-me.bin']) files.items.add(new File([new Uint8Array(1024).fill(123)], name));
input.files = files.files; input.dispatchEvent(new Event('change', { bubbles: true }));
});
await evaluate(sender, () => window.__hellcon.element<HTMLButtonElement>('button[aria-label="Remove remove-me.bin"]').click());
await evaluate(receiver, () => window.__hellcon.chooseFile(8193, 'return.bin'));
await wait(sender, () => !!document.querySelector('.incoming'));
await wait(receiver, () => !!document.querySelector('.incoming'));
await click(receiver, 'Decline file');
await wait(receiver, () => document.querySelector('.incoming')?.textContent?.includes('queued.bin'));
await click(sender, 'Receive in memory (up to 64 MiB)');
await click(receiver, 'Receive in memory (up to 64 MiB)');
await wait(sender, () => document.querySelector<HTMLAnchorElement>('a.download')?.download === 'return.bin');
await wait(receiver, () => document.querySelector<HTMLAnchorElement>('a.download')?.download === 'queued.bin');
for (const [session, size] of [[sender, 8193], [receiver, 1024]] as const) {
const received = await evaluate(session, async () => {
const bytes = new Uint8Array(await (await fetch(window.__hellcon.element<HTMLAnchorElement>('a.download').href)).arrayBuffer());
return { length: bytes.length, valid: bytes.every(byte => byte === 123) };
});
assert.deepEqual(received, { length: size, valid: true });
await checkAccessibility(session, 'Bidirectional session');
}
assert.equal(await evaluate(sender, () => [...document.querySelectorAll('.tabs button')].every(button => (button as HTMLButtonElement).disabled)), true);
assert.deepEqual(await evaluate(sender, () => [...document.querySelectorAll('.fp-row code')].map(e => e.textContent)), originalFingerprints);
console.log('PASS: simultaneous bidirectional transfers, multiple-file queue, removal, decline, exact bytes, and locked setup tabs.');
await click(sender, 'Reset'); await click(receiver, 'Reset');
assert.equal(await evaluate(sender, () => window.__hellcon.element('[role=status]').textContent), 'Choose a file to start.');
assert.equal(await evaluate(receiver, () => window.__hellcon.element('[role=status]').textContent), 'Paste the sender’s connection code to start.');
@@ -254,14 +303,17 @@ try {
await connect(sender, receiver, 2 * 1024 * 1024);
await click(receiver, 'Choose destination & receive to disk');
await wait(receiver, () => !!window.__hellcon.releaseWrite);
await click(sender, 'Receive');
await evaluate(sender, () => window.__hellcon.chooseFile(1024, 'pending-at-disconnect.bin'));
assert.equal(await evaluate(sender, () => !!document.querySelector('ul[aria-label="Files waiting to send"]')), true);
await click(sender, 'Disconnect');
assert.equal(await evaluate(sender, () => !!document.querySelector('ul[aria-label="Files waiting to send"]')), false);
await wait(receiver, () => window.__hellcon.aborted);
assert.equal(await evaluate(receiver, () => !!document.querySelector('a.download')), false);
await wait(receiver, () => window.__hellcon.element<HTMLTextAreaElement>('#connection-diagnostics').value.includes('pairs='));
assert.match(await evaluate(receiver, () => window.__hellcon.element<HTMLTextAreaElement>('#connection-diagnostics').value), /session failed/);
console.log('PASS: privacy-safe candidate/check diagnostics remain available after completion and failure.');
console.log('PASS: switching away from Send closes the connection and aborts the receiver’s pending disk write.');
await click(sender, 'Send'); await click(receiver, 'Reset');
console.log('PASS: Disconnect closes the connection and aborts the receiver’s pending disk write.');
await click(sender, 'Reset'); await click(receiver, 'Reset');
await connect(sender, receiver, 2048);
await click(receiver, 'Receive in memory (up to 64 MiB)');
await wait(sender, () => window.__hellcon.element('[role=status]').textContent?.includes('confirmed the complete file'));
+1
View File
@@ -53,6 +53,7 @@ try {
if(bytes.length!==2*1024*1024+7||!bytes.every(b=>b===123))throw new Error('File content mismatch');
}else{
await stage('waiting for receipt');await wait(()=>element('[role=status]').textContent?.includes('confirmed the complete file'));
click('Disconnect');
}
await post(role+'Result',{ok:true});
}catch(error){