Skip to content

Commit 8acf83a

Browse files
committed
Refactor ClientPage selectors and improve test stability.
1 parent fe48b61 commit 8acf83a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

playwright/pages/client.page.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
88

9-
import { Page, Locator, expect } from '@playwright/test';
9+
import { Locator, expect } from '@playwright/test';
1010
import { BasePage } from './BasePage';
1111

1212
/**
@@ -49,9 +49,9 @@ export class ClientPage extends BasePage {
4949
return this.page.locator('table.bordered-table tbody tr');
5050
}
5151

52-
// Get the first client name cell (carries the routerLink).
52+
// Get the first client name cell (the displayName column carries the routerLink).
5353
get firstClientNameCell(): Locator {
54-
return this.page.locator('table.bordered-table tbody tr td').first();
54+
return this.page.locator('table.bordered-table tbody tr td.mat-column-displayName').first();
5555
}
5656

5757
// Get the "No client was found" alert message.
@@ -134,6 +134,8 @@ export class ClientPage extends BasePage {
134134
} catch (e) {
135135
console.log('Network idle timeout on clients page - proceeding anyway');
136136
}
137+
// Verify the UI is ready by checking for the search input
138+
await this.searchInput.waitFor({ state: 'visible', timeout: 15000 });
137139
}
138140

139141
/**
@@ -149,6 +151,11 @@ export class ClientPage extends BasePage {
149151
} catch (e) {
150152
console.log('Network idle timeout after search - proceeding anyway');
151153
}
154+
// Wait for observable results: either rows appear or "no client found" message
155+
await Promise.race([
156+
this.clientRows.first().waitFor({ state: 'visible', timeout: 15000 }),
157+
this.noClientFoundMessage.waitFor({ state: 'visible', timeout: 15000 })
158+
]);
152159
}
153160

154161
/**

playwright/tests/client.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,11 @@ test.describe('Client Module', () => {
5353
await expect(page).toHaveURL(/.*clients\/create.*/);
5454
});
5555

56-
test('should open a client profile', async ({ page }) => {
56+
test('should open a client profile', async () => {
5757
await clientPage.navigateToClients();
5858

5959
// Trigger search to populate the table
6060
await clientPage.searchClient('');
61-
await page.waitForTimeout(3000);
6261

6362
await expect(clientPage.clientRows.first()).toBeVisible({ timeout: 30000 });
6463
await clientPage.openClientProfile();

0 commit comments

Comments
 (0)