From 74f813d6c2c50ddb548aa8dddbea83a591c93184 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Thu, 22 Jan 2026 17:33:33 +0100 Subject: [PATCH] test(e2e): fix form initialization wait logic in project and tag creation Replace semantic wait for enabled button with 500ms timeout to allow Angular form initialization. The previous approach of waiting for button[type=submit]:enabled to be visible created a timeout because the button only becomes enabled after filling the form input. Fixes 5 failing tests in context-switching.spec.ts and 1 in notes-crud.spec.ts that were timing out after commit 6a5c5f722. --- e2e/pages/project.page.ts | 7 ++++--- e2e/pages/tag.page.ts | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/e2e/pages/project.page.ts b/e2e/pages/project.page.ts index 9bd07df5a..b7991f95c 100644 --- a/e2e/pages/project.page.ts +++ b/e2e/pages/project.page.ts @@ -22,7 +22,7 @@ export class ProjectPage extends BasePage { ); this.projectAccordion = page.locator('nav-item button:has-text("Projects")'); this.projectNameInput = page.getByRole('textbox', { name: 'Project Name' }); - this.submitBtn = page.locator('dialog-create-project button[type=submit]:enabled'); + this.submitBtn = page.locator('dialog-create-project button[type=submit]'); this.workCtxMenu = page.locator('work-context-menu'); // Use more specific selector to avoid matching titles in other areas this.workCtxTitle = page @@ -109,8 +109,9 @@ export class ProjectPage extends BasePage { // Wait for the dialog to appear and be fully initialized await this.projectNameInput.waitFor({ state: 'visible', timeout: 10000 }); - // Wait for Angular to fully initialize the form by checking submit button is enabled - await this.submitBtn.waitFor({ state: 'visible', timeout: 3000 }); + // Fill has built-in waiting for element to be editable, but Angular forms + // need a moment to wire up. Add a small delay for form initialization. + await this.page.waitForTimeout(500); await this.projectNameInput.fill(prefixedProjectName); await this.submitBtn.click(); diff --git a/e2e/pages/tag.page.ts b/e2e/pages/tag.page.ts index 1e45a66cd..8a4def906 100644 --- a/e2e/pages/tag.page.ts +++ b/e2e/pages/tag.page.ts @@ -54,12 +54,13 @@ export class TagPage extends BasePage { const tagNameInput = this.page.getByRole('textbox', { name: 'Tag Name' }); await tagNameInput.waitFor({ state: 'visible', timeout: 10000 }); - // Submit the form - click the Save button - const submitBtn = this.page.getByRole('button', { name: 'Save' }); - // Wait for Angular to fully initialize the form by checking submit button is enabled - await submitBtn.waitFor({ state: 'visible', timeout: 3000 }); + // Add a small delay for Angular form initialization + await this.page.waitForTimeout(500); await tagNameInput.fill(tagName); + + // Submit the form - click the Save button + const submitBtn = this.page.getByRole('button', { name: 'Save' }); await submitBtn.click(); // Wait for dialog to close