Skip to content

refactor: tests selectors#113

Open
RocioCM wants to merge 15 commits into
mainfrom
refactor/styled-components
Open

refactor: tests selectors#113
RocioCM wants to merge 15 commits into
mainfrom
refactor/styled-components

Conversation

@RocioCM

@RocioCM RocioCM commented Jul 17, 2026

Copy link
Copy Markdown
Member

What & why

Groundwork for the styled-components refactor: today both the unit specs and the e2e suite select DOM by CSS class name (.card, .spinner-box--column, .cover-picker__tile.is-selected, …). Once styling moves to styled-components those class names become generated hashes, which would break every test. This PR migrates the whole test surface onto stable data-testid / data-* hooks so the refactor won't touch tests.

Commits

  1. Add data-testid hooks and migrate specs off CSS-class selectors — instruments components & pages with data-testid (plus state/variant attrs: data-selected, data-direction, data-size, data-variant, data-kind) and switches the 9 unit specs onto them. SaleCountdown gains an optional testId prop.
  2. Migrate e2e suite off CSS-class selectors onto data-testid — rewrites every puppeteer selector across 16 e2e spec files onto the hooks, and adds the three the e2e flows still needed: data-testid="modal" on SellModal + MigrateModal (parity with PrimaryListModal), and data-testid="store-settings-save" on the store-settings save button.

Verification

  • tsc -b — clean
  • npm run lint — clean
  • Unit suite — 619 passed / 46 files
  • e2e — every spec passes in isolation (full-suite runs showed only timeout flake under heavy parallel machine load; each flaky spec passes green when re-run alone)

No behavior change — this is test/instrumentation only.

RocioCM and others added 12 commits July 16, 2026 17:08
…ssertion, split contract types

- Add `import/first: off` to the spec override in eslint.config.js and remove
  all 26 inline `// eslint-disable-next-line import/first` suppressions
- Restore the `!` non-null assertion on `intls[locale]` in i18n.ts to avoid a
  potential TS compile error with Partial<Record> indexed access
- Split `AggregatorContract` into `OracleReaderContract` (marketplace's
  `manaUsdAggregator()`) and `AggregatorContract` (Chainlink's `decimals()` +
  `latestRoundData()`) in both buy.ts and mana-rate.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instrument components and pages with stable data-testid attributes
(plus data-* state/variant attrs: data-selected, data-direction,
data-size, data-variant) and switch the unit specs from brittle
CSS-class selectors (.creator__ava, .spinner-box--column) onto those
hooks. Decouples the tests from styling class names ahead of the
styled-components refactor. SaleCountdown gains an optional testId
prop so callers can label individual instances.

No behavior change. tsc, lint, and the full unit suite (619 tests)
stay green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rewrites every puppeteer selector in the e2e suite (16 spec files)
from brittle CSS class names (.card, .pack, .subnav__balance,
.cover-picker__tile.is-selected, .search-pop__row--collection, …) onto
the stable data-testid / data-* hooks added in the prior commit —
e.g. [data-testid="card"], [data-testid="cover-picker-tile"][data-selected="true"],
[data-testid="search-pop-row"][data-kind="collection"].

Adds the three hooks the e2e flows still needed:
- SellModal + MigrateModal dialogs: data-testid="modal" (parity with
  PrimaryListModal), so the secondary-listing / import flows can target
  the modal without .modal.
- StoreSettings save button: data-testid="store-settings-save".

Completes the classname decoupling (unit specs were migrated in the
prior commit): tests no longer depend on styling class names, so the
upcoming styled-components refactor won't break them. No behavior
change. tsc, lint, unit suite (619) all green; every e2e spec passes
in isolation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@RocioCM RocioCM self-assigned this Jul 17, 2026
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shop Ready Ready Preview, Comment Jul 17, 2026 2:18pm

Request Review

…nents

# Conflicts:
#	app/e2e/collection.e2e.ts
#	app/e2e/credits.e2e.ts
#	app/e2e/search.e2e.ts
#	app/e2e/store-settings.e2e.ts
#	app/src/components/CollectionThumb.tsx
#	app/src/components/FittingRoom.tsx
#	app/src/pages/StoreSettings.tsx
RocioCM added 2 commits July 17, 2026 11:12
Resolves conflicts from #112 (buy/cart UI fixes) against the data-testid
work:
- CreatorBadge: keep main's hidePrefix + the creator-name testid
- NavBar: adopt main's new cart button (opens drawer) + subnav-cart /
  subnav-cart-badge testids
- cart.e2e: adopt main's new drawer flow (go-to-cart link)

Also fixes lint errors #112 introduced under the strict type-aware
config so the tree stays 0/0: typed the resume-buy JSON.parse as
CatalogItem, void-marked floating/misused promises in BuyModal & Cart,
dropped an unnecessary CheckoutPhase assertion, and added navigate to a
useCallback dep list.
Codifies the convention behind the styled-components test migration:
tests target elements via stable data-testid / data-* attributes, never
presentational class names.
@RocioCM

RocioCM commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

@decentraland-bot review

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.

2 participants