Initial import: open-design source for helix-mind.ai distribution
Some checks failed
ci / Validate workspace (push) Successful in 12m32s
landing-page-ci / Validate landing page (push) Successful in 9m41s
landing-page-deploy / Deploy landing page (push) Failing after 5m23s
github-metrics / Generate repository metrics SVG (push) Failing after 2m6s
refresh-contributors-wall / Refresh contributors wall cache bust (push) Failing after 12s
Some checks failed
ci / Validate workspace (push) Successful in 12m32s
landing-page-ci / Validate landing page (push) Successful in 9m41s
landing-page-deploy / Deploy landing page (push) Failing after 5m23s
github-metrics / Generate repository metrics SVG (push) Failing after 2m6s
refresh-contributors-wall / Refresh contributors wall cache bust (push) Failing after 12s
This repository contains the open-design daemon CLI source code, built and packaged at https://helix-mind.ai/cli/open-design/latest.tgz for use by the HelixMind /design slash command. Licenses: Apache-2.0 (root) + MIT (skills/*)
This commit is contained in:
42
apps/web/tests/utils/apiProtocol.test.ts
Normal file
42
apps/web/tests/utils/apiProtocol.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { apiProtocolLabel, apiProtocolModelLabel } from '../../src/utils/apiProtocol';
|
||||
import {
|
||||
agentDisplayName,
|
||||
agentModelDisplayName,
|
||||
exactAgentDisplayName,
|
||||
} from '../../src/utils/agentLabels';
|
||||
|
||||
describe('api protocol labels', () => {
|
||||
it('labels the selected API protocol instead of assuming Anthropic', () => {
|
||||
expect(apiProtocolLabel('openai')).toBe('OpenAI API');
|
||||
expect(apiProtocolLabel('google')).toBe('Google Gemini');
|
||||
expect(apiProtocolLabel(undefined)).toBe('Anthropic API');
|
||||
});
|
||||
|
||||
it('includes the selected model when labeling API assistant messages', () => {
|
||||
expect(apiProtocolModelLabel('openai', 'google/gemma-4-e4b')).toBe(
|
||||
'OpenAI API · google/gemma-4-e4b',
|
||||
);
|
||||
expect(apiProtocolModelLabel('azure', ' ')).toBe('Azure OpenAI');
|
||||
});
|
||||
|
||||
it('includes explicit local CLI models when labeling agent messages', () => {
|
||||
expect(agentModelDisplayName('claude', 'Claude Code', 'claude-sonnet-4-6')).toBe(
|
||||
'Claude · claude-sonnet-4-6',
|
||||
);
|
||||
expect(agentModelDisplayName('claude', 'Claude Code', 'default')).toBe('Claude');
|
||||
});
|
||||
|
||||
it('normalizes Qoder local CLI ids, aliases, and executable paths', () => {
|
||||
expect(agentDisplayName('qoder')).toBe('Qoder');
|
||||
expect(exactAgentDisplayName('qodercli')).toBe('Qoder');
|
||||
expect(exactAgentDisplayName('Qoder CLI')).toBe('Qoder');
|
||||
expect(agentDisplayName('/opt/homebrew/bin/qodercli')).toBe('Qoder');
|
||||
expect(agentDisplayName('C:\\Tools\\qodercli.cmd')).toBe('Qoder');
|
||||
});
|
||||
|
||||
it('includes explicit Qoder models but hides the default model', () => {
|
||||
expect(agentModelDisplayName('qoder', 'Qoder CLI', 'ultimate')).toBe('Qoder · ultimate');
|
||||
expect(agentModelDisplayName('qoder', 'Qoder CLI', 'default')).toBe('Qoder');
|
||||
});
|
||||
});
|
||||
31
apps/web/tests/utils/chatTime.test.ts
Normal file
31
apps/web/tests/utils/chatTime.test.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import type { ChatMessage } from '../../src/types';
|
||||
import { messageTime } from '../../src/utils/chatTime';
|
||||
|
||||
describe('messageTime', () => {
|
||||
it('uses assistant startedAt before persisted createdAt', () => {
|
||||
const message: ChatMessage = {
|
||||
id: 'assistant-1',
|
||||
role: 'assistant',
|
||||
content: 'Done',
|
||||
startedAt: 100,
|
||||
createdAt: 200,
|
||||
endedAt: 300,
|
||||
};
|
||||
|
||||
expect(messageTime(message)).toBe(100);
|
||||
});
|
||||
|
||||
it('keeps user createdAt as the primary timestamp', () => {
|
||||
const message: ChatMessage = {
|
||||
id: 'user-1',
|
||||
role: 'user',
|
||||
content: 'Build this',
|
||||
startedAt: 100,
|
||||
createdAt: 200,
|
||||
};
|
||||
|
||||
expect(messageTime(message)).toBe(200);
|
||||
});
|
||||
});
|
||||
97
apps/web/tests/utils/notifications.test.ts
Normal file
97
apps/web/tests/utils/notifications.test.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { showCompletionNotification } from '../../src/utils/notifications';
|
||||
|
||||
type NotificationOptionsWithRenotify = NotificationOptions & { renotify?: boolean };
|
||||
|
||||
class MockNotification {
|
||||
static permission: NotificationPermission = 'granted';
|
||||
static instances: MockNotification[] = [];
|
||||
|
||||
onclose: (() => void) | null = null;
|
||||
onclick: (() => void) | null = null;
|
||||
onerror: (() => void) | null = null;
|
||||
|
||||
constructor(
|
||||
public title: string,
|
||||
public options?: NotificationOptionsWithRenotify,
|
||||
) {
|
||||
MockNotification.instances.push(this);
|
||||
}
|
||||
|
||||
close(): void {
|
||||
// Fire synchronously so tests can observe cleanup without browser events.
|
||||
this.onclose?.();
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
MockNotification.permission = 'granted';
|
||||
MockNotification.instances = [];
|
||||
});
|
||||
|
||||
describe('showCompletionNotification', () => {
|
||||
it('creates a renotifying desktop notification when permission is granted', async () => {
|
||||
vi.stubGlobal('Notification', MockNotification as unknown as typeof Notification);
|
||||
|
||||
const result = await showCompletionNotification({
|
||||
status: 'succeeded',
|
||||
title: 'Task completed',
|
||||
body: 'Done',
|
||||
});
|
||||
|
||||
expect(result).toBe('shown');
|
||||
expect(MockNotification.instances).toHaveLength(1);
|
||||
expect(MockNotification.instances[0]!.title).toBe('Task completed');
|
||||
expect(MockNotification.instances[0]!.options).toMatchObject({
|
||||
body: 'Done',
|
||||
tag: 'od-task-succeeded',
|
||||
renotify: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('uses the service worker notification API when available', async () => {
|
||||
const showNotification = vi.fn().mockResolvedValue(undefined);
|
||||
const registration = { showNotification };
|
||||
const register = vi.fn().mockResolvedValue(registration);
|
||||
vi.stubGlobal('Notification', MockNotification as unknown as typeof Notification);
|
||||
vi.stubGlobal('navigator', {
|
||||
serviceWorker: {
|
||||
register,
|
||||
ready: Promise.resolve(registration),
|
||||
},
|
||||
});
|
||||
|
||||
const result = await showCompletionNotification({
|
||||
status: 'succeeded',
|
||||
title: 'Task completed',
|
||||
body: 'Done',
|
||||
});
|
||||
|
||||
expect(result).toBe('shown');
|
||||
expect(register).toHaveBeenCalledWith('/od-notifications-sw.js');
|
||||
expect(showNotification).toHaveBeenCalledWith(
|
||||
'Task completed',
|
||||
expect.objectContaining({
|
||||
body: 'Done',
|
||||
tag: 'od-task-succeeded',
|
||||
renotify: true,
|
||||
}),
|
||||
);
|
||||
expect(MockNotification.instances).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('does not create a notification when permission is not granted', async () => {
|
||||
MockNotification.permission = 'denied';
|
||||
vi.stubGlobal('Notification', MockNotification as unknown as typeof Notification);
|
||||
|
||||
const result = await showCompletionNotification({
|
||||
status: 'failed',
|
||||
title: 'Task failed',
|
||||
body: 'Error',
|
||||
});
|
||||
|
||||
expect(result).toBe('permission-denied');
|
||||
expect(MockNotification.instances).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user