|
1 | 1 | import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "@workflow/serde"; |
2 | 2 | import { afterEach, beforeEach, describe, expect, it } from "vitest"; |
| 3 | +import { ChannelImpl, type SerializedChannel } from "./channel"; |
3 | 4 | import { Chat } from "./chat"; |
4 | 5 | import { clearChatSingleton } from "./chat-singleton"; |
5 | 6 | import { Message, type SerializedMessage } from "./message"; |
@@ -827,6 +828,43 @@ describe("Serialization", () => { |
827 | 828 | expect(parsed.text).toBe("Direct usage"); |
828 | 829 | expect(parsed.metadata.dateSent).toBeInstanceOf(Date); |
829 | 830 | }); |
| 831 | + |
| 832 | + it("should allow re-serialization of a revived Thread without singleton", () => { |
| 833 | + const json: SerializedThread = { |
| 834 | + _type: "chat:Thread", |
| 835 | + id: "slack:C123:1234.5678", |
| 836 | + channelId: "C123", |
| 837 | + isDM: false, |
| 838 | + adapterName: "slack", |
| 839 | + }; |
| 840 | + |
| 841 | + clearChatSingleton(); |
| 842 | + |
| 843 | + const thread = ThreadImpl.fromJSON(json); |
| 844 | + const reserialized = thread.toJSON(); |
| 845 | + |
| 846 | + expect(reserialized._type).toBe("chat:Thread"); |
| 847 | + expect(reserialized.adapterName).toBe("slack"); |
| 848 | + expect(reserialized.id).toBe("slack:C123:1234.5678"); |
| 849 | + }); |
| 850 | + |
| 851 | + it("should allow re-serialization of a revived Channel without singleton", () => { |
| 852 | + const json: SerializedChannel = { |
| 853 | + _type: "chat:Channel", |
| 854 | + id: "C123", |
| 855 | + isDM: false, |
| 856 | + adapterName: "slack", |
| 857 | + }; |
| 858 | + |
| 859 | + clearChatSingleton(); |
| 860 | + |
| 861 | + const channel = ChannelImpl.fromJSON(json); |
| 862 | + const reserialized = channel.toJSON(); |
| 863 | + |
| 864 | + expect(reserialized._type).toBe("chat:Channel"); |
| 865 | + expect(reserialized.adapterName).toBe("slack"); |
| 866 | + expect(reserialized.id).toBe("C123"); |
| 867 | + }); |
830 | 868 | }); |
831 | 869 |
|
832 | 870 | describe("@workflow/serde integration", () => { |
|
0 commit comments