Files
websitebuilder/tests/e2e/profile.spec.ts
Kunthawat Greethong 4d1bb6892b
Some checks failed
CI / build (push) Has been cancelled
CI / test (push) Has been cancelled
CI / e2e (push) Has been cancelled
CI / lint (push) Has been cancelled
Add websitebuilder app
2026-01-26 12:50:12 +07:00

60 lines
2.3 KiB
TypeScript

import { expect, test } from '@playwright/test';
test.describe('Profile Page', () => {
test.beforeEach(async ({ page }) => {
// Navigate to profile page
await page.goto('/dashboard/profile');
});
test('should display profile page', async ({ page }) => {
await expect(page.locator('h1')).toContainText('Profile');
});
test('should display profile form', async ({ page }) => {
await expect(page.locator('text=Profile Information')).toBeVisible();
await expect(page.locator('input#fullName')).toBeVisible();
await expect(page.locator('input#avatarUrl')).toBeVisible();
});
test('should display password change form', async ({ page }) => {
await expect(page.locator('text=Change Password')).toBeVisible();
await expect(page.locator('input#currentPassword')).toBeVisible();
await expect(page.locator('input#newPassword')).toBeVisible();
await expect(page.locator('input#confirmPassword')).toBeVisible();
});
test('should display account information', async ({ page }) => {
await expect(page.locator('text=Account Information')).toBeVisible();
});
test('should update profile information', async ({ page }) => {
const fullName = 'Test User Updated';
await page.fill('input#fullName', fullName);
await page.click('button:has-text("Save Changes")');
// Wait for success message
await expect(page.locator('text=Profile updated successfully')).toBeVisible();
});
test('should change password', async ({ page }) => {
await page.fill('input#currentPassword', 'OldPassword123!');
await page.fill('input#newPassword', 'NewPassword123!');
await page.fill('input#confirmPassword', 'NewPassword123!');
await page.click('button:has-text("Change Password")');
// Wait for success message
await expect(page.locator('text=Password changed successfully')).toBeVisible();
});
test('should show error when passwords do not match', async ({ page }) => {
await page.fill('input#currentPassword', 'OldPassword123!');
await page.fill('input#newPassword', 'NewPassword123!');
await page.fill('input#confirmPassword', 'DifferentPassword123!');
await page.click('button:has-text("Change Password")');
// Wait for error message
await expect(page.locator('text=Passwords do not match')).toBeVisible();
});
});