From b7ed2a5e8578786c0c2ac60007773974b58a6410 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Mon, 5 Oct 2026 22:38:44 +0800 Subject: [PATCH] test(experimental): resolve optional fixtures from their owners --- apps/cli/tests/github-webhook-real.e2e.ts | 17 +++++++++++++++-- apps/cli/tests/profiles/webhook-packed.e2e.ts | 5 ++++- apps/cli/tests/web-agent-presets.e2e.ts | 2 +- scripts/fixture-file.ts | 15 +++++++++++++++ .../verify-default-product-isolation.spec.ts | 11 +++-------- scripts/verify-product-use.spec.ts | 11 +++-------- scripts/verify-product-use.ts | 3 +-- 7 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 scripts/fixture-file.ts diff --git a/apps/cli/tests/github-webhook-real.e2e.ts b/apps/cli/tests/github-webhook-real.e2e.ts index 78ad62c968..4aa80186ae 100644 --- a/apps/cli/tests/github-webhook-real.e2e.ts +++ b/apps/cli/tests/github-webhook-real.e2e.ts @@ -4,15 +4,16 @@ import type { ChildProcess } from 'node:child_process' import { spawn } from 'node:child_process' import { createHmac, randomUUID } from 'node:crypto' import { existsSync } from 'node:fs' -import { mkdir, mkdtemp, realpath, rm } from 'node:fs/promises' +import { mkdir, mkdtemp, readFile, realpath, rm, symlink, writeFile } from 'node:fs/promises' import { createServer } from 'node:net' import type { AddressInfo } from 'node:net' import { tmpdir } from 'node:os' -import { join } from 'node:path' +import { dirname, join } from 'node:path' import { setTimeout as delay } from 'node:timers/promises' import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' import WebSocket from 'ws' +import { initProfile, PROFILE_TEMPLATES } from '@deepseek-ai/dsh-app-boot' const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url)) const BUILT_BIN = join(REPO_ROOT, 'apps/cli/lib/bin.js') @@ -357,6 +358,18 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('GitHub webhook through the real const workspacePath = join(root, 'workspace') await mkdir(workspacePath) const canonicalWorkspacePath = await realpath(workspacePath) + const profile = join(root, '.dsh/profiles/web') + initProfile(profile, PROFILE_TEMPLATES.web!.bundles) + const manifestPath = join(profile, 'package.json') + const manifest = JSON.parse(await readFile(manifestPath, 'utf8')) as { dependencies: Record } + for (const name of ['@deepseek-ai/dsh-experimental-webhook', '@deepseek-ai/dsh-experimental-webhook-github']) { + const directory = dirname(fileURLToPath(import.meta.resolve(`${name}/package.json`))) + const link = join(profile, 'node_modules', name) + await mkdir(dirname(link), { recursive: true }) + await symlink(directory, link, 'junction') + manifest.dependencies[name] = `file:${directory}` + } + await writeFile(manifestPath, `${JSON.stringify(manifest)}\n`) const webhookPort = await freePort() const child = spawn(process.execPath, [ BUILT_BIN, diff --git a/apps/cli/tests/profiles/webhook-packed.e2e.ts b/apps/cli/tests/profiles/webhook-packed.e2e.ts index a68769a7c5..022122d4fd 100644 --- a/apps/cli/tests/profiles/webhook-packed.e2e.ts +++ b/apps/cli/tests/profiles/webhook-packed.e2e.ts @@ -105,8 +105,11 @@ it.skipIf(!built)('loads the packed GitHub example with its explicitly installed const initialLinks = await workspaceLinks(sourceDirectories) onTestFinished(async () => { expect(await workspaceLinks(sourceDirectories)).toEqual(initialLinks) }) const closure = packedWorkspaceClosure('@deepseek-ai/dsh', packages) + // A signed ping creates no Session and runs no confined process. The native + // platform packages load lazily for those operations and have separate smokes. const runtimeMembers = closure.filter(member => ( - (!Array.isArray(member.manifest.os) || member.manifest.os.includes(process.platform)) + !member.name.startsWith('@deepseek-ai/node-addon-system-') + && (!Array.isArray(member.manifest.os) || member.manifest.os.includes(process.platform)) && (!Array.isArray(member.manifest.cpu) || member.manifest.cpu.includes(process.arch)) )) const members = new Map(runtimeMembers.map(member => [member.name, member])) diff --git a/apps/cli/tests/web-agent-presets.e2e.ts b/apps/cli/tests/web-agent-presets.e2e.ts index 04246877e3..29c159b3d0 100644 --- a/apps/cli/tests/web-agent-presets.e2e.ts +++ b/apps/cli/tests/web-agent-presets.e2e.ts @@ -93,7 +93,7 @@ async function bootWeb( // A deployment-level skill on the host registry's GLOBAL layer — the same // registration shape a repository plugin's skill root uses. The layered // skills test below proves it reaches preset-composed agents. - { insert: [{ id: 'skill-badge', name: '@deepseek-ai/dsh-experimental-skill-badge' }] }, + { insert: [{ id: 'skill-badge', name: import.meta.resolve('@deepseek-ai/dsh-experimental-skill-badge') }] }, { id: 'modules', disabled: true }, // The physical Connection row owns the disabled HTTP server. bootWeb // supplies only its in-process registries so Host services still prove diff --git a/scripts/fixture-file.ts b/scripts/fixture-file.ts new file mode 100644 index 0000000000..9582a3fbf4 --- /dev/null +++ b/scripts/fixture-file.ts @@ -0,0 +1,15 @@ +/** File creation shared by repository scanner fixtures. */ +import { mkdirSync, writeFileSync } from 'node:fs' +import { dirname, join } from 'node:path' + +/** + * Write a text or JSON fixture, creating its containing directories. + * @param root - Owning temporary fixture directory. + * @param path - Path relative to that directory. + * @param value - Literal text or JSON-serializable fixture value. + */ +export function writeFixtureFile(root: string, path: string, value: unknown): void { + const target = join(root, path) + mkdirSync(dirname(target), { recursive: true }) + writeFileSync(target, typeof value === 'string' ? value : `${JSON.stringify(value)}\n`) +} diff --git a/scripts/verify-default-product-isolation.spec.ts b/scripts/verify-default-product-isolation.spec.ts index 1c5b6b28e1..9e85a076c5 100644 --- a/scripts/verify-default-product-isolation.spec.ts +++ b/scripts/verify-default-product-isolation.spec.ts @@ -1,11 +1,12 @@ /** Source, installation, and composition regressions for default-product isolation. */ -import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs' +import { mkdirSync, mkdtempSync, readFileSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' -import { dirname, join } from 'node:path' +import { join } from 'node:path' import { pathToFileURL } from 'node:url' import { afterEach, describe, expect, it } from 'vitest' import { verifyDefaultProductIsolation } from './verify-default-product-isolation.ts' +import { writeFixtureFile as write } from './fixture-file.ts' const roots: string[] = [] const experimental = '@deepseek-ai/dsh-experimental-prototype' @@ -15,12 +16,6 @@ const profile = 'packages/boot/app-boot/src/profile.ts' const preset = 'packages/bundle/web-app/presets/standard.patch.yml' const patch = 'packages/bundle/base/cordis.patch.yml' -function write(root: string, path: string, value: unknown): void { - const target = join(root, path) - mkdirSync(dirname(target), { recursive: true }) - writeFileSync(target, typeof value === 'string' ? value : `${JSON.stringify(value)}\n`) -} - function manifest(root: string, path: string, fields: Record): void { const existing = JSON.parse(readFileSync(join(root, path), 'utf8')) as Record write(root, path, { ...existing, ...fields }) diff --git a/scripts/verify-product-use.spec.ts b/scripts/verify-product-use.spec.ts index a405302c06..8615d57898 100644 --- a/scripts/verify-product-use.spec.ts +++ b/scripts/verify-product-use.spec.ts @@ -1,11 +1,12 @@ /** Product-use regressions exercise source reachability and effective Loader composition. */ -import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs' +import { mkdtempSync, readFileSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' -import { dirname, join } from 'node:path' +import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' import type { ProductPackagePolicy } from './product-package-policy.ts' import { verifyProductUse } from './verify-product-use.ts' +import { writeFixtureFile as write } from './fixture-file.ts' const roots: string[] = [] const base = '@deepseek-ai/dsh-base' @@ -15,12 +16,6 @@ const candidateDir = 'packages/core/candidate' const profile = 'packages/boot/app-boot/src/profile.ts' const patch = 'packages/bundle/base/cordis.patch.yml' -function write(root: string, path: string, value: unknown): void { - const target = join(root, path) - mkdirSync(dirname(target), { recursive: true }) - writeFileSync(target, typeof value === 'string' ? value : `${JSON.stringify(value)}\n`) -} - function pkg(root: string, directory: string, name: string, fields: Record = {}): void { write(root, `${directory}/package.json`, { name, ...fields }) write(root, `${directory}/src/index.ts`, 'export {}\n') diff --git a/scripts/verify-product-use.ts b/scripts/verify-product-use.ts index 09860f5622..00e10ed86a 100644 --- a/scripts/verify-product-use.ts +++ b/scripts/verify-product-use.ts @@ -7,8 +7,7 @@ import { JSDOM } from 'jsdom' import ts from 'typescript' import { applyEntryPatches, type PatchOptions } from '@deepseek-ai/cordis-plugin-include' import type { EntryOptions } from '@deepseek-ai/cordis-plugin-loader' -import { loadOverlayPatches } from '../packages/boot/app-boot/src/index.ts' -import { bundlePatchPaths, composeEntries } from '../packages/boot/app-boot/src/profile.ts' +import { bundlePatchPaths, composeEntries, loadOverlayPatches } from '../packages/boot/app-boot/src/index.ts' import type { DshBundleManifest } from '../packages/util/package-manifest/src/types.ts' import { assertNever } from '../packages/util/values/src/index.ts' import { isAgentPresetEntry, isCordisGroupEntry, loadCordisYaml } from './cordis-yaml.ts'