Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to add data-test attributes #1447

Open
koendehondt opened this issue Oct 25, 2024 · 2 comments
Open

Add a method to add data-test attributes #1447

koendehondt opened this issue Oct 25, 2024 · 2 comments

Comments

@koendehondt
Copy link

Several frontend frameworks support data-test-* attributes. They are intended to be used in tests, not in production. It allows tests to easily identify elements in the DOM, without relying on long CSS selectors or element IDs, and without impacting the behaviour of the application. In fact, several frameworks render data-test-* attributes only during development, not during production. It would be nice if Seaside would support data-test-* attributes too.

The first step is to have a dedicated method to add a data-test-* attribute. Seaside provides WATagBrush>>#htmlDataAttributeAt:put:, which means that today code like this is required to add a data-test-* attribute:

html htmlDataAttributeAt: 'test-some-element' put: true

I suggest adding:

WATagBrush >> htmlDataTestAttribute: aString

	self attributes at: 'data-test-' , aString put: true
@marschall
Copy link
Contributor

marschall commented Oct 27, 2024

How would you switch them off for production? Different canvas class? #ifTrue: in component code? Configuration attribute?

@jbrichau
Copy link
Member

@marschall I was thinking a separate configuration attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants