Open History to see the last commit
1import { EnvironmentId } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3
4import { shouldShowOpenInPicker } from "./OpenInPicker.logic";
5
6describe("shouldShowOpenInPicker", () => {
7 const primaryEnvironmentId = EnvironmentId.make("environment-primary");
8
9 it("shows the picker for projects in the primary environment", () => {
10 expect(
11 shouldShowOpenInPicker({
12 activeProjectName: "codething-mvp",
13 activeThreadEnvironmentId: primaryEnvironmentId,
14 primaryEnvironmentId,
15 remoteOpenMode: "local-exec",
16 }),
17 ).toBe(true);
18 });
19
20 it("shows the picker for remote environments in deep-link mode", () => {
21 expect(
22 shouldShowOpenInPicker({
23 activeProjectName: "codething-mvp",
24 activeThreadEnvironmentId: EnvironmentId.make("environment-remote"),
25 primaryEnvironmentId,
26 remoteOpenMode: "remote-links",
27 }),
28 ).toBe(true);
29 });
30
31 it("shows the picker's unavailable state for remote environments without an SSH route", () => {
32 expect(
33 shouldShowOpenInPicker({
34 activeProjectName: "codething-mvp",
35 activeThreadEnvironmentId: EnvironmentId.make("environment-remote"),
36 primaryEnvironmentId: null,
37 remoteOpenMode: "remote-unavailable",
38 }),
39 ).toBe(true);
40 });
41
42 it("hides the picker for non-primary local backends", () => {
43 expect(
44 shouldShowOpenInPicker({
45 activeProjectName: "codething-mvp",
46 activeThreadEnvironmentId: EnvironmentId.make("environment-remote"),
47 primaryEnvironmentId,
48 remoteOpenMode: "local-exec",
49 }),
50 ).toBe(false);
51 });
52
53 it("hides the picker when there is no active project", () => {
54 expect(
55 shouldShowOpenInPicker({
56 activeProjectName: undefined,
57 activeThreadEnvironmentId: primaryEnvironmentId,
58 primaryEnvironmentId,
59 remoteOpenMode: "remote-links",
60 }),
61 ).toBe(false);
62 });
63});