Comments (1)
Hi @mkilp,
thanks for submitting this issue. I checked your repository and after adjusting a few things could run the test. Here is what I did:
App.js:
-import { useRef } from "react";
+import { useRef, useState } from "react";
import {
LdButton,
LdModal,
LdTypo,
LdSelect,
LdOption
} from "@emdgroup-liquid/liquid/dist/react";
import "./styles.css";
import { defineCustomElements } from "@emdgroup-liquid/liquid/dist/loader";
import "@emdgroup-liquid/liquid/dist/css/liquid.global.css";
export default function App() {
defineCustomElements();
const modalRef = useRef(null);
const tetherOptions = {
bodyElement: modalRef.current,
constraints: [{ to: "scrollParent" }]
};
+ const [open, setOpen] = useState(false)
return (
<div className="App">
- <LdModal ref={modalRef} tetherOptions={tetherOptions}>
+ <LdModal
+ ref={modalRef}
+ tetherOptions={tetherOptions}
+ open={open}
+ onLdmodalclosed={() => setOpen(false)}>
<LdSelect
filter
placeholder={"select"}
name={"filter"}
mode="detached"
tetherOptions={tetherOptions}
>
<LdOption key={0} value={"test"} selected={false} disabled={false}>
- <LdTypo variant="h6">test</LdTypo>
+ test
</LdOption>
</LdSelect>
</LdModal>
- <LdButton onClick={() => modalRef.current.showModal()}>
+ <LdButton
+ onClick={() => {
+ setOpen(true)
+ }}>
Open Modal
</LdButton>
</div>
);
}
example.spec.ts:
import {expect, test} from "@playwright/test";
test('Custom Filter: Selected Filters Area', async ({page}) => {
await page.goto('./');
- await page.locator('_react=LdButton').click();
- await page.locator('_react=LdSelect').click();
- let test = await page.locator('_react=LdSelect')
- .locator("_react=LdOption")
- .nth(0)
- .click();
+
+ await page.getByRole('button', { name: 'Open Modal' }).click();
+
+ await page.getByLabel('select').click();
+ await page.getByRole('option', { name: 'test' }).click();
+
+ await page.getByLabel('test').click();
+ await page.getByRole('option', { name: 'test' }).click();
+
+ await page.getByLabel('Dismiss').click();
});
The LdOption
component is not a UI-Component. It's only there for you to declaratively compose the options of the LdSelect
component. So you cannot click it. What the LdSelect
component does "under the hood" is the following: It watches the LdOption
s and copies them to the popper element (that is handled by Tether) as LdOptionInternal
components. The LdOptionInternal
component is a UI component and can be clicked. Though, in your test code, it doesn't suffice to just change LdOption
to LdOptionInternal
, because the LdOptionInternal
component is not located within the LdSelect
component, but rather in the popper element.
To get around such issues when writing tests in general, I suggest you to use selectors which do not rely on implementation details. I also highly recommend you to have a look at Playwright's awesome codegen
feature, which will help you to come up with correct selectors.
from liquid.
Related Issues (20)
- Placeholder of LdSelect HOT 1
- bug: table is not accessible via VoiceOver
- bug: Very long LdPagination size increases parents container width HOT 6
- bug: Liquid as external dependency stopped working with version 4.6.0 and above HOT 4
- bug: event handlers not called in ld-tooltip HOT 1
- bug: ld-tooltip causes "Failed to execute 'removeChild' on 'Node'" HOT 1
- bug: onClick handler not called on LdMenuitem HOT 2
- feat(ld-cookie-notice): apply requirements from legal HOT 1
- bug: LdTabs inside LdSidenav moves content on changing tab index HOT 1
- feat: ld-card without padding
- bug: LdSelect with filter doesn't always get focus HOT 1
- feat: add download attribute for LdLink HOT 2
- bug: https://downgit.github.io reports "harmful programs" HOT 1
- feat(ld-sidenav-navitem): add support for secondary label
- feat: grouping feature to the Select component HOT 2
- improvement: Refactor ld-select.tsx as it's almost 1,500 lines big now
- bug: ld-sidenav-navitem text overflows container in single line mode
- bug: Placeholder of ld-input is too dark HOT 1
- bug: LdInput readonly bind on boolean value are still editable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liquid.