From 1ed97621aa97fc495ecc01d53ae52d9395223622 Mon Sep 17 00:00:00 2001 From: Gabriel Birke Date: Mon, 2 Dec 2024 17:48:28 +0100 Subject: [PATCH] Add ADR for test markers Suggestion for a separation of concerns between naming elements for styling and naming them for referencing them in tests. --- docs/adr/006-test-markers.md | 122 +++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 docs/adr/006-test-markers.md diff --git a/docs/adr/006-test-markers.md b/docs/adr/006-test-markers.md new file mode 100644 index 000000000..ead94c46e --- /dev/null +++ b/docs/adr/006-test-markers.md @@ -0,0 +1,122 @@ +# Test markers to separate testing from styling + +Date: 2024-12-03 + +Deciders: Abban Dunne, Corinna Hillebrand, Gabriel Birke, Tanuja D. + +## Status + +Accepted + +## Context + +Our unit and integration tests use class names for finding elements (to +check their existence or to trigger their events). This leads to two +problems: + +1. In cases where we want to improve the semantics of names for styling by + simplifying/restructuring the markup, we need to keep the old class + names to avoid breaking the tests. See Mobile-DE-11. +2. In cases where we introduce a new element for similar purposes (e.g. + close button with and without text) we need to use the old class name + to avoid breaking the tests and need to specify the CSS with a + qualifying 2nd class. + +To avoid these problems, we would like to separate *style names* from +*markers for testing*. + + +## Decison + +- TBD: copy one of the options considered +- TBD: When do we do this (during the campaign, not until after the campaign) + + +### Other options considered + +#### Test markers as unique IDs in data attributes + +Example + +```html + +``` + +```typescript +await wrapper.find( '[data=soft-close-close-button]' ).trigger( 'click' ); +``` + +### Test markers with local semantic meaning in data attributes + +Example + +```html +
+ +