skillhub/plugins/dsh/test/integration/source-reference-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

63 lines
4 KiB
JavaScript

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();
const card = page.getByRole('region', { name: 'SkillHub 搜索结果' });
const showCard = async () => {
if (!await card.isVisible()) {
const turn = page.locator('button[data-turn-process]:enabled').last();
if (await turn.getAttribute('aria-expanded') === 'false') await turn.click();
}
if (!await card.isVisible()) await page.getByText('Called tools', { exact: true }).click();
await card.waitFor();
};
await showCard();
const drawer = page.getByRole('dialog', { name: '技能详情', exact: true });
await card.getByRole('button', { name: '查看技能详情', exact: true }).click();
await drawer.getByRole('heading', { name: 'Document helper', exact: true }).waitFor();
await drawer.getByRole('button', { name: '关闭技能详情', exact: true }).click();
const changeSource = async (address) => {
await page.getByText('Plugins', { exact: true }).click();
await page.getByText('@astron-team/skillhub-dsh', { exact: true }).first().click();
const form = page.getByRole('form', { name: 'SkillHub 配置' });
await form.getByRole('textbox', { name: 'Registry 地址' }).fill(address);
await form.getByRole('button', { name: '保存配置', exact: true }).click();
await form.getByText('配置已保存。', { exact: true }).waitFor();
await page.getByText('技能中心', { exact: true }).click();
const plaza = page.getByRole('region', { name: 'SkillHub 技能广场' });
await plaza.getByText(address, { exact: true }).waitFor();
await plaza.getByRole('button', { name: '返回会话', exact: true }).click();
await showCard();
};
for (const address of ['http://127.0.0.1:43220', 'http://127.0.0.1:43219']) {
await changeSource(address);
await card.getByRole('button', { name: '查看技能详情', exact: true }).click();
await drawer.getByText('这条搜索记录已失效或不属于当前会话,请重新搜索。', { exact: true }).waitFor();
assert.equal(await drawer.getByRole('button', { name: /安装到/ }).count(), 0);
await drawer.getByRole('button', { name: '关闭技能详情', exact: true }).click();
}
assert.deepEqual(errors, []);
await page.screenshot({ path: `${output}/source-reference.png` });
const result = { passed: true, freshReferenceValid: true, changedSourceRejected: true, returningSourceStillRejected: true, modelInvoked: false, originalSourceRestored: true, errors };
await writeFile(`${output}/source-reference-result.json`, JSON.stringify(result, null, 2));
console.log(JSON.stringify(result));
} catch (error) {
await page.screenshot({ path: `${output}/source-reference-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(); }