Skip to content

Commit 3492454

Browse files
Laoujinclaude
andcommitted
Fix login handling in ConfigPage for CI environment
- Navigate to home first to detect login page - Wait for navbar to appear after login - Use longer timeouts for login detection Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 549ef93 commit 3492454

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

helpers/pages/ConfigPage.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,33 @@ export class ConfigPage {
7979
* Login with anonymous user if not already logged in
8080
*/
8181
async ensureLoggedIn(userName: string = 'Test Admin') {
82-
// Check if we're on login page by looking for the login button
83-
if (await this.loginButton.isVisible({ timeout: 1000 }).catch(() => false)) {
82+
// Navigate to home first to see login page
83+
await this.page.goto('/');
84+
85+
// Check if we're on login page by looking for the login button or input
86+
const loginVisible = await this.loginButton.isVisible({ timeout: 2000 }).catch(() => false);
87+
const inputVisible = await this.loginNameInput.isVisible({ timeout: 500 }).catch(() => false);
88+
89+
if (loginVisible || inputVisible) {
8490
await this.loginNameInput.fill(userName);
8591
await this.loginButton.click();
86-
// Wait for navigation to complete
87-
await this.page.waitForURL(/.*(?<!login)$/);
92+
// Wait for navigation to complete - wait for the navbar to appear
93+
await this.page.waitForSelector('#basic-navbar-nav', { timeout: 10000 });
8894
}
8995
}
9096

9197
async goto() {
92-
await this.page.goto('/config');
98+
// First ensure we're logged in
99+
await this.page.goto('/');
93100

94-
// Handle login if redirected to login page
95-
if (await this.loginButton.isVisible({ timeout: 1000 }).catch(() => false)) {
101+
// Check if login is required
102+
const loginVisible = await this.loginButton.isVisible({ timeout: 2000 }).catch(() => false);
103+
if (loginVisible) {
96104
await this.ensureLoggedIn();
97-
await this.page.goto('/config');
98105
}
99106

107+
// Now navigate to config
108+
await this.page.goto('/config');
100109
await expect(this.page).toHaveTitle(/Configuratie/);
101110
}
102111

0 commit comments

Comments
 (0)