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

@@ -71,10 +71,10 @@ The migration sequence is:
7. Remove only with explicit breaking-release approval.
Deprecated records must include a warning start date, replacement, docs link,
and target removal date no more than three months after deprecation. Do not add
a deprecated compatibility path with an open-ended removal window unless
maintainers explicitly decide it is permanent compatibility and mark it
`active` instead.
and final removal date no more than three months after the warning starts. Do
not add a deprecated compatibility path with an open-ended removal window unless
maintainers explicitly decide it is permanent compatibility and mark it `active`
instead.
## Current compatibility areas

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);
}