skillhub/plugins/dsh/test/integration/upgrade-keyboard-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

49 lines
3.3 KiB
JavaScript

import { selectValue } from './select-field.mjs';
import assert from 'node:assert/strict';
import { writeFile } from 'node:fs/promises';
import { join, resolve, sep } from 'node:path';
import { tmpdir } from 'node:os';
import { chromium } from 'playwright';
const { DSH_PROBE_URL: entry, DSH_PROBE_OUTPUT: output, DSH_INSTALL_FIXTURE_TITLE: title,
DSH_INSTALL_FIXTURE_WORKSPACE: workspace, DSH_INSTALL_FIXTURE_PROJECT: project } = process.env;
assert(entry && output && title && workspace && project);
assert(resolve(project).startsWith(resolve(tmpdir()) + sep));
const browser = await chromium.launch({ headless: true, executablePath: process.env.DSH_PROBE_CHROMIUM });
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
let writes = 0;
page.on('request', request => { if (/\/(startInstall|executePlan|recoverOperation)$/.test(new URL(request.url()).pathname)) writes++; });
try {
await page.goto(entry, { waitUntil: 'domcontentloaded' });
await page.getByRole('button', { name: 'Configure later', exact: true }).click();
if (!await page.getByText(title, { exact: true }).waitFor({ timeout: 3000 }).then(() => true, () => false)) {
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 installed = plaza.getByRole('region', { name: '已安装技能', exact: true });
await selectValue(installed.getByRole('combobox', { name: '筛选安装范围' }), 'project');
await installed.getByRole('button', { name: '查看已安装详情', exact: true }).click();
const detail = plaza.getByRole('region', { name: '已安装技能详情' });
const remove = detail.getByRole('button', { name: '卸载此安装位置', exact: true });
await remove.waitFor();
await page.waitForFunction(() => [...document.querySelectorAll('button')].some(button => button.textContent === '卸载此安装位置' && !button.disabled));
assert(process.env.DSH_FIXTURE_UPDATE_STATE);
await writeFile(process.env.DSH_FIXTURE_UPDATE_STATE, 'newer');
await detail.getByRole('button', { name: '检查更新', exact: true }).click();
const upgrade = detail.getByRole('button', { name: '生成升级计划', exact: true });
await upgrade.waitFor();
assert(await upgrade.isEnabled());
await upgrade.focus();
await page.keyboard.press('Enter');
const cancel = detail.getByRole('button', { name: '取消', exact: true });
await cancel.waitFor();
assert(await cancel.evaluate(button => button === document.activeElement), 'Prepared plan must move focus to cancellation');
await page.keyboard.press('Enter');
await upgrade.waitFor();
assert(await upgrade.evaluate(button => button === document.activeElement), 'Cancel must restore the plan trigger');
assert.equal(writes, 0);
await writeFile(join(output, 'upgrade-keyboard-result.json'), JSON.stringify({ passed: true,
keyboardPrepare:true,cancelFocused:true,cancelRestoresTrigger:true,writeRequests:writes,modelInvoked:false }, null, 2));
} finally { if (process.env.DSH_FIXTURE_UPDATE_STATE) await writeFile(process.env.DSH_FIXTURE_UPDATE_STATE, 'current'); await browser.close(); }