- Extend i18n locales to include `company_id` and `company_id_desc` strings for API synchronization. - Add `CompanyID` field to Workfeed configuration UI in `ConfigurationWorkfeed.vue`. - Update unit and e2e tests to validate `CompanyID` functionality. - Adjust Workfeed module logic to handle `CompanyID` get/set operations.
85 lines
3.8 KiB
JavaScript
85 lines
3.8 KiB
JavaScript
import { expect, test } from "@playwright/test";
|
|
import { mockApi, seedAuthenticatedState } from "./support/network.js";
|
|
|
|
async function primeSuperuserSession(page) {
|
|
const token = "superuser-workfeed-token";
|
|
await seedAuthenticatedState(page, token);
|
|
await page.goto("/login");
|
|
await page.evaluate(async (sessionToken) => {
|
|
const sessionModule = await import("/src/components/session/token/SessionUser.vue");
|
|
window.localStorage.setItem("token", sessionToken);
|
|
sessionModule.SessionUser.token.value = sessionToken;
|
|
sessionModule.SessionUser.authenticated.value = true;
|
|
sessionModule.SessionUser.permissions.value = ["superuser", "user"];
|
|
sessionModule.SessionUser.initiated.value = true;
|
|
}, token);
|
|
}
|
|
|
|
async function runDiagnostic(page, testId, inputValue = "") {
|
|
await page.locator(`[data-testid="${testId}"]:visible`).first().click();
|
|
await expect(page.locator(".swal2-popup")).toBeVisible();
|
|
const input = page.locator(".swal2-input");
|
|
if (await input.isVisible()) {
|
|
await input.fill(inputValue);
|
|
}
|
|
await page.locator(".swal2-confirm").click();
|
|
await expect(page.locator(".swal2-popup pre")).toBeVisible();
|
|
}
|
|
|
|
async function closeResultModal(page) {
|
|
await page.locator(".swal2-confirm").click();
|
|
await expect(page.locator(".swal2-popup")).toBeHidden();
|
|
}
|
|
|
|
async function expandCategory(page, title) {
|
|
await page.locator(".card-header.is-clickable:visible").filter({ hasText: title }).first().click();
|
|
}
|
|
|
|
test.describe("Workfeed configuration smoke", () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await mockApi(page, {
|
|
authenticated: true,
|
|
permissions: ["superuser", "user"],
|
|
});
|
|
await primeSuperuserSession(page);
|
|
});
|
|
|
|
test("@smoke renders workfeed config page and runs diagnostics", async ({ page }) => {
|
|
await page.goto("/superuser/configuration/workfeed");
|
|
|
|
await expect(page).toHaveURL(/\/superuser\/configuration\/workfeed$/);
|
|
await expect(page.locator("body")).toContainText("Workfeed configuration");
|
|
await expandCategory(page, "General settings");
|
|
await expect(page.locator("body")).toContainText("Enable Workfeed");
|
|
await expandCategory(page, "API connection settings");
|
|
await expect(page.locator("body")).toContainText("Company ID");
|
|
|
|
await expandCategory(page, "Diagnostics");
|
|
await expect(page.locator('[data-testid="workfeed-diagnostics-list-departments"]:visible').first()).toBeVisible();
|
|
await expect(page.locator('[data-testid="workfeed-diagnostics-list-employees"]:visible').first()).toBeVisible();
|
|
await expect(page.locator('[data-testid="workfeed-diagnostics-list-shifts"]:visible').first()).toBeVisible();
|
|
await expect(page.locator('[data-testid="workfeed-diagnostics-get-employee"]:visible').first()).toBeVisible();
|
|
await expect(page.locator('[data-testid="workfeed-diagnostics-get-shift"]:visible').first()).toBeVisible();
|
|
|
|
await runDiagnostic(page, "workfeed-diagnostics-list-departments");
|
|
await expect(page.locator(".swal2-popup pre")).toContainText("North Facility");
|
|
await closeResultModal(page);
|
|
|
|
await runDiagnostic(page, "workfeed-diagnostics-list-employees", "anne");
|
|
await expect(page.locator(".swal2-popup pre")).toContainText("Anne Nielsen");
|
|
await closeResultModal(page);
|
|
|
|
await runDiagnostic(page, "workfeed-diagnostics-list-shifts", "published");
|
|
await expect(page.locator(".swal2-popup pre")).toContainText("Morning Shift");
|
|
await closeResultModal(page);
|
|
|
|
await runDiagnostic(page, "workfeed-diagnostics-get-employee", "emp_01J5P2F2A0CQKBBX4P8M3Y7R5P");
|
|
await expect(page.locator(".swal2-popup pre")).toContainText("Anne Nielsen");
|
|
await closeResultModal(page);
|
|
|
|
await runDiagnostic(page, "workfeed-diagnostics-get-shift", "shf_01J5P3X9D35R9C6BDZ1S0R4V6Q");
|
|
await expect(page.locator(".swal2-popup pre")).toContainText("Morning Shift");
|
|
await closeResultModal(page);
|
|
});
|
|
});
|