Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,64 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
type MigratedAnalyticsRoute = {
|
||||
path: string;
|
||||
packageImports: string[];
|
||||
};
|
||||
|
||||
const migratedAnalyticsRoutes: MigratedAnalyticsRoute[] = [
|
||||
{
|
||||
path: "overview.tsx",
|
||||
packageImports: ["getAnalyticsOverview"],
|
||||
},
|
||||
{
|
||||
path: "visitors.tsx",
|
||||
packageImports: ["getAnalyticsVisitorList"],
|
||||
},
|
||||
{
|
||||
path: "events.tsx",
|
||||
packageImports: ["getAnalyticsEventFilterOptions", "getAnalyticsEventList"],
|
||||
},
|
||||
{
|
||||
path: "page-views.tsx",
|
||||
packageImports: ["getAnalyticsPageViewFilterOptions", "getAnalyticsPageViewList"],
|
||||
},
|
||||
{
|
||||
path: "settings.tsx",
|
||||
packageImports: ["deleteAllAnalyticsData", "getOrCreateAnalyticsSettings", "removeAnalyticsIgnoredPage", "updateAnalyticsSettingsPreferences"],
|
||||
},
|
||||
];
|
||||
|
||||
const forbiddenAnalyticsBoundaryImports = [
|
||||
"~/utils/db.server",
|
||||
"~/utils/helpers/.server/AnalyticsService",
|
||||
"~/utils/db/users.db.server",
|
||||
"~/modules/featureFlags/db/featureFlags.db.server",
|
||||
];
|
||||
|
||||
function readRouteSource(path: string) {
|
||||
return readFileSync(new URL(path, import.meta.url), "utf8");
|
||||
}
|
||||
|
||||
describe("migrated admin analytics route DB boundary imports", () => {
|
||||
it("uses the package-owned analytics server helpers in every migrated route", () => {
|
||||
for (const route of migratedAnalyticsRoutes) {
|
||||
const source = readRouteSource(route.path);
|
||||
|
||||
expect(source, `${route.path} should import the analytics package boundary`).toContain("@toolctrl/db/analytics.server");
|
||||
for (const packageImport of route.packageImports) {
|
||||
expect(source, `${route.path} should import ${packageImport}`).toContain(packageImport);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("does not reintroduce app-local analytics DB imports in migrated routes", () => {
|
||||
for (const route of migratedAnalyticsRoutes) {
|
||||
const source = readRouteSource(route.path);
|
||||
|
||||
for (const forbiddenImport of forbiddenAnalyticsBoundaryImports) {
|
||||
expect(source, `${route.path} should not import ${forbiddenImport}`).not.toContain(forbiddenImport);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user