mirror of
https://github.com/iflytek/skillhub.git
synced 2026-11-24 22:08:02 +00:00
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
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>
44 lines
3.3 KiB
JavaScript
44 lines
3.3 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
import { chromium } from 'playwright';
|
|
const { DSH_PROBE_URL: entry, DSH_PROBE_OUTPUT: output, DSH_FIXTURE_REQUEST_LOG: log } = process.env;
|
|
if (!entry || !output || !log) throw new Error('Set isolated Host URL, output and Registry request log');
|
|
const browser = await chromium.launch({ headless: true, executablePath: process.env.DSH_PROBE_CHROMIUM });
|
|
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
|
|
const errors = [];
|
|
let remoteImages = 0;
|
|
page.on('pageerror', error => errors.push(error.message.replace(/token=[^\s&]+/g, 'token=[redacted]')));
|
|
page.on('request', request => { if (request.url().includes('example.invalid')) remoteImages++; });
|
|
try {
|
|
await page.goto(entry, { waitUntil: 'domcontentloaded' });
|
|
const welcome = page.getByRole('button', { name: /^(Continue|继续)$/ });
|
|
const later = page.getByRole('button', { name: /^(Configure later|稍后配置)$/ });
|
|
await welcome.or(later).first().waitFor();
|
|
if (await welcome.isVisible()) await welcome.click();
|
|
await later.click();
|
|
await page.getByText('技能中心', { exact: true }).click();
|
|
const plaza = page.getByRole('region', { name: 'SkillHub 技能广场' });
|
|
await plaza.getByText('共匹配 55 项,当前显示 20 项。', { exact: true }).waitFor();
|
|
await plaza.getByText('当前来源仅支持首批搜索,不支持分页与排序。可输入更具体的关键词缩小范围。', { exact: true }).waitFor();
|
|
assert.equal(await plaza.getByRole('combobox', { name: '技能排序' }).count(), 0);
|
|
assert.equal(await plaza.getByRole('button', { name: /document-helper/ }).count(), 20);
|
|
assert.equal(await plaza.getByRole('button', { name: /加载更多|下一页|上一页/ }).count(), 0);
|
|
await plaza.getByRole('button', { name: /@demo-0\/document-helper/ }).click();
|
|
await plaza.getByRole('heading', { name: 'Document helper', exact: true }).waitFor();
|
|
const article = plaza.getByRole('article', { name: '技能说明' });
|
|
await article.getByText('提取摘要 & 关键结论。', { exact: true }).waitFor();
|
|
assert.equal(await article.locator('script, img, a[href^="javascript:"]').count(), 0);
|
|
assert.equal(await page.evaluate(() => window.fixtureUnsafe === true), false);
|
|
const requests = (await readFile(log, 'utf8')).trim().split('\n').map(line => JSON.parse(line));
|
|
const resolves = requests.filter(item => item.path === '/api/cli/v1/skills/demo-0/document-helper/resolve');
|
|
assert(resolves.length > 0);
|
|
assert(resolves.every(item => item.version === '1.2.0'));
|
|
assert(requests.some(item => item.path === '/api/v1/skills/demo-0/document-helper/versions/1.2.0/file'));
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
await page.screenshot({ path: `${output}/catalog-range-mobile.png` });
|
|
const width = await plaza.evaluate(element => ({ client: element.clientWidth, scroll: element.scrollWidth }));
|
|
assert(width.client > 0 && width.scroll <= width.client + 1, JSON.stringify(width));
|
|
assert.equal(remoteImages, 0); assert.deepEqual(errors, []);
|
|
await writeFile(`${output}/catalog-range-result.json`, JSON.stringify({ passed: true, total: 55, returned: 20,
|
|
noFakePagination: true, fixedVersion: '1.2.0', safeMarkdown: true, remoteImages, mobile: width, errors }, null, 2));
|
|
} finally { await browser.close(); }
|