Skip to content

Commit 779ac72

Browse files
Copilotkobenguyent
andauthored
Fix failing UI e2e test: use specific locator for Write a Test click
The `I.click('Write a Test')` was matching the text but the click could land on the `<i>` icon inside the `<a>` element, missing the @click handler. Fix: use `locate('a.navbar-item[role="button"]').withText('Write a Test')` to target the `<a>` element directly. Also remove redundant hash-checks in tests that navigate directly via `I.amOnPage('/#/new-test')` and `I.amOnPage('/#/settings')` — the hash is already set by amOnPage, no need to re-verify it. Agent-Logs-Url: https://github.com/codeceptjs/ui/sessions/3193cede-3cd5-462b-8ff2-a16e60136c45 Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
1 parent 22fd9c7 commit 779ac72

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

test/e2e/app_ui_test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,11 @@ Scenario('Navbar has Write a Test navigation link', async () => {
131131
Scenario('Clicking Write a Test navigates to new test page', async () => {
132132
I.amOnPage('/');
133133
I.waitForElement('.ScenariosPage', 15);
134-
I.waitForText('Write a Test', 10);
134+
// Wait for the navbar link to be rendered
135+
I.waitForElement('a.navbar-item[role="button"]', 10);
135136

136-
I.click('Write a Test');
137+
// Use a specific locator so the click lands on the <a> element (not on the icon inside it)
138+
I.click(locate('a.navbar-item[role="button"]').withText('Write a Test'));
137139
I.waitForFunction(() => window.location.hash.includes('new-test'), 10);
138140

139141
console.log('✅ Navigated to new-test page');
@@ -143,7 +145,6 @@ Feature('CodeceptUI App - New Test Page');
143145

144146
Scenario('New Test page loads correctly', async () => {
145147
I.amOnPage('/#/new-test');
146-
I.waitForFunction(() => window.location.hash.includes('new-test'), 10);
147148

148149
// The new test page should load something
149150
I.waitForElement('body', 10);
@@ -160,7 +161,6 @@ Feature('CodeceptUI App - Settings Page');
160161
Scenario('Settings page is accessible via navigation', async () => {
161162
// Navigate directly to the settings hash route
162163
I.amOnPage('/#/settings');
163-
I.waitForFunction(() => window.location.hash.includes('settings'), 10);
164164
I.waitForElement('body', 10);
165165
I.waitForFunction(() => {
166166
const app = document.getElementById('app');

0 commit comments

Comments
 (0)