|
1 | 1 | import { beforeEach, describe, expect, it, vi } from "vite-plus/test"; |
2 | | -import { |
3 | | - COMPOSER_CONTEXT_MAX_RECORDS, |
4 | | - ComposerContextId, |
5 | | - EnvironmentId, |
6 | | - ThreadId, |
7 | | -} from "@t3tools/contracts"; |
| 2 | +import { ComposerContextId, EnvironmentId } from "@t3tools/contracts"; |
8 | 3 | import { encodeComposerContextFragment } from "@t3tools/shared/composerContextClipboard"; |
9 | 4 |
|
10 | 5 | const mocks = vi.hoisted(() => ({ |
@@ -147,55 +142,6 @@ describe("mobile context clipboard imports", () => { |
147 | 142 | expect(mocks.download).not.toHaveBeenCalled(); |
148 | 143 | }); |
149 | 144 |
|
150 | | - const thread = (id: string, environmentId: string) => ({ |
151 | | - version: 1 as const, |
152 | | - kind: "thread" as const, |
153 | | - contextId: ComposerContextId.make(id), |
154 | | - label: id, |
155 | | - environmentId: EnvironmentId.make(environmentId), |
156 | | - threadId: ThreadId.make(id), |
157 | | - title: id, |
158 | | - }); |
159 | | - |
160 | | - it("drops threads owned by another machine than the destination", async () => { |
161 | | - const result = await importComposerContextClipboard( |
162 | | - { |
163 | | - text: "[local](t3-context://v1/thread/local) [foreign](t3-context://v1/thread/foreign)", |
164 | | - fragment: encodeComposerContextFragment({ |
165 | | - version: 1, |
166 | | - source: { environmentId: EnvironmentId.make("source") }, |
167 | | - records: [thread("local", "destination"), thread("foreign", "source")], |
168 | | - })!, |
169 | | - html: "", |
170 | | - }, |
171 | | - 0, |
172 | | - new AbortController().signal, |
173 | | - // Only one slot is free: the dropped thread must not count against it. |
174 | | - COMPOSER_CONTEXT_MAX_RECORDS - 1, |
175 | | - EnvironmentId.make("destination"), |
176 | | - ); |
177 | | - expect(result?.context.records.map((record) => record.label)).toEqual(["local"]); |
178 | | - expect(result?.skippedThreads).toEqual(["foreign"]); |
179 | | - }); |
180 | | - |
181 | | - it("keeps threads when the destination machine is unknown", async () => { |
182 | | - const result = await importComposerContextClipboard( |
183 | | - { |
184 | | - text: "[foreign](t3-context://v1/thread/foreign)", |
185 | | - fragment: encodeComposerContextFragment({ |
186 | | - version: 1, |
187 | | - source: { environmentId: EnvironmentId.make("source") }, |
188 | | - records: [thread("foreign", "source")], |
189 | | - })!, |
190 | | - html: "", |
191 | | - }, |
192 | | - 0, |
193 | | - new AbortController().signal, |
194 | | - ); |
195 | | - expect(result?.context.records.map((record) => record.label)).toEqual(["foreign"]); |
196 | | - expect(result?.skippedThreads).toEqual([]); |
197 | | - }); |
198 | | - |
199 | 145 | it("refuses an overflowing context paste before copying files", async () => { |
200 | 146 | await expect( |
201 | 147 | importComposerContextClipboard(clipboard, 0, new AbortController().signal, 200), |
|
0 commit comments