Open History to see the last commit
1import { EnvironmentId } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3
4import {
5 canUseMarkdownFileShellActions,
6 shouldUseMarkdownFileBrowserPrimaryAction,
7} from "./ChatMarkdown";
8
9describe("canUseMarkdownFileShellActions", () => {
10 const environmentId = EnvironmentId.make("environment-1");
11
12 it("allows editor and file manager actions only for resolved local environments", () => {
13 expect(canUseMarkdownFileShellActions(environmentId, "local-exec", true)).toBe(true);
14 expect(canUseMarkdownFileShellActions(environmentId, "local-exec", false)).toBe(false);
15 expect(canUseMarkdownFileShellActions(environmentId, "remote-links", true)).toBe(false);
16 expect(canUseMarkdownFileShellActions(environmentId, "remote-unavailable", true)).toBe(false);
17 expect(canUseMarkdownFileShellActions(null, "local-exec", true)).toBe(false);
18 });
19});
20
21describe("shouldUseMarkdownFileBrowserPrimaryAction", () => {
22 const html = { iconPath: "/tmp/report.html", canOpenInBrowser: true };
23
24 it("uses the browser only when it is the sole action, except for PDFs", () => {
25 expect(
26 shouldUseMarkdownFileBrowserPrimaryAction({
27 ...html,
28 canOpenInEditor: false,
29 canOpenInPanel: false,
30 }),
31 ).toBe(true);
32 expect(
33 shouldUseMarkdownFileBrowserPrimaryAction({
34 ...html,
35 canOpenInEditor: true,
36 canOpenInPanel: false,
37 }),
38 ).toBe(false);
39 expect(
40 shouldUseMarkdownFileBrowserPrimaryAction({
41 ...html,
42 canOpenInEditor: false,
43 canOpenInPanel: true,
44 }),
45 ).toBe(false);
46 expect(
47 shouldUseMarkdownFileBrowserPrimaryAction({
48 iconPath: "/tmp/report.pdf",
49 canOpenInEditor: true,
50 canOpenInBrowser: true,
51 canOpenInPanel: true,
52 }),
53 ).toBe(true);
54 });
55});