croz-ltd / tiller

🔖 Tiller DS is an open-source UI library that provides a range of visual, functional components and patterns that speed up design and development.
https://croz-ltd.github.io/tiller
Apache License 2.0
28 stars 1 forks source link

Autogenerate testId based on field name - all Tiller components #272

Open vbiankini opened 5 months ago

vbiankini commented 5 months ago

Basic information

Additional information

None.

Enhancement description

Test Id is added to all Tiller component so finding a field is much faster, easier and more reliable.

Current behaviour

Some components like toggle buttons, upload file component, buttons do not have any test Id like it is with input field (testId: input-firstName) so I need to find a component by it's label, for example label. r('div').filter({ hasText: /^Show All$/ }).

Wanted behaviour

We want the data-testid to be generated for all Tiller components based on the field name. That would enable our automated testing code to find these fields via their id, whereas now the field can't be found directly/reliably.

This is the preferred method of finding elements. For example, this is a code sample from Playwright framework: await page.getByTestId('checkbox-showAll').click();

Possible workarounds

As a workaround, we currently try and find the toggle by looking up the label associated with it and then looking for the checkbox inside that div.