Skip to content

Conversation

@itsjustriley
Copy link
Contributor

WHY are these changes introduced?

Closes developer-tools-team/issues/978

WHAT is this pull request doing?

Adds e2e tests for discount counts that verify:

  • Applying and displaying discount codes
  • Verifying discount values reduce subtotal
  • URL-based discount application (/discount/{code})
  • Removing discount codes
  • Persistence across page reloads
  • Case-insensitive code handling
  • Invalid code rejection
  • Empty code submission
  • Duplicate code prevention

HOW to test your changes?

Run tests (covered by CI)

  • this also confirms gift-card secrets are encrypted

Notes for Reviewers

  • some accessibility improvements made to the template to help with selectors
  • the visible selector is a bit clunky but necessary because the checkout and drawer both render the same component, but the drawer is hidden
  • follow-up: should include testing related to the drawer as well
  • follow-up: error message display and tests for invalid discount codes

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

@shopify
Copy link
Contributor

shopify bot commented Jan 29, 2026

Oxygen deployed a preview of your E2E-Discount-code-functionality branch. Details:

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

Learn more about Hydrogen's GitHub integration.

@itsjustriley itsjustriley marked this pull request as ready for review January 29, 2026 17:31
@itsjustriley itsjustriley requested a review from a team as a code owner January 29, 2026 17:31
@itsjustriley itsjustriley force-pushed the E2E-Discount-code-functionality branch from 6ca9a08 to 44c2b83 Compare January 29, 2026 20:35
Copy link
Contributor

@kdaviduik kdaviduik left a comment

Choose a reason for hiding this comment

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

Needs a rebase to fix E2E tests in CI but other than that LGTM! :)

await storefront.tryApplyDiscountCode(inactiveDiscountCode);

const appliedCodes = await storefront.getAppliedDiscountCodes();
expect(appliedCodes).not.toContain(inactiveDiscountCode);
Copy link
Contributor

Choose a reason for hiding this comment

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

This verifies the code isn't applied, but doesn't verify that helpful feedback is shown to the user (which is indeed the case right now).

Since we're going to be fixing this soon, it would be great to add a TODO comment here for our future selves to add an assertion that an error message is displayed - this catches both functionality and UX regressions.

});

test('Applies discount via URL', async ({storefront}) => {
await storefront.goto(`/discount/${activeDiscountCode}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

oooh i forgot this route even existed, nice catch

@@ -0,0 +1,59 @@
import {execSync} from 'node:child_process';
Copy link
Contributor

Choose a reason for hiding this comment

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

CI looks like it's failing because this file isn't using the secrets properly. I've now merged this PR so if you rebase with main and keep my version of this file then things should work for you :)

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