Repository navigation
fix(admin): only exclude past-dated deactivations #3507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
packages/shared/src/components/models-directory/deactivation.spec.ts
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
packages/shared/src/components/models-directory/deactivation.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { describe, expect, test } from "vitest"; | ||
|
|
||
| import { | ||
| isDeactivationScheduledSoon, | ||
| isMappingDeactivated, | ||
| } from "./deactivation"; | ||
|
|
||
| const now = new Date("2026-07-27T00:00:00.000Z"); | ||
|
|
||
| describe("isMappingDeactivated", () => { | ||
| test("is false without a deactivation date", () => { | ||
| expect(isMappingDeactivated({}, now)).toBe(false); | ||
| expect(isMappingDeactivated({ deactivatedAt: null }, now)).toBe(false); | ||
| }); | ||
|
|
||
| test("is true once the date has passed", () => { | ||
| expect( | ||
| isMappingDeactivated({ deactivatedAt: new Date("2026-07-26") }, now), | ||
| ).toBe(true); | ||
| expect(isMappingDeactivated({ deactivatedAt: "2026-01-01" }, now)).toBe( | ||
| true, | ||
| ); | ||
| }); | ||
|
|
||
| test("is false for a scheduled future deactivation", () => { | ||
| expect( | ||
| isMappingDeactivated({ deactivatedAt: new Date("2026-07-28") }, now), | ||
| ).toBe(false); | ||
| expect(isMappingDeactivated({ deactivatedAt: "2026-12-31" }, now)).toBe( | ||
| false, | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("isDeactivationScheduledSoon", () => { | ||
| test("is false without a deactivation date", () => { | ||
| expect(isDeactivationScheduledSoon({}, now)).toBe(false); | ||
| expect(isDeactivationScheduledSoon({ deactivatedAt: null }, now)).toBe( | ||
| false, | ||
| ); | ||
| }); | ||
|
|
||
| test("is true inside the notice window", () => { | ||
| expect( | ||
| isDeactivationScheduledSoon({ deactivatedAt: "2026-07-28" }, now), | ||
| ).toBe(true); | ||
| expect( | ||
| isDeactivationScheduledSoon( | ||
| { deactivatedAt: new Date("2026-08-25T00:00:00.000Z") }, | ||
| now, | ||
| ), | ||
| ).toBe(true); | ||
| }); | ||
|
|
||
| test("is false beyond the notice window", () => { | ||
| expect( | ||
| isDeactivationScheduledSoon( | ||
| { deactivatedAt: new Date("2026-08-27T00:00:00.001Z") }, | ||
| now, | ||
| ), | ||
| ).toBe(false); | ||
| expect( | ||
| isDeactivationScheduledSoon({ deactivatedAt: "2028-01-11" }, now), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| test("is false once the date has passed", () => { | ||
| expect( | ||
| isDeactivationScheduledSoon({ deactivatedAt: "2026-07-26" }, now), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| test("honours a custom window", () => { | ||
| expect( | ||
| isDeactivationScheduledSoon({ deactivatedAt: "2026-08-10" }, now, 7), | ||
| ).toBe(false); | ||
| expect( | ||
| isDeactivationScheduledSoon({ deactivatedAt: "2026-07-30" }, now, 7), | ||
| ).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * How close a scheduled deactivation has to be before it is worth surfacing. | ||
| * A date further out than this is catalogue bookkeeping (providers routinely | ||
| * publish retirement dates a year or more ahead) — the mapping routes normally | ||
| * and nothing about it should read as "deactivated". | ||
| */ | ||
| export const DEACTIVATION_NOTICE_DAYS = 30; | ||
|
|
||
| const DAY_MS = 24 * 60 * 60 * 1000; | ||
|
|
||
| /** | ||
| * A provider mapping only counts as deactivated once its deactivation date has | ||
| * passed — a future date is a scheduled deactivation and the mapping is still | ||
| * routable, so it stays visible in public model lists. | ||
| */ | ||
| export function isMappingDeactivated( | ||
| mapping: { deactivatedAt?: Date | string | null }, | ||
| now: Date = new Date(), | ||
| ): boolean { | ||
| return Boolean( | ||
| mapping.deactivatedAt && new Date(mapping.deactivatedAt) <= now, | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * True while the mapping is still live but its scheduled deactivation falls | ||
| * inside the notice window. Such a mapping is fully routable — only how its | ||
| * status is displayed changes, so callers must never use this to filter. | ||
| */ | ||
| export function isDeactivationScheduledSoon( | ||
| mapping: { deactivatedAt?: Date | string | null }, | ||
| now: Date = new Date(), | ||
| withinDays: number = DEACTIVATION_NOTICE_DAYS, | ||
| ): boolean { | ||
| if (!mapping.deactivatedAt) { | ||
| return false; | ||
| } | ||
| const deactivatedAt = new Date(mapping.deactivatedAt); | ||
| return ( | ||
| deactivatedAt > now && | ||
| deactivatedAt.getTime() - now.getTime() <= withinDays * DAY_MS | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.