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.

3.5 KB
Raw Blame
import { describe, expect, it } from 'vitest';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { LOCALES } from '../../src/main/i18n';

const root = path.join(__dirname, '../..');
const read = (relativePath: string) => fs.readFileSync(path.join(root, relativePath), 'utf8');

describe('conversation load-more control', () => {
  it('offers to show more conversations in every supported locale', () => {
    const expected = {
      zh: '显示更多',
      'zh-tw': '顯示更多',
      en: 'Show more',
      fr: 'Afficher plus',
      de: 'Mehr anzeigen',
      hi: 'और दिखाएँ',
      id: 'Tampilkan lebih banyak',
      it: 'Mostra altro',
      ja: 'さらに表示',
      ko: '더 보기',
      pt: 'Mostrar mais',
      'pt-pt': 'Mostrar mais',
      ru: 'Показать ещё',
      es: 'Mostrar más',
      'es-419': 'Mostrar más',
      th: 'แสดงเพิ่มเติม',
      tr: 'Daha fazla göster',
      vi: 'Hiển thị thêm',
      ar: 'عرض المزيد',
    };

    expect(Object.keys(expected).sort()).toEqual(LOCALES.map(locale => locale.code).sort());
    for (const [locale, label] of Object.entries(expected)) {
      const messages = JSON.parse(read(`src/renderer/locales/${locale}.json`));
      expect(messages['sidebar.load_more_conversations']).toBe(label);
    }
  });

  it('provides responsive, focus, disabled, and loading styles', () => {
    const styles = read('src/renderer/style.css');

    // Accept shared selector lists while keeping each property in its owning rule.
    const rule = Array.from(styles.replace(/\/\*[\s\S]*?\*\//g, '').matchAll(/([^{}]+)\{([^{}]*)\}/g))
      .find(match => match[1].split(',').some(selector => selector.trim() === '.conversation-list-load-more'));
    expect(rule, 'the load-more selector must own its base declarations').toBeDefined();
    expect(rule![2]).toMatch(/width:\s*calc\(100% - 16px\)/);
    expect(rule![2]).toMatch(/border:\s*0;/);
    expect(styles).toContain('.conversation-list-load-more:focus-visible');
    expect(styles).toContain('.conversation-list-load-more:disabled');
    expect(styles).toContain('.conversation-list-load-more[aria-busy="true"]::before');
    expect(styles).toMatch(/\.project-conv-list > \.conversation-list-load-more\s*\{[\s\S]*?margin-bottom:\s*0;/);
    expect(styles).toMatch(/\.project-conv-list:has\(> \.conversation-list-load-more\) \+ \.project-row\s*\{[\s\S]*?margin-top:\s*0;/);
  });

  it('exposes pending requests to assistive technology in every list context', () => {
    for (const source of [
      'src/renderer/modules/conversation.js',
      'src/renderer/modules/project-detail.js',
      'src/renderer/modules/projects.js',
      'src/renderer/modules/auto.js',
    ]) {
      expect(read(source)).toContain("setAttribute('aria-busy', 'true')");
      expect(read(source)).toContain("removeAttribute('aria-busy')");
    }
  });

  it('uses one pagination control instead of collapsible time buckets', () => {
    const conversation = read('src/renderer/modules/conversation.js');
    const styles = read('src/renderer/style.css');

    expect(conversation).not.toContain('data-conv-bucket-toggle');
    expect(conversation).not.toContain('data-conv-bucket-more');
    expect(conversation).toContain('data-unprojected-conv-more');
    expect(conversation).not.toContain('_conversationExpandedBuckets');
    expect(styles).not.toContain('.conv-list-section-header.is-collapsible');
    expect(styles).not.toContain('.conv-list-section-count');
  });
});