mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-11-04 08:10:28 +09:00
형식이 잘못된 세션 쿠키로 인해 서버 오류가 발생하던 문제와 업로드 중 오류가 무시되거나 무한히 대기하던 문제 등 버그 수정
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bb0328b39e
commit
9119c21881
11 files changed
+161
-77
No files matched your search
@@ -0,0 +1,56 @@
|
||||
import axios from "axios";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { uploadBlob } from "#lib/client/transfer/chunked-upload.ts";
|
||||
import { generateDataKey } from "#lib/shared/crypto/index.ts";
|
||||
import { CHUNK_SIZE } from "#lib/shared/format/index.ts";
|
||||
|
||||
vi.mock("axios", () => ({ default: { post: vi.fn() } }));
|
||||
|
||||
const post = vi.mocked(axios.post);
|
||||
|
||||
const createBlob = (chunks: number) => new Blob([new Uint8Array((chunks - 1) * CHUNK_SIZE + 1)]);
|
||||
|
||||
beforeEach(() => {
|
||||
post.mockReset();
|
||||
post.mockResolvedValue({});
|
||||
});
|
||||
|
||||
describe("uploadBlob", () => {
|
||||
it("uploads every chunk", async () => {
|
||||
const { dataKey } = await generateDataKey();
|
||||
|
||||
const { encContentHash } = await uploadBlob("upload", createBlob(3), dataKey);
|
||||
|
||||
expect(encContentHash).toBeTruthy();
|
||||
expect(post.mock.calls.map(([url]) => url).sort()).toEqual([
|
||||
"/api/upload/upload/chunks/1",
|
||||
"/api/upload/upload/chunks/2",
|
||||
"/api/upload/upload/chunks/3",
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects if encryption fails", async () => {
|
||||
const { dataKey } = await generateDataKey();
|
||||
const error = new Error("Encryption failed");
|
||||
|
||||
await expect(
|
||||
uploadBlob("upload", createBlob(2), dataKey, {
|
||||
onPlaintextChunk: async (chunkIndex) => {
|
||||
if (chunkIndex === 1) throw error;
|
||||
},
|
||||
}),
|
||||
).rejects.toBe(error);
|
||||
});
|
||||
|
||||
it("rejects if uploading a chunk fails", async () => {
|
||||
const { dataKey } = await generateDataKey();
|
||||
const error = new Error("Upload failed");
|
||||
post.mockImplementation(async (url) => {
|
||||
if (url.endsWith("/2")) throw error;
|
||||
return {};
|
||||
});
|
||||
|
||||
// More chunks than the queue can hold, so that the producer would block if not stopped
|
||||
await expect(uploadBlob("upload", createBlob(16), dataKey)).rejects.toBe(error);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user