e2eSpecAdmission.test.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. import { readFileSync } from "node:fs";
  2. import { copyFile, mkdtemp, mkdir, readFile, writeFile, rm } from "node:fs/promises";
  3. import { pathToFileURL } from "node:url";
  4. import { tmpdir } from "node:os";
  5. import { describe, expect, it } from "vitest";
  6. import { resolve, join } from "node:path";
  7. import ts from "typescript";
  8. import { resolveE2EScheduledSpecFiles } from "#e2e/helpers/e2e-spec-resolution";
  9. import {
  10. hasRequiredSshE2EEnvironment,
  11. isFormalSpecAdmittedByEnvironment,
  12. isSshFormalSpec,
  13. isExplicitE2ESpecSelection,
  14. MANUAL_REVIEW_SPEC_GLOB,
  15. resolveEnvironmentGatedFormalSpecExcludes,
  16. SSH_FORMAL_SPEC_GLOB,
  17. } from "../scripts/e2e-formal-spec-selection.mjs";
  18. import {
  19. DEDICATED_FIXTURE_SPECS,
  20. QUEUED_SPECIAL_ENVIRONMENT_SPECS,
  21. } from "../scripts/r3-remote-spec-inventory.mjs";
  22. import { listDefaultFormalE2ESpecs } from "../scripts/run-windows-e2e-shards.mjs";
  23. async function loadMochaTimeoutConfig(holdMs = 0) {
  24. const source = await readFile(new URL("../wdio.conf.ts", import.meta.url), "utf8");
  25. const file = ts.createSourceFile("wdio.conf.ts", source, ts.ScriptTarget.Latest, true);
  26. let expression = "";
  27. let workerAssignment = "";
  28. let resolverSource = "";
  29. let pluginSpecConstant = "";
  30. const visit = (node: ts.Node) => {
  31. if (ts.isFunctionDeclaration(node) && node.name?.text === "resolveMochaTimeout") {
  32. resolverSource = node.getText(file);
  33. }
  34. if (
  35. ts.isVariableDeclaration(node) &&
  36. node.name.getText(file) === "PLUGIN_NO_GIT_GITHUB_ARCHIVE_SPEC"
  37. ) {
  38. pluginSpecConstant = `const ${node.getText(file)};`;
  39. }
  40. if (
  41. ts.isPropertyAssignment(node) &&
  42. node.name.getText(file) === "mochaOpts" &&
  43. ts.isObjectLiteralExpression(node.initializer)
  44. ) {
  45. const timeout = node.initializer.properties.find(
  46. (property) =>
  47. ts.isPropertyAssignment(property) && property.name.getText(file) === "timeout",
  48. );
  49. if (timeout && ts.isPropertyAssignment(timeout))
  50. expression = timeout.initializer.getText(file);
  51. }
  52. if (ts.isMethodDeclaration(node) && node.name.getText(file) === "beforeSession") {
  53. workerAssignment =
  54. node.body?.statements
  55. .filter((statement) => statement.getText(file).startsWith("_config.mochaOpts ="))
  56. .map((statement) => statement.getText(file))
  57. .join("\n") ?? "";
  58. }
  59. ts.forEachChild(node, visit);
  60. };
  61. visit(file);
  62. expect(expression).not.toBe("");
  63. expect(resolverSource).not.toBe("");
  64. expect(workerAssignment).not.toBe("");
  65. const context = `
  66. const requestSecuritySpecTimeout = (_, fallback) => fallback;
  67. const manualReviewHoldMs = ${holdMs};
  68. ${pluginSpecConstant}
  69. ${ts.transpileModule(resolverSource, { compilerOptions: { target: ts.ScriptTarget.ESNext } }).outputText}
  70. `;
  71. return {
  72. readBudget: new Function("configuredE2ESpecs", `${context} return ${expression};`) as (
  73. specs: string[],
  74. ) => number,
  75. applyWorkerBudget: new Function("_config", "specs", `${context} ${workerAssignment}`) as (
  76. config: { mochaOpts: { timeout: number } },
  77. specs: string[],
  78. ) => void,
  79. };
  80. }
  81. describe("desktop E2E environment-gated formal spec admission", () => {
  82. // 混合文件曾被 SSH 门禁整份排除;分开入口后,本地覆盖不能再依赖远端环境。
  83. it.each([
  84. ...["terminal", "unread"].map((scenario) => {
  85. const local = `conversation-session/remote/mobile/conversation-session-web-remote-${scenario}.test.ts`;
  86. return [scenario, local, local.replace(".test.ts", "-ssh.test.ts")];
  87. }),
  88. [
  89. "settings polish",
  90. "settings/general/settings-ui-polish.test.ts",
  91. "settings/general/settings-ui-polish-ssh.test.ts",
  92. ],
  93. [
  94. "settings notice",
  95. "conversation-session/remote/configuration/conversation-session-settings-no-editing-notice.test.ts",
  96. "conversation-session/remote/configuration/conversation-session-remote-settings-safeguards.test.ts",
  97. ],
  98. ])("keeps local %s coverage without SSH", (_scenario, localSpec, sshSpec) => {
  99. const local = `./test/e2e/${localSpec}`;
  100. const ssh = `./test/e2e/${sshSpec}`;
  101. const credentials = {
  102. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  103. ZCODE_E2E_SSH_USERNAME: "example",
  104. ZCODE_E2E_SSH_PASSWORD: "example",
  105. };
  106. for (const env of [{}, credentials]) {
  107. const selected = listDefaultFormalE2ESpecs(resolve("packages/desktop"), env);
  108. expect(selected).toContain(local);
  109. expect(selected).not.toContain(ssh);
  110. const excludes = resolveEnvironmentGatedFormalSpecExcludes({ env, targeted: false });
  111. expect(excludes).not.toContain(local);
  112. expect(excludes).toContain(ssh);
  113. expect(isFormalSpecAdmittedByEnvironment(local, env)).toBe(true);
  114. expect(isFormalSpecAdmittedByEnvironment(ssh, env)).toBe(false);
  115. }
  116. const harness = { ...credentials, ZCODE_E2E_SSH_CONTAINER: "example" };
  117. const selected = listDefaultFormalE2ESpecs(resolve("packages/desktop"), harness);
  118. expect(selected).toContain(local);
  119. expect(selected).toContain(ssh);
  120. expect(resolveEnvironmentGatedFormalSpecExcludes({ env: {}, targeted: true })).toEqual([]);
  121. });
  122. it("keeps the remote draft wrapper budget after promotion and preserves larger shard budgets", async () => {
  123. const { readBudget } = await loadMochaTimeoutConfig();
  124. const formal =
  125. "./test/e2e/conversation-session/remote/connection/conversation-session-remote-draft-prewarm.test.ts";
  126. expect(readBudget([formal])).toBe(20 * 60_000);
  127. expect(readBudget([formal.replace("remote/connection/", "manual-review/pending/")])).toBe(
  128. 20 * 60_000,
  129. );
  130. expect(readBudget([formal, "conversation-session-r3-mobile.test.ts"])).toBe(40 * 60_000);
  131. // 合并时两侧在同一预算表扩展用例,须同时保留预装工具预算与远端草稿预算。
  132. expect(
  133. readBudget([formal, "conversation-session-preinstalled-tools-real-loopback.test.ts"]),
  134. ).toBe(25 * 60_000);
  135. expect(
  136. readBudget([formal, "conversation-session-preinstalled-tools-builtin-cdn.test.ts"]),
  137. ).toBe(60 * 60_000);
  138. expect(readBudget(["smoke.test.ts"])).toBe(120_000);
  139. expect(
  140. readBudget([
  141. "./test/e2e/conversation-session/hooks/conversation-session-hook-trust-worktree.test.ts",
  142. ]),
  143. ).toBe(180_000);
  144. });
  145. it("preserves the local runtime scenario budget for explicit files and glob workers", async () => {
  146. const { readBudget, applyWorkerBudget } = await loadMochaTimeoutConfig();
  147. const relative =
  148. "test/e2e/conversation-session/runtime/conversation-session-local-config-runtime-usage.test.ts";
  149. const paths = [
  150. `./${relative}`,
  151. resolve("packages/desktop", relative),
  152. `C:\\workspace\\z-code\\packages\\desktop\\${relative.replaceAll("/", "\\")}`,
  153. ];
  154. for (const spec of paths) {
  155. expect(readBudget([spec])).toBe(40 * 60_000);
  156. const config = { mochaOpts: { timeout: readBudget(["./test/e2e/**/*.test.ts"]) } };
  157. applyWorkerBudget(config, [spec]);
  158. expect(config.mochaOpts.timeout).toBe(40 * 60_000);
  159. }
  160. expect(
  161. readBudget([relative, "conversation-session-preinstalled-tools-builtin-cdn.test.ts"]),
  162. ).toBe(60 * 60_000);
  163. expect(readBudget(["smoke.test.ts"])).toBe(120_000);
  164. });
  165. it("applies actual worker budgets when macOS CI keeps its formal globs", async () => {
  166. // GitLab 构建图测试核对这组原样入参;公开准入测试不依赖闭源 CI YAML。
  167. const patterns = [
  168. "./test/e2e/conversation-session/**/*.test.ts",
  169. "./test/e2e/plugins/**/*.test.ts",
  170. "./test/e2e/workspace/files/workspace-file-tree-refresh.test.ts",
  171. "./test/e2e/feedback/logs/export-logs-jsonl-redaction.test.ts",
  172. "./test/e2e/settings/general/settings-ui-polish.test.ts",
  173. ];
  174. const { readBudget, applyWorkerBudget } = await loadMochaTimeoutConfig();
  175. const selected = resolveE2EScheduledSpecFiles({
  176. baseDir: resolve("packages/desktop"),
  177. specs: patterns,
  178. exclude: [
  179. MANUAL_REVIEW_SPEC_GLOB,
  180. ...resolveEnvironmentGatedFormalSpecExcludes({ env: {}, targeted: false }),
  181. ],
  182. });
  183. for (const scenario of ["terminal", "unread"]) {
  184. const spec = `test/e2e/conversation-session/remote/mobile/conversation-session-web-remote-${scenario}.test.ts`;
  185. expect(selected).toContain(spec);
  186. const config = { mochaOpts: { timeout: readBudget(patterns) } };
  187. applyWorkerBudget(config, [resolve("packages/desktop", spec)]);
  188. expect(config.mochaOpts.timeout).toBe(15 * 60_000);
  189. }
  190. const config = { mochaOpts: { timeout: 30 * 60_000 } };
  191. applyWorkerBudget(config, ["test/e2e/infrastructure/smoke/smoke.test.ts"]);
  192. expect(config.mochaOpts.timeout).toBe(30 * 60_000);
  193. const unlimited = { mochaOpts: { timeout: 0 } };
  194. applyWorkerBudget(unlimited, [
  195. "test/e2e/conversation-session/remote/mobile/conversation-session-web-remote-terminal.test.ts",
  196. ]);
  197. expect(unlimited.mochaOpts.timeout).toBe(0);
  198. });
  199. it("retains manual-review time and Mocha options without inflating short workers", async () => {
  200. const { readBudget, applyWorkerBudget } = await loadMochaTimeoutConfig(3_000);
  201. const rootHooks = { beforeAll: () => undefined };
  202. const config = {
  203. mochaOpts: { timeout: readBudget(["./test/e2e/**/*.test.ts"]), grep: "example", rootHooks },
  204. };
  205. applyWorkerBudget(config, ["test/e2e/infrastructure/smoke/smoke.test.ts"]);
  206. expect(config.mochaOpts).toEqual({ timeout: 123_000, grep: "example", rootHooks });
  207. applyWorkerBudget(config, [
  208. "test/e2e/conversation-session/remote/mobile/conversation-session-web-remote-terminal.test.ts",
  209. ]);
  210. expect(config.mochaOpts.timeout).toBe(903_000);
  211. expect(config.mochaOpts.rootHooks).toBe(rootHooks);
  212. });
  213. it("loads public admission rules without the internal remote harness", async () => {
  214. const fixture = await mkdtemp(join(tmpdir(), "e2e-public-admission-"));
  215. try {
  216. const scripts = join(fixture, "packages/desktop/scripts");
  217. await mkdir(scripts, { recursive: true });
  218. for (const file of [
  219. "e2e-formal-spec-selection.mjs",
  220. "e2e-remote-target-specs.json",
  221. "r3-remote-spec-inventory.mjs",
  222. ]) {
  223. await copyFile(resolve("packages/desktop/scripts", file), join(scripts, file));
  224. }
  225. const admission = await import(
  226. pathToFileURL(join(scripts, "e2e-formal-spec-selection.mjs")).href
  227. );
  228. expect(
  229. admission.resolveEnvironmentGatedFormalSpecExcludes({ env: {}, targeted: false }),
  230. ).toContain(
  231. "./test/e2e/conversation-session/remote/configuration/conversation-session-r3-model-switch.test.ts",
  232. );
  233. expect(
  234. admission.isSshFormalSpec(
  235. "./test/e2e/conversation-session/remote/connection/conversation-session-remote-offline-icons.test.ts",
  236. ),
  237. ).toBe(false);
  238. } finally {
  239. await rm(fixture, { recursive: true, force: true });
  240. }
  241. });
  242. it("excludes every manual-review domain from the default recursive glob", () => {
  243. const scheduled = resolveE2EScheduledSpecFiles({
  244. baseDir: resolve("packages/desktop"),
  245. specs: ["./test/e2e/**/*.test.ts"],
  246. exclude: [MANUAL_REVIEW_SPEC_GLOB],
  247. });
  248. expect(scheduled).toContain("test/e2e/infrastructure/smoke/smoke.test.ts");
  249. expect(scheduled.some((spec) => spec.includes("/manual-review/"))).toBe(false);
  250. });
  251. it.each(["bots", "settings", "feedback"])(
  252. "keeps explicit %s candidates discoverable",
  253. async (domain) => {
  254. const fixture = await mkdtemp(join(tmpdir(), "e2e-spec-discovery-"));
  255. try {
  256. // 转正后领域可以没有候选;发现规则必须使用独立 fixture,不能依赖仓库一直留有 pending。
  257. const directory = join(fixture, "test/e2e", domain, "manual-review/pending");
  258. await mkdir(directory, { recursive: true });
  259. await writeFile(join(directory, "example.test.ts"), "");
  260. const scheduled = resolveE2EScheduledSpecFiles({
  261. baseDir: fixture,
  262. specs: [`./test/e2e/${domain}/manual-review/**/*.test.ts`],
  263. exclude: [],
  264. });
  265. expect(scheduled).toEqual([`test/e2e/${domain}/manual-review/pending/example.test.ts`]);
  266. } finally {
  267. await rm(fixture, { recursive: true, force: true });
  268. }
  269. },
  270. );
  271. it("applies environment gates to formal globs but keeps exact-file runs fail-closed", () => {
  272. const glob = ["./test/e2e/conversation-session/*.test.ts"];
  273. // 此处验证 canonical 正式目标;实际候选可以暂留 pending,不能随目录回退改掉门禁输入。
  274. const file = [
  275. "./test/e2e/conversation-session/remote/configuration/conversation-session-r3-model-switch.test.ts",
  276. ];
  277. expect(isExplicitE2ESpecSelection(glob)).toBe(false);
  278. expect(isExplicitE2ESpecSelection([])).toBe(false);
  279. expect(isExplicitE2ESpecSelection(file)).toBe(true);
  280. expect(
  281. resolveEnvironmentGatedFormalSpecExcludes({
  282. env: {},
  283. targeted: isExplicitE2ESpecSelection(glob),
  284. }),
  285. ).toContain(file[0]);
  286. expect(
  287. resolveEnvironmentGatedFormalSpecExcludes({
  288. env: {},
  289. targeted: isExplicitE2ESpecSelection(file),
  290. }),
  291. ).toEqual([]);
  292. });
  293. it("gates promoted remote targets while retaining local offline coverage", () => {
  294. expect(
  295. isSshFormalSpec(
  296. "./test/e2e/conversation-session/remote/configuration/conversation-session-r3-model-switch.test.ts",
  297. ),
  298. ).toBe(true);
  299. expect(
  300. isSshFormalSpec(
  301. "./test/e2e/conversation-session/remote/navigation/conversation-session-chat-remote-folder.test.ts",
  302. ),
  303. ).toBe(true);
  304. expect(
  305. isSshFormalSpec(
  306. "./test/e2e/conversation-session/remote/connection/conversation-session-remote-offline-icons.test.ts",
  307. ),
  308. ).toBe(false);
  309. expect(isSshFormalSpec("./test/e2e/bots/runtime/bot-r3-workspace-identity.test.ts")).toBe(
  310. false,
  311. );
  312. expect(resolveEnvironmentGatedFormalSpecExcludes({ env: {}, targeted: false })).toContain(
  313. "./test/e2e/conversation-session/remote/configuration/conversation-session-r3-model-switch.test.ts",
  314. );
  315. });
  316. it("excludes real SSH specs from default runs without complete credentials", () => {
  317. expect(hasRequiredSshE2EEnvironment({})).toBe(false);
  318. expect(resolveEnvironmentGatedFormalSpecExcludes({ env: {}, targeted: false })).toContain(
  319. "./test/e2e/conversation-session/**/conversation-session-ssh-remote*.test.ts",
  320. );
  321. });
  322. it("keeps explicit SSH runs fail-closed and admits configured default runs", () => {
  323. const env = {
  324. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  325. ZCODE_E2E_SSH_USERNAME: "root",
  326. ZCODE_E2E_SSH_PASSWORD: "secret-from-test-env",
  327. ZCODE_E2E_SSH_CONTAINER: "zcode-r3-server-example",
  328. };
  329. expect(hasRequiredSshE2EEnvironment(env)).toBe(true);
  330. expect(resolveEnvironmentGatedFormalSpecExcludes({ env, targeted: false })).toEqual(
  331. expect.arrayContaining(
  332. [...DEDICATED_FIXTURE_SPECS, ...QUEUED_SPECIAL_ENVIRONMENT_SPECS].map(
  333. (spec) => `./test/e2e/${spec.replace("/manual-review/pending/", "/")}`,
  334. ),
  335. ),
  336. );
  337. expect(resolveEnvironmentGatedFormalSpecExcludes({ env: {}, targeted: true })).toEqual([]);
  338. });
  339. it.each(["python-resource", "rewrite"])(
  340. "keeps preinstalled tools %s in explicitly prepared runs",
  341. (suffix) => {
  342. const formal = `./test/e2e/conversation-session/conversation-session-preinstalled-tools-${suffix}.test.ts`;
  343. const env = {
  344. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  345. ZCODE_E2E_SSH_USERNAME: "dev",
  346. ZCODE_E2E_SSH_PASSWORD: "test-password",
  347. ZCODE_E2E_SSH_CONTAINER: "ordinary-ssh-target",
  348. ZCODE_E2E_PYTHON_ARTIFACT: "/tmp/example.artifact.json",
  349. };
  350. for (const batchEnv of [{}, env]) {
  351. expect(isFormalSpecAdmittedByEnvironment(formal, batchEnv)).toBe(false);
  352. expect(
  353. resolveEnvironmentGatedFormalSpecExcludes({ env: batchEnv, targeted: false }),
  354. ).toContain(formal);
  355. expect(
  356. listDefaultFormalE2ESpecs(resolve(process.cwd(), "packages/desktop"), batchEnv),
  357. ).not.toContain(formal);
  358. }
  359. expect(resolveEnvironmentGatedFormalSpecExcludes({ env, targeted: true })).toEqual([]);
  360. },
  361. );
  362. it("keeps dedicated fixture cases out of ordinary batches even with an SSH container", () => {
  363. const env = {
  364. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  365. ZCODE_E2E_SSH_USERNAME: "dev",
  366. ZCODE_E2E_SSH_PASSWORD: "test-password",
  367. ZCODE_E2E_SSH_CONTAINER: "ordinary-ssh-target",
  368. };
  369. for (const spec of DEDICATED_FIXTURE_SPECS) {
  370. const formal = `./test/e2e/${spec.replace("/manual-review/pending/", "/")}`;
  371. expect(isFormalSpecAdmittedByEnvironment(formal, env)).toBe(false);
  372. expect(resolveEnvironmentGatedFormalSpecExcludes({ env, targeted: false })).toContain(formal);
  373. }
  374. expect(resolveEnvironmentGatedFormalSpecExcludes({ env, targeted: true })).toEqual([]);
  375. });
  376. it.each([
  377. "configuration/conversation-session-r3-live-zapi.test.ts",
  378. "configuration/conversation-session-r3-live-bigmodel-team.test.ts",
  379. "installation/conversation-session-r3-install-environment.test.ts",
  380. ])("requires explicit specialized setup for %s", (suffix) => {
  381. const env = {
  382. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  383. ZCODE_E2E_SSH_USERNAME: "dev",
  384. ZCODE_E2E_SSH_PASSWORD: "test-password",
  385. ZCODE_E2E_SSH_CONTAINER: "ordinary-ssh-target",
  386. };
  387. const formal = `./test/e2e/conversation-session/remote/${suffix}`;
  388. expect(isFormalSpecAdmittedByEnvironment(formal, env)).toBe(false);
  389. expect(resolveEnvironmentGatedFormalSpecExcludes({ env, targeted: false })).toContain(formal);
  390. expect(resolveEnvironmentGatedFormalSpecExcludes({ env, targeted: true })).toEqual([]);
  391. });
  392. it("requires the harness container for queued remote targets", () => {
  393. // 远程队列按 case 准备干净目标;只有共享 SSH 凭据的 runner 不能运行这些用例。
  394. const credentials = {
  395. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  396. ZCODE_E2E_SSH_USERNAME: "root",
  397. ZCODE_E2E_SSH_PASSWORD: "secret-from-test-env",
  398. };
  399. const queued =
  400. "./test/e2e/conversation-session/remote/configuration/conversation-session-r3-model-switch.test.ts";
  401. const queuedSshRemote =
  402. "./test/e2e/conversation-session/remote/connection/conversation-session-ssh-remote-development-p0.test.ts";
  403. // 尚未排进队列的 ssh-remote 用例只依赖真实服务器凭据。
  404. const unqueuedSshRemote =
  405. "./test/e2e/conversation-session/conversation-session-ssh-remote-example.test.ts";
  406. const excludes = resolveEnvironmentGatedFormalSpecExcludes({
  407. env: credentials,
  408. targeted: false,
  409. });
  410. expect(excludes).toContain(queued);
  411. expect(excludes).toContain(queuedSshRemote);
  412. expect(excludes).not.toContain(SSH_FORMAL_SPEC_GLOB);
  413. expect(isFormalSpecAdmittedByEnvironment(queued, credentials)).toBe(false);
  414. expect(isFormalSpecAdmittedByEnvironment(queuedSshRemote, credentials)).toBe(false);
  415. expect(isFormalSpecAdmittedByEnvironment(unqueuedSshRemote, credentials)).toBe(true);
  416. expect(isFormalSpecAdmittedByEnvironment(unqueuedSshRemote, {})).toBe(false);
  417. expect(
  418. isFormalSpecAdmittedByEnvironment(queued, {
  419. ...credentials,
  420. ZCODE_E2E_SSH_CONTAINER: "zcode-r3-server-example",
  421. }),
  422. ).toBe(true);
  423. expect(
  424. isFormalSpecAdmittedByEnvironment(
  425. "./test/e2e/conversation-session/remote/connection/conversation-session-remote-offline-icons.test.ts",
  426. {},
  427. ),
  428. ).toBe(true);
  429. });
  430. it("keeps nested formal scenarios discoverable and nested candidates excluded", () => {
  431. const formal = resolveE2EScheduledSpecFiles({
  432. baseDir: resolve("packages/desktop"),
  433. specs: ["./test/e2e/conversation-session/**/*.test.ts"],
  434. exclude: [MANUAL_REVIEW_SPEC_GLOB],
  435. });
  436. expect(formal).toContain(
  437. "test/e2e/conversation-session/composer/conversation-session-first-send.test.ts",
  438. );
  439. expect(formal).toContain(
  440. "test/e2e/conversation-session/remote/connection/conversation-session-ssh-remote-banner-reconnect.test.ts",
  441. );
  442. expect(formal.some((spec) => spec.includes("/manual-review/"))).toBe(false);
  443. expect(
  444. isSshFormalSpec(
  445. "./test/e2e/conversation-session/remote/connection/conversation-session-ssh-remote-example.test.ts",
  446. ),
  447. ).toBe(true);
  448. });
  449. it("uses the shared admission helper in the WDIO exclude list", () => {
  450. const source = readFileSync(new URL("../wdio.conf.ts", import.meta.url), "utf8");
  451. expect(source).toContain("resolveEnvironmentGatedFormalSpecExcludes({");
  452. expect(source).toContain("hasRequiredSshE2EEnvironment(process.env)");
  453. });
  454. });