Files
pleno-vue/tests/unit/superuser-department-modules-workfeed.spec.js
T
Jeppe Bundgaard b39b458f4f Add .prettierrc.json and refactor test files for improved formatting consistency:
- Introduced `.prettierrc.json` to enforce consistent code formatting across the project.
- Updated unit and e2e test files to address formatting issues, improve readability, and ensure alignment with the new Prettier configuration.
2026-04-13 09:13:27 +02:00

39 lines
1.6 KiB
JavaScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
const root = process.cwd();
const source = readFileSync(
join(root, "src/views/dashboards/superUserDashboard/department/modules/DepartmentModulesSetup.vue"),
"utf8"
);
describe("superuser department modules workfeed mapping contract", () => {
it("persists the workfeed department mapping in department variables", () => {
expect(source).toContain('"workfeed_department_id"');
expect(source).toContain("SessionUser.objects.department_variables.add(");
});
it("loads available departments from the workfeed module endpoint", () => {
expect(source).toContain("SessionUser.superUser.modules.workfeed.functions.listDepartments()");
expect(source).toContain("getWorkfeedDepartmentOptions()");
});
it("normalizes list response shapes and maps options", () => {
expect(source).toContain("Array.isArray(payload?.items)");
expect(source).toContain("Array.isArray(payload?.results)");
expect(source).toContain("Array.isArray(payload)");
expect(source).toContain("label: mappedDepartmentName || mappedDepartmentId");
});
it("includes an explicit unset option in the select", () => {
expect(source).toContain('{ value: "", label: "No Workfeed department" }');
});
it("wires configuration select to save and render the stored string value", () => {
expect(source).toContain(':on-select="setWorkfeedDepartmentId"');
expect(source).toContain(":value=\"getVariableStringValue('workfeed_department_id')\"");
expect(source).toContain(':disabled="isLoadingWorkfeedDepartments"');
});
});