retired-app-unit-evidence.test.mjs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import assert from "node:assert/strict";
  2. import test from "node:test";
  3. import {
  4. inspectRetiredAppUnitEvidence,
  5. inspectCoverageMatrices,
  6. } from "../lib/retired-app-unit-evidence.mjs";
  7. const unit = "packages/ui/test/example.test.ts";
  8. const e2e = "packages/desktop/test/e2e/conversation-session/example.test.ts";
  9. const options = { engineeringTests: new Set(["packages/desktop/test/fixture.test.ts"]) };
  10. test("retired evidence is rejected in prose, arbitrary aliases and extended case IDs", () => {
  11. for (const text of [
  12. `正文由 \`${unit}\` 覆盖`,
  13. `| \`LONG\` | \`${unit}\` |`,
  14. `| M06g | unit | \`${unit}\` | behavior |`,
  15. ])
  16. assert.ok(inspectRetiredAppUnitEvidence(text, options).length > 0, text);
  17. });
  18. test("retirement notes cannot keep a positive status backed only by retired evidence", () => {
  19. for (const status of ["unit", "covered", "partial", "covered-unit"]) {
  20. assert.ok(
  21. inspectRetiredAppUnitEvidence(
  22. `| M06g | ${status} | \`retired:${unit}\` | behavior |`,
  23. options,
  24. ).length > 0,
  25. );
  26. assert.ok(
  27. inspectRetiredAppUnitEvidence(
  28. `| \`LONG\` | \`retired:${unit}\` |\n| CASE-01 | ${status} | LONG | behavior |`,
  29. options,
  30. ).length > 0,
  31. );
  32. }
  33. });
  34. test("historical labels, planned E2E and retained CLI CUA browser engineering evidence remain valid", () => {
  35. const markdown = [
  36. `历史:\`retired:${unit}\`,2026-01-01 通过 3/3。`,
  37. `| M06g | unit-retired | \`retired:${unit}\` | 待补 E2E |`,
  38. `| M06o | partial | \`retired:${unit}\` + \`${e2e}\` | remaining E2E |`,
  39. `| \`LONG\` | \`${e2e}\`(planned) |`,
  40. "`apps/zcode-cli/packages/core/tests/read-tool-contract.test.ts`",
  41. "`packages/zcode-cua/test/example.test.ts`",
  42. "`packages/ui/test/browser/manual-review/pending/example.test.mjs`",
  43. "`packages/desktop/test/fixture.test.ts`",
  44. ].join("\n");
  45. assert.deepEqual(inspectRetiredAppUnitEvidence(markdown, options), []);
  46. });
  47. test("all current coverage matrices stop claiming retired App evidence", async () => {
  48. const errors = await inspectCoverageMatrices();
  49. assert.deepEqual(errors, []);
  50. });
  51. test("planned prose cannot stand in for retained evidence", () => {
  52. assert.ok(
  53. inspectRetiredAppUnitEvidence(
  54. `| CASE-01 | covered | \`retired:${unit}\` + E2E 待补 | behavior |`,
  55. options,
  56. ).length > 0,
  57. );
  58. });
  59. test("retirement cannot relabel protected CLI CUA browser E2E or engineering evidence", () => {
  60. for (const path of [
  61. e2e,
  62. "apps/zcode-cli/packages/core/tests/read-tool-contract.test.ts",
  63. "packages/zcode-cua/test/example.test.ts",
  64. "packages/ui/test/browser/example.test.mjs",
  65. "packages/desktop/test/fixture.test.ts",
  66. ]) {
  67. assert.ok(
  68. inspectRetiredAppUnitEvidence(
  69. `| CASE-01 | unit-retired | \`retired:${path}\` | behavior |`,
  70. options,
  71. ).length > 0,
  72. path,
  73. );
  74. }
  75. });