96 lines
4.1 KiB
JavaScript
96 lines
4.1 KiB
JavaScript
import { expect, test } from "@playwright/test";
|
|
import { mockApi, primeMockSession } from "./support/network.js";
|
|
|
|
async function primeSuperuserSession(page) {
|
|
const token = "superuser-workfeed-token";
|
|
await primeMockSession(page, { 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 runShiftDiagnostic(page, { startFrom, startTo, employeeID = "", released = "" }) {
|
|
await page.locator('[data-testid="workfeed-diagnostics-list-shifts"]:visible').first().click();
|
|
await expect(page.locator(".swal2-popup")).toBeVisible();
|
|
await page.locator("#workfeed-start-from").fill(startFrom);
|
|
await page.locator("#workfeed-start-to").fill(startTo);
|
|
if (employeeID) {
|
|
await page.locator("#workfeed-employee-id").selectOption(employeeID);
|
|
}
|
|
if (released !== "") {
|
|
await page.locator("#workfeed-released").selectOption(released);
|
|
}
|
|
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 @pr 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");
|
|
await expect(page.locator(".swal2-popup pre")).toContainText("Anne Nielsen");
|
|
await closeResultModal(page);
|
|
|
|
await runShiftDiagnostic(page, {
|
|
startFrom: "2026-03-24T00:00",
|
|
startTo: "2026-03-25T00:00",
|
|
employeeID: "emp_01J5P2F2A0CQKBBX4P8M3Y7R5P",
|
|
released: "true",
|
|
});
|
|
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);
|
|
});
|
|
});
|