C4 follow-up #3: RFC 8594 Deprecation/Sunset headers + call counter on legacy hire routes

This commit is contained in:
ZacharyZhang-NY committed 2026-04-20 14:56:34 -04:00
1 parent 1fad88bad1
commit d2b6f91023
4 files changed
+104

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
import { beforeEach, describe, expect, it } from "vitest";
import {
incrementDeprecationCall,
readDeprecationCounters,
resetDeprecationCounters,
} from "../../src/main/api-server/deprecation-counter";
/**
* C4-followup #3: the in-process deprecation counter backs the
* "has legacy traffic hit zero?" decision. Keep these tests tight —
* the module has one job.
*/
describe("deprecation counter", () => {
beforeEach(() => {
resetDeprecationCounters();
});
it("increments and reads back the count for a single route", () => {
incrementDeprecationCall("POST /legacy/hire");
incrementDeprecationCall("POST /legacy/hire");
expect(readDeprecationCounters()).toEqual({ "POST /legacy/hire": 2 });
});
it("tracks multiple route labels independently", () => {
incrementDeprecationCall("POST /legacy/hire");
incrementDeprecationCall("POST /legacy/approvals");
incrementDeprecationCall("POST /legacy/hire");
expect(readDeprecationCounters()).toEqual({
"POST /legacy/hire": 2,
"POST /legacy/approvals": 1,
});
});
it("resets all counters back to empty", () => {
incrementDeprecationCall("POST /legacy/hire");
resetDeprecationCounters();
expect(readDeprecationCounters()).toEqual({});
});
it("throws on an empty routeLabel instead of silently recording", () => {
expect(() => incrementDeprecationCall("")).toThrow(/non-empty routeLabel/);
});
});