源码快照 @ 2026-09-02 (source-only, 剔除非源码素材)
This commit is contained in:
commit
04bac1f6e2
2200 files changed
+489415
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { expect } from "vitest";
|
||||
import { test } from "@openwork/testkit";
|
||||
import {
|
||||
dedupeSearchableSessions,
|
||||
searchableSessionKey,
|
||||
type SearchableSession,
|
||||
} from "../../apps/app/src/react-app/domains/session/search/session-search";
|
||||
|
||||
const session = (workspaceId: string, sessionId: string, updatedAt: number): SearchableSession => ({
|
||||
workspaceId,
|
||||
sessionId,
|
||||
title: `${workspaceId} ${sessionId} ${updatedAt}`,
|
||||
workspaceTitle: workspaceId,
|
||||
updatedAt,
|
||||
});
|
||||
|
||||
test("session search keeps one fresh result per workspace session", ({ evidence }) => {
|
||||
const stale = session("workspace-a", "session-1", 10);
|
||||
const fresh = session("workspace-a", "session-1", 20);
|
||||
const otherWorkspace = session("workspace-b", "session-1", 15);
|
||||
|
||||
const unique = dedupeSearchableSessions([stale, otherWorkspace, fresh]);
|
||||
|
||||
expect(unique).toEqual([fresh, otherWorkspace]);
|
||||
expect(unique.map(searchableSessionKey)).toEqual([
|
||||
"workspace-a\u0000session-1",
|
||||
"workspace-b\u0000session-1",
|
||||
]);
|
||||
expect(new Set(unique.map(searchableSessionKey)).size).toBe(unique.length);
|
||||
|
||||
evidence.recordAssertionEvidence(
|
||||
"Session search renders one result per workspace session identity",
|
||||
"Duplicate entries collapsed to the freshest record while an identical session id in another workspace remained distinct.",
|
||||
true,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user