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,56 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { readRepoFile } from "~/utils/testing/repoPaths";
|
||||
|
||||
const routePath = "apps/web/app/routes/admin/analytics/overview.tsx";
|
||||
const tableRoutePaths = ["apps/web/app/routes/admin/analytics/visitors.tsx", "apps/web/app/routes/admin/analytics/events.tsx", "apps/web/app/routes/admin/analytics/page-views.tsx"];
|
||||
|
||||
function readRoute(route = routePath) {
|
||||
return readRepoFile(route);
|
||||
}
|
||||
|
||||
describe("admin analytics overview route DB boundary", () => {
|
||||
it("uses the package analytics overview helper", () => {
|
||||
const source = readRoute();
|
||||
|
||||
expect(source).toContain("@toolctrl/db/analytics.server");
|
||||
expect(source).toContain("getAnalyticsOverview");
|
||||
expect(source).toContain("withUsers: true");
|
||||
expect(source).toContain("portalId: undefined");
|
||||
expect(source).toContain("getTranslations(request)");
|
||||
expect(source).toContain("locale,");
|
||||
});
|
||||
|
||||
it("validates the period before calling the package helper", () => {
|
||||
const source = readRoute();
|
||||
|
||||
expect(source).toContain("PeriodHelper.getPeriodFromRequest({ request })");
|
||||
expect(source).toContain("isAnalyticsPeriod(period) ? period : defaultAnalyticsPeriod");
|
||||
});
|
||||
|
||||
it("does not import the legacy AnalyticsService", () => {
|
||||
const source = readRoute();
|
||||
|
||||
expect(source).not.toContain("~/utils/helpers/.server/AnalyticsService");
|
||||
});
|
||||
|
||||
it("keeps migrated table routes behind the package analytics boundary", () => {
|
||||
for (const tableRoutePath of tableRoutePaths) {
|
||||
const source = readRoute(tableRoutePath);
|
||||
|
||||
expect(source).toContain("@toolctrl/db/analytics.server");
|
||||
expect(source).not.toContain('from "~/utils/db.server"');
|
||||
expect(source).not.toContain('from "~/utils/db/users.db.server"');
|
||||
expect(source).not.toContain('from "~/modules/featureFlags/db/featureFlags.db.server"');
|
||||
expect(source).not.toMatch(/\bdb\.analytics(?:UniqueVisitor|Event|PageView)\b/);
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps migrated table route dates on locale-aware formatters", () => {
|
||||
const source = tableRoutePaths.map((tableRoutePath) => readRoute(tableRoutePath)).join("\n");
|
||||
|
||||
expect(source).toContain("useLocaleFormatters");
|
||||
expect(source).toContain("formatters.dateTime");
|
||||
expect(source).toContain("formatters.relativeDate");
|
||||
expect(source).not.toContain("DateUtils");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user