Skip to content

Conversation

@kdaviduik
Copy link
Contributor

@kdaviduik kdaviduik commented Jan 27, 2026

WHY are these changes introduced?

Closes https://github.com/Shopify/developer-tools-team/issues/979.

The skeleton template includes gift card functionality, but we had no automated tests verifying it works correctly. This adds E2E coverage to catch regressions in gift card apply/remove flows.

WHAT is this pull request doing?

Adds a comprehensive E2E test suite for gift card functionality with 10 test cases:

Core Functionality (5 tests):

  • Apply multiple gift cards sequentially
  • Verify gift card amounts are displayed
  • Remove individual gift cards
  • Remove all gift cards
  • Persist gift cards across page reload

Edge Cases (5 tests):

  • Duplicate code handling (no duplicates added)
  • Case-insensitive code acceptance
  • Invalid code rejection
  • Empty/whitespace code handling
  • Amount display verification

HOW to test your changes?

These are automatically run as part of CI. But you can also manually test with:

npx playwright test e2e/skeleton/giftCards.spec.ts --project=skeleton

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

Copy link
Contributor Author

kdaviduik commented Jan 27, 2026

@shopify
Copy link
Contributor

shopify bot commented Jan 27, 2026

Oxygen deployed a preview of your kd-gift-cards-e2e branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment January 29, 2026 4:00 PM

Learn more about Hydrogen's GitHub integration.

@kdaviduik kdaviduik force-pushed the kd-set-up-secrets-for-e2e branch from 4e260be to d6bf802 Compare January 27, 2026 02:28
Comment on lines +952 to +956
/**
* Get the amount for a specific applied gift card.
* The DOM structure has the amount as a sibling of the code element within the same parent.
*/
private async getAppliedCardAmount(lastCharacters: string): Promise<string> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wouldn't be opposed to not testing this (eg: this seems like logic that's fairly brittle). My vote would be to keep it in for now but if it starts causing us issues in the future we can axe it

@kdaviduik kdaviduik force-pushed the kd-gift-cards-e2e branch 3 times, most recently from 1bbaade to e143db3 Compare January 27, 2026 03:33
@kdaviduik kdaviduik marked this pull request as ready for review January 27, 2026 03:33
@kdaviduik kdaviduik requested a review from a team as a code owner January 27, 2026 03:33
Copy link
Contributor

@fredericoo fredericoo left a comment

Choose a reason for hiding this comment

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

we spotted a bug!

  • add a VALID gift card
  • remove it
  • add a gift card DIFFERENT than the first one
  • the first one will be resurrected 😇

the reason is probably related to us storing the inputs of the card form as a ref (CartSummary.tsx line 113)

@kdaviduik kdaviduik force-pushed the kd-set-up-secrets-for-e2e branch from d6bf802 to 4f0b3ea Compare January 27, 2026 17:35
@kdaviduik kdaviduik force-pushed the kd-gift-cards-e2e branch 2 times, most recently from 2e3c7b2 to d7e2cc3 Compare January 27, 2026 19:04
@kdaviduik kdaviduik requested a review from fredericoo January 27, 2026 19:30
@kdaviduik
Copy link
Contributor Author

@fredericoo this PR should fix the gift card resurrection bug (where a deleted gift card could come back). I haven't had a chance to manually tophat yet, so that's why it's still a draft. But if you get a chance feel free to un-draft the PR

Add infrastructure for securely loading test secrets from secrets.ejson
using EJSON encryption. This enables E2E tests to use real gift card codes
without hardcoding them in test files.

Example usage in an E2E test file:

```typescript
import {getRequiredSecret} from '../../fixtures/test-secrets';

const GIFT_CARD_CODE_1 = getRequiredSecret('gift_card_code_1');
const GIFT_CARD_CODE_2 = getRequiredSecret('gift_card_code_2');
```

How it works:
- Secrets stored encrypted in secrets.ejson under `e2e-testing` section
- Local dev: Uses ejson keydir at /opt/ejson/keys (standard convention)
- CI: Uses EJSON_PRIVATE_KEY env var passed via --key-from-stdin
- Single code path for both environments

Security considerations:
- Uses execFileSync (not execSync) to prevent shell injection
- Private key passed via stdin, never on command line or disk
- Secrets decrypted in-memory, never written to files
Add comprehensive E2E tests for gift card functionality in the Hydrogen
skeleton template. This validates that gift cards can be applied, removed,
and persisted across page reloads.

Tests use the hydrogenPreviewStorefront store with encrypted gift card
codes stored in secrets.ejson. The test suite includes:

- Core functionality: apply/remove single and multiple gift cards,
  persistence across reload
- Edge cases: duplicate codes, case-insensitivity, invalid codes,
  empty/whitespace handling

Implementation follows deep module pattern with gift card helpers in
StorefrontPage fixture. Uses 3-phase waiting (response → input clear →
element visible) to prevent race conditions.
Copy link
Contributor

i have rebased this PR so we get GiftCardCodesAdd back

@kdaviduik kdaviduik force-pushed the kd-set-up-secrets-for-e2e branch from 4f0b3ea to 8f952fb Compare January 30, 2026 03:48
Base automatically changed from kd-set-up-secrets-for-e2e to main January 30, 2026 06:11
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