feat(housekeeping): cut over administration to ase
This commit is contained in:
1 parent
c9e35cf602
commit
2b8f73a91d
457 files changed
+589
-55936
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { PERMS } from "@/lib/permission-slugs";
|
||||
import { contentMigrationEntries } from "./content";
|
||||
import { ownedLegacyPages } from "./discover-legacy-pages";
|
||||
import { ownedLegacyPages, recordedLegacyPages } from "./discover-legacy-pages";
|
||||
import { HOUSEKEEPING_MIGRATION_MATRIX } from "./matrix";
|
||||
import { validateMigrationEntries } from "./validate-matrix";
|
||||
|
||||
const CONTENT_PREFIXES = [
|
||||
@@ -24,7 +25,10 @@ const CONTENT_PREFIXES = [
|
||||
|
||||
describe("contentMigrationEntries", () => {
|
||||
it("covers every content page without legacy-domain targets", () => {
|
||||
const expected = ownedLegacyPages(CONTENT_PREFIXES);
|
||||
const expected = ownedLegacyPages(
|
||||
CONTENT_PREFIXES,
|
||||
recordedLegacyPages(HOUSEKEEPING_MIGRATION_MATRIX),
|
||||
);
|
||||
expect(validateMigrationEntries(expected, contentMigrationEntries)).toEqual(
|
||||
[],
|
||||
);
|
||||
|
||||
@@ -26,37 +26,8 @@ function createRouteTree(files: readonly string[]): string {
|
||||
}
|
||||
|
||||
describe("discoverLegacyPages", () => {
|
||||
it("discovers the exact legacy administration inventory", () => {
|
||||
const pages = discoverLegacyPages();
|
||||
|
||||
expect(pages).toHaveLength(137);
|
||||
expect(pages).toContainEqual({
|
||||
surface: "admin",
|
||||
legacyPath: "/admin/users/:id/edit",
|
||||
sourceFile: "src/app/admin/users/[id]/edit/page.tsx",
|
||||
});
|
||||
expect(pages).toContainEqual({
|
||||
surface: "mod",
|
||||
legacyPath: "/mod/cfh/:id",
|
||||
sourceFile: "src/app/mod/cfh/[id]/page.tsx",
|
||||
});
|
||||
});
|
||||
|
||||
it("discovers root administration and moderation routes", () => {
|
||||
expect(discoverLegacyPages()).toEqual(
|
||||
expect.arrayContaining([
|
||||
{
|
||||
surface: "admin",
|
||||
legacyPath: "/admin",
|
||||
sourceFile: "src/app/admin/page.tsx",
|
||||
},
|
||||
{
|
||||
surface: "mod",
|
||||
legacyPath: "/mod",
|
||||
sourceFile: "src/app/mod/page.tsx",
|
||||
},
|
||||
]),
|
||||
);
|
||||
it("returns no routes after the atomic cutover", () => {
|
||||
expect(discoverLegacyPages()).toEqual([]);
|
||||
});
|
||||
|
||||
it("discovers root routes in a controlled route tree", () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { readdirSync } from "node:fs";
|
||||
import { existsSync, readdirSync } from "node:fs";
|
||||
import { join, relative } from "node:path";
|
||||
import type { LegacyPage, LegacySurface } from "./types";
|
||||
|
||||
@@ -23,6 +23,7 @@ function discoverSurface(
|
||||
): LegacyPage[] {
|
||||
const surfaceDirectory = join(rootDir, "src", "app", surface);
|
||||
const pages: LegacyPage[] = [];
|
||||
if (!existsSync(surfaceDirectory)) return pages;
|
||||
|
||||
function walk(directory: string): void {
|
||||
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
||||
@@ -51,6 +52,22 @@ function discoverSurface(
|
||||
return pages;
|
||||
}
|
||||
|
||||
export function recordedLegacyPages(
|
||||
entries: readonly LegacyPage[],
|
||||
): LegacyPage[] {
|
||||
return entries
|
||||
.map(({ surface, legacyPath, sourceFile }) => ({
|
||||
surface,
|
||||
legacyPath,
|
||||
sourceFile,
|
||||
}))
|
||||
.sort((a, b) =>
|
||||
`${a.surface}:${a.legacyPath}:${a.sourceFile}`.localeCompare(
|
||||
`${b.surface}:${b.legacyPath}:${b.sourceFile}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function discoverLegacyPages(rootDir = process.cwd()): LegacyPage[] {
|
||||
return (["admin", "mod"] as const)
|
||||
.flatMap((surface) => discoverSurface(rootDir, surface))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { ownedLegacyPages } from "./discover-legacy-pages";
|
||||
import { ownedLegacyPages, recordedLegacyPages } from "./discover-legacy-pages";
|
||||
import { economyMigrationEntries } from "./economy";
|
||||
import { HOUSEKEEPING_MIGRATION_MATRIX } from "./matrix";
|
||||
import { validateMigrationEntries } from "./validate-matrix";
|
||||
|
||||
const ECONOMY_PREFIXES = [
|
||||
@@ -20,7 +21,10 @@ const ECONOMY_PREFIXES = [
|
||||
|
||||
describe("economyMigrationEntries", () => {
|
||||
it("covers every economy page without legacy-domain targets", () => {
|
||||
const expected = ownedLegacyPages(ECONOMY_PREFIXES);
|
||||
const expected = ownedLegacyPages(
|
||||
ECONOMY_PREFIXES,
|
||||
recordedLegacyPages(HOUSEKEEPING_MIGRATION_MATRIX),
|
||||
);
|
||||
expect(validateMigrationEntries(expected, economyMigrationEntries)).toEqual(
|
||||
[],
|
||||
);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { PERMS } from "@/lib/permission-slugs";
|
||||
import { ownedLegacyPages } from "./discover-legacy-pages";
|
||||
import { ownedLegacyPages, recordedLegacyPages } from "./discover-legacy-pages";
|
||||
import { hotelMigrationEntries } from "./hotel";
|
||||
import { HOUSEKEEPING_MIGRATION_MATRIX } from "./matrix";
|
||||
import { validateMigrationEntries } from "./validate-matrix";
|
||||
|
||||
const HOTEL_PREFIXES = [
|
||||
@@ -15,7 +16,10 @@ describe("hotelMigrationEntries", () => {
|
||||
it("maps all hotel tools below the hotel target root", () => {
|
||||
expect(
|
||||
validateMigrationEntries(
|
||||
ownedLegacyPages(HOTEL_PREFIXES),
|
||||
ownedLegacyPages(
|
||||
HOTEL_PREFIXES,
|
||||
recordedLegacyPages(HOUSEKEEPING_MIGRATION_MATRIX),
|
||||
),
|
||||
hotelMigrationEntries,
|
||||
),
|
||||
).toEqual([]);
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { discoverLegacyPages } from "./discover-legacy-pages";
|
||||
import {
|
||||
discoverLegacyPages,
|
||||
recordedLegacyPages,
|
||||
} from "./discover-legacy-pages";
|
||||
import { HOUSEKEEPING_MIGRATION_MATRIX } from "./matrix";
|
||||
import { validateMigrationEntries } from "./validate-matrix";
|
||||
|
||||
describe("HOUSEKEEPING_MIGRATION_MATRIX", () => {
|
||||
it("covers all 137 legacy pages exactly once", () => {
|
||||
it("keeps all 137 historical pages recorded after cutover", () => {
|
||||
const discovered = discoverLegacyPages();
|
||||
const recorded = recordedLegacyPages(HOUSEKEEPING_MIGRATION_MATRIX);
|
||||
|
||||
expect(HOUSEKEEPING_MIGRATION_MATRIX).toHaveLength(137);
|
||||
expect(discovered).toEqual([]);
|
||||
expect(
|
||||
validateMigrationEntries(discovered, HOUSEKEEPING_MIGRATION_MATRIX),
|
||||
validateMigrationEntries(recorded, HOUSEKEEPING_MIGRATION_MATRIX),
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { discoverLegacyPages } from "./discover-legacy-pages";
|
||||
import { recordedLegacyPages } from "./discover-legacy-pages";
|
||||
import { HOUSEKEEPING_MIGRATION_MATRIX } from "./matrix";
|
||||
import { operationsMigrationEntries } from "./operations";
|
||||
import { peopleMigrationEntries } from "./people";
|
||||
import { validateMigrationEntries } from "./validate-matrix";
|
||||
@@ -52,7 +53,7 @@ describe("peopleMigrationEntries", () => {
|
||||
});
|
||||
|
||||
it("covers every Operations and People legacy page exactly once", () => {
|
||||
const expected = discoverLegacyPages().filter(
|
||||
const expected = recordedLegacyPages(HOUSEKEEPING_MIGRATION_MATRIX).filter(
|
||||
(page) =>
|
||||
page.legacyPath === "/admin" ||
|
||||
PEOPLE_PREFIXES.some(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { PERMS } from "@/lib/permission-slugs";
|
||||
import { ownedLegacyPages } from "./discover-legacy-pages";
|
||||
import { ownedLegacyPages, recordedLegacyPages } from "./discover-legacy-pages";
|
||||
import { HOUSEKEEPING_MIGRATION_MATRIX } from "./matrix";
|
||||
import { systemMigrationEntries } from "./system";
|
||||
import { validateMigrationEntries } from "./validate-matrix";
|
||||
|
||||
@@ -23,7 +24,10 @@ describe("systemMigrationEntries", () => {
|
||||
expect(systemMigrationEntries).toHaveLength(19);
|
||||
expect(
|
||||
validateMigrationEntries(
|
||||
ownedLegacyPages(SYSTEM_PREFIXES),
|
||||
ownedLegacyPages(
|
||||
SYSTEM_PREFIXES,
|
||||
recordedLegacyPages(HOUSEKEEPING_MIGRATION_MATRIX),
|
||||
),
|
||||
systemMigrationEntries,
|
||||
),
|
||||
).toEqual([]);
|
||||
|
||||
Reference in new issue
Block a user