-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.spec.js
More file actions
69 lines (58 loc) · 2.36 KB
/
Copy pathadmin.spec.js
File metadata and controls
69 lines (58 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { test, expect } from '@playwright/test';
import { LoginPage } from '../../pages/LoginPage';
import { DashboardPage } from '../../pages/DashboardPage';
import { AdminPage } from '../../pages/AdminPage';
test.describe('Admin Module Tests', () => {
let loginPage;
let dashboardPage;
let adminPage;
test.beforeEach(async ({ page }) => {
loginPage = new LoginPage(page);
dashboardPage = new DashboardPage(page);
adminPage = new AdminPage(page);
// Login before each test
await loginPage.goto();
await loginPage.loginAndWaitForDashboard('Admin', 'admin123');
await expect(page).toHaveURL(/.*dashboard/);
await dashboardPage.navigateToAdmin();
});
test('TC-ADMIN-001: Navigate to Admin Module', async ({ page }) => {
await test.step('Verify Admin page is displayed', async () => {
const isAdminVisible = await adminPage.isAdminPageVisible();
expect(isAdminVisible).toBeTruthy();
});
});
test('TC-ADMIN-002: Search User by Username', async ({ page }) => {
await test.step('Search for Admin user', async () => {
await adminPage.searchByUsername('Admin');
await page.waitForTimeout(2000); // Wait for search results
});
await test.step('Verify search results are displayed', async () => {
const recordsText = await adminPage.getRecordsCount();
expect(recordsText).toContain('Record');
});
});
test('TC-ADMIN-003: Add Button Click', async ({ page }) => {
await test.step('Click Add button', async () => {
await adminPage.clickAddButton();
});
await test.step('Verify Add User page is displayed', async () => {
// Use explicit timeout — the demo site can be slow to navigate after clicking Add
await expect(page.getByRole('heading', { name: 'Add User' })).toBeVisible({ timeout: 30000 });
});
});
test('TC-ADMIN-007: Reset Search', async ({ page }) => {
await test.step('Perform a search', async () => {
await adminPage.searchByUsername('Admin');
await page.waitForTimeout(1000);
});
await test.step('Click Reset button', async () => {
await adminPage.resetButton.click();
await page.waitForTimeout(1000);
});
await test.step('Verify search fields are cleared', async () => {
const usernameValue = await adminPage.usernameSearchInput.inputValue();
expect(usernameValue).toBe('');
});
});
});