- Introduced `mobileOrderCompletion.js` for mobile order metadata handling with safety seal syncing, metadata persistence, and booking linking utilities. - Added tests for Subuser navigation menu (`navigation-menu-items-user-subusers.spec.js`) to validate links and permission gating. - Created unit and end-to-end tests for Subuser grant permissions and management, including permission nodes and invites (`subuser-grant-permission-nodes.spec.js`, `subuser-management.spec.ts`). - Implemented `SubuserCompleteRegistrationPage.vue` with validation, token handling, and registration flow for Subuser setup. - Enhanced Playwright e2e tests for Subuser features (`subuserCompleteRegistration.spec.ts`).
88 lines
3.6 KiB
TypeScript
88 lines
3.6 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { loginAsUser } from "./fixtures";
|
|
|
|
async function openUserSecurity(page) {
|
|
await loginAsUser(page);
|
|
await page.goto("/user/profile");
|
|
const securityCard = page.getByTestId("user-profile-security-card");
|
|
await expect(securityCard).toBeVisible();
|
|
await securityCard.locator(".card-header").click();
|
|
await expect(page.getByTestId("user-profile-security-edit-email")).toBeVisible();
|
|
return securityCard;
|
|
}
|
|
|
|
async function expectLogoutButtonStyling(page, button) {
|
|
await expect(button).toHaveClass(/is-danger/);
|
|
await expect(button).toHaveClass(/is-outlined/);
|
|
|
|
const viewportWidth = page.viewportSize()?.width ?? Number.MAX_SAFE_INTEGER;
|
|
if (viewportWidth <= 768) {
|
|
const dimensions = await button.evaluate((element) => {
|
|
const rect = element.getBoundingClientRect();
|
|
const parentRect = element.parentElement?.getBoundingClientRect();
|
|
return {
|
|
width: rect.width,
|
|
parentWidth: parentRect?.width ?? rect.width,
|
|
};
|
|
});
|
|
|
|
expect(Math.abs(dimensions.parentWidth - dimensions.width)).toBeLessThanOrEqual(2);
|
|
}
|
|
}
|
|
|
|
test("[PROFILE][User][Security] renders the current security surface", async ({ page }) => {
|
|
await openUserSecurity(page);
|
|
|
|
await expect(page.getByTestId("user-profile-security-edit-email")).toBeVisible();
|
|
await expect(page.getByTestId("user-profile-security-edit-phone")).toBeVisible();
|
|
await expect(page.getByTestId("user-profile-security-change-password")).toBeVisible();
|
|
const logoutButton = page.getByTestId("user-profile-security-logout");
|
|
await expect(logoutButton).toBeVisible();
|
|
await expectLogoutButtonStyling(page, logoutButton);
|
|
await expect(page.getByTestId("user-profile-passkeys").getByTestId("passkey-add")).toBeVisible();
|
|
await expect(page.getByTestId("user-profile-two-factor").getByTestId("two-factor-status")).toBeVisible();
|
|
await expect(page.getByTestId("subuser-profile-security-logout")).toHaveCount(0);
|
|
});
|
|
|
|
test("[PROFILE][User][Security] opens the logout confirmation dialog", async ({ page }) => {
|
|
await openUserSecurity(page);
|
|
|
|
await page.getByTestId("user-profile-security-logout").click();
|
|
await expect(page.locator(".swal2-popup")).toBeVisible();
|
|
});
|
|
|
|
test("[PROFILE][User][Security] opens the email password-confirmation dialog", async ({ page }) => {
|
|
await openUserSecurity(page);
|
|
|
|
await page.getByTestId("user-profile-security-edit-email").click();
|
|
await expect(page.locator(".swal2-popup")).toBeVisible();
|
|
await expect(page.locator(".swal2-input")).toBeVisible();
|
|
});
|
|
|
|
test("[PROFILE][User][Security] validates the phone-number dialog before submit", async ({ page }) => {
|
|
await openUserSecurity(page);
|
|
|
|
await page.getByTestId("user-profile-security-edit-phone").click();
|
|
await expect(page.locator(".swal2-popup")).toBeVisible();
|
|
await page.click(".swal2-confirm");
|
|
await expect(page.locator(".swal2-validation-message")).toBeVisible();
|
|
});
|
|
|
|
test("[PROFILE][User][Security] validates the password dialog before submit", async ({ page }) => {
|
|
await openUserSecurity(page);
|
|
|
|
await page.getByTestId("user-profile-security-change-password").click();
|
|
await expect(page.locator(".swal2-popup")).toBeVisible();
|
|
await page.click(".swal2-confirm");
|
|
await expect(page.locator(".swal2-validation-message")).toBeVisible();
|
|
});
|
|
|
|
test("[PROFILE][User][Security] closes the password dialog when cancelled", async ({ page }) => {
|
|
await openUserSecurity(page);
|
|
|
|
await page.getByTestId("user-profile-security-change-password").click();
|
|
await expect(page.locator(".swal2-popup")).toBeVisible();
|
|
await page.click(".swal2-cancel");
|
|
await expect(page.locator(".swal2-popup")).toBeHidden();
|
|
});
|