Files
pleno-vue/tests/e2e/subuserProfileInformation.spec.ts
T
Jeppe Bundgaard 60742bf947 Refactor and migrate Playwright E2E tests:
- Remove `playwright.config.js` to clean up configuration.
- Add new E2E test suites (`admin-pos-orders`, `admin-module-goals`, `admin-module-pos-mobile-order-flow`) to structure Admin module tests.
- Introduce reusable authentication and data seeding utilities in `fixtures` for streamlined test flows and maintainability.
2026-03-19 12:46:47 +01:00

142 lines
4.6 KiB
TypeScript

import { test, expect } from '@playwright/test';
import {
userCredentials,
loginAsSubuserByPhone,
} from './fixtures';
// Navigate to profile page helper
async function goToUserProfile(page) {
await page.click('a[href="/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();
});