0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Allowed Stripe network access in Playwright tests

no issue

Previous test change that blocks network access broke the Playwright tests, that need to access the Stripe checkout page.
This commit is contained in:
Simon Backx 2023-03-08 11:48:47 +01:00
parent 6f8dc6b29e
commit df9df4be80

View file

@ -9,6 +9,7 @@ const {stopGhost} = require('../../utils/e2e-utils');
const MailgunClient = require('@tryghost/mailgun-client/lib/mailgun-client'); const MailgunClient = require('@tryghost/mailgun-client/lib/mailgun-client');
const sinon = require('sinon'); const sinon = require('sinon');
const ObjectID = require('bson-objectid').default; const ObjectID = require('bson-objectid').default;
const nock = require('nock');
const startWebhookServer = () => { const startWebhookServer = () => {
const command = `stripe listen --forward-to ${config.getSiteUrl()}members/webhooks/stripe/ ${process.env.CI ? `--api-key ${process.env.STRIPE_SECRET_KEY}` : ''}`.trim(); const command = `stripe listen --forward-to ${config.getSiteUrl()}members/webhooks/stripe/ ${process.env.CI ? `--api-key ${process.env.STRIPE_SECRET_KEY}` : ''}`.trim();
@ -65,6 +66,11 @@ const stubMailgun = () => {
}); });
}; };
const allowStripeNetwork = () => {
// Allow Stripe
nock.enableNetConnect('stripe.com');
};
/** /**
* Setup the environment * Setup the environment
*/ */
@ -86,6 +92,9 @@ const setup = async (playwrightConfig) => {
server: true, server: true,
backend: true backend: true
}); });
// StartGhost automatically disables network, so we need to re-enable it for Stripe
allowStripeNetwork();
} }
const {baseURL, storageState} = playwrightConfig.projects[0].use; const {baseURL, storageState} = playwrightConfig.projects[0].use;