Files
paseo/packages/app/src/composer/draft/workspace-tab.test.ts
T
paseo-bot[bot]andIvan Malison 60fa12c4de Report disconnected hosts in new agent drafts (#7303)
* fix(app): report offline hosts in new agent drafts

A disconnected client still exists, and pending form resolution and retained loading catalogs outlive the connection. Use host connection state for draft readiness and model loading while keeping known models available for reconnect.

Co-authored-by: Ivan Malison <IvanMalison@gmail.com>

* test(app): confirm draft recovery on a fresh host connection

---------

Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
Co-authored-by: Ivan Malison <IvanMalison@gmail.com>
2026-10-18 11:57:41 +02:00

86 lines
2.2 KiB
TypeScript

import { describe, expect, test } from "vitest";
import { shouldAllowEmptyDraftText, validateDraftSubmission } from "./workspace-tab-core";
const baseComposerState = {
providerDefinitions: [{ id: "codewhale" }],
selectedProvider: "codewhale",
isModelLoading: false,
effectiveModelId: "",
availableModels: [],
};
function validate(overrides = {}) {
return validateDraftSubmission({
text: "hello",
allowsEmptyAutoSubmit: false,
composerState: baseComposerState,
autoSubmitConfig: null,
workspaceDirectory: "/tmp/project",
isConnected: true,
...overrides,
});
}
describe("workspace draft agent model validation", () => {
test("reports an offline host before an absent catalog or pending model defaults", () => {
expect(
validate({
isConnected: false,
composerState: {
...baseComposerState,
providerDefinitions: [],
selectedProvider: null,
isModelLoading: true,
},
}),
).toBe("Host is not connected");
});
test("allows a ready provider with no models to submit without a selected model", () => {
expect(validate({})).toBeNull();
});
test("keeps waiting while model defaults are loading", () => {
expect(
validate({
composerState: {
...baseComposerState,
isModelLoading: true,
},
}),
).toBe("Model defaults are still loading");
});
test("still requires a selected model when the provider exposes models", () => {
expect(
validate({
composerState: {
...baseComposerState,
availableModels: [{ id: "deepseek/deepseek-v4-pro" }],
},
}),
).toBe("No model is available for the selected provider");
});
});
describe("workspace draft empty text readiness", () => {
test("allows attachment-only retries after a fork draft create fails", () => {
expect(
shouldAllowEmptyDraftText({
allowsEmptyAutoSubmit: false,
attachments: [{ kind: "chat_history" }],
}),
).toBe(true);
});
test("still rejects empty drafts with no auto-submit and no attachments", () => {
expect(
shouldAllowEmptyDraftText({
allowsEmptyAutoSubmit: false,
attachments: [],
}),
).toBe(false);
});
});