Files
pleno-vue/tests/e2e/subuserProfileInformation.spec.ts
T
Jeppe Bundgaard 8f3ec2cf09 Add booking selection popup and refactor POS booking flow logic:
- Introduced `PosDepartmentStepMobilePopupSelectOrderBooking.vue` for mobile booking selection.
- Refactored vehicle and booking handling in `SelectVehicleFormPOS.vue` with better plate matching, booking persistence, and customer association logic.
- Updated `PosVehicle` object type to include booking matches.
- Enhanced POS transaction history and booking views with improved readability, functionality, and `data-testid` attributes.
- Adjusted `PosPopup.vue` components to support the new booking popup.
2026-04-13 17:27:37 +02:00

139 lines
4.5 KiB
TypeScript

import { test, expect } from "@playwright/test";
import { userCredentials, loginAsSubuserByPhone } from "./fixtures";
// Navigate to profile page helper
async function goToUserProfile(page) {
await page.goto("/user/profile");
await expect(page).toHaveURL(/\/user\/profile(?:[?#].*)?$/);
}
// Helper to expand a category section by clicking its header
async function expandCategory(page, categoryText: string) {
const categoryHeader = page.locator(".card-header").filter({ hasText: categoryText }).first();
await categoryHeader.click();
// Wait for expansion animation
await page.waitForTimeout(200);
}
// Subuser profile information display tests
test("[PROFILE][Subuser][Profile] should display profile information section", async ({ page }) => {
await loginAsSubuserByPhone(page);
await goToUserProfile(page);
// Should display the driver/subuser profile section header
await expect(page.locator(".card-header").filter({ hasText: "Chauffør" }).first()).toBeVisible();
});
test("[PROFILE][Subuser][Profile] should display username field (read-only)", async ({ page }) => {
await loginAsSubuserByPhone(page);
await goToUserProfile(page);
// Expand the profile section (first Chauffør section)
await expandCategory(page, "Chauffør");
// Username field should be visible
await expect(page.getByText("Brugernavn", { exact: true })).toBeVisible();
});
test("[PROFILE][Subuser][Profile] should display name field", async ({ page }) => {
await loginAsSubuserByPhone(page);
await goToUserProfile(page);
// Expand the profile section
await expandCategory(page, "Chauffør");
// Name field should be visible
await expect(page.getByText("Navn", { exact: true })).toBeVisible();
});
test("[PROFILE][Subuser][Profile] should display edit name button", async ({ page }) => {
await loginAsSubuserByPhone(page);
await goToUserProfile(page);
// Expand the profile section
await expandCategory(page, "Chauffør");
// Edit name button should be visible
const editNameButton = page.locator('button:has-text("Rediger navn")');
await expect(editNameButton).toBeVisible();
});
test("[PROFILE][Subuser][Profile] should open edit name dialog when clicking edit name button", async ({ page }) => {
await loginAsSubuserByPhone(page);
await goToUserProfile(page);
// Expand the profile section
await expandCategory(page, "Chauffør");
// Click edit name button
const editNameButton = page.locator('button:has-text("Rediger navn")');
await editNameButton.click();
// Should show name dialog (SweetAlert)
await expect(page.locator(".swal2-popup")).toBeVisible();
await expect(page.locator(".swal2-title")).toContainText("navn");
});
/** Subuser Name Validation Tests */
test("[PROFILE][Subuser][Profile] should show validation error when name is empty", async ({ page }) => {
await loginAsSubuserByPhone(page);
await goToUserProfile(page);
// Expand the profile section
await expandCategory(page, "Chauffør");
// Click edit name button
const editNameButton = page.locator('button:has-text("Rediger navn")');
await editNameButton.click();
// Clear the input and click confirm
await page.fill(".swal2-input", "");
await page.click(".swal2-confirm");
// Should show validation error
await expect(page.locator(".swal2-validation-message")).toBeVisible();
});
test("[PROFILE][Subuser][Profile] should show validation error when name is too short", async ({ page }) => {
await loginAsSubuserByPhone(page);
await goToUserProfile(page);
// Expand the profile section
await expandCategory(page, "Chauffør");
// Click edit name button
const editNameButton = page.locator('button:has-text("Rediger navn")');
await editNameButton.click();
// Fill in name that is too short
await page.fill(".swal2-input", "A");
await page.click(".swal2-confirm");
// Should show validation error
await expect(page.locator(".swal2-validation-message")).toBeVisible();
});
/** Dialog Cancel Tests */
test("[PROFILE][Subuser][Profile] should close dialog when cancel is clicked on name change", async ({ page }) => {
await loginAsSubuserByPhone(page);
await goToUserProfile(page);
// Expand the profile section
await expandCategory(page, "Chauffør");
// Click edit name button
const editNameButton = page.locator('button:has-text("Rediger navn")');
await editNameButton.click();
// Verify dialog is open
await expect(page.locator(".swal2-popup")).toBeVisible();
// Click cancel
await page.click(".swal2-cancel");
// Dialog should be closed
await expect(page.locator(".swal2-popup")).not.toBeVisible();
});