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.
This commit is contained in:
Johannes Millan 2026-01-22 17:33:33 +01:00
parent 70aae24449
commit 74f813d6c2
2 changed files with 9 additions and 7 deletions

View file

@ -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();

View file

@ -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