From 3029332165a01276021875310fcc7fc639d4029f Mon Sep 17 00:00:00 2001 From: Michel Bade Date: Fri, 14 Feb 2025 15:06:38 +0100 Subject: [PATCH] fix: setup as own project --- .../fixtures/PayPalAccountFixture.ts | 38 ------------------- tests/acceptance/global.types.ts | 1 - tests/acceptance/playwright.config.ts | 5 +++ .../acceptance/setup/paypal-account.setup.ts | 35 +++++++++++++++++ .../tests/Settings/ShippingCarrier.spec.ts | 1 - 5 files changed, 40 insertions(+), 40 deletions(-) delete mode 100644 tests/acceptance/fixtures/PayPalAccountFixture.ts create mode 100644 tests/acceptance/setup/paypal-account.setup.ts diff --git a/tests/acceptance/fixtures/PayPalAccountFixture.ts b/tests/acceptance/fixtures/PayPalAccountFixture.ts deleted file mode 100644 index 4cdfa1831..000000000 --- a/tests/acceptance/fixtures/PayPalAccountFixture.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { test as base, expect } from '@shopware-ag/acceptance-test-suite'; -import type * as PayPal from 'SwagPayPal/types'; - -export const test = base.extend({ - DefaultPayPalAccount: async ({ AdminApiContext, IdProvider }, use) => { - const { uuid } = IdProvider.getWorkerDerivedStableId('salesChannel'); - - const isSandbox = Boolean(process.env.PAYPAL_SANDBOX); - const prefix = isSandbox ? 'Sandbox' : ''; - const clientId = String(process.env.PAYPAL_CLIENT_ID); - const clientSecret = String(process.env.PAYPAL_CLIENT_SECRET); - const merchantId = String(process.env.PAYPAL_MERCHANT_ID); - - const response = await AdminApiContext.post('./_action/paypal/save-settings', { - data: { - null: { - [`SwagPayPal.settings.clientId${prefix}`]: clientId, - [`SwagPayPal.settings.clientSecret${prefix}`]: clientSecret, - [`SwagPayPal.settings.merchantPayerId${prefix}`]: merchantId, - 'SwagPayPal.settings.sandbox': isSandbox, - }, - } - }); - - expect(response.ok()).toBeTruthy(); - - const json = await response.json() as PayPal.Api.Operations<'saveSettings'>; - - if (isSandbox) { - //expect(json[uuid].sandboxCredentialsChanged).toBeTruthy(); - //expect(json[uuid].sandboxCredentialsValid).toBeTruthy(); - } else { - expect(json[uuid].liveCredentialsChanged).toBeTruthy(); - expect(json[uuid].liveCredentialsValid).toBeTruthy(); - } - await use(() => Promise.resolve()); - }, -}); diff --git a/tests/acceptance/global.types.ts b/tests/acceptance/global.types.ts index f4a77d9fa..5c77233c5 100644 --- a/tests/acceptance/global.types.ts +++ b/tests/acceptance/global.types.ts @@ -6,7 +6,6 @@ import type { ShopAdminTasks } from '@tasks/ShopAdminTasks'; import type { ShopCustomerTasks } from '@tasks/ShopCustomerTasks'; interface TestFixtureTypes extends AdminPageTypes, StorefrontPageTypes, DataFixtureTypes, ShopAdminTasks, ShopCustomerTasks { - DefaultPayPalAccount: () => Promise } declare global { diff --git a/tests/acceptance/playwright.config.ts b/tests/acceptance/playwright.config.ts index 49013e93d..fec90a092 100644 --- a/tests/acceptance/playwright.config.ts +++ b/tests/acceptance/playwright.config.ts @@ -45,6 +45,11 @@ export default defineConfig({ }, projects: [ + { + name: 'PayPal Setup', + testMatch: /.*\.setup\.ts/, + use: { trace: 'off' }, + }, { name: 'PayPal', use: { diff --git a/tests/acceptance/setup/paypal-account.setup.ts b/tests/acceptance/setup/paypal-account.setup.ts new file mode 100644 index 000000000..8b1cd6e52 --- /dev/null +++ b/tests/acceptance/setup/paypal-account.setup.ts @@ -0,0 +1,35 @@ +// eslint-disable playwright/no-conditional-expect +import { test } from '@fixtures/AcceptanceTest'; +import { expect } from '@shopware-ag/acceptance-test-suite'; +import type * as PayPal from 'SwagPayPal/types'; + +test('PayPal Account setup', {}, async ({ AdminApiContext }) => { + const isSandbox = Boolean(process.env.PAYPAL_SANDBOX); + const prefix = isSandbox ? 'Sandbox' : ''; + const clientId = String(process.env.PAYPAL_CLIENT_ID); + const clientSecret = String(process.env.PAYPAL_CLIENT_SECRET); + const merchantId = String(process.env.PAYPAL_MERCHANT_ID); + + const response = await AdminApiContext.post('./_action/paypal/save-settings', { + data: { + null: { + [`SwagPayPal.settings.clientId${prefix}`]: clientId, + [`SwagPayPal.settings.clientSecret${prefix}`]: clientSecret, + [`SwagPayPal.settings.merchantPayerId${prefix}`]: merchantId, + 'SwagPayPal.settings.sandbox': isSandbox, + }, + }, + }); + + expect(response.ok()).toBeTruthy(); + + const json = await response.json() as PayPal.Api.Operations<'saveSettings'>; + + expect(json).toHaveProperty('null'); + + if (json.null.sandboxCredentialsChanged) { + expect(json.null.sandboxCredentialsValid).toBeTruthy(); + } else if (json.null.liveCredentialsChanged) { + expect(json.null.liveCredentialsValid).toBeTruthy(); + } +}); diff --git a/tests/acceptance/tests/Settings/ShippingCarrier.spec.ts b/tests/acceptance/tests/Settings/ShippingCarrier.spec.ts index f93867cb1..16327b6f1 100644 --- a/tests/acceptance/tests/Settings/ShippingCarrier.spec.ts +++ b/tests/acceptance/tests/Settings/ShippingCarrier.spec.ts @@ -2,7 +2,6 @@ import { test } from '@fixtures/AcceptanceTest'; test('As an admin, I can select a standard carrier that is used to be displayed by PayPal', { tag: ['@Settings'] }, async ({ ShopAdmin, - DefaultPayPalAccount, AdminShippingDetail, TestDataService, SetStandardCarrier,