Organize uploader storage and restore transfer readiness
This commit is contained in:
@@ -52,6 +52,16 @@ try {
|
||||
const original = navigator.geolocation.getCurrentPosition.bind(navigator.geolocation);
|
||||
navigator.geolocation.getCurrentPosition = (...args) => {
|
||||
window.__geoCalls++;
|
||||
if (window.__holdGeo) {
|
||||
const [success, failure, options] = args;
|
||||
return original(
|
||||
(position) => {
|
||||
window.__releaseGeo = () => success(position);
|
||||
},
|
||||
failure,
|
||||
options,
|
||||
);
|
||||
}
|
||||
return original(...args);
|
||||
};
|
||||
});
|
||||
@@ -104,6 +114,50 @@ try {
|
||||
document.dispatchEvent(new Event('visibilitychange'));
|
||||
});
|
||||
await sender.locator('.peer-card').first().waitFor();
|
||||
// A native file picker hides the page. Sending immediately on return must wait for
|
||||
// the fresh location acknowledgement, without a failed first request or lost files.
|
||||
await sender.locator('.peer-card').first().click();
|
||||
await sender.evaluate(() => {
|
||||
window.__holdGeo = true;
|
||||
window.__geoVisible = false;
|
||||
document.dispatchEvent(new Event('visibilitychange'));
|
||||
});
|
||||
await receiver.locator('button.peer-card').waitFor({ state: 'hidden' });
|
||||
await sender
|
||||
.locator('.send-dialog input[type="file"]')
|
||||
.setInputFiles({
|
||||
name: 'picker.txt',
|
||||
mimeType: 'text/plain',
|
||||
buffer: Buffer.from('file picker return'),
|
||||
});
|
||||
await sender.evaluate(() => {
|
||||
window.__geoVisible = true;
|
||||
document.dispatchEvent(new Event('visibilitychange'));
|
||||
});
|
||||
await sender.waitForFunction(() => Boolean(window.__releaseGeo));
|
||||
let transferPosts = 0;
|
||||
const countTransfer = (request) => {
|
||||
if (request.method() === 'POST' && new URL(request.url()).pathname === '/api/transfer-requests')
|
||||
transferPosts++;
|
||||
};
|
||||
sender.on('request', countTransfer);
|
||||
await sender.getByRole('button', { name: '전송하기', exact: true }).click();
|
||||
await sender.waitForTimeout(250);
|
||||
assert.equal(transferPosts, 0, '위치 복귀 전 요청을 보내지 않음');
|
||||
assert.equal(await sender.locator('.error-toast').count(), 0, '첫 전송 오류 없음');
|
||||
assert.match(await sender.locator('.selected-files').innerText(), /picker.txt/);
|
||||
await sender.evaluate(() => {
|
||||
window.__holdGeo = false;
|
||||
window.__releaseGeo();
|
||||
delete window.__releaseGeo;
|
||||
});
|
||||
await receiver.getByRole('button', { name: '수락', exact: true }).waitFor();
|
||||
const pickedDownload = receiver.waitForEvent('download');
|
||||
await receiver.getByRole('button', { name: '수락', exact: true }).click();
|
||||
assert.equal((await pickedDownload).suggestedFilename(), 'picker.txt');
|
||||
assert.equal(transferPosts, 1, '파일 요청은 한 번만 생성');
|
||||
sender.off('request', countTransfer);
|
||||
await sender.locator('.send-dialog').waitFor({ state: 'hidden' });
|
||||
await b.route('https://example.com/**', (route) =>
|
||||
route.fulfill({ status: 200, contentType: 'text/html', body: '<title>Nearby link</title>' }),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user