Fix PIM test failures: resilient navigation + unique Employee ID generation - #35
Merged
Merged
Conversation
…eneration Co-authored-by: bg-playground <259109604+bg-playground@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix PIM test failures due to incorrect navigation assumptions
Fix PIM test failures: resilient navigation + unique Employee ID generation
Mar 6, 2026
bg-playground
marked this pull request as ready for review
March 6, 2026 03:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent root causes were causing all 5 PIM tests to fail in CI:
navigateToPIM()blocked on a Dashboard heading that isn't present when called from a non-Dashboard page, and auto-generated Employee IDs collided with existing records on the shared demo site.Changes
DashboardPage.js—navigateToPIM()dashboardTitle.waitFor()guard (was timing out after 60s whenbeforeEachran on subsequent tests while already on the PIM page)/web/index.php/pim/viewEmployeeList) is now the primary path; sidebar menu click is the fallbackPIMPage.js—AddEmployeePage.addEmployee()"Employee Id already exists"errors on the shared OrangeHRM demo siteOriginal prompt
Fix PIM test failures: navigation assumes Dashboard page state + Employee ID collisions
Replaces the approach in PR #32, which misdiagnosed the root cause and made failures slower without fixing them.
Root Cause Analysis
Problem 1:
navigateToPIM()assumes we're on the Dashboard pageIn
automated-testing/pages/DashboardPage.js, thenavigateToPIM()method (line 64-81) starts with:This waits up to 60 seconds for the "Dashboard" heading to be visible. However,
pim.spec.jscallsnavigateToPIM()inbeforeEach(line 22), andbeforeEachruns before EVERY test. After the first test runs and the browser is on the PIM page, subsequentbeforeEachcalls hitnavigateToPIM()while still on the PIM page — causing a 60-second timeout waiting for a "Dashboard" heading that isn't there.Evidence from CI: all 5 PIM tests fail at
DashboardPage.js:68(thenavigateToPIMmethod), and the total run time is ~9.6 minutes — consistent with multiple 60-second timeouts.However, this actually works in practice because
pim.spec.jsline 19-21 doesloginPage.goto()+loginAndWaitForDashboard()before callingnavigateToPIM(), which navigates to the login page and then to the dashboard. So the test always starts from Dashboard. The real issue is that the OrangeHRM demo site is sometimes slow to load the Dashboard heading, causing the 60-second timeout to be insufficient, OR the login redirects to a different page.The fix should make
navigateToPIM()resilient — navigate directly via URL rather than depending on the Dashboard heading being visible, matching the pattern used bynavigateToAdmin()'s fallback.Problem 2:
addEmployee()doesn't clear/set a unique Employee IDIn
automated-testing/pages/PIMPage.js, theAddEmployeePage.addEmployee()method (line 44-52) only sets a custom Employee ID if one is explicitly passed. When called without an Employee ID frompim.spec.jsline 49-51, the auto-generated ID from OrangeHRM might collide with existing employees on the shared demo site. The screenshot evidence shows error "Employee Id already exists" for ID0456.The fix:
addEmployee()should always clear the Employee ID field and fill it with a unique value based on the timestamp to prevent collisions.Files to Modify
1.
automated-testing/pages/DashboardPage.jsReplace the
navigateToPIM()method (lines 64-81) with a more robust version that:/web/index.php/pim/viewEmployeeList) as the primary approach, rather than depending on being on the Dashboard page firstthis.dashboardTitle— this is the root cause of the timeoutThe new
navigateToPIM()should look like this:Do NOT modify any other methods in
DashboardPage.js. ThenavigateToAdmin(),navigateToLeave(),navigateToTime(),navigateToRecruitment(), constructor,isDashboardVisible(),logout(),ensureMenuVisible(), andgetUsername()methods must remain exactly as they are.2.
automated-testing/pages/PIMPage.jsModify the
addEmployee()method in theAddEmployeePageclass (lines 44-52) to always generate and use a unique Employee ID when none is provided. This prevents "Employee Id already exists" errors on the shared demo site:Do NOT modify any other methods or classes in
PIMPage.js. ThePIMPageclass and all its methods must remain exactly as they are.What NOT to change
pim.spec.js— the test file is correctThis pull request was created from Copilot chat.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.