diff --git a/.github/workflows/tests-launcher.yml b/.github/workflows/tests-launcher.yml index ddf60035..18397ae2 100644 --- a/.github/workflows/tests-launcher.yml +++ b/.github/workflows/tests-launcher.yml @@ -7,25 +7,25 @@ on: - cron: '30 02 * * *' jobs: - javascript-code-analysis: - name: Javascript - uses: ./.github/workflows/javascript-code-analysis.yml - secrets: inherit - - php-code-analysis: - name: PHP - uses: ./.github/workflows/php-code-analysis.yml - secrets: inherit - - php-unit-tests-shopware-5-7: - name: Unit tests - uses: ./.github/workflows/php-unit-tests-shopware-5-7.yml - secrets: inherit - - php-unit-tests-shopware-legacy-versions: - name: Unit tests legacy - uses: ./.github/workflows/php-unit-tests-shopware-legacy.yml - secrets: inherit +# javascript-code-analysis: +# name: Javascript +# uses: ./.github/workflows/javascript-code-analysis.yml +# secrets: inherit +# +# php-code-analysis: +# name: PHP +# uses: ./.github/workflows/php-code-analysis.yml +# secrets: inherit +# +# php-unit-tests-shopware-5-7: +# name: Unit tests +# uses: ./.github/workflows/php-unit-tests-shopware-5-7.yml +# secrets: inherit +# +# php-unit-tests-shopware-legacy-versions: +# name: Unit tests legacy +# uses: ./.github/workflows/php-unit-tests-shopware-legacy.yml +# secrets: inherit php-e2e-tests-shopware-5-7: name: E2E diff --git a/Tests/E2E/helper/backendLoginHelper.mjs b/Tests/E2E/helper/backendLoginHelper.mjs index 11992e6e..856c089f 100644 --- a/Tests/E2E/helper/backendLoginHelper.mjs +++ b/Tests/E2E/helper/backendLoginHelper.mjs @@ -1,19 +1,20 @@ import credentials from '../test/credentials.mjs'; -import { expect } from '@playwright/test'; +import {expect} from '@playwright/test'; -export default (function () { +export default (function() { return { - login: async function (page) { - await page.goto('/backend', { waitUntil: 'load' }); + login: async function(page) { + await page.goto('/backend', {waitUntil: 'load'}); await expect(page).toHaveTitle(/Backend/); await expect(page.locator('#button-1019-btnEl')).toHaveText(/Login/); + const userNameField = await page.locator('input[name="username"]'); // Wait for the focus change of the shopware login - await expect(page.locator('input[name="username"]')).toBeFocused(); + await expect(userNameField).toBeFocused(); - await page.fill('input[name="username"]', credentials.defaultBackendUserUsername); - await page.fill('input[name="password"]', credentials.defaultBackendUserPassword); + await userNameField.type(credentials.defaultBackendUserUsername); + await page.locator('input[name="password"]').type(credentials.defaultBackendUserPassword); await page.click('#button-1019-btnEl'); diff --git a/Tests/E2E/helper/scenario/pay_with_card/locatorHelper.mjs b/Tests/E2E/helper/scenario/pay_with_card/locatorHelper.mjs index 75e30c5e..6e86c191 100644 --- a/Tests/E2E/helper/scenario/pay_with_card/locatorHelper.mjs +++ b/Tests/E2E/helper/scenario/pay_with_card/locatorHelper.mjs @@ -1,81 +1,69 @@ -export const locators = (function () { +export const locators = (function() { return { - /** - * @var {Locator} - */ - contingencyHandlerWrapper: null, - - /** - * @var {FrameLocator} - */ - contingencyHandlerIFrame: null, - - /** - * @var {FrameLocator} - */ - threeDSecureIFrame: null, - - /** - * @var {FrameLocator} - */ - cardinalStepUpIFrame: null, - - /** - * @var {Locator} - */ - submitTokenForm: null, - - /** - * @var {Locator} - */ - resendTokenForm: null, - - /** - * @var {Locator} - */ - cancelForm: null, - - /** - * @var {Locator} - */ - submitTokenInput: null, - - /** - * @var {Locator} - */ - submitButton: null, - - /** - * @var {Locator} - */ - resendButton: null, - - /** - * @var {Locator} - */ - cancelButton: null, - - /** - * @var {Locator} - */ - paypalUnifiedErrorMessageContainer: null, - - /** - * @param {Page} page - */ - init: function (page) { - this.contingencyHandlerWrapper = page.locator('div[id~="payments-sdk-contingency-handler"]'); - this.contingencyHandlerIFrame = page.frameLocator('iframe[title~="payments_sdk_contingency_handler"]'); - this.threeDSecureIFrame = this.contingencyHandlerIFrame.frameLocator('iframe[id="threedsIframeV2"]'); - this.cardinalStepUpIFrame = this.threeDSecureIFrame.frameLocator('iframe[id^="cardinal-stepUpIframe"]'); - this.submitTokenForm = this.cardinalStepUpIFrame.locator('form[name="cardholderInput"]'); - this.resendTokenForm = this.cardinalStepUpIFrame.locator('form[name="resendChallengeData"]'); - this.cancelForm = this.cardinalStepUpIFrame.locator('form[name="cancel"]'); - this.submitTokenInput = this.submitTokenForm.locator('input[name="challengeDataEntry"]'); - this.submitButton = this.submitTokenForm.locator('input[type="submit"]'); - this.resendButton = this.resendTokenForm.locator('input[type="submit"]'); - this.cancelButton = this.cancelForm.locator('input[value="CANCEL"]'); - this.paypalUnifiedErrorMessageContainer = page.locator('.paypal-unified--error'); + paypalUnifiedErrorMessageContainer: async function(page) { + return await page.locator('.paypal-unified--error'); + }, + + cancelButton: async function(page) { + const cancelForm = await this.cancelForm(page); + + return await cancelForm.locator('input[value="CANCEL"]'); + }, + + resendButton: async function(page) { + const resendTokenForm = await this.resendTokenForm(page); + + return await resendTokenForm.locator('input[value="RESEND CODE"]'); + }, + + submitButton: async function(page) { + const submitTokenForm = await this.submitTokenForm(page); + + return await submitTokenForm.locator('input[value="SUBMIT"]'); + }, + + submitTokenInput: async function(page) { + const submitTokenForm = await this.submitTokenForm(page); + + return await submitTokenForm.locator('input[name="challengeDataEntry"]'); + }, + + cancelForm: async function(page) { + const cardinalStepUpIFrame = await this.cardinalStepUpIFrame(page); + + return await cardinalStepUpIFrame.locator('form[name="cancel"]'); + }, + + resendTokenForm: async function(page) { + const cardinalStepUpIFrame = await this.cardinalStepUpIFrame(page); + + return await cardinalStepUpIFrame.locator('form[name="resendChallengeData"]'); + }, + + submitTokenForm: async function(page) { + const cardinalStepUpIFrame = await this.cardinalStepUpIFrame(page); + + return await cardinalStepUpIFrame.locator('form[name="cardholderInput"]'); + }, + + cardinalStepUpIFrame: async function(page) { + const threeDSecureIFrame = await this.threeDSecureIFrame(page); + + return await threeDSecureIFrame.frameLocator('iframe[id^="cardinal-stepUpIframe"]'); + }, + + threeDSecureIFrame: async function(page) { + const contingencyHandlerIFrame = await this.contingencyHandlerIFrame(page); + + return await contingencyHandlerIFrame.frameLocator('iframe[id="threedsIframeV2"]'); + }, + + contingencyHandlerIFrame: async function(page) { + return await page.frameLocator('iframe[title~="payments_sdk_contingency_handler"]'); + }, + + contingencyHandlerWrapper: async function(page) { + return await page.locator('div[id~="payments-sdk-contingency-handler"]'); }, }; })(); diff --git a/Tests/E2E/test/backend_tracking_url.spec.mjs b/Tests/E2E/test/backend_tracking_url.spec.mjs index c9c53f78..d8a0e3fb 100644 --- a/Tests/E2E/test/backend_tracking_url.spec.mjs +++ b/Tests/E2E/test/backend_tracking_url.spec.mjs @@ -20,6 +20,13 @@ test.describe('Tracking url testing', () => { await page.hover('.customers--main'); await page.click('.customers--orders'); + await page.waitForTimeout(1000); + const popupCloseButtons = await page.$$('text=\'Schließen\''); + for (let i = 0; i < popupCloseButtons.length; i++) { + await popupCloseButtons[i].click(); + } + await page.waitForTimeout(500); + await page.waitForSelector('.sprite-pencil'); const orders = await page.$$('.sprite-pencil'); diff --git a/Tests/E2E/test/pay_later_button_is_shown.spec.mjs b/Tests/E2E/test/pay_later_button_is_shown.spec.mjs new file mode 100644 index 00000000..2daa9579 --- /dev/null +++ b/Tests/E2E/test/pay_later_button_is_shown.spec.mjs @@ -0,0 +1,68 @@ +import { test, expect } from '@playwright/test'; +import credentials from './credentials.mjs'; +import MysqlFactory from '../helper/mysqlFactory.mjs'; +import defaultPaypalSettingsSql from '../helper/paypalSqlHelper.mjs'; +import clearCacheHelper from '../helper/clearCacheHelper.mjs'; +import getPaypalPaymentMethodSelector from '../helper/getPayPalPaymentMethodSelector.mjs'; +import payLaterSettingsHelper from '../helper/payLaterSettingsHelper.mjs'; + +const connection = MysqlFactory.getInstance(); + +test.use({ locale: 'de-DE' }); + +test.describe('Test Pay Later is shown', () => { + test.beforeEach(async () => { + await connection.query(defaultPaypalSettingsSql); + await clearCacheHelper.clearCache(); + }); + + test('Is PayLater button available: ProductDetailPage, OffCanvasBasket, CheckoutPage, ProductListingPage @notIn5.2', async ({ page }) => { + await clearCacheHelper.clearCache(); + + // Go to product listing + await page.goto('/sommerwelten/beachwear/', { waitUntil: 'load' }); + + // Check listing page + const listingPageLocator = await page.frameLocator('.component-frame').first().locator('div[data-funding-source="paylater"]'); + await expect(listingPageLocator.locator('.paypal-button-text')).toHaveText(/Später Bezahlen/); + + // Go to detail page + await page.goto('/sommerwelten/beachwear/178/strandtuch-ibiza', { waitUntil: 'load' }); + + // Check product detail page + const detailPageLocator = await page.frameLocator('.component-frame').locator('div[data-funding-source="paylater"]'); + await expect(detailPageLocator.locator('.paypal-button-text')).toHaveText(/Später Bezahlen/); + + // Add product to cart + await page.click('.buybox--button'); + + // Check offcanvas basket + const offCanvasLocator = await page.locator('.ajax--cart').frameLocator('.component-frame').locator('div[data-funding-source="paylater"]'); + await expect(offCanvasLocator.locator('.paypal-button-text')).toHaveText(/Später Bezahlen/); + + // Go to checkout + await page.goto('checkout/confirm', { waitUntil: 'load' }); + + // Check checkout page + const checkoutLocator = await page.frameLocator('.component-frame').locator('div[data-funding-source="paylater"]'); + await expect(checkoutLocator.locator('.paypal-button-text')).toHaveText(/Später Bezahlen/); + + // Login + await page.fill('#email', credentials.defaultShopCustomerEmail); + await page.fill('#passwort', credentials.defaultShopCustomerPassword); + await page.click('.register--login-btn'); + + // Change payment + await page.click('.btn--change-payment'); + const selector = await getPaypalPaymentMethodSelector.getSelector( + getPaypalPaymentMethodSelector.paymentMethodNames.SwagPaymentPayPalUnified + ); + await page.locator(selector).check(); + await page.waitForLoadState('load'); + await page.click('text=Weiter >> nth=1'); + + // Check checkout confirm page + const checkoutConfirmLocator = await page.frameLocator('.component-frame').locator('div[data-funding-source="paylater"]'); + await expect(checkoutConfirmLocator.locator('.paypal-button-text')).toHaveText(/Später Bezahlen/); + }); +}); diff --git a/Tests/E2E/test/pay_with_acdc.spec.mjs b/Tests/E2E/test/pay_with_acdc.spec.mjs index e37304a9..048a4116 100644 --- a/Tests/E2E/test/pay_with_acdc.spec.mjs +++ b/Tests/E2E/test/pay_with_acdc.spec.mjs @@ -1,31 +1,27 @@ -import { test, expect } from '@playwright/test'; +import {test, expect} from '@playwright/test'; import defaultPaypalSettingsSql from '../helper/paypalSqlHelper.mjs'; import MysqlFactory from '../helper/mysqlFactory.mjs'; import loginHelper from '../helper/loginHelper.mjs'; import clearCacheHelper from '../helper/clearCacheHelper.mjs'; import cookieHelper from '../helper/cookieHelper.mjs'; -import { locators } from '../helper/scenario/pay_with_card/locatorHelper.mjs'; +import {locators} from '../helper/scenario/pay_with_card/locatorHelper.mjs'; import scenarioHelper from '../helper/scenario/pay_with_card/scenarioHelper.mjs'; import getPaypalPaymentMethodSelector from '../helper/getPayPalPaymentMethodSelector.mjs'; const connection = MysqlFactory.getInstance(); test.describe('Pay with credit card', () => { - test.beforeAll(async () => { - await clearCacheHelper.clearCache(); - }); - - test.beforeEach(({ page }) => { + test.beforeEach(async({page}) => { connection.query(defaultPaypalSettingsSql); - locators.init(page); + await clearCacheHelper.clearCache(); }); - test('Buy a product with a credit card wich is secured and complete the payment process', async ({ page }) => { + test('Buy a product with a credit card wich is secured and complete the payment process', async({page}) => { await loginHelper.login(page); // Buy Product - await page.goto('genusswelten/edelbraende/9/special-finish-lagerkorn-x.o.-32', { waitUntil: 'load' }); + await page.goto('genusswelten/edelbraende/9/special-finish-lagerkorn-x.o.-32', {waitUntil: 'load'}); await page.click('.buybox--button'); // Go to checkout @@ -49,6 +45,13 @@ test.describe('Pay with credit card', () => { await page.click('text=Weiter >> nth=1'); await page.waitForLoadState('load'); + await page.waitForTimeout(1000); + if (await page.getByText(/Invalides Formular-Token!/).count() > 0) { + await page.goBack(); + await page.click('text=Weiter >> nth=1'); + await page.waitForLoadState('load'); + } + await expect(page.locator('.payment--description')).toHaveText('Kredit- oder Debitkarte'); await page.click('input[name="sAGB"]'); @@ -63,29 +66,26 @@ test.describe('Pay with credit card', () => { await page.click('button:has-text("Zahlungspflichtig bestellen")'); await page.waitForLoadState('load'); - await cookieHelper.acceptCookies(locators.contingencyHandlerIFrame); + const contingencyHandlerIFrame = await locators.contingencyHandlerIFrame(page); - const infoText = await locators.cardinalStepUpIFrame.locator('p.challengeinfotext').textContent(); - const threeDSecureToken = scenarioHelper.readThreeDSecureToken(infoText); + const submitTokenForm = await locators.submitTokenForm(page); + await submitTokenForm.scrollIntoViewIfNeeded(); - await locators.submitTokenForm.scrollIntoViewIfNeeded(); + await cookieHelper.acceptCookies(contingencyHandlerIFrame); - const consentButton = await locators.contingencyHandlerIFrame.locator('#acceptAllButton'); - if (await consentButton.count() > 0 && await consentButton.isVisible()) { - await consentButton.click(); - } - - await locators.submitTokenInput.fill(threeDSecureToken); - await locators.submitButton.click(); + const submitTokenInput = await locators.submitTokenInput(page); + const submitButton = await locators.submitButton(page); + await submitTokenInput.fill('1234'); + await submitButton.click(); await expect(page.locator('.teaser--title')).toHaveText(/Vielen Dank für Ihre Bestellung bei Shopware Demo/); }); - test('Buy a product with a credit card wich is secured and abort the payment process', async ({ page }) => { + test('Buy a product with a credit card wich is secured and abort the payment process', async({page}) => { await loginHelper.login(page); // Buy Product - await page.goto('genusswelten/edelbraende/9/special-finish-lagerkorn-x.o.-32', { waitUntil: 'load' }); + await page.goto('genusswelten/edelbraende/9/special-finish-lagerkorn-x.o.-32', {waitUntil: 'load'}); await page.click('.buybox--button'); // Go to checkout @@ -106,6 +106,13 @@ test.describe('Pay with credit card', () => { await page.click('text=Weiter >> nth=1'); await page.waitForLoadState('load'); + await page.waitForTimeout(1000); + if (await page.getByText(/Invalides Formular-Token!/).count() > 0) { + await page.goBack(); + await page.click('text=Weiter >> nth=1'); + await page.waitForLoadState('load'); + } + await expect(page.locator('.payment--description')).toHaveText('Kredit- oder Debitkarte'); await page.click('input[name="sAGB"]'); @@ -120,17 +127,26 @@ test.describe('Pay with credit card', () => { await page.click('button:has-text("Zahlungspflichtig bestellen")'); await page.waitForLoadState('load'); - await cookieHelper.acceptCookies(locators.contingencyHandlerIFrame); + const contingencyHandlerIFrame = await locators.contingencyHandlerIFrame(page); - await locators.cancelButton.click(); + await page.waitForTimeout(1000); + const cancelButton = await locators.cancelButton(page); + await cancelButton.scrollIntoViewIfNeeded(); + await cookieHelper.acceptCookies(contingencyHandlerIFrame); + await cancelButton.click(); - await locators.contingencyHandlerWrapper.waitFor({ state: 'detached' }); - await page.waitForResponse(/.*www.sandbox.paypal.com.*\/session\/patchThreeds.*/); + const contingencyHandlerWrapper = await locators.contingencyHandlerWrapper(page) + await contingencyHandlerWrapper.waitFor({state: 'detached'}); + // await page.waitForResponse(/.*www.sandbox.paypal.com.*\/session\/patchThreeds.*/); await expect(page.locator('.step--confirm.is--active')).toBeVisible(); - await expect(locators.paypalUnifiedErrorMessageContainer).toBeVisible(); + const paypalUnifiedErrorMessageContainer = await locators.paypalUnifiedErrorMessageContainer(page); + await expect(paypalUnifiedErrorMessageContainer).toBeVisible(); + + const messageContainer = await page.locator('.paypal-unified--error >> .alert--content'); + await messageContainer.scrollIntoViewIfNeeded(); - await expect(page.locator('.paypal-unified--error >> .alert--content')).toHaveText(/.*Während der Sicherheitsüberprüfung Ihrer Kreditkarte ist etwas schief gelaufen. Bitte versuchen Sie es erneut.*/); + await expect(messageContainer).toHaveText(/.*Während der Sicherheitsüberprüfung Ihrer Kreditkarte ist etwas schief gelaufen. Bitte versuchen Sie es erneut.*/); }); }); diff --git a/Tests/E2E/test/pay_with_pay_later.spec.mjs b/Tests/E2E/test/pay_with_pay_later.spec.mjs index 41600e10..42beab90 100644 --- a/Tests/E2E/test/pay_with_pay_later.spec.mjs +++ b/Tests/E2E/test/pay_with_pay_later.spec.mjs @@ -12,63 +12,9 @@ const connection = MysqlFactory.getInstance(); test.use({ locale: 'de-DE' }); test.describe('Is Pay Later fully functional', () => { - test.beforeAll(async () => { - await clearCacheHelper.clearCache(); - }); - - test.beforeEach(() => { + test.beforeEach(async () => { connection.query(defaultPaypalSettingsSql); - }); - - test('Is PayLater button available: ProductDetailPage, OffCanvasBasket, CheckoutPage, ProductListingPage @notIn5.2', async ({ page }) => { - await payLaterSettingsHelper.activateAll(); await clearCacheHelper.clearCache(); - - // Go to product listing - await page.goto('/sommerwelten/beachwear/', { waitUntil: 'load' }); - - // Check listing page - const listingPageLocator = await page.frameLocator('.component-frame').first().locator('div[data-funding-source="paylater"]'); - await expect(listingPageLocator.locator('.paypal-button-text')).toHaveText(/Später Bezahlen/); - - // Go to detail page - await page.goto('/sommerwelten/beachwear/178/strandtuch-ibiza', { waitUntil: 'load' }); - - // Check product detail page - const detailPageLocator = await page.frameLocator('.component-frame').locator('div[data-funding-source="paylater"]'); - await expect(detailPageLocator.locator('.paypal-button-text')).toHaveText(/Später Bezahlen/); - - // Add product to cart - await page.click('.buybox--button'); - - // Check offcanvas basket - const offCanvasLocator = await page.locator('.ajax--cart').frameLocator('.component-frame').locator('div[data-funding-source="paylater"]'); - await expect(offCanvasLocator.locator('.paypal-button-text')).toHaveText(/Später Bezahlen/); - - // Go to checkout - await page.goto('checkout/confirm', { waitUntil: 'load' }); - - // Check checkout page - const checkoutLocator = await page.frameLocator('.component-frame').locator('div[data-funding-source="paylater"]'); - await expect(checkoutLocator.locator('.paypal-button-text')).toHaveText(/Später Bezahlen/); - - // Login - await page.fill('#email', credentials.defaultShopCustomerEmail); - await page.fill('#passwort', credentials.defaultShopCustomerPassword); - await page.click('.register--login-btn'); - - // Change payment - await page.click('.btn--change-payment'); - const selector = await getPaypalPaymentMethodSelector.getSelector( - getPaypalPaymentMethodSelector.paymentMethodNames.SwagPaymentPayPalUnified - ); - await page.locator(selector).check(); - await page.waitForLoadState('load'); - await page.click('text=Weiter >> nth=1'); - - // Check checkout confirm page - const checkoutConfirmLocator = await page.frameLocator('.component-frame').locator('div[data-funding-source="paylater"]'); - await expect(checkoutConfirmLocator.locator('.paypal-button-text')).toHaveText(/Später Bezahlen/); }); test('Buy a product with Pay Later', async ({ page }) => {