Improve test reliability with semantic selectors and data attributes#124
Merged
Conversation
Replace CSS class selectors (.strike-animated, .cursor-grab, .inline.font-semibold), inline style queries, tooltip-content attributes, and structural DOM selectors with semantic alternatives (aria-label, role, data-testid, data-completed). Add test hook attributes to Task, List, Header, and Todo components. Update E2E regions, E2E specs, and unit tests to use the new resilient selectors. https://claude.ai/code/session_01ArE4Fhc46FgTh63NCGPpeS
✅ Deploy Preview for what-todo-web ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR improves test reliability and maintainability by replacing fragile CSS selectors and class-based queries with semantic HTML attributes, test IDs, and accessible queries. The changes span both e2e tests and unit tests, making them more resilient to styling changes.
Key Changes
E2E Tests (e2e/app.spec.ts)
.strike-animated) withdata-completedattribute checks for task completion verificationwaitForDismiss()toexpect().toBeHidden()for better reliabilitygetByTestId()for settings and completed panels.cursor-grabclass todata-testid="drag-handle"Unit Tests
aria-labelattributes instead ofdata-tooltip-contentand class namesdocument.querySelectortoscreenqueries for better testing practicesdata-testidinstead of class nameSource Code Changes
data-testidattributes to key elements:task-titleon task title display elementdrag-handleon reorderable list handlescompleted-panelandsettings-panelon sidebar panelsheader-dateon header date elementaria-labelattributes to form inputs:data-completedattribute to task title element for completion state trackinggetByRole()queries in e2e testsBenefits
https://claude.ai/code/session_01ArE4Fhc46FgTh63NCGPpeS