87 lines
3.6 KiB
JavaScript
87 lines
3.6 KiB
JavaScript
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const readSource = (relativePath) =>
|
|
readFileSync(fileURLToPath(new URL(`../../${relativePath}`, import.meta.url)), "utf8");
|
|
|
|
describe("Superuser user overview source", () => {
|
|
const overviewWidgetSources = [
|
|
"src/views/dashboards/superUserDashboard/user/User.vue",
|
|
"src/views/dashboards/superUserDashboard/user/SuperUserSelectedUserObject.vue",
|
|
"src/views/dashboards/superUserDashboard/user/SuperuserUserMetricGrid.vue",
|
|
"src/views/dashboards/superUserDashboard/user/UserOrders.vue",
|
|
"src/views/dashboards/superUserDashboard/user/UserPricing.vue",
|
|
"src/views/dashboards/superUserDashboard/user/UserOther.vue",
|
|
"src/views/dashboards/superUserDashboard/user/UserVehicles.vue",
|
|
"src/views/dashboards/superUserDashboard/user/UserXLVask.vue",
|
|
"src/views/dashboards/superUserDashboard/user/displays/UserDefaultDepartment.vue",
|
|
"src/views/dashboards/superUserDashboard/user/displays/UserFixedPricing.vue",
|
|
"src/views/dashboards/superUserDashboard/user/displays/other/UserOtherSpecialArrangement.vue",
|
|
"src/views/dashboards/superUserDashboard/user/displays/other/UserOtherVaskeabonnement.vue",
|
|
"src/views/dashboards/superUserDashboard/user/displays/vehicles/UserVehicleSubscriptionsDisplay.vue",
|
|
];
|
|
|
|
it("keeps the overview page on the cleaned management hub implementation", () => {
|
|
const source = readSource("src/views/dashboards/superUserDashboard/user/User.vue");
|
|
|
|
expect(source).toContain('content-test-id="superuser-user-overview-page"');
|
|
expect(source).toContain("SuperuserUserPanelGrid");
|
|
expect(source).not.toContain("<template #title>");
|
|
expect(source).not.toContain("SessionUser.valueOf()");
|
|
expect(source).not.toContain("JSON.stringify(user");
|
|
});
|
|
|
|
it("keeps the user detail subpages on the tile layout implementation", () => {
|
|
const expectations = [
|
|
[
|
|
"src/views/dashboards/superUserDashboard/user/UserOrders.vue",
|
|
"SuperuserUserMetricGrid",
|
|
"superuser-user-orders-metrics",
|
|
],
|
|
[
|
|
"src/views/dashboards/superUserDashboard/user/UserPricing.vue",
|
|
"SuperuserUserMetricGrid",
|
|
"superuser-user-pricing-metrics",
|
|
],
|
|
[
|
|
"src/views/dashboards/superUserDashboard/user/UserOther.vue",
|
|
"SuperuserUserPanelGrid",
|
|
"superuser-user-other-tiles",
|
|
],
|
|
[
|
|
"src/views/dashboards/superUserDashboard/user/UserVehicles.vue",
|
|
"SuperuserUserPanelGrid",
|
|
"superuser-user-vehicles-tiles",
|
|
],
|
|
[
|
|
"src/views/dashboards/superUserDashboard/user/UserXLVask.vue",
|
|
"SuperuserUserPanelGrid",
|
|
"superuser-user-xlvask-tiles",
|
|
],
|
|
];
|
|
|
|
for (const [relativePath, componentName, testId] of expectations) {
|
|
const source = readSource(relativePath);
|
|
|
|
expect(source).toContain(componentName);
|
|
expect(source).toContain(testId);
|
|
expect(source).not.toContain("<template #title>");
|
|
}
|
|
});
|
|
|
|
it("keeps the selected user state loadable and retry-aware", () => {
|
|
const source = readSource("src/views/dashboards/superUserDashboard/user/SuperUserSelectedUserObject.vue");
|
|
|
|
expect(source).toContain("isUserLoading");
|
|
expect(source).toContain("userLoadError");
|
|
expect(source).toContain("activeLoadPromise");
|
|
});
|
|
|
|
it("keeps the overview and directly embedded widgets free of debug logging", () => {
|
|
for (const relativePath of overviewWidgetSources) {
|
|
expect(readSource(relativePath), relativePath).not.toContain("console.log");
|
|
}
|
|
});
|
|
});
|