diff --git a/playwright/fixtures/ui5-fixtures.ts b/playwright/fixtures/ui5-fixtures.ts index e987ccf05fc..e57ecad835f 100644 --- a/playwright/fixtures/ui5-fixtures.ts +++ b/playwright/fixtures/ui5-fixtures.ts @@ -25,7 +25,7 @@ export class UI5WCHelpers { * * @param locator Locator of the UI5 custom element to click. */ - private async clickViaDomRef(locator: Locator): Promise { + async clickViaDomRef(locator: Locator): Promise { await locator.evaluate((element: HTMLElement) => { const host = element as HTMLElement & { getDomRef?: () => HTMLElement | null }; (host.getDomRef?.() ?? host).click(); diff --git a/playwright/test/UI5Fixtures.gallery.tsx b/playwright/test/UI5Fixtures.gallery.tsx index 77baa684c1e..47cbef56c15 100644 --- a/playwright/test/UI5Fixtures.gallery.tsx +++ b/playwright/test/UI5Fixtures.gallery.tsx @@ -64,6 +64,18 @@ export const AttributeTestComp = () => { return ; }; +export const ClickViaDomRefTestComp = () => { + const [clicked, setClicked] = useState(false); + return ( + <> + + {clicked ? 'yes' : 'no'} + + ); +}; + export const SelectTestComp = () => { const [selectedValue, setSelectedValue] = useState(''); return ( diff --git a/playwright/test/ui5-fixtures.spec.tsx b/playwright/test/ui5-fixtures.spec.tsx index 1d0315dff7a..7c1a06f74ab 100644 --- a/playwright/test/ui5-fixtures.spec.tsx +++ b/playwright/test/ui5-fixtures.spec.tsx @@ -1,6 +1,14 @@ import { expect, test } from '../fixtures/gallery-fixtures.js'; test.describe('UI5 Web Components Fixtures', () => { + test('clickViaDomRef - clicks the element via its DOM ref', async ({ mount, page, ui5wc }) => { + await mount('test/UI5Fixtures/ClickViaDomRefTestComp'); + + await ui5wc.clickViaDomRef(page.getByTestId('test-button')); + + await expect(page.getByTestId('button-clicked')).toHaveText('yes'); + }); + test('typeIntoInput - types text into UI5 input', async ({ mount, page, ui5wc }) => { await mount('test/UI5Fixtures/InputTestComp');