-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpim.spec.js
More file actions
84 lines (71 loc) · 2.84 KB
/
Copy pathpim.spec.js
File metadata and controls
84 lines (71 loc) · 2.84 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { test, expect } from '@playwright/test';
import { LoginPage } from '../../pages/LoginPage';
import { DashboardPage } from '../../pages/DashboardPage';
import { PIMPage, AddEmployeePage } from '../../pages/PIMPage';
test.describe('PIM Module Tests', () => {
let loginPage;
let dashboardPage;
let pimPage;
let addEmployeePage;
test.beforeEach(async ({ page }) => {
loginPage = new LoginPage(page);
dashboardPage = new DashboardPage(page);
pimPage = new PIMPage(page);
addEmployeePage = new AddEmployeePage(page);
// Login before each test
await loginPage.goto();
await loginPage.loginAndWaitForDashboard('Admin', 'admin123');
await expect(page).toHaveURL(/.*dashboard/);
await dashboardPage.navigateToPIM();
});
test('TC-PIM-001: Navigate to PIM Module', async ({ page }) => {
await test.step('Verify PIM page is displayed', async () => {
const isPIMVisible = await pimPage.isPIMPageVisible();
expect(isPIMVisible).toBeTruthy();
});
});
test('TC-PIM-002: Click Add Employee Button', async ({ page }) => {
await test.step('Click Add Employee button', async () => {
await pimPage.clickAddEmployee();
});
await test.step('Verify Add Employee page is displayed', async () => {
await expect(page.getByRole('heading', { name: 'Add Employee' })).toBeVisible();
});
});
test('TC-PIM-003: Add New Employee', async ({ page }) => {
await test.step('Navigate to Add Employee page', async () => {
await pimPage.clickAddEmployee();
});
await test.step('Fill employee details', async () => {
const timestamp = Date.now();
await addEmployeePage.addEmployee(
`TestFirstName${timestamp}`,
`TestLastName${timestamp}`
);
});
await test.step('Verify employee is saved', async () => {
// Use heading role to avoid strict mode violation — the page has both
// a link and a heading with text "Personal Details"
await expect(page.getByRole('heading', { name: 'Personal Details' })).toBeVisible({ timeout: 30000 });
});
});
test('TC-PIM-004: Search Employee by ID', async ({ page }) => {
await test.step('Search for employee with ID', async () => {
await pimPage.searchByEmployeeId('0001');
await page.waitForTimeout(2000);
});
await test.step('Verify search results', async () => {
const recordsText = await pimPage.getRecordsCount();
expect(recordsText).toContain('Record');
});
});
test('TC-PIM-005: Employee List View', async ({ page }) => {
await test.step('Verify employee list is displayed', async () => {
await expect(page.getByRole('table')).toBeVisible();
});
await test.step('Verify employee records exist', async () => {
const recordsText = await pimPage.getRecordsCount();
expect(recordsText).toContain('Record');
});
});
});