- 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.
104 lines
5.6 KiB
JavaScript
104 lines
5.6 KiB
JavaScript
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const root = process.cwd();
|
|
const workfeedModuleSource = readFileSync(
|
|
join(root, "src/components/session/token/superUser/modules/workfeed/Workfeed.vue"),
|
|
"utf8"
|
|
);
|
|
const workfeedConfigSource = readFileSync(
|
|
join(root, "src/components/session/token/superUser/modules/workfeed/Config.vue"),
|
|
"utf8"
|
|
);
|
|
const workfeedPageSource = readFileSync(
|
|
join(root, "src/views/dashboards/superUserDashboard/configuration/ConfigurationWorkfeed.vue"),
|
|
"utf8"
|
|
);
|
|
|
|
describe("workfeed module contract", () => {
|
|
it("defines module metadata and config endpoint", () => {
|
|
expect(workfeedModuleSource).toContain('title: "Workfeed"');
|
|
expect(workfeedModuleSource).toContain('endpoint: "/modules/workfeed"');
|
|
expect(workfeedModuleSource).toContain('config_endpoint: "/configuration/workfeed"');
|
|
});
|
|
|
|
it("defines list and get endpoint wrappers for employees, shifts, and departments", () => {
|
|
expect(workfeedModuleSource).toContain('"/modules/workfeed/employees"');
|
|
expect(workfeedModuleSource).toContain('"/modules/workfeed/employees/" + encodeURIComponent(id)');
|
|
expect(workfeedModuleSource).toContain('"/modules/workfeed/shifts"');
|
|
expect(workfeedModuleSource).toContain('"/modules/workfeed/shifts/" + encodeURIComponent(id)');
|
|
expect(workfeedModuleSource).toContain('"/modules/workfeed/departments"');
|
|
});
|
|
|
|
it("matches openapi shift query parameters and required constraints", () => {
|
|
expect(workfeedModuleSource).toContain("startFrom");
|
|
expect(workfeedModuleSource).toContain("startTo");
|
|
expect(workfeedModuleSource).toContain("employeeID");
|
|
expect(workfeedModuleSource).toContain("released");
|
|
expect(workfeedModuleSource).toContain('throw new Error("startFrom and startTo are required")');
|
|
expect(workfeedModuleSource).toContain("sanitizeQuery");
|
|
});
|
|
});
|
|
|
|
describe("workfeed config contract", () => {
|
|
it("uses workfeed config endpoints", () => {
|
|
expect(workfeedConfigSource).toContain('"/workfeed/config?variable=" + variable');
|
|
expect(workfeedConfigSource).toContain('"/workfeed/config"');
|
|
});
|
|
|
|
it("supports openapi config variables", () => {
|
|
expect(workfeedConfigSource).toContain('Config.get("enabled")');
|
|
expect(workfeedConfigSource).toContain('Config.get("api_url")');
|
|
expect(workfeedConfigSource).toContain('Config.get("api_key")');
|
|
expect(workfeedConfigSource).toContain('Config.get("CompanyID")');
|
|
expect(workfeedConfigSource).toContain('Config.set("enabled", enabled)');
|
|
expect(workfeedConfigSource).toContain('Config.set("api_url", value)');
|
|
expect(workfeedConfigSource).toContain('Config.set("api_key", value)');
|
|
expect(workfeedConfigSource).toContain('Config.set("CompanyID", value)');
|
|
});
|
|
});
|
|
|
|
describe("workfeed config page contract", () => {
|
|
it("uses i18n keys and module bindings for controls", () => {
|
|
expect(workfeedPageSource).toContain("$t('configuration.workfeed.title')");
|
|
expect(workfeedPageSource).toContain("$t('configuration.workfeed.subtitle')");
|
|
expect(workfeedPageSource).toContain("$t('configuration.workfeed.enable')");
|
|
expect(workfeedPageSource).toContain("$t('configuration.workfeed.api_url')");
|
|
expect(workfeedPageSource).toContain("$t('configuration.workfeed.company_id')");
|
|
expect(workfeedPageSource).toContain("$t('configuration.workfeed.api_key')");
|
|
expect(workfeedPageSource).toContain(':on-switch="SessionUser.superUser.modules.workfeed.config.enabled.set"');
|
|
expect(workfeedPageSource).toContain(':on-save="SessionUser.superUser.modules.workfeed.config.keys.api_url.set"');
|
|
expect(workfeedPageSource).toContain(':on-save="SessionUser.superUser.modules.workfeed.config.keys.companyId.set"');
|
|
expect(workfeedPageSource).toContain(':on-save="SessionUser.superUser.modules.workfeed.config.keys.api_key.set"');
|
|
});
|
|
|
|
it("exposes modal diagnostic actions for each workfeed endpoint family", () => {
|
|
expect(workfeedPageSource).toContain("onClickListDepartments");
|
|
expect(workfeedPageSource).toContain("onClickListEmployees");
|
|
expect(workfeedPageSource).toContain("onClickListShifts");
|
|
expect(workfeedPageSource).toContain("onClickGetEmployee");
|
|
expect(workfeedPageSource).toContain("onClickGetShift");
|
|
expect(workfeedPageSource).toContain("workfeed-diagnostics-list-departments");
|
|
expect(workfeedPageSource).toContain("workfeed-diagnostics-list-employees");
|
|
expect(workfeedPageSource).toContain("workfeed-diagnostics-list-shifts");
|
|
expect(workfeedPageSource).toContain("workfeed-diagnostics-get-employee");
|
|
expect(workfeedPageSource).toContain("workfeed-diagnostics-get-shift");
|
|
expect(workfeedPageSource).toContain("prompt_start_from");
|
|
expect(workfeedPageSource).toContain("prompt_start_to");
|
|
expect(workfeedPageSource).toContain("prompt_released_optional");
|
|
expect(workfeedPageSource).toContain('type="datetime-local"');
|
|
expect(workfeedPageSource).toContain('<select id="workfeed-employee-id"');
|
|
expect(workfeedPageSource).toContain('<select id="workfeed-released"');
|
|
expect(workfeedPageSource).toContain("select_employee_all");
|
|
expect(workfeedPageSource).toContain("select_released_all");
|
|
expect(workfeedPageSource).toContain("select_released_true");
|
|
expect(workfeedPageSource).toContain("select_released_false");
|
|
expect(workfeedPageSource).toContain("validation_shift_range_required");
|
|
expect(workfeedPageSource).toContain("validation_datetime_invalid");
|
|
expect(workfeedPageSource).toContain("getEmployeeDisplayName");
|
|
expect(workfeedPageSource).toContain("employee?.firstName");
|
|
expect(workfeedPageSource).toContain("employee?.lastname");
|
|
});
|
|
});
|