test(plugins): enforce compat removal window

This commit is contained in:
Vincent Koc
2026-04-26 02:51:26 -07:00
parent 5baf90ffef
commit bb2425e612
2 changed files with 16 additions and 4 deletions

View File

@@ -9,6 +9,16 @@ import {
const datePattern = /^\d{4}-\d{2}-\d{2}$/u;
function parseDate(date: string): Date {
return new Date(`${date}T00:00:00Z`);
}
function addUtcMonths(date: Date, months: number): Date {
const next = new Date(date);
next.setUTCMonth(next.getUTCMonth() + months);
return next;
}
describe("plugin compatibility registry", () => {
it("keeps compatibility codes unique and lookup-safe", () => {
const records = listPluginCompatRecords();
@@ -25,6 +35,8 @@ describe("plugin compatibility registry", () => {
expect(record.deprecated, record.code).toMatch(datePattern);
expect(record.warningStarts, record.code).toMatch(datePattern);
expect(record.removeAfter, record.code).toMatch(datePattern);
const maxRemoveAfter = addUtcMonths(parseDate(record.warningStarts), 3);
expect(parseDate(record.removeAfter) <= maxRemoveAfter, record.code).toBe(true);
expect(record.replacement, record.code).toBeTruthy();
expect(record.docsPath, record.code).toMatch(/^\//u);
}