Skip to content

Conversation

@SteedMonteiro
Copy link
Contributor

Summary

Refactored component tests to use data-testid attributes for DOM element selection instead of relying on generic selectors like tag names and class names. This improves test reliability and maintainability by making assertions more explicit and less brittle.

Key Changes

  • Image.test.tsx: Updated ImageBackground test to use data-testid selectors for both the component and its child span element
  • Text.test.tsx:
    • Modified tests to add data-testid attributes to Text components and child elements
    • Enhanced the "render empty when no children" test to explicitly verify the rendered element is a span tag
  • View.test.tsx: Refactored className test to use data-testid selector and explicitly check classList instead of relying on querySelector with class selector

Benefits

  • More resilient tests: Tests no longer break if CSS classes or DOM structure changes
  • Better test clarity: data-testid attributes make it explicit what elements are being tested
  • Improved maintainability: Easier to understand test intent and update selectors when needed
  • Reduced false positives: Explicit assertions prevent tests from passing for unintended reasons

https://claude.ai/code/session_012rYreUmQGJAkR377wVFM8N

Updated test files to use data-testid selectors instead of dynamic CSS class
selectors to work properly with app-studio's CSS-in-props approach:

- View.test.tsx: Changed querySelector('.custom-class') to use data-testid
- Text.test.tsx: Replaced querySelector('span') with data-testid selectors
- Image.test.tsx: Updated querySelector('span') to use data-testid

All 26 component tests now pass successfully with proper selector strategies.

https://claude.ai/code/session_012rYreUmQGJAkR377wVFM8N
@github-actions
Copy link

github-actions bot commented Feb 1, 2026

size-limit report 📦

Path Size
dist/app-studio.cjs.production.min.js 23.55 KB (0%)
dist/app-studio.esm.js 23.36 KB (0%)
dist/app-studio.umd.production.min.js 23.79 KB (0%)

@SteedMonteiro SteedMonteiro merged commit 7aa9523 into main Feb 1, 2026
2 of 8 checks passed
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

Successfully merging this pull request may close these issues.

3 participants