Add websitebuilder app
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

This commit is contained in:
Kunthawat Greethong
2026-01-26 12:50:12 +07:00
parent 93cfc18d1f
commit 4d1bb6892b
227 changed files with 35610 additions and 75 deletions

View File

@@ -0,0 +1,103 @@
import { expect, test } from '@playwright/test';
test.describe('Admin Users Page', () => {
test.beforeEach(async ({ page }) => {
// Navigate to admin users page
await page.goto('/admin/users');
});
test('should display user management page', async ({ page }) => {
await expect(page.locator('h1')).toContainText('User Management');
});
test('should display user list', async ({ page }) => {
await expect(page.locator('text=Users')).toBeVisible();
});
test('should display search input', async ({ page }) => {
await expect(page.locator('input[placeholder="Search users..."]')).toBeVisible();
});
test('should display role filter', async ({ page }) => {
await expect(page.locator('select')).toBeVisible();
});
test('should search users', async ({ page }) => {
await page.fill('input[placeholder="Search users..."]', 'test');
// Wait for search to complete
await page.waitForTimeout(500);
});
test('should filter by role', async ({ page }) => {
await page.selectOption('select', 'admin');
// Wait for filter to complete
await page.waitForTimeout(500);
});
test('should display user details when user is clicked', async ({ page }) => {
// Click on first user
const firstUser = page.locator('[class*="border"]').first();
await firstUser.click();
// Wait for user details to appear
await expect(page.locator('text=User Details')).toBeVisible();
});
test('should update user information', async ({ page }) => {
// Click on first user
const firstUser = page.locator('[class*="border"]').first();
await firstUser.click();
// Wait for user details to appear
await expect(page.locator('text=User Details')).toBeVisible();
// Update user information
await page.fill('input#fullName', 'Updated Name');
await page.click('button:has-text("Save Changes")');
// Wait for success message
await expect(page.locator('text=User updated successfully')).toBeVisible();
});
test('should deactivate user', async ({ page }) => {
// Click on deactivate button for first user
const deactivateButton = page.locator('button:has-text("Deactivate")').first();
await deactivateButton.click();
// Wait for success message
await expect(page.locator('text=User deactivated successfully')).toBeVisible();
});
test('should paginate users', async ({ page }) => {
// Check if pagination controls are visible
const nextButton = page.locator('button:has-text("Next")');
const prevButton = page.locator('button:has-text("Previous")');
if (await nextButton.isVisible()) {
await nextButton.click();
await page.waitForTimeout(500);
}
if (await prevButton.isVisible()) {
await prevButton.click();
await page.waitForTimeout(500);
}
});
test('should close user details when cancel is clicked', async ({ page }) => {
// Click on first user
const firstUser = page.locator('[class*="border"]').first();
await firstUser.click();
// Wait for user details to appear
await expect(page.locator('text=User Details')).toBeVisible();
// Click cancel button
await page.click('button:has-text("Cancel")');
// Wait for user details to disappear
await expect(page.locator('text=User Details')).not.toBeVisible();
});
});

59
tests/e2e/profile.spec.ts Normal file
View File

@@ -0,0 +1,59 @@
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();
});
});