

























@@ -57,79 +57,86 @@ describe.each(storeFactories)("msteams conversation store ($name)", ({ createSto
5757it("upserts, lists, removes, and resolves users by both AAD and Bot Framework ids", async () => {
5858const store = await createStore();
595960-await store.upsert("conv-a", {
61-conversation: { id: "conv-a" },
62-channelId: "msteams",
63-serviceUrl: "https://service.example.com",
64-user: { id: "user-a", aadObjectId: "aad-a", name: "Alice" },
65-});
60+vi.useFakeTimers();
61+try {
62+vi.setSystemTime(new Date("2026-03-25T20:00:00.000Z"));
63+await store.upsert("conv-a", {
64+conversation: { id: "conv-a" },
65+channelId: "msteams",
66+serviceUrl: "https://service.example.com",
67+user: { id: "user-a", aadObjectId: "aad-a", name: "Alice" },
68+});
666967-await store.upsert("conv-b", {
68-conversation: { id: "conv-b" },
69-channelId: "msteams",
70-serviceUrl: "https://service.example.com",
71-user: { id: "user-b", aadObjectId: "aad-b", name: "Bob" },
72-});
70+vi.setSystemTime(new Date("2026-03-25T20:00:30.000Z"));
71+await store.upsert("conv-b", {
72+conversation: { id: "conv-b" },
73+channelId: "msteams",
74+serviceUrl: "https://service.example.com",
75+user: { id: "user-b", aadObjectId: "aad-b", name: "Bob" },
76+});
737774-await expect(store.get("conv-a")).resolves.toEqual({
75-conversation: { id: "conv-a" },
76-channelId: "msteams",
77-serviceUrl: "https://service.example.com",
78-user: { id: "user-a", aadObjectId: "aad-a", name: "Alice" },
79-lastSeenAt: expect.any(String),
80-});
78+ await expect(store.get("conv-a")).resolves.toEqual({
79+ conversation: { id: "conv-a" },
80+ channelId: "msteams",
81+ serviceUrl: "https://service.example.com",
82+ user: { id: "user-a", aadObjectId: "aad-a", name: "Alice" },
83+ lastSeenAt: "2026-03-25T20:00:00.000Z",
84+ });
818582-await expect(store.list()).resolves.toEqual([
83-{
84-conversationId: "conv-a",
85-reference: {
86-conversation: { id: "conv-a" },
87-channelId: "msteams",
88-serviceUrl: "https://service.example.com",
89-user: { id: "user-a", aadObjectId: "aad-a", name: "Alice" },
90-lastSeenAt: expect.any(String),
86+await expect(store.list()).resolves.toEqual([
87+{
88+conversationId: "conv-a",
89+reference: {
90+conversation: { id: "conv-a" },
91+channelId: "msteams",
92+serviceUrl: "https://service.example.com",
93+user: { id: "user-a", aadObjectId: "aad-a", name: "Alice" },
94+lastSeenAt: "2026-03-25T20:00:00.000Z",
95+},
96+},
97+{
98+conversationId: "conv-b",
99+reference: {
100+conversation: { id: "conv-b" },
101+channelId: "msteams",
102+serviceUrl: "https://service.example.com",
103+user: { id: "user-b", aadObjectId: "aad-b", name: "Bob" },
104+lastSeenAt: "2026-03-25T20:00:30.000Z",
105+},
91106},
92-},
93-{
107+]);
108+109+await expect(store.findPreferredDmByUserId(" aad-b ")).resolves.toEqual({
94110conversationId: "conv-b",
95111reference: {
96112conversation: { id: "conv-b" },
97113channelId: "msteams",
98114serviceUrl: "https://service.example.com",
99115user: { id: "user-b", aadObjectId: "aad-b", name: "Bob" },
100-lastSeenAt: expect.any(String),
116+lastSeenAt: "2026-03-25T20:00:30.000Z",
101117},
102-},
103-]);
104-105-await expect(store.findPreferredDmByUserId(" aad-b ")).resolves.toEqual({
106-conversationId: "conv-b",
107-reference: {
108-conversation: { id: "conv-b" },
109-channelId: "msteams",
110-serviceUrl: "https://service.example.com",
111-user: { id: "user-b", aadObjectId: "aad-b", name: "Bob" },
112-lastSeenAt: expect.any(String),
113-},
114-});
115-await expect(store.findPreferredDmByUserId("user-a")).resolves.toEqual({
116-conversationId: "conv-a",
117-reference: {
118-conversation: { id: "conv-a" },
119-channelId: "msteams",
120-serviceUrl: "https://service.example.com",
121-user: { id: "user-a", aadObjectId: "aad-a", name: "Alice" },
122-lastSeenAt: expect.any(String),
123-},
124-});
125-await expect(store.findByUserId("user-a")).resolves.toEqual(
126-await store.findPreferredDmByUserId("user-a"),
127-);
128-await expect(store.findPreferredDmByUserId(" ")).resolves.toBeNull();
129-130-await expect(store.remove("conv-a")).resolves.toBe(true);
131-await expect(store.get("conv-a")).resolves.toBeNull();
132-await expect(store.remove("missing")).resolves.toBe(false);
118+});
119+await expect(store.findPreferredDmByUserId("user-a")).resolves.toEqual({
120+conversationId: "conv-a",
121+reference: {
122+conversation: { id: "conv-a" },
123+channelId: "msteams",
124+serviceUrl: "https://service.example.com",
125+user: { id: "user-a", aadObjectId: "aad-a", name: "Alice" },
126+lastSeenAt: "2026-03-25T20:00:00.000Z",
127+},
128+});
129+await expect(store.findByUserId("user-a")).resolves.toEqual(
130+await store.findPreferredDmByUserId("user-a"),
131+);
132+await expect(store.findPreferredDmByUserId(" ")).resolves.toBeNull();
133+134+await expect(store.remove("conv-a")).resolves.toBe(true);
135+await expect(store.get("conv-a")).resolves.toBeNull();
136+await expect(store.remove("missing")).resolves.toBe(false);
137+} finally {
138+vi.useRealTimers();
139+}
133140});
134141135142it("preserves existing timezone when upsert omits timezone", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。