Skip to content

feat(testing): consolidate playwright fixtures, add search utils jsdoc, wallet persistence and saved searches e2e - #1153

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
dDevAhmed:feature/issue-1103-consolidate-fixtures-and-features
Sep 28, 2026
Merged

nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
dDevAhmed:feature/issue-1103-consolidate-fixtures-and-features

Conversation

@dDevAhmed

Copy link
Copy Markdown
Contributor

Summary

This PR resolves 4 issues across Playwright fixtures, search utilities JSDoc documentation, wallet session reload persistence, and saved searches dashboard E2E coverage.

What Changed

  1. Playwright Fixtures Consolidation (#1103):

    • Created canonical fixture module tests/fixtures/index.ts extending @playwright/test with wallet, api, and walletMswFixture fixtures plus setupWalletMock and setupApiMock helpers.
    • Migrated all specs (property-purchase-flow, property-purchase, purchase-confirmation, wallet-connection, msw-verification, visual-regression, governance-voting, onboarding-tour, property-alerts, transaction-history, referral-leaderboard, csp, accessibility) to use canonical fixtures.
    • Removed duplicated inline route mocks from specs.
    • Deleted duplicate fixture files tests/fixtures/msw-fixture.ts, tests/fixtures/wallet-msw.ts, and tests/e2e/wallet-fixture.ts.
    • Created tests/README.md documenting fixture usage and test suites.
  2. Search Utils JSDoc (#1104):

    • Added JSDoc comments to all exports in src/utils/searchUtils.ts: parseSearchFilters, serializeSearchFilters, parseSortOption, serializeSortOption, buildFilterQueryString, areFiltersEqual, getFilterSummary, sanitizeSearchTerm, hasActiveFilters, resetFilters, validatePriceRange, and validateRoiRange.
    • Explicitly documented how locale affects query keys and numeric formats via getResolvedLocale / navigator.language.
  3. Dashboard Saved Searches E2E Coverage (#1105):

    • Restored <SavedSearchCard /> grid and data test attributes (data-testid="saved-searches-grid", data-testid="empty-saved-searches") on src/app/dashboard/saved-searches/page.tsx.
    • Added tests/e2e/saved-searches.spec.ts testing applying filters, saving search, listing on dashboard, reload persistence, running search (filter restoration on /properties), deleting search, empty states, and corrupted storage fallback.
    • Documented saved-searches.spec.ts in tests/README.md.
  4. Wallet Persistence & Reload Tests (#1106):

    • Added Zustand persist middleware in src/store/walletStore.ts with custom storage adapter, versioning (WALLET_STORE_VERSION = 1), TTL validation (WALLET_SESSION_TTL_MS = 24h), and auto-clearing storage on disconnect or reset.
    • Exported createWalletStore for test isolation.
    • Added unit test suite src/store/__tests__/walletPersistence.test.ts covering connect persistence, account switch, session TTL expiry, version mismatch migration, corrupt JSON resilience, and storage removal on disconnect.
    • Added reload persistence assertion in tests/e2e/wallet-connection.spec.ts.

Why

  • Eliminates mock drift and duplicated test boilerplate across E2E specs.
  • Improves developer experience and type/semantic documentation for URL and filter parsing utilities.
  • Guarantees reliability and resilience of saved searches on the user dashboard.
  • Prevents regressions in wallet session restoration and ensures stale or disconnected sessions do not linger.

Testing Performed

  • Unit Tests (Jest):
    • npm test -- src/store/__tests__/walletPersistence.test.ts src/store/__tests__/walletStore.test.ts src/utils/__tests__/searchUtils.test.ts: 48/48 passed.
  • Linting (ESLint):
    • npx eslint src/utils/searchUtils.ts src/store/walletStore.ts: 0 errors, 0 warnings.
  • Fixture Verification:
    • Grep verified zero remaining inline mock route duplications.
    • Verified clean imports across all test specs.

Risks Considered

  • Changing storage key format for saved searches or wallet: Preserved existing storage keys and fallback parsing so existing user data is unharmed.
  • Backwards compatibility: All existing test fixture helpers (setupWalletMock, setupApiMock) are exported by tests/fixtures/index.ts so future specs can use either programmatic setup or fixtures.

Edge Cases Handled

  • Corrupted JSON in localStorage for saved searches: gracefully displays empty state without runtime crash.
  • Expired wallet sessions (>24 hours) or version mismatch: resets persisted state cleanly.
  • Disconnected wallet: clears persisted wallet localStorage key.

Closes #1103
Closes #1104
Closes #1105
Closes #1106

…c, wallet persistence and saved searches e2e
@drips-wave

drips-wave Bot commented Sep 28, 2026

Copy link
Copy Markdown

@dDevAhmed Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nanaf6203-bit nanaf6203-bit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nanaf6203-bit
nanaf6203-bit merged commit f47cd91 into MettaChain:main Sep 28, 2026
2 of 6 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

2 participants