Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions src/downshift.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,22 @@ function createContext(usage: {
const status = vi.fn();
const select = vi.fn();
const input = vi.fn();
const notify = vi.fn();
const ctx = {
hasUI: true,
getContextUsage: () => usage.current,
ui: {
setStatus: status,
select,
input,
notify: vi.fn(),
notify,
},
};
return {
commandContext: ctx as unknown as ExtensionCommandContext,
context: ctx as unknown as ExtensionContext,
input,
notify,
select,
status,
};
Expand Down Expand Up @@ -123,7 +125,7 @@ describe("downshift lifecycle adapter", () => {
expect(handlers.has("thinking_level_select")).toBe(true);
});

it("refreshes status immediately after saving configuration", async () => {
it("opens configuration for the bare command", async () => {
const usage = { current: { tokens: 100, percent: 10 } };
const { commands } = createExtension();
const { commandContext, select, input, status } = createContext(usage);
Expand All @@ -144,4 +146,39 @@ describe("downshift lifecycle adapter", () => {
status.mock.invocationCallOrder[0],
);
});

it("warns with help for the unsupported config subcommand", async () => {
const { commands } = createExtension();
const { commandContext, notify } = createContext({
current: { tokens: 100, percent: 10 },
});

await commands.get("downshift")?.("config", commandContext);

expect(notify).toHaveBeenCalledWith(
expect.stringContaining("/downshift - configure Downshift"),
"warning",
);
expect(fsMocks.writeFile).not.toHaveBeenCalled();
});

it("does not advertise the unsupported config subcommand in help or status", async () => {
const { commands } = createExtension();
const { commandContext, notify } = createContext({
current: { tokens: 100, percent: 10 },
});

await commands.get("downshift")?.("help", commandContext);
expect(notify).toHaveBeenCalledWith(
expect.not.stringContaining("/downshift config"),
"info",
);

notify.mockClear();
await commands.get("downshift")?.("status", commandContext);
expect(notify).toHaveBeenCalledWith(
expect.not.stringContaining("/downshift config"),
"info",
);
});
});
2 changes: 1 addition & 1 deletion src/downshift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ const STATUS_LINE_BUILDERS: Array<
(config) => `upshift: ${yesNoMode(config?.upshiftAfterCompaction, "on")}`,
(config) => `source: ${config?.premiumSource ?? "current"}`,
() => `version: ${VERSION}`,
() => `commands: /downshift status | now | config | on | off | help`,
() => `commands: /downshift | status | now | on | off | help`,
];

function formatOptionalRemaining(
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"noEmit": true,
"types": ["node", "vitest/globals"]
},
"include": ["downshift.ts", "src/**/*.ts"]
"include": ["index.ts", "src/**/*.ts"]
}
Loading