diff --git a/tests/test_upload_layer2.test.mjs b/tests/test_upload_layer2.test.mjs index 8febfea..847be0c 100644 --- a/tests/test_upload_layer2.test.mjs +++ b/tests/test_upload_layer2.test.mjs @@ -231,3 +231,32 @@ test('uploadViaVM: прерывание через signal', async () => { assert.equal(res.ok, false); assert.equal(res.aborted, true); }); + +test('uploadViaVM: отмена после первого файла не начинает второй PUT', async () => { + installFetch(async (url, opts) => ({ + ok: true, + json: async () => ({ ok: true, session: 'partial-sid', count: 1 }), + })); + + const ac = new AbortController(); + const statuses = []; + const files = [new File(['first'], 'first.txt'), new File(['second'], 'second.txt')]; + const p = uploadViaVM(files, { + vmUploadUrl: 'https://vm-buffer/upload/', + signal: ac.signal, + onFileStatus: (idx, status) => statuses.push({ idx, status }), + }); + + await tick(); + assert.equal(lastXHR.url.endsWith('_0'), true); + lastXHR.status = 201; + lastXHR.onload(); + ac.abort(); + const res = await p; + + assert.equal(res.ok, false); + assert.equal(res.aborted, true); + assert.equal(fetchCalls.length, 1); + assert.equal(lastXHR.url.endsWith('_0'), true); + assert.ok(statuses.some(({ idx, status }) => idx === 0 && status.includes('Доставлен'))); +});