Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playwright/fixtures/ui5-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class UI5WCHelpers {
*
* @param locator Locator of the UI5 custom element to click.
*/
private async clickViaDomRef(locator: Locator): Promise<void> {
async clickViaDomRef(locator: Locator): Promise<void> {
await locator.evaluate((element: HTMLElement) => {
const host = element as HTMLElement & { getDomRef?: () => HTMLElement | null };
(host.getDomRef?.() ?? host).click();
Expand Down
12 changes: 12 additions & 0 deletions playwright/test/UI5Fixtures.gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ export const AttributeTestComp = () => {
return <Button data-testid="test-button">Click me</Button>;
};

export const ClickViaDomRefTestComp = () => {
const [clicked, setClicked] = useState(false);
return (
<>
<Button data-testid="test-button" onClick={() => setClicked(true)}>
Click me
</Button>
<span data-testid="button-clicked">{clicked ? 'yes' : 'no'}</span>
</>
);
};

export const SelectTestComp = () => {
const [selectedValue, setSelectedValue] = useState('');
return (
Expand Down
8 changes: 8 additions & 0 deletions playwright/test/ui5-fixtures.spec.tsx
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
Loading