Skip to content

feat: stubs out initial customer accounts e2e test#3532

Draft
andguy95 wants to merge 1 commit intomainfrom
an-e2e-customer-accounts-test
Draft

feat: stubs out initial customer accounts e2e test#3532
andguy95 wants to merge 1 commit intomainfrom
an-e2e-customer-accounts-test

Conversation

@andguy95
Copy link
Collaborator

@andguy95 andguy95 commented Mar 5, 2026

Here's a draft PR summary:


E2E for Customer Account flows

Summary

Adds the E2E test infrastructure for testing customer account login, logout, and account page navigation against the skeleton template. This lays the foundation so a teammate can expand coverage to profile updates, address CRUD, order history, etc. without needing to solve the auth plumbing.

The tests use a benchmark shop OTP bypass (per Shawn Lee-Kwong's guidance in #hydrogen-headless) -- a special loadtest header + @example.com email makes the OTP always 000000, no email sent.

What changed

  • e2e/fixtures/customer-account-utils.ts (new) -- CustomerAccountUtil fixture with login(), logout(), auth state assertions, and account page helpers
  • e2e/fixtures/index.ts -- Added customerAccount fixture and store key; setTestStore() now accepts an options param for customerAccountPush: true
  • e2e/specs/skeleton/customerAccount.spec.ts (new) -- 8 MVP tests: login, account nav, auth persistence, subpage navigation (orders/profile/addresses), logout, unauthenticated redirect
  • e2e/envs/.env.customerAccount (new) -- Env config pointing at the [e2e] Customer Auth benchmark store
  • secrets.ejson -- Added customer_account_email (the @example.com test email)

How to run

# With ejson configured:
npx playwright test --project=skeleton e2e/specs/skeleton/customerAccount.spec.ts

# Without ejson (env var fallback):
CUSTOMER_ACCOUNT_TEST_EMAIL="hydrogen-e2e-test@example.com" \
  npx playwright test --project=skeleton e2e/specs/skeleton/customerAccount.spec.ts

Tests are configured to run serially (test.describe.configure({mode: 'serial'})) to avoid spawning multiple Cloudflare tunnels.

Prerequisites

  • Shopify CLI authenticated (cd templates/skeleton && npx shopify auth login)
  • Skeleton linked to the benchmark store (cd templates/skeleton && npx shopify hydrogen link)

Gotchas

  1. Hosted login page selectors need validation -- The login() method in customer-account-utils.ts interacts with Shopify's hosted login page (email input, OTP input, submit buttons). These selectors were written defensively with fallbacks, but haven't been validated against the real page yet. On your first successful run, the selectors for the OTP input in particular may need adjusting.

  2. Cloudflare tunnel rate limiting -- If you run the tests too many times in quick succession (or with --workers>1), Cloudflare will return 429 and the tunnel won't start. Wait ~15-30 min for the rate limit to reset. The spec is configured for serial mode to mitigate this, but rapid re-runs can still trigger it. I think during testing I spawned to much and couldn't get passed this rate limit.

  3. The loadtest header -- The LOADTEST_HEADER constant in customer-account-utils.ts is currently a placeholder (<ADD THE LOADTEST HEADER HERE>). This needs to be set to the real header name from the slack thread (X-Shopify-Loadtest-...).

  4. No localhost fallback -- The Hydrogen SDK hard-rejects customer account OAuth requests that don't come from *.tryhydrogen.dev. There is no way to test customer account flows without the tunnel.

  5. Test customer creation -- A customer with the @example.com email needs to exist on the store. If the test customer gets deleted or the store is reset, you'll need to recreate it. With the benchmark bypass, signing in with a new @example.com email should auto-create the account.

  6. Adding new tests is straightforward -- Use the customerAccount fixture, call customerAccount.login(testEmail) in beforeEach, and write assertions against the account pages. See the existing Account Pages describe block for the pattern.

@shopify
Copy link
Contributor

shopify bot commented Mar 5, 2026

Oxygen deployed a preview of your an-e2e-customer-accounts-test branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment March 5, 2026 8:31 AM

Learn more about Hydrogen's GitHub integration.

import type {Page} from '@playwright/test';
import {expect} from '@playwright/test';

const LOADTEST_HEADER = '<ADD THE LOADTEST HEADER HERE>';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@itsjustriley here is the place to add in that header. Might have to add it to the secrets JSON. I wasnt able to get ejson working

@fredericoo
Copy link
Contributor

Couldn’t tophat it, can you help?

  • first i was getting Error: Not logged in to Shopify CLI. Run: cd templates/skeleton && npx shopify auth login
  • then i was getting the same for link
  • now we have added the header according to this thread
  • now i get this:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants