feat: add data-kjb-element attributes for QE end-to-end tests #2032
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Note: this is a work in progress. My next step is to review it with Monica. I'll update the version and changelog when it's ready for final review.
This PR is for my feature feature request #2030 to add
data-kjb-element
attributes to Sage React components for use in the Quality Engineering team's end-to-end UI tests.UI test automation needs to be able to locate elements based on attributes in the DOM. Currently, most of our locators are based on CSS classes. This is unreliable and makes UI automation dependent on the presentation of the app. These locators are likely to break when minor UI changes are made to the app such as changing classes, changing the types of elements, or changing the structure of a component. The best practice for UI automation is to add test ID attributes to the elements that UI tests interact with. This attribute should be used only for automated UI tests. The attribute should only change when the functionality in the app changes. This allows developers to change the presentation (styles, element tag type, etc) without breaking UI automation.
We already use the attribute
data-kjb-element
on Ruby components. I would like to add them to the Sage React components as well.Please refer to this design document for additional information.
Screenshots
PageHeading
component appears once on a page and does not need the attribute to be customized. The E2E tests can identify the page title and other elements in the header on any page.Link
components get individualdata-kjb-element
IDs for test automation to identify themTesting in
sage-lib
The changes can be tested using Storybook.
data-kjb-element
attributes are in the correct location by adding them to Storybook stories. View the component in Storybook then inspect it in the browser's dev tools. The attribute should be shown with the correct value.Testing in
kajabi-products
kjbElementId
parameters to components, allowing existing components to be used without any code changeskjbElementId
parameter for componentskjbElementId
. Verify that the attribute is in the DOM and that the page loads and behaves properly.Related