Skip to content

Commit 54424aa

Browse files
committed
add: add JS doc comments and snapshots
1 parent 93c88ce commit 54424aa

File tree

10 files changed

+114
-34
lines changed

10 files changed

+114
-34
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ node_modules/
66
.env
77
.DS_Store
88
artifacts/
9-
visual-automation-snapshots/
98.7 KB
Loading
172 KB
Loading
153 KB
Loading
106 KB
Loading
105 KB
Loading

specs/visual-automation/test-add-employee.spec.js

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const { test, expect } = require("@playwright/test");
22

3+
4+
// Import utility functions for login, navigation, and employee management
35
const { userLogin } = require("../../utils/visualUtils/loginUtils");
46

57
const {
@@ -16,7 +18,11 @@ const {
1618
addEmployeeRecord,
1719
} = require("../../utils/visualUtils/addEmployeeUtils");
1820

19-
test.describe("Admin Dashboard Verification", () => {
21+
22+
/**
23+
* Test suite for verifying the add employee functionality.
24+
*/
25+
test.describe("Add Employee Feature Verification", () => {
2026
let empName = "";
2127
let testCode = 0;
2228

@@ -27,26 +33,42 @@ test.describe("Admin Dashboard Verification", () => {
2733
let employeeUsername = "";
2834
let employeePassword = "";
2935

36+
/**
37+
* Setup function executed once before all tests.
38+
* Generates static employee details for consistency in visual tests.
39+
*/
3040
test.beforeAll(() => {
31-
empName = employeeNameGenerator(5);
32-
testCode = generateTestCode();
41+
empName = employeeNameGenerator(5); // Generate a random employee name prefix
42+
testCode = generateTestCode(); // Generate a unique test code
3343

34-
employeeFirstName = `${empName}Fname${testCode}`;
35-
employeeMiddleName = `${empName}Lname${testCode}`;
36-
employeeLastName = `${empName}Lname${testCode}`;
44+
// Reduced some dynamic inputs to avoid excessive masks in visual tests.
45+
// employeeFirstName = `${empName}Fname${testCode}`;
46+
// employeeMiddleName = `${empName}Lname${testCode}`;
47+
// employeeLastName = `${empName}Lname${testCode}`;
3748

49+
// Use static employee details to minimize dynamic elements in visual tests
50+
employeeFirstName = 'test_Emp_FName';
51+
employeeMiddleName = 'test_Emp_MName';
52+
employeeLastName = 'test_Emp_LName';
53+
54+
// Employee Credentials
3855
employeeUsername = `${empName}_${testCode}`;
3956
employeePassword = `${empName}pwd123`;
4057
});
4158

4259
test.beforeEach(async ({ page }) => {
43-
await userLogin(page);
4460

45-
await visitAddEmployeePage(page);
61+
await userLogin(page); // Perform user login
62+
63+
await visitAddEmployeePage(page); // Navigate to the Add Employee page
4664
});
4765

66+
/**
67+
* Test to validate the UI of the Add Employee form.
68+
* Captures and compares a screenshot with the baseline image.
69+
*/
4870
test("It should Validate the add employee form UI", async ({ page }) => {
49-
await page.waitForTimeout(3000);
71+
await page.waitForTimeout(3000); // Wait for elements to stabilize
5072

5173
// Capture the screenshot and compare with the baseline
5274
await expect(page).toHaveScreenshot("add-employee-form.png", {
@@ -55,11 +77,16 @@ test.describe("Admin Dashboard Verification", () => {
5577
});
5678
});
5779

80+
/**
81+
* Test to validate the Employee Details page after adding a new employee.
82+
* Captures and compares a screenshot with the baseline image.
83+
*/
5884
test.only("It should validate the employee details page after adding new employee", async ({
5985
page,
6086
}) => {
61-
await page.waitForTimeout(2000);
87+
await page.waitForTimeout(2000); // Wait before starting interactions
6288

89+
// Add a new employee using predefined details
6390
await addEmployeeRecord(
6491
page,
6592
employeeFirstName,
@@ -69,17 +96,17 @@ test.describe("Admin Dashboard Verification", () => {
6996
employeePassword
7097
);
7198

72-
await page.waitForTimeout(7000);
99+
await page.waitForTimeout(7000); // Allow time for employee details page to load
73100

74101
// Capture the screenshot and compare with the baseline
75102
await expect(page).toHaveScreenshot("employee-details.png", {
76103
timeout: 3000, // Set the timeout for the screenshot action
77104
fullPage: true, // Capture a full-page screenshot
78105
mask: [
79-
page.locator("div.orangehrm-edit-employee-navigation"),
80-
page.locator('input[name="firstName"]'),
81-
page.locator('input[name="middleName"]'),
82-
page.locator('input[name="lastName"]'),
106+
// page.locator("div.orangehrm-edit-employee-navigation"),
107+
// page.locator('input[name="firstName"]'),
108+
// page.locator('input[name="middleName"]'),
109+
// page.locator('input[name="lastName"]'),
83110
page
84111
.locator("input[data-v-1f99f73c].oxd-input.oxd-input--active")
85112
.nth(4),

specs/visual-automation/test-admin-dashboard.spec.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
const { test, expect } = require('@playwright/test');
22

3+
// Import utility function for user login
34
const { userLogin } = require('../../utils/visualUtils/loginUtils');
45

6+
/**
7+
* Test suite for verifying the Admin Dashboard functionality.
8+
*/
59
test.describe('Admin Dashboard Verification', ()=>{
610

11+
/**
12+
* Setup function executed before each test.
13+
* Ensures user is logged in before proceeding with tests.
14+
*/
715
test.beforeEach(async({page})=>{
8-
await userLogin(page);
16+
await userLogin(page); // Perform user login
917
})
1018

19+
/**
20+
* Test to validate the visual appearance of the Admin Dashboard after logging in.
21+
* Captures and compares a screenshot with the baseline image.
22+
*/
1123
test('It should Validate the visual appearance of the Admin Dashboard after logging in', async ({ page }) => {
1224

13-
await page.waitForTimeout(3000);
25+
await page.waitForTimeout(3000); // Wait for the dashboard to load completely
1426

1527
// Capture the screenshot and compare with the baseline
1628
await expect(page).toHaveScreenshot('admin-dashboard.png',{

specs/visual-automation/test-assign-supervisor.spec.js

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const { test, expect } = require("@playwright/test");
22

3-
const { userLogin } = require('../../utils/visualUtils/loginUtils');
43

4+
// Import utility functions for login, navigation, employee management, and search
5+
const { userLogin } = require('../../utils/visualUtils/loginUtils');
56

67
const {
78
employeeNameGenerator,
@@ -17,6 +18,10 @@ const { visitAddEmployeePage } = require('../../utils/visualUtils/visitAddEmploy
1718

1819
const { searchEmployee } = require('../../utils/visualUtils/searchEmployeeUtils');
1920

21+
22+
/**
23+
* Test suite for verifying the Supervisor Assignment UI.
24+
*/
2025
test.describe("Supervisor Assignment UI verification ", () => {
2126
let empName = "";
2227
let testCode = 0;
@@ -36,37 +41,57 @@ test.describe("Supervisor Assignment UI verification ", () => {
3641
let supervisorUname = '';
3742
let supervisorPwd = '';
3843

44+
/**
45+
* Setup function executed before each test.
46+
* Generates unique employee and supervisor details.
47+
* Logs in the user and navigates to the Add Employee page.
48+
*/
3949
test.beforeEach(async ({ page }) => {
40-
empName = employeeNameGenerator(5);
41-
testCode = generateTestCode();
50+
empName = employeeNameGenerator(5); // Generate random name prefix
51+
testCode = generateTestCode(); // Generate unique test code
4252

53+
// Reduced some dynamic inputs to avoid excessive masks in visual tests.
4354
employeeFirstName = `${empName}Fname${testCode}`;
4455
employeeMiddleName = `${empName}Lname${testCode}`;
4556
employeeLastName = `${empName}Lname${testCode}`;
4657

58+
// Static employee details to ensure consistency in visual tests
59+
// employeeFirstName = 'test_Emp_FName';
60+
// employeeMiddleName = 'test_Emp_MName';
61+
// employeeLastName = 'test_Emp_LName';
62+
63+
// Dynamic Employee Credentials
4764
employeeUsername = `${empName}_${testCode}`;
4865
employeePassword = `${empName}pwd123`;
4966

67+
// Reduced some dynamic inputs to avoid excessive masks in visual tests.
5068
supervisorFirstName = `testsupervisorfname${testCode}`;
5169
supervisorMidName = `testsupervisormname${testCode}`;
5270
supervisorLastName = `testsupervisorlname${testCode}`;
5371

72+
// Static supervisor details for consistency
73+
// supervisorFirstName = `test_supervisor_fname`;
74+
// supervisorMidName = `test_supervisor_mname`;
75+
// supervisorLastName = `test_supervisor_lname`;
76+
77+
// Dynamic Supervisor Crdentials
5478
supervisorUname = `testsupervisoruname${testCode}`;
5579
supervisorPwd = `testsupervisorpwd${testCode}`;
5680

57-
await userLogin(page);
81+
await userLogin(page); // Perform user login
5882

59-
await visitAddEmployeePage(page);
83+
await visitAddEmployeePage(page); // Wait before starting interactions
6084
});
6185

6286
test("It should verify the UI after supervisor assignment", async ({
6387
page,
6488
}) => {
6589

66-
test.slow();
90+
test.slow(); // Mark test as slow due to multiple interactions
6791

68-
await page.waitForTimeout(2000);
92+
await page.waitForTimeout(2000); // Wait before starting interactions
6993

94+
// Add a new employee
7095
await addEmployeeRecord(
7196
page,
7297
employeeFirstName,
@@ -75,11 +100,10 @@ test.describe("Supervisor Assignment UI verification ", () => {
75100
employeeUsername,
76101
employeePassword
77102
);
78-
79103
await page.waitForTimeout(5000);
80104

105+
// Add a new supervisor
81106
await visitAddEmployeePage(page);
82-
83107
await addEmployeeRecord(
84108
page,
85109
supervisorFirstName,
@@ -92,42 +116,49 @@ test.describe("Supervisor Assignment UI verification ", () => {
92116
await page.waitForTimeout(5000);
93117

94118

95-
119+
// Navigate to Employee List
96120
const employeeListTab = page.locator('.oxd-topbar-body-nav-tab:nth-child(2)');
97121
await employeeListTab.click();
98122

123+
// Search for the added employee
99124
await searchEmployee(page,employeeFirstName);
100125

126+
// Edit employee record
101127
const editEmployeeRecord = page.locator('div.oxd-table-row.oxd-table-row--with-border.oxd-table-row--clickable:nth-child(1) i.oxd-icon.bi-pencil-fill');
102128
await page.waitForTimeout(2000);
103129
await editEmployeeRecord.click();
104130

131+
// Navigate to 'Reports To' tab
105132
const reportsToTab = page.locator('.orangehrm-tabs-wrapper:nth-child(8) a');
106133
await reportsToTab.click();
107134

135+
// Click 'Add Supervisor' button
108136
const addSupervisorBtn = page.locator('div').filter({ hasText: /^Assigned Supervisors Add No Records FoundNameReporting MethodActions$/ }).getByRole('button');
109137
await addSupervisorBtn.click();
110138

111139
// const supervisorNameField = page.locator('input[data-v-75e744cd]');
112140
// await supervisorNameField.fill(`${supervisorFirstName} ${supervisorMidName} ${supervisorLastName}`);
113141

142+
// Select Supervisor
114143
await page.getByPlaceholder('Type for hints...').fill(supervisorFirstName);
115144
await page.waitForTimeout(2000);
116145
await page.getByText(supervisorFirstName).click();
117146

147+
// Select 'Direct' as Reporting Method
118148
await page.getByText('-- Select --').click();
119149
await page.getByText('Direct', { exact: true }).click();
120150

151+
// Save Supervisor Assignment
121152
await page.getByRole('button', { name: 'Save' }).click();
122-
123153
await page.waitForTimeout(5000);
124154

125155
// Capture the screenshot and compare with the baseline
126156
await expect(page).toHaveScreenshot('supervisor-assignment.png',{
127157
timeout: 2000, // Set the timeout for the screenshot action
128158
fullPage: true, // Capture a full-page screenshot
129-
mask: [page.locator('div.orangehrm-edit-employee-navigation'),
130-
page.locator('div[data-v-6c07a142]').nth(0)
159+
mask: [
160+
page.locator('div.orangehrm-edit-employee-navigation'),
161+
page.locator('div[data-v-6c07a142]').nth(0) // Masking dynamic elements to prevent unnecessary test failures
131162
],
132163
});
133164

specs/visual-automation/test-employee-searchlist-ui.spec.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,29 @@ const { userLogin } = require('../../utils/visualUtils/loginUtils');
66
// Utiliy function for employee search
77
const { searchEmployee } = require('../../utils/visualUtils/searchEmployeeUtils');
88

9+
/**
10+
* Test suite for verifying the UI consistency of the Employee List page after searching.
11+
*/
912
test.describe('Employee Search Results',()=>{
1013

14+
/**
15+
* Setup function executed before each test.
16+
* Ensures user is logged in and performs a search for "Amy".
17+
*/
1118
test.beforeEach(async ({page})=>{
1219

13-
await userLogin(page);
20+
await userLogin(page); // Perform user login
1421

15-
await searchEmployee(page, "Amy");
22+
await searchEmployee(page, "Amy"); // Perform search operation
1623
});
1724

25+
/**
26+
* Test to verify the UI consistency of the Employee List page after performing a search.
27+
* Captures and compares a screenshot with the baseline image.
28+
*/
1829
test('It should Verify the UI consistency of the Employee List page after performing a search.', async({page})=>{
1930

20-
await page.waitForTimeout(3000);
31+
await page.waitForTimeout(3000); // Wait for UI elements to load fully
2132

2233
// Capture the screenshot and compare with the baseline
2334
await expect(page).toHaveScreenshot('employee-searchlist.png',{

0 commit comments

Comments
 (0)