fix(downloads): show — instead of 待整理 for unorganized external tasks (DL-2b)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
3f1c4d6c3b
commit
f0c2c79785
3 files changed
+28
-11
No files matched your search
@@ -27,14 +27,14 @@ describe("下载面板展示换算(DL-2)", () => {
|
||||
|
||||
it("最近一次整理结果:已入库 / 整理中 / 待整理 / 入库失败 / 部分入库;有待处理事项时链到待处理", () => {
|
||||
expect(organizeState({ status: "completed", organize: null })).toMatchObject({ label: "待整理", to: null });
|
||||
expect(organizeState({ status: "importing", organize: null }).label).toBe("整理中");
|
||||
expect(organizeState({ status: "imported", organize: null }).label).toBe("已入库");
|
||||
expect(organizeState({ status: "importing", organize: null })?.label).toBe("整理中");
|
||||
expect(organizeState({ status: "imported", organize: null })?.label).toBe("已入库");
|
||||
expect(organizeState({ status: "completed", organize: rec("succeeded") })).toMatchObject({
|
||||
label: "已入库",
|
||||
tone: "success",
|
||||
to: `/console/organize/${RID}`,
|
||||
});
|
||||
expect(organizeState({ status: "completed", organize: rec("running") }).label).toBe("整理中");
|
||||
expect(organizeState({ status: "completed", organize: rec("running") })?.label).toBe("整理中");
|
||||
const failed = organizeState({
|
||||
status: "completed",
|
||||
organize: rec("failed", {
|
||||
@@ -48,20 +48,20 @@ describe("下载面板展示换算(DL-2)", () => {
|
||||
tone: "destructive",
|
||||
hint: "没识别出作品。指定作品后重新整理",
|
||||
});
|
||||
expect(failed.to).toBe("/console/inbox?kind=identity_unresolved");
|
||||
expect(organizeState({ status: "completed", organize: rec("failed", { reason: "磁盘已满" }) }).hint).toBe(
|
||||
expect(failed?.to).toBe("/console/inbox?kind=identity_unresolved");
|
||||
expect(organizeState({ status: "completed", organize: rec("failed", { reason: "磁盘已满" }) })?.hint).toBe(
|
||||
"磁盘已满",
|
||||
);
|
||||
expect(organizeState({ status: "completed", organize: rec("partial") }).label).toBe("部分入库");
|
||||
expect(organizeState({ status: "completed", organize: rec("failed", { reason: "transfer_failed" }) }).hint).toBe(
|
||||
expect(organizeState({ status: "completed", organize: rec("partial") })?.label).toBe("部分入库");
|
||||
expect(organizeState({ status: "completed", organize: rec("failed", { reason: "transfer_failed" }) })?.hint).toBe(
|
||||
"文件没有整理成功。在整理记录里查看失败的文件",
|
||||
);
|
||||
expect(
|
||||
organizeState({ status: "completed", organize: rec("partial", { reason: "blocked:target_exists" }) }).hint,
|
||||
organizeState({ status: "completed", organize: rec("partial", { reason: "blocked:target_exists" }) })?.hint,
|
||||
).toBe("媒体库里已有同名文件。在待处理里选择替换或跳过");
|
||||
// 不认识的码不显示
|
||||
expect(
|
||||
organizeState({ status: "completed", organize: rec("failed", { reason: "some_new_code" }) }).hint,
|
||||
organizeState({ status: "completed", organize: rec("failed", { reason: "some_new_code" }) })?.hint,
|
||||
).toBeNull();
|
||||
expect(organizeState({ status: "completed", organize: rec("cancelled") })).toMatchObject({
|
||||
label: "待整理",
|
||||
@@ -69,6 +69,16 @@ describe("下载面板展示换算(DL-2)", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("外部任务:没整理过显示 —(null),整理过的照常显示结果", () => {
|
||||
expect(organizeState({ status: "completed", organize: null, managed: false })).toBeNull();
|
||||
expect(organizeState({ status: "completed", organize: null, managed: true })?.label).toBe("待整理");
|
||||
expect(organizeState({ status: "completed", organize: rec("succeeded"), managed: false })?.label).toBe("已入库");
|
||||
expect(
|
||||
organizeState({ status: "completed", organize: rec("failed", { reason: "transfer_failed" }), managed: false })
|
||||
?.label,
|
||||
).toBe("入库失败");
|
||||
});
|
||||
|
||||
it("连接数:全 0 且总数未知时不显示", () => {
|
||||
const base = {
|
||||
dlSpeed: 0,
|
||||
|
||||
@@ -39,9 +39,15 @@ export function reasonHint(raw: string | null | undefined): string | null {
|
||||
return reasonLine(raw, "") || null;
|
||||
}
|
||||
|
||||
/** 已完成任务的最近一次整理结果:已入库 / 整理中 / 待整理 / 入库失败 / 部分入库 */
|
||||
export function organizeState(t: Pick<DownloadBoardItem, "status" | "organize">): OrganizeState {
|
||||
/**
|
||||
* 已完成任务的最近一次整理结果:已入库 / 整理中 / 待整理 / 入库失败 / 部分入库。
|
||||
* 外部任务(managed=false)没整理过时不算"待整理",返回 null(界面显示 —);整理过的照常显示结果。
|
||||
*/
|
||||
export function organizeState(
|
||||
t: Pick<DownloadBoardItem, "status" | "organize"> & { managed?: boolean },
|
||||
): OrganizeState | null {
|
||||
const rec = t.organize;
|
||||
if (t.managed === false && !rec && t.status !== "importing" && t.status !== "imported") return null;
|
||||
const to = rec?.decision
|
||||
? `${consolePath("inbox")}?kind=${rec.decision.kind}`
|
||||
: rec
|
||||
|
||||
@@ -195,6 +195,7 @@ export function activeColumns(): DataColumn<DownloadBoardItem>[] {
|
||||
|
||||
function OrganizeBadge({ t }: { t: DownloadBoardItem }) {
|
||||
const s = organizeState(t);
|
||||
if (!s) return <span className="text-meta text-muted-foreground">—</span>;
|
||||
const badge = <StatusBadge tone={s.tone}>{s.label}</StatusBadge>;
|
||||
return (
|
||||
<div className="flex max-w-56 flex-col items-start gap-0.5">
|
||||
|
||||
Reference in new issue
Block a user