9d65dd12be
Build and Push Docker Image / build (push) Successful in 2m10s
- clickable error count in header shows file names + error messages - inbox sort dropdown (scan time / name, asc / desc) - inbox movies no longer minimal (show available badges) - stop buttons use solid danger style, descriptive labels (Stop Scan, Stop Job, Stop Sorting) - double checkmarks overlap like WhatsApp read receipts - processInbox logs start/completion to stdout for Docker visibility - fix byTitle in language-resolver test, bump to 2026.04.21.1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import { Database } from "bun:sqlite";
|
|
import { describe, expect, test } from "bun:test";
|
|
import { SCHEMA } from "../../db/schema";
|
|
import { enqueueAudioJob } from "../review";
|
|
|
|
function makeDb(): Database {
|
|
const db = new Database(":memory:");
|
|
for (const stmt of SCHEMA.split(";")) {
|
|
const trimmed = stmt.trim();
|
|
if (trimmed) db.run(trimmed);
|
|
}
|
|
db.prepare("INSERT INTO media_items (id, type, name, file_path) VALUES (?, 'Movie', 'T', '/x.mkv')").run(1);
|
|
return db;
|
|
}
|
|
|
|
describe("enqueueAudioJob dedup", () => {
|
|
test("inserts a job when none exists", () => {
|
|
const db = makeDb();
|
|
expect(enqueueAudioJob(db, 1, "ffmpeg a")).toBe(true);
|
|
const { n } = db.prepare("SELECT COUNT(*) as n FROM jobs WHERE item_id = 1").get() as { n: number };
|
|
expect(n).toBe(1);
|
|
});
|
|
|
|
test("no-ops when a pending job already exists", () => {
|
|
const db = makeDb();
|
|
enqueueAudioJob(db, 1, "ffmpeg a");
|
|
expect(enqueueAudioJob(db, 1, "ffmpeg b")).toBe(false);
|
|
expect(enqueueAudioJob(db, 1, "ffmpeg c")).toBe(false);
|
|
const rows = db.prepare("SELECT command FROM jobs WHERE item_id = 1").all() as { command: string }[];
|
|
expect(rows.length).toBe(1);
|
|
expect(rows[0].command).toBe("ffmpeg a");
|
|
});
|
|
|
|
test("allows a new pending job once the previous one is done or errored", () => {
|
|
const db = makeDb();
|
|
enqueueAudioJob(db, 1, "ffmpeg a");
|
|
db.prepare("UPDATE jobs SET status = 'done' WHERE item_id = 1").run();
|
|
expect(enqueueAudioJob(db, 1, "ffmpeg b")).toBe(true);
|
|
|
|
db.prepare("UPDATE jobs SET status = 'error' WHERE command = 'ffmpeg b'").run();
|
|
expect(enqueueAudioJob(db, 1, "ffmpeg c")).toBe(true);
|
|
|
|
const pending = db.prepare("SELECT COUNT(*) as n FROM jobs WHERE item_id = 1 AND status = 'pending'").get() as {
|
|
n: number;
|
|
};
|
|
expect(pending.n).toBe(1);
|
|
});
|
|
});
|