Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a15e72178e |
No files matched your search
@@ -174,20 +174,20 @@ it("continues to step3 while sample GET is pending without calling completion AP
|
|||||||
expect(screen.queryByText(/^已生成.*记忆/)).toBeNull();
|
expect(screen.queryByText(/^已生成.*记忆/)).toBeNull();
|
||||||
});
|
});
|
||||||
it.each([
|
it.each([
|
||||||
"pending",
|
["pending", "已扫描 100 条,正在筛选"],
|
||||||
"paused",
|
["paused", "已扫描 100 条,尚未保存"],
|
||||||
"interrupted",
|
["interrupted", "已扫描 100 条,尚未保存"],
|
||||||
"failed",
|
["failed", "已扫描 100 条,尚未保存"],
|
||||||
"cancelled",
|
["cancelled", "已扫描 100 条,尚未保存"],
|
||||||
"completed",
|
["completed", "已扫描 100 条,本次没有可保存的对话"],
|
||||||
] as const)(
|
] as const)(
|
||||||
"shows %s without mutating jobs or fetching missing content",
|
"shows %s without mutating jobs or fetching missing content",
|
||||||
(status) => {
|
(status, expected) => {
|
||||||
setup({
|
setup({
|
||||||
jobs: [{ ...job, status, stored: 0 }],
|
jobs: [{ ...job, status, stored: 0 }],
|
||||||
sources: [{ ...source, imported_messages: 0 }],
|
sources: [{ ...source, imported_messages: 0 }],
|
||||||
});
|
});
|
||||||
expect(screen.getByText("已扫描 100 条,正在保存")).toBeTruthy();
|
expect(screen.getByText(expected)).toBeTruthy();
|
||||||
expect(api.receipt).not.toHaveBeenCalled();
|
expect(api.receipt).not.toHaveBeenCalled();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -38,6 +38,71 @@ it("uses the selected job's message count, never the source total or fake percen
|
|||||||
expect(container.textContent).not.toContain("%");
|
expect(container.textContent).not.toContain("%");
|
||||||
expect(container.textContent).not.toContain("持续导入中");
|
expect(container.textContent).not.toContain("持续导入中");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not describe scanned-but-skipped history as saved", () => {
|
||||||
|
const { container } = render(
|
||||||
|
<R6ImportProgress
|
||||||
|
sourceIds={["cursor"]}
|
||||||
|
sources={[source]}
|
||||||
|
jobs={[
|
||||||
|
{
|
||||||
|
...job,
|
||||||
|
status: "completed",
|
||||||
|
discovered: 12_375,
|
||||||
|
stored: 0,
|
||||||
|
skipped: 12_375,
|
||||||
|
history_after: "2026-10-15T00:00:00Z",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
screen.getByText("已扫描 12,375 条,本次没有符合时间范围的对话"),
|
||||||
|
).toBeTruthy();
|
||||||
|
expect(screen.getByText("导入完成")).toBeTruthy();
|
||||||
|
expect(container.textContent).not.toContain("正在保存");
|
||||||
|
expect(container.textContent).not.toContain("已保存 12,375");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("calls an active bounded scan filtering rather than saving", () => {
|
||||||
|
render(
|
||||||
|
<R6ImportProgress
|
||||||
|
sourceIds={["cursor"]}
|
||||||
|
sources={[source]}
|
||||||
|
jobs={[
|
||||||
|
{
|
||||||
|
...job,
|
||||||
|
discovered: 3_522,
|
||||||
|
stored: 0,
|
||||||
|
history_after: "2026-10-15T00:00:00Z",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
expect(screen.getByText("已扫描 3,522 条,正在筛选最近 3 天")).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reports only stored rows as saved after a completed partial import", () => {
|
||||||
|
const { container } = render(
|
||||||
|
<R6ImportProgress
|
||||||
|
sourceIds={["cursor"]}
|
||||||
|
sources={[source]}
|
||||||
|
jobs={[
|
||||||
|
{
|
||||||
|
...job,
|
||||||
|
status: "completed",
|
||||||
|
discovered: 25_177,
|
||||||
|
stored: 20_826,
|
||||||
|
skipped: 4_351,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
expect(screen.getByText("已保存 20,826 条消息")).toBeTruthy();
|
||||||
|
expect(screen.getByText("导入完成")).toBeTruthy();
|
||||||
|
expect(container.textContent).not.toContain("25,177");
|
||||||
|
});
|
||||||
|
|
||||||
it.each(["paused", "interrupted", "failed", "completed", "cancelled"] as const)(
|
it.each(["paused", "interrupted", "failed", "completed", "cancelled"] as const)(
|
||||||
"does not animate %s as active work",
|
"does not animate %s as active work",
|
||||||
(status) => {
|
(status) => {
|
||||||
|
|||||||
@@ -3,6 +3,21 @@ import { useEffect, useLayoutEffect, useRef } from "react";
|
|||||||
import { AppMark } from "./app-mark";
|
import { AppMark } from "./app-mark";
|
||||||
import "./r6-import-progress.css";
|
import "./r6-import-progress.css";
|
||||||
|
|
||||||
|
function progressText(job: ImportJob): string | null {
|
||||||
|
if (job.stored > 0) return `已保存 ${job.stored.toLocaleString()} 条消息`;
|
||||||
|
if (job.discovered <= 0) return null;
|
||||||
|
const scanned = `已扫描 ${job.discovered.toLocaleString()} 条`;
|
||||||
|
if (job.status === "completed")
|
||||||
|
return job.history_after
|
||||||
|
? `${scanned},本次没有符合时间范围的对话`
|
||||||
|
: `${scanned},本次没有可保存的对话`;
|
||||||
|
if (job.status === "pending" || job.status === "running")
|
||||||
|
return job.history_after
|
||||||
|
? `${scanned},正在筛选最近 3 天`
|
||||||
|
: `${scanned},正在筛选`;
|
||||||
|
return `${scanned},尚未保存`;
|
||||||
|
}
|
||||||
|
|
||||||
export function R6ImportProgress({
|
export function R6ImportProgress({
|
||||||
sourceIds,
|
sourceIds,
|
||||||
sources,
|
sources,
|
||||||
@@ -86,8 +101,9 @@ export function R6ImportProgress({
|
|||||||
interrupted: "已中断",
|
interrupted: "已中断",
|
||||||
failed: "导入遇到问题",
|
failed: "导入遇到问题",
|
||||||
cancelled: "已取消",
|
cancelled: "已取消",
|
||||||
completed: "已保存",
|
completed: "导入完成",
|
||||||
};
|
};
|
||||||
|
const progress = job ? progressText(job) : null;
|
||||||
return (
|
return (
|
||||||
<article
|
<article
|
||||||
className="r6-import-progress-card"
|
className="r6-import-progress-card"
|
||||||
@@ -102,10 +118,8 @@ export function R6ImportProgress({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h2>{source?.display_name ?? id}</h2>
|
<h2>{source?.display_name ?? id}</h2>
|
||||||
{job && job.stored > 0 ? (
|
{progress ? (
|
||||||
<p>{`已保存 ${job.stored.toLocaleString()} 条消息`}</p>
|
<p>{progress}</p>
|
||||||
) : job && job.discovered > 0 ? (
|
|
||||||
<p>{`已扫描 ${job.discovered.toLocaleString()} 条,正在保存`}</p>
|
|
||||||
) : noImportedHistory ? (
|
) : noImportedHistory ? (
|
||||||
<p>没有可保存的历史对话</p>
|
<p>没有可保存的历史对话</p>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
Reference in new issue
Block a user