mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 23:00:43 +00:00
test(plugins): enforce compat removal window
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user