chore(format): run prettier over src/ and scripts/

Formatting was configured but never enforced: `bun run format:check`
reported 199 unformatted files and ran in no workflow and in no git hook,
so .prettierrc (printWidth 100, trailing commas) described an intention
rather than the tree.

This is the one-time sweep that makes the check gateable. Whitespace and
token-reflow only -- no behavioural change: `bun run check` reports 0
errors and all 1053 frontend tests pass before and after.

Kept out of every other commit on purpose. A 199-file diff mixed with
real changes is unreviewable, and the next commit turns format:check
into a hard CI gate so this cannot silently accumulate again.
This commit is contained in:
2026-08-21 17:41:44 +02:00
parent d095e1f410
commit ad48d89dfe
199 changed files with 4698 additions and 3453 deletions
+104 -46
View File
@@ -24,10 +24,12 @@ describe("downloads store", () => {
mockInvoke.mockReset();
// Capture the event handler when listen is called
mockListen.mockImplementation((_event: string, handler: (event: { payload: unknown }) => void) => {
eventHandler = handler;
return Promise.resolve(() => {});
});
mockListen.mockImplementation(
(_event: string, handler: (event: { payload: unknown }) => void) => {
eventHandler = handler;
return Promise.resolve(() => {});
},
);
});
afterEach(async () => {
@@ -76,7 +78,7 @@ describe("downloads store", () => {
"user-1",
"/path/to/file.mp3",
"audio/mpeg",
10
10,
);
expect(mockInvoke).toHaveBeenCalledWith("download_item", {
@@ -98,34 +100,32 @@ describe("downloads store", () => {
it("should refresh downloads after queuing", async () => {
const { downloads } = await import("./downloads");
mockInvoke
.mockResolvedValueOnce(123)
.mockResolvedValueOnce({
downloads: [
{
id: 123,
itemId: "item-1",
userId: "user-1",
filePath: "/path/to/file.mp3",
status: "pending",
progress: 0,
bytesDownloaded: 0,
queuedAt: "2024-01-01T00:00:00Z",
retryCount: 0,
priority: 10,
mediaType: "audio",
downloadSource: "user",
},
],
stats: {
total: 1,
activeCount: 0,
queuedCount: 1,
completedCount: 0,
failedCount: 0,
pausedCount: 0,
mockInvoke.mockResolvedValueOnce(123).mockResolvedValueOnce({
downloads: [
{
id: 123,
itemId: "item-1",
userId: "user-1",
filePath: "/path/to/file.mp3",
status: "pending",
progress: 0,
bytesDownloaded: 0,
queuedAt: "2024-01-01T00:00:00Z",
retryCount: 0,
priority: 10,
mediaType: "audio",
downloadSource: "user",
},
});
],
stats: {
total: 1,
activeCount: 0,
queuedCount: 1,
completedCount: 0,
failedCount: 0,
pausedCount: 0,
},
});
await downloads.downloadItem("item-1", "user-1", "/path/to/file.mp3");
@@ -315,18 +315,76 @@ describe("downloads store", () => {
// `transfers` derivation: active + pending + failed.
// TRACES: UR-055 | DR-084 | UT-052
it("transfers set excludes completed downloads", async () => {
const { downloads, activeDownloads, pendingDownloads, failedDownloads } = await import(
"./downloads"
);
const { downloads, activeDownloads, pendingDownloads, failedDownloads } =
await import("./downloads");
mockInvoke.mockResolvedValueOnce({
downloads: [
{ id: 1, itemId: "a", userId: "u", filePath: "/a", status: "downloading", progress: 0.5, bytesDownloaded: 5, queuedAt: "t", retryCount: 0, priority: 0, mediaType: "audio", downloadSource: "user" },
{ id: 2, itemId: "b", userId: "u", filePath: "/b", status: "pending", progress: 0, bytesDownloaded: 0, queuedAt: "t", retryCount: 0, priority: 0, mediaType: "audio", downloadSource: "user" },
{ id: 3, itemId: "c", userId: "u", filePath: "/c", status: "completed", progress: 1, bytesDownloaded: 9, queuedAt: "t", retryCount: 0, priority: 0, mediaType: "audio", downloadSource: "user" },
{ id: 4, itemId: "d", userId: "u", filePath: "/d", status: "failed", progress: 0, bytesDownloaded: 0, queuedAt: "t", retryCount: 1, priority: 0, mediaType: "audio", downloadSource: "user" },
{
id: 1,
itemId: "a",
userId: "u",
filePath: "/a",
status: "downloading",
progress: 0.5,
bytesDownloaded: 5,
queuedAt: "t",
retryCount: 0,
priority: 0,
mediaType: "audio",
downloadSource: "user",
},
{
id: 2,
itemId: "b",
userId: "u",
filePath: "/b",
status: "pending",
progress: 0,
bytesDownloaded: 0,
queuedAt: "t",
retryCount: 0,
priority: 0,
mediaType: "audio",
downloadSource: "user",
},
{
id: 3,
itemId: "c",
userId: "u",
filePath: "/c",
status: "completed",
progress: 1,
bytesDownloaded: 9,
queuedAt: "t",
retryCount: 0,
priority: 0,
mediaType: "audio",
downloadSource: "user",
},
{
id: 4,
itemId: "d",
userId: "u",
filePath: "/d",
status: "failed",
progress: 0,
bytesDownloaded: 0,
queuedAt: "t",
retryCount: 1,
priority: 0,
mediaType: "audio",
downloadSource: "user",
},
],
stats: { total: 4, activeCount: 1, queuedCount: 1, completedCount: 1, failedCount: 1, pausedCount: 0 },
stats: {
total: 4,
activeCount: 1,
queuedCount: 1,
completedCount: 1,
failedCount: 1,
pausedCount: 0,
},
});
await downloads.refresh("u");
@@ -920,9 +978,9 @@ describe("downloads store", () => {
return Promise.reject(new Error(`Unexpected command: ${command}`));
});
await expect(
downloads.downloadItem("item-1", "user-1", "/path/to/file.mp3")
).rejects.toThrow("Backend error: failed to queue download");
await expect(downloads.downloadItem("item-1", "user-1", "/path/to/file.mp3")).rejects.toThrow(
"Backend error: failed to queue download",
);
});
it("should throw error when refresh fails", async () => {
@@ -935,9 +993,9 @@ describe("downloads store", () => {
return Promise.reject(new Error(`Unexpected command: ${command}`));
});
await expect(
downloads.refresh("user-1")
).rejects.toThrow("Backend error: failed to fetch downloads");
await expect(downloads.refresh("user-1")).rejects.toThrow(
"Backend error: failed to fetch downloads",
);
});
});
});