Skip to content

test(payments): Add test coverage for Checkout - PayPal flows#20710

Open
xlisachan wants to merge 2 commits into
mainfrom
PAY-3688_paypal
Open

test(payments): Add test coverage for Checkout - PayPal flows#20710
xlisachan wants to merge 2 commits into
mainfrom
PAY-3688_paypal

Conversation

@xlisachan

@xlisachan xlisachan commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This pull request

  • Adds unit, integration, and component-level test coverage for PayPal payment method error handling on the subscription management page

Note: PayPal checkout success functional tests will only run on stage, as the sandbox is not reachable on local

Issue that this pull request solves

Closes: PAY-3688

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.

@xlisachan xlisachan force-pushed the PAY-3688_paypal branch 6 times, most recently from 6507c18 to 35b5fee Compare June 9, 2026 18:17
@xlisachan xlisachan marked this pull request as ready for review June 9, 2026 18:36
@xlisachan xlisachan requested a review from a team as a code owner June 9, 2026 18:36
This pull request
- Adds unit, integration, and component-level test coverage for PayPal payment method error handling on the subscription management page

Closes: PAY-3688
Comment on lines +165 to +181
const baseSession = {
user: {
id: MOCK_USER_ID,
email: 'user@example.com',
metricsEnabled: true,
},
};

const basePageContent = {
accountCreditBalance: { balance: 0, currency: null },
defaultPaymentMethod: undefined,
isStripeCustomer: true,
subscriptions: [],
appleIapSubscriptions: [],
googleIapSubscriptions: [],
trialSubscriptions: [],
};

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.

issue: Could these be replaced with a factory in the corresponding library instead of defining them in the test?

});

it('does not render error banner when there is no payment method error', async () => {
mockGetSubManPageContentAction.mockResolvedValue({

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.

issue: could this use a factory instead, where possible? This also applies to all other similar instances in this test.

});

it('renders error banner with PayPal funding source error content', async () => {
const paypalFundingSourceError = {

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.

issue: could this use a factory instead, where possible? This also applies to all other similar instances in this test.


const MOCK_USER_ID = 'user-123';

const baseSession = {

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.

issue: could this use a factory instead?

* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

const SENTRY_DSN = process.env.SENTRY__CLIENT_DSN;

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.

question: is there a library that has all these functions already, that can be reused?

Comment on lines +47 to +48
await checkout.emailInput.fill(credentials.email);
await checkout.signInContinueButton.click();

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.

question: Will the test fail in Stage, since it's expecting OTP instead of email/password signin?


test('Stripe checkout success', async ({
test.describe('with retries', () => {
test.describe.configure({ retries: 2 });

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.

question: aren't retries defined globally also set to 2 retries?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Global retries are set to 1 on CI, and 0 locally.

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.

question: are the tests excluded from the build?

The tests and imports of those tests should not be included in the final build of payments-next.

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