Show how a session is doing on the progress bar
Each side's bar now shows the session's phase by color and movement, with a short line below saying what is going on: a sweep while connecting, a pulse while someone has to act, a slow pink sweep while retrying after a failure (with the reason and the attempt), then the transfer, done, stopped or error. A receiver whose code no tracker knows says so right away instead of after 6 minutes, and a connection that fails though both sides have a public address names a blocking network as the likely reason. The log marks where each session starts. The send card names the session's file once another one is picked, and a blocked clipboard is shown inline with the text selected for copying by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
02668de602
commit
f7e8999439
4 files changed
+348
-67
No files matched your search
+57
@@ -324,6 +324,8 @@ async function connect(mode: string, sender: Page, receiver: Page, source: strin
|
||||
for (const page of [sender, receiver]) {
|
||||
await expect(page.locator('#log')).toContainText('waiting for the security check');
|
||||
}
|
||||
await expect(sender.locator('#send-status')).toHaveText('Compare the security codes above with the receiver');
|
||||
await expect(receiver.locator('#receive-status')).toHaveText('Compare the security codes above with the sender');
|
||||
}
|
||||
|
||||
// Resolves with the download, which starts once the receiver clicked Download, and the receiver log
|
||||
@@ -355,6 +357,8 @@ async function start(mode: string, sender: Page, receiver: Page, source: string)
|
||||
await expect(receiver.locator('#incoming')).toContainText(source.split('/').pop()!);
|
||||
await expect(sender.locator('#log')).toContainText('waiting for the receiver to download');
|
||||
await expect(receiver.locator('#log')).not.toContainText('receiving');
|
||||
await expect(sender.locator('[data-phase=wait] #send-status')).toHaveText('Waiting for the receiver to download');
|
||||
await expect(receiver.locator('[data-phase=wait] #receive-status')).toHaveText('Click Download to save the file');
|
||||
await receiver.click('#download');
|
||||
return started;
|
||||
}
|
||||
@@ -385,6 +389,8 @@ async function transfer(
|
||||
}
|
||||
await expect(sender.locator('#send-progress')).toHaveJSProperty('value', 100);
|
||||
await expect(receiver.locator('#receive-progress')).toHaveJSProperty('value', 100);
|
||||
await expect(sender.locator('[data-phase=done] #send-status')).toHaveText('Delivered');
|
||||
await expect(receiver.locator('[data-phase=done] #receive-status')).toHaveText('Download complete');
|
||||
// Removed hidden pages release the service worker for updates.
|
||||
await expect(receiver.locator('iframe')).toHaveCount(0);
|
||||
await expectClosed(sender);
|
||||
@@ -633,6 +639,7 @@ for (const name of Object.keys(BROWSERS)) {
|
||||
// A transfer that already finished would report no failure.
|
||||
expect(await download.failure()).toBe('canceled');
|
||||
await expect(receiver.locator('#log')).toContainText('download cancelled');
|
||||
await expect(receiver.locator('[data-phase=stopped] #receive-status')).toHaveText('Download cancelled');
|
||||
await expect(receiver.locator('iframe')).toHaveCount(0);
|
||||
expect(await log(receiver)).not.toContain('download complete');
|
||||
// The window keeps the sender from having sent everything before it hears about the cancel.
|
||||
@@ -665,9 +672,13 @@ for (const name of Object.keys(BROWSERS)) {
|
||||
await withLogs(sender, receiver, async () => {
|
||||
await start('offline', sender, receiver, source);
|
||||
await expect(sender.locator('#log')).toContainText('delivered');
|
||||
await expect(sender.locator('#send-file')).toHaveCount(0);
|
||||
const other = { name: 'other.bin', mimeType: 'application/octet-stream', buffer: Buffer.alloc(200_000) };
|
||||
await sender.setInputFiles('input[type=file]', other);
|
||||
await expect(sender.locator('#send-progress')).toHaveJSProperty('value', 100);
|
||||
// The status names the file it belongs to, not the one picked now.
|
||||
await expect(sender.locator('#send-file')).toHaveText('payload.bin');
|
||||
await expect(sender.locator('#send-status')).toHaveText('Delivered');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -713,6 +724,31 @@ for (const name of Object.keys(BROWSERS)) {
|
||||
});
|
||||
});
|
||||
|
||||
test(`copy: ${name} selects the text when the browser blocks the clipboard`, async () => {
|
||||
const sender = await open(name, {
|
||||
init: () => {
|
||||
navigator.clipboard.writeText = () => Promise.reject(new DOMException('blocked', 'NotAllowedError'));
|
||||
},
|
||||
});
|
||||
|
||||
await withLogs(sender, sender, async () => {
|
||||
await sender.uncheck('#stun');
|
||||
await sender.setInputFiles('input[type=file]', await payload(randomBytes(1000)));
|
||||
await sender.click('#send-manual summary');
|
||||
await sender.click('#create-offer');
|
||||
await expect(sender.locator('#offer')).toHaveValue(/.+/);
|
||||
await sender.click('#copy-offer');
|
||||
await expect(sender.locator('#copy-offer')).toHaveText('Copy failed');
|
||||
await expect(sender.locator('#send-manual [role=alert]')).toHaveText(
|
||||
'The browser blocked copying. The offer is selected, copy it yourself.',
|
||||
);
|
||||
const offer = sender.locator('#offer');
|
||||
expect(await offer.evaluate((area: HTMLTextAreaElement) => area.selectionEnd - area.selectionStart)).toBe(
|
||||
(await offer.inputValue()).length,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// Share, Receive and the manual exchange each start a session, a new one ends the one before.
|
||||
test(`session: ${name} a new operation ends the previous one`, async () => {
|
||||
const [sender, receiver] = await Promise.all([open(name), open(name)]);
|
||||
@@ -729,6 +765,11 @@ for (const name of Object.keys(BROWSERS)) {
|
||||
await receiver.fill('#receive-code', 'nobody');
|
||||
await receiver.click('#receive');
|
||||
await expect.poll(() => sockets.get(receiver)!.length).toBeGreaterThan(0);
|
||||
// The log tells the sessions apart.
|
||||
await expect(sender.locator('#log')).toContainText(
|
||||
/--- share payload\.bin via tracker ---[\s\S]*--- share payload/,
|
||||
);
|
||||
await expect(receiver.locator('#log')).toContainText('--- receive via tracker ---');
|
||||
|
||||
// Closes all of the above, transfer checks that.
|
||||
await transfer('offline', sender, receiver, source, 100_000);
|
||||
@@ -1062,6 +1103,15 @@ for (const name of Object.keys(BROWSERS)) {
|
||||
await expect(receiver.locator('#log')).toContainText(`looking on ${urls[2]}`);
|
||||
expect([trackers.sockets.length, trackers.open]).toEqual([3, 3]);
|
||||
await expect(receiver.locator('#receive-error')).toHaveCount(0);
|
||||
// None has it any more, the search goes on but says so.
|
||||
await expect(receiver.locator('[data-phase=retry] #receive-status')).toHaveText(
|
||||
'No sender with this code on any tracker. Check the code, still looking',
|
||||
);
|
||||
// A sender showed up, busy with another receiver maybe: the code was right.
|
||||
trackers.sockets[2]!.send(JSON.stringify({ action: 'announce', interval: 120, complete: 1 }));
|
||||
await expect(receiver.locator('[data-phase=wait] #receive-status')).toHaveText(
|
||||
'Found the share on three.test, waiting for the sender to answer',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1263,6 +1313,13 @@ for (const name of Object.keys(BROWSERS)) {
|
||||
await expect(receiver.locator('#log')).toContainText(
|
||||
`sender via ${tracker} did not connect: this side ${NO_PUBLIC}`,
|
||||
);
|
||||
// Both keep trying, and say why the last attempt failed.
|
||||
await expect(sender.locator('[data-phase=retry] #send-status')).toContainText(
|
||||
`could not connect to the receiver: the receiver ${NO_PUBLIC}`,
|
||||
);
|
||||
await expect(receiver.locator('[data-phase=retry] #receive-status')).toContainText(
|
||||
`could not connect to the sender: this side ${NO_PUBLIC}`,
|
||||
);
|
||||
// Then once more for the turn a new offer may have taken meanwhile.
|
||||
await fastForward('06:00');
|
||||
await fastForward(CONNECT_TIMEOUT);
|
||||
|
||||
Reference in new issue
Block a user