diff --git a/web/e2e/fixtures/FormFixture.ts b/web/e2e/fixtures/FormFixture.ts index 80bdb7fae1c1..a1130b53e6a9 100644 --- a/web/e2e/fixtures/FormFixture.ts +++ b/web/e2e/fixtures/FormFixture.ts @@ -1,7 +1,7 @@ import { PageFixture } from "#e2e/fixtures/PageFixture"; import type { LocatorContext } from "#e2e/selectors/types"; -import { expect, Page } from "@playwright/test"; +import { expect, Locator, Page } from "@playwright/test"; export class FormFixture extends PageFixture { static fixtureName = "Form"; @@ -18,22 +18,62 @@ export class FormFixture extends PageFixture { * @param fieldName The name of the form element. * @param value the value to set. */ - public fill = async ( - fieldName: string, - value: string, - parent: LocatorContext = this.page, - ): Promise => { - const control = parent - .getByRole("textbox", { - name: fieldName, + public findTextualInput = async ( + fieldName: string | RegExp, + context: LocatorContext = this.page, + ) => { + const control = context + .getByLabel(fieldName, { exact: true }) + .filter({ + hasNot: context.getByRole("presentation"), }) .or( - parent.getByRole("spinbutton", { + context.getByRole("textbox", { + name: fieldName, + }), + ) + .or( + context.getByRole("spinbutton", { name: fieldName, }), ); - await expect(control, `Field (${fieldName}) should be visible`).toBeVisible(); + const role = await control.getAttribute("role"); + + let textbox: Locator; + + if (role === "combobox") { + // Comboboxes, such as our Query Language input need additional handling... + const textbox = control.getByRole("textbox"); + + return textbox; + } else { + textbox = control; + } + + await expect(textbox, `Field (${fieldName}) should be visible`).toBeVisible(); + + return textbox; + }; + + /** + * Set the value of a text input. + * + * @param target The name of the form element. + * @param value the value to set. + */ + public fill = async ( + target: string | RegExp | Locator, + value: string, + context: LocatorContext = this.page, + ): Promise => { + let control: Locator; + + if (typeof target === "string" || target instanceof RegExp) { + control = await this.findTextualInput(target, context); + } else { + control = target; + } await control.fill(value); }; diff --git a/web/e2e/fixtures/PointerFixture.ts b/web/e2e/fixtures/PointerFixture.ts index 04453e89241f..e7d540cdf66c 100644 --- a/web/e2e/fixtures/PointerFixture.ts +++ b/web/e2e/fixtures/PointerFixture.ts @@ -18,12 +18,14 @@ export class PointerFixture extends PageFixture { public static fixtureName = "Pointer"; public click = ( - name: string, + name: string | RegExp, optionsOrRole?: ARIAOptions | ARIARole, context: LocatorContext = this.page, ): Promise => { if (typeof optionsOrRole === "string") { - return context.getByRole(optionsOrRole, { name }).click(); + return context.getByRole(optionsOrRole, { name }).click({ + force: true, + }); } const options = { @@ -36,7 +38,9 @@ export class PointerFixture extends PageFixture { // --- .getByRole("button", options) .or(context.getByRole("link", options)) - .click() + .click({ + force: true, + }) ); }; } diff --git a/web/src/admin/applications/ApplicationListPage.ts b/web/src/admin/applications/ApplicationListPage.ts index 199f1e21e73c..1e6f25726792 100644 --- a/web/src/admin/applications/ApplicationListPage.ts +++ b/web/src/admin/applications/ApplicationListPage.ts @@ -80,7 +80,7 @@ export class ApplicationListPage extends WithBrandConfig(TablePage) protected renderSidebarAfter(): TemplateResult { return html`