mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: tighten messaging helper assertions
This commit is contained in:
@@ -71,7 +71,6 @@ describe("mattermost setup contract", () => {
|
|||||||
expectedAccountId: "default",
|
expectedAccountId: "default",
|
||||||
assertPatchedConfig: (cfg) => {
|
assertPatchedConfig: (cfg) => {
|
||||||
const mattermostConfig = cfg.channels?.mattermost;
|
const mattermostConfig = cfg.channels?.mattermost;
|
||||||
expect(mattermostConfig).toBeDefined();
|
|
||||||
if (!mattermostConfig) {
|
if (!mattermostConfig) {
|
||||||
throw new Error("expected Mattermost config patch");
|
throw new Error("expected Mattermost config patch");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,15 +31,18 @@ describe("mattermost doctor", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const mattermostConfig = result.config.channels?.mattermost;
|
const mattermostConfig = result.config.channels?.mattermost;
|
||||||
expect(mattermostConfig).toBeDefined();
|
|
||||||
if (!mattermostConfig) {
|
if (!mattermostConfig) {
|
||||||
throw new Error("expected normalized Mattermost config");
|
throw new Error("expected normalized Mattermost config");
|
||||||
}
|
}
|
||||||
expect(mattermostConfig.network).toEqual({
|
expect(mattermostConfig.network).toEqual({
|
||||||
dangerouslyAllowPrivateNetwork: true,
|
dangerouslyAllowPrivateNetwork: true,
|
||||||
});
|
});
|
||||||
const workAccount = mattermostConfig.accounts?.work as { network?: Record<string, unknown> };
|
const workAccount = mattermostConfig.accounts?.work as
|
||||||
expect(workAccount).toBeDefined();
|
| { network?: Record<string, unknown> }
|
||||||
|
| undefined;
|
||||||
|
if (!workAccount) {
|
||||||
|
throw new Error("expected Mattermost work account config");
|
||||||
|
}
|
||||||
expect(workAccount.network).toEqual({
|
expect(workAccount.network).toEqual({
|
||||||
dangerouslyAllowPrivateNetwork: false,
|
dangerouslyAllowPrivateNetwork: false,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -277,12 +277,10 @@ describe("updateMattermostPost", () => {
|
|||||||
const { calls } = await updatePostAndCapture({ message: "Updated" });
|
const { calls } = await updatePostAndCapture({ message: "Updated" });
|
||||||
|
|
||||||
const firstCall = calls[0];
|
const firstCall = calls[0];
|
||||||
expect(firstCall).toBeDefined();
|
|
||||||
if (!firstCall) {
|
if (!firstCall) {
|
||||||
throw new Error("expected Mattermost update post request");
|
throw new Error("expected Mattermost update post request");
|
||||||
}
|
}
|
||||||
expect(firstCall.url).toContain("/posts/post1");
|
expect(firstCall.url).toContain("/posts/post1");
|
||||||
expect(firstCall.init).toBeDefined();
|
|
||||||
if (!firstCall.init) {
|
if (!firstCall.init) {
|
||||||
throw new Error("expected Mattermost update post request init");
|
throw new Error("expected Mattermost update post request init");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,12 +60,10 @@ describe("Mattermost model picker", () => {
|
|||||||
expect(view.text).toContain("Browse keeps the current runtime");
|
expect(view.text).toContain("Browse keeps the current runtime");
|
||||||
expect(view.text).toContain("/oc_model <provider/model> --runtime <runtime>");
|
expect(view.text).toContain("/oc_model <provider/model> --runtime <runtime>");
|
||||||
const firstRow = view.buttons[0];
|
const firstRow = view.buttons[0];
|
||||||
expect(firstRow).toBeDefined();
|
|
||||||
if (!firstRow) {
|
if (!firstRow) {
|
||||||
throw new Error("expected Mattermost model picker button row");
|
throw new Error("expected Mattermost model picker button row");
|
||||||
}
|
}
|
||||||
const browseButton = firstRow[0];
|
const browseButton = firstRow[0];
|
||||||
expect(browseButton).toBeDefined();
|
|
||||||
if (!browseButton) {
|
if (!browseButton) {
|
||||||
throw new Error("expected Mattermost browse providers button");
|
throw new Error("expected Mattermost browse providers button");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ describe("slash-commands", () => {
|
|||||||
|
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
const firstCommand = result[0];
|
const firstCommand = result[0];
|
||||||
expect(firstCommand).toBeDefined();
|
|
||||||
if (!firstCommand) {
|
if (!firstCommand) {
|
||||||
throw new Error("expected Mattermost slash command result");
|
throw new Error("expected Mattermost slash command result");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,7 +392,6 @@ describe("mattermost setup", () => {
|
|||||||
);
|
);
|
||||||
expect(textMessages).toEqual(["Enter Mattermost bot token", "Enter Mattermost base URL"]);
|
expect(textMessages).toEqual(["Enter Mattermost bot token", "Enter Mattermost base URL"]);
|
||||||
const mattermostConfig = result.cfg.channels?.mattermost;
|
const mattermostConfig = result.cfg.channels?.mattermost;
|
||||||
expect(mattermostConfig).toBeDefined();
|
|
||||||
if (!mattermostConfig) {
|
if (!mattermostConfig) {
|
||||||
throw new Error("expected Mattermost config");
|
throw new Error("expected Mattermost config");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ describe("Synology Chat TLS verification defaults", () => {
|
|||||||
await settleTimers(invoke());
|
await settleTimers(invoke());
|
||||||
const httpsRequest = vi.mocked(https.request);
|
const httpsRequest = vi.mocked(https.request);
|
||||||
const firstCall = httpsRequest.mock.calls[0];
|
const firstCall = httpsRequest.mock.calls[0];
|
||||||
expect(firstCall).toBeDefined();
|
|
||||||
if (!firstCall) {
|
if (!firstCall) {
|
||||||
throw new Error("expected Synology Chat HTTPS request");
|
throw new Error("expected Synology Chat HTTPS request");
|
||||||
}
|
}
|
||||||
@@ -159,7 +158,6 @@ describe("sendMessage", () => {
|
|||||||
await settleTimers(sendMessage("https://nas.example.com/incoming", "Hello", undefined, true));
|
await settleTimers(sendMessage("https://nas.example.com/incoming", "Hello", undefined, true));
|
||||||
const httpsRequest = vi.mocked(https.request);
|
const httpsRequest = vi.mocked(https.request);
|
||||||
const firstCall = httpsRequest.mock.calls[0];
|
const firstCall = httpsRequest.mock.calls[0];
|
||||||
expect(firstCall).toBeDefined();
|
|
||||||
if (!firstCall) {
|
if (!firstCall) {
|
||||||
throw new Error("expected Synology Chat HTTPS request");
|
throw new Error("expected Synology Chat HTTPS request");
|
||||||
}
|
}
|
||||||
@@ -387,7 +385,6 @@ describe("fetchChatUsers", () => {
|
|||||||
|
|
||||||
const httpsGet = vi.mocked(https.get);
|
const httpsGet = vi.mocked(https.get);
|
||||||
const firstCall = httpsGet.mock.calls[0];
|
const firstCall = httpsGet.mock.calls[0];
|
||||||
expect(firstCall).toBeDefined();
|
|
||||||
if (!firstCall) {
|
if (!firstCall) {
|
||||||
throw new Error("expected Synology Chat HTTPS get");
|
throw new Error("expected Synology Chat HTTPS get");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
describe("vitest process group helpers", () => {
|
describe("vitest process group helpers", () => {
|
||||||
function getListenerSet(listeners: Map<string, Set<() => void>>, event: string) {
|
function getListenerSet(listeners: Map<string, Set<() => void>>, event: string) {
|
||||||
const set = listeners.get(event);
|
const set = listeners.get(event);
|
||||||
expect(set).toBeDefined();
|
|
||||||
if (!set) {
|
if (!set) {
|
||||||
throw new Error(`expected ${event} listener set`);
|
throw new Error(`expected ${event} listener set`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user