skillhub/plugins/dsh/test/integration/installed-navigation-probe.mjs
XiaoSeS 3560679793
Some checks failed
Deploy Docs / build (push) Has been cancelled
Security / Dependency Review (push) Has been cancelled
Security / CodeQL (java-kotlin) (push) Has been cancelled
Security / CodeQL (javascript-typescript) (push) Has been cancelled
Security / CodeQL (python) (push) Has been cancelled
Deploy Docs / Deploy (push) Has been cancelled
feat(dsh): add native SkillHub plugin for DeepSeek Harness (#956)
Add the native SkillHub plugin for DeepSeek Harness with a scoped skill center, conversation search/install tools, exact-version installation and protected lifecycle management. Prepare the independently versioned 0.1.0 npm candidate with an empty default Registry and documented compatibility limits.

Keep formal specifications and executable regression tests; remove archived development screenshots and runtime reports from the final tree. Review fixes cover independent scopes, installed references, pre-staging recovery and idempotent discovery.

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-10-16 19:22:26 +08:00

61 lines
4.3 KiB
JavaScript

import { selectValue, selectedValue } from './select-field.mjs';
import assert from 'node:assert/strict';
import { writeFile } from 'node:fs/promises';
import { chromium } from 'playwright';
const { DSH_PROBE_URL: entry, DSH_PROBE_OUTPUT: output, DSH_SEARCH_FIXTURE_TITLE: title } = process.env;
if (!entry || !output || !title) throw new Error('Set isolated Host URL, output and session title');
const browser = await chromium.launch({ headless: true, executablePath: process.env.DSH_PROBE_CHROMIUM });
const page = await browser.newPage({ viewport: { width: 1440, height: 700 } });
const errors = [];
page.on('pageerror', error => errors.push(error.message.replace(/token=[^\s&]+/g, 'token=[redacted]')));
try {
await page.goto(entry, { waitUntil: 'domcontentloaded' });
await page.getByRole('button', { name: 'Configure later', exact: true }).click();
const sessionVisible = await page.getByText(title, { exact: true }).waitFor({ state: 'visible', timeout: 3000 }).then(() => true, () => false);
if (!sessionVisible) {
const workspace = process.env.DSH_SEARCH_FIXTURE_WORKSPACE;
if (!workspace) throw new Error('Set fixture workspace to expand its session');
await page.getByText(workspace, { exact: true }).click();
}
await page.getByText(title, { exact: true }).click();
await page.getByText('技能中心', { exact: true }).click();
const plaza = page.getByRole('region', { name: 'SkillHub 技能广场' });
await plaza.getByRole('tab', { name: '已安装', exact: true }).click();
const scope = plaza.getByRole('combobox', { name: '筛选安装范围' });
const keyword = plaza.getByRole('searchbox', { name: '过滤已安装技能' });
await selectValue(scope, 'project');
await keyword.fill('document-helper');
await plaza.getByRole('button', { name: '查看已安装详情', exact: true }).click();
await plaza.getByRole('region', { name: '已安装技能详情', exact: true }).waitFor();
await plaza.getByRole('button', { name: '返回会话', exact: true }).click();
await page.getByText('技能中心', { exact: true }).click();
await plaza.getByRole('region', { name: '已安装技能详情', exact: true }).waitFor();
await plaza.getByRole('button', { name: '← 返回已安装', exact: true }).click();
assert.equal(await selectedValue(scope), 'project', 'Scope lost after detail reopen');
assert.equal(await keyword.inputValue(), 'document-helper', 'Filter lost after detail reopen');
await plaza.getByRole('tab', { name: '浏览技能', exact: true }).click();
await plaza.getByLabel('搜索技能').waitFor();
await plaza.getByRole('tab', { name: '已安装', exact: true }).click();
assert.equal(await selectedValue(scope), 'project', 'Scope lost after Tab return');
assert.equal(await keyword.inputValue(), 'document-helper', 'Filter lost after Tab return');
await plaza.getByRole('button', { name: '返回会话', exact: true }).click();
const otherTitle = process.env.DSH_OTHER_FIXTURE_TITLE;
const otherWorkspace = process.env.DSH_OTHER_FIXTURE_WORKSPACE;
if (!otherTitle || !otherWorkspace) throw new Error('Set another isolated session for context reset');
if (!await page.getByText(otherTitle, { exact: true }).isVisible()) await page.getByText(otherWorkspace, { exact: true }).click();
await page.getByText(otherTitle, { exact: true }).click();
await page.getByText('技能中心', { exact: true }).click();
await scope.waitFor();
assert.equal(await selectedValue(scope), 'all', 'Previous session scope leaked');
assert.equal(await keyword.inputValue(), '', 'Previous session filter leaked');
assert.equal(await plaza.getByRole('region', { name: '已安装技能详情', exact: true }).count(), 0);
assert.deepEqual(errors, []);
await page.screenshot({ path: `${output}/installed-navigation.png` });
const result = { passed: true, detailReopen: true, scopeRetained: true, filterRetained: true, tabReturn: true, sessionReset: true, errors };
await writeFile(`${output}/installed-navigation-result.json`, JSON.stringify(result, null, 2));
console.log(JSON.stringify(result));
} catch (error) {
await page.screenshot({ path: `${output}/installed-navigation-failure.png` });
console.log(JSON.stringify({ passed: false, error: error.message.replace(/token=[^\s&]+/g, 'token=[redacted]'), errors }));
process.exitCode = 1;
} finally { await browser.close(); }