Open History to see the last commit
1import { EnvironmentId, ThreadId } from "@v12/contracts";
2import { describe, expect, it } from "vite-plus/test";
3
4import {
5 buildThreadTerminalAttachInput,
6 threadTerminalSubscriptionKey,
7 type ThreadTerminalSubscriptionIdentity,
8} from "./threadTerminalPanelModel";
9
10const identity: ThreadTerminalSubscriptionIdentity = {
11 environmentId: EnvironmentId.make("env-1"),
12 threadId: ThreadId.make("thread-1"),
13 terminalId: "default",
14 cwd: "/repo",
15 worktreePath: "/repo",
16};
17
18describe("threadTerminalSubscriptionKey", () => {
19 it("does not include mutable terminal dimensions", () => {
20 const initialAttach = buildThreadTerminalAttachInput(identity, { cols: 80, rows: 24 });
21 const resizedAttach = buildThreadTerminalAttachInput(identity, { cols: 132, rows: 40 });
22
23 expect(initialAttach).not.toEqual(resizedAttach);
24 expect(threadTerminalSubscriptionKey({ ...identity, ...initialAttach })).toBe(
25 threadTerminalSubscriptionKey({ ...identity, ...resizedAttach }),
26 );
27 });
28
29 it.each([
30 ["environment", { environmentId: EnvironmentId.make("env-2") }],
31 ["thread", { threadId: ThreadId.make("thread-2") }],
32 ["terminal", { terminalId: "term-2" }],
33 ["cwd", { cwd: "/repo/packages/app" }],
34 ["worktree", { worktreePath: "/repo/worktrees/feature" }],
35 ])("changes when the %s identity changes", (_label, update) => {
36 expect(threadTerminalSubscriptionKey({ ...identity, ...update })).not.toBe(
37 threadTerminalSubscriptionKey(identity),
38 );
39 });
40});