






















@@ -0,0 +1,78 @@
1+import fs from "node:fs";
2+import { describe, expect, it } from "vitest";
3+import {
4+getDoctorDeprecationCompatRecord,
5+isDoctorDeprecationCompatCode,
6+listDeprecatedDoctorDeprecationCompatRecords,
7+listDoctorDeprecationCompatRecords,
8+} from "./deprecation-compat.js";
9+10+const datePattern = /^\d{4}-\d{2}-\d{2}$/u;
11+12+const requiredDoctorCompatCodes = [
13+"doctor-agent-runtime-embedded-harness",
14+"doctor-plugin-install-config-ledger",
15+"doctor-bundled-plugin-load-paths",
16+"doctor-web-search-plugin-config",
17+"doctor-web-fetch-plugin-config",
18+"doctor-x-search-plugin-config",
19+] as const;
20+21+function parseDate(date: string): Date {
22+return new Date(`${date}T00:00:00Z`);
23+}
24+25+function addUtcMonths(date: Date, months: number): Date {
26+const next = new Date(date);
27+next.setUTCMonth(next.getUTCMonth() + months);
28+return next;
29+}
30+31+describe("doctor deprecation compatibility inventory", () => {
32+it("keeps compatibility codes unique and lookup-safe", () => {
33+const records = listDoctorDeprecationCompatRecords();
34+const codes = records.map((record) => record.code);
35+36+expect(new Set(codes).size).toBe(codes.length);
37+expect(isDoctorDeprecationCompatCode("doctor-web-search-plugin-config")).toBe(true);
38+expect(isDoctorDeprecationCompatCode("missing-code")).toBe(false);
39+expect(getDoctorDeprecationCompatRecord("doctor-web-search-plugin-config").owner).toBe(
40+"provider",
41+);
42+});
43+44+it("tracks the known doctor migrations that protect plugin/config rollout", () => {
45+for (const code of requiredDoctorCompatCodes) {
46+expect(isDoctorDeprecationCompatCode(code), code).toBe(true);
47+}
48+});
49+50+it("requires dated deprecation metadata with a three-month maximum window", () => {
51+for (const record of listDeprecatedDoctorDeprecationCompatRecords()) {
52+expect(record.deprecated, record.code).toMatch(datePattern);
53+expect(record.warningStarts, record.code).toMatch(datePattern);
54+expect(record.removeAfter, record.code).toMatch(datePattern);
55+if (!record.warningStarts || !record.removeAfter) {
56+throw new Error(`${record.code} is missing deprecation window dates`);
57+}
58+const maxRemoveAfter = addUtcMonths(parseDate(record.warningStarts), 3);
59+const removeAfter = parseDate(record.removeAfter);
60+expect(removeAfter <= maxRemoveAfter, record.code).toBe(true);
61+}
62+});
63+64+it("keeps every record actionable", () => {
65+for (const record of listDoctorDeprecationCompatRecords()) {
66+expect(record.introduced, record.code).toMatch(datePattern);
67+expect(record.source, record.code).toBeTruthy();
68+expect(record.migration, record.code).toBeTruthy();
69+expect(record.replacement, record.code).toBeTruthy();
70+expect(record.docsPath, record.code).toMatch(/^\//u);
71+expect(fs.existsSync(record.migration), `${record.code}: ${record.migration}`).toBe(true);
72+expect(record.tests.length, record.code).toBeGreaterThan(0);
73+for (const testPath of record.tests) {
74+expect(fs.existsSync(testPath), `${record.code}: ${testPath}`).toBe(true);
75+}
76+}
77+});
78+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。