Files
openworker/docs-site/scripts/code-tabs.test.mjs
T
Rohit PrasadandDevika Verma d53e058eda Introduce OpenWorker Harness SDK (in beta), agent service cluster and relevant developer documentation (#844)
Allow developers to easily build AI apps without worrying about the harness part.
Bundles the Rust agent runtime as a SDK (Rust and TypeScript) for building desktop and web applications. Applications can manage a local harness or connect to an authenticated harness service on k8s with separately scaled workers and sandbox execution.

The implementation is primarily contained in harness/, with deployment tooling in deploy/, Markdown guides in docs/harness/guides/, and the static documentation site in docs-site/. It does not replace the existing Python harness or migrate OpenWorker Desktop.

Co-authored-by: Devika Verma <devikaverma11@gmail.com>
2026-11-06 09:45:20 -08:00

33 lines
1.8 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {readFileSync} from 'node:fs';
import {fileURLToPath} from 'node:url';
import {renderCodeTabs} from './code-tabs.mjs';
const desktop=readFileSync(fileURLToPath(new URL('../../docs/harness/guides/desktop.md',import.meta.url)),'utf8');
const snippets=s=>[...s.matchAll(/^```[^\n]*\n([\s\S]*?)^```/gm)].map(m=>m[1]);
test('guide tabs retain all code and provide unique linked accessible panels',()=>{
const result=renderCodeTabs(desktop,'desktop');
assert.deepEqual(snippets(result),snippets(desktop));
assert.equal((result.match(/data-sdk-tabs/g)||[]).length,5);
assert.equal((result.match(/role="tablist"/g)||[]).length,5);
const ids=[...result.matchAll(/\bid="([^"]+)"/g)].map(m=>m[1]);
assert.equal(ids.length,20);assert.equal(new Set(ids).size,ids.length);
for(const [,target]of result.matchAll(/(?:aria-controls|aria-labelledby)="([^"]+)"/g))assert.ok(ids.includes(target));
assert.equal((result.match(/class="sdk-tab-fallback"/g)||[]).length,10);
assert.equal((result.match(/role="tabpanel"[^>]*\bhidden/g)||[]).length,0);
assert.ok(!result.includes('<!-- sdk-tabs -->'));
assert.ok(result.includes('data-tab-kind="installer"'));
assert.ok(result.includes('data-tab-kind="language"'));
assert.ok(result.includes('aria-label="Coding agent"'));
});
test('malformed language markers stop the build instead of hiding content',()=>{
for(const source of [
'<!-- sdk-tabs -->\n### TypeScript\nhello',
'<!-- sdk-tabs -->\n### TypeScript\none\n### TypeScript\ntwo\n<!-- /sdk-tabs -->',
'<!-- sdk-tabs -->\n### Python\none\n### Rust\ntwo\n<!-- /sdk-tabs -->',
'<!-- /sdk-tabs -->',
'<!-- sdk-install-tabs -->\n### Codex\nhello',
'<!-- sdk-install-tabs -->\n### TypeScript\none\n### Rust\ntwo\n<!-- /sdk-install-tabs -->',
])assert.throws(()=>renderCodeTabs(source,'broken'));
});