Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

test(renderer): repair stale icon and home layout checks

CloudTianTian458bec19166a
diff --git a/test/renderer/icons.test.ts b/test/renderer/icons.test.ts
index 7fbef0a6..4ac9614c 100644
--- a/test/renderer/icons.test.ts
+++ b/test/renderer/icons.test.ts
@@ -2,6 +2,30 @@ import { describe, expect, it } from 'vitest';
import * as fs from 'node:fs';
import * as path from 'node:path';
import * as vm from 'node:vm';
+import * as ts from 'typescript';
+
+function literalIconNames(html: string, scripts: readonly string[]): Set<string> {
+ const names = new Set<string>();
+ const attributes = (text: string) => {
+ for (const match of text.matchAll(/data-ui-icon=(["'])(.*?)\1/gs)) names.add(match[2]);
+ };
+ attributes(html);
+ for (const source of scripts) {
+ const file = ts.createSourceFile('renderer.js', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
+ const visit = (node: ts.Node) => {
+ // Template-expression fragments cannot contain a complete interpolated
+ // attribute; actual static attributes and literal calls remain checked.
+ if (ts.isStringLiteralLike(node) || ts.isTemplateHead(node) || ts.isTemplateMiddle(node) || ts.isTemplateTail(node)) attributes(node.text);
+ if (ts.isCallExpression(node) && /^(?:window\.)?_?uiIconHtml$/.test(node.expression.getText(file))) {
+ const name = node.arguments[0];
+ if (name && ts.isStringLiteralLike(name)) names.add(name.text);
+ }
+ ts.forEachChild(node, visit);
+ };
+ visit(file);
+ }
+ return names;
+}
function loadIcons() {
const context: any = {
@@ -65,20 +89,22 @@ describe('icons.js', () => {
expect(html).not.toContain('onload=');
});
+ it('distinguishes static icon references from interpolated attributes and calls', () => {
+ const names = literalIconNames('<i data-ui-icon="unknown-static"></i><i data-ui-icon="line\nname"></i>', [
+ 'const dynamic = `<span data-ui-icon="${icon}"></span><span data-ui-icon="${open ? \'chevron-down\' : \'chevron-right\'}"></span>`;',
+ 'const fixed = `<span data-ui-icon="folder"></span>`; uiIconHtml("missing-call"); uiIconHtml(icon); uiIconHtml(`arrow-${direction}`);',
+ 'const literal = \'<span data-ui-icon="${literal-name}"></span>\';',
+ ]);
+ expect([...names].sort()).toEqual(['${literal-name}', 'folder', 'line\nname', 'missing-call', 'unknown-static']);
+ });
+
it('defines every literal icon referenced by Renderer HTML and JavaScript', () => {
const { uiIconHtml } = loadIcons();
const rendererRoot = path.join(__dirname, '../../src/renderer');
- const sources = [
- fs.readFileSync(path.join(rendererRoot, 'index.html'), 'utf8'),
- ...fs.readdirSync(path.join(rendererRoot, 'modules'))
+ const scripts = fs.readdirSync(path.join(rendererRoot, 'modules'))
.filter((name) => name.endsWith('.js'))
- .map((name) => fs.readFileSync(path.join(rendererRoot, 'modules', name), 'utf8')),
- ];
- const names = new Set<string>();
- for (const source of sources) {
- for (const match of source.matchAll(/data-ui-icon=["']([^"']+)["']/g)) names.add(match[1]);
- for (const match of source.matchAll(/\b(?:window\.)?_?uiIconHtml\(\s*["']([^"']+)["']/g)) names.add(match[1]);
- }
+ .map((name) => fs.readFileSync(path.join(rendererRoot, 'modules', name), 'utf8'));
+ const names = literalIconNames(fs.readFileSync(path.join(rendererRoot, 'index.html'), 'utf8'), scripts);
expect(names.size).toBeGreaterThan(30);
for (const name of names) {
diff --git a/test/renderer/new-chat-home.test.ts b/test/renderer/new-chat-home.test.ts
index a0b6a48b..e29429d8 100644
--- a/test/renderer/new-chat-home.test.ts
+++ b/test/renderer/new-chat-home.test.ts
@@ -89,7 +89,6 @@ describe('new chat home surface', () => {
const css = read('src/renderer/style.css');
expect(css).toMatch(/#panel-new-chat\s*{[\s\S]*?position:\s*relative;/);
- expect(css).toContain('.quick-panel-more');
expect(css).not.toContain('.sb-connect');
expect(css).not.toContain('.sidebar-external-agent-btn');
expect(css).not.toContain('.new-chat-external-agent-btn');