From 48db5df426d8b16e5d5b957f1f8582125cd5b5e1 Mon Sep 17 00:00:00 2001 From: Sedat Date: Mon, 10 Feb 2025 09:51:17 +0300 Subject: [PATCH 1/5] linting script updated --- tests/qa/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qa/package.json b/tests/qa/package.json index cc937571e..ca66a66bf 100644 --- a/tests/qa/package.json +++ b/tests/qa/package.json @@ -40,7 +40,7 @@ "lint:md": "wp-scripts lint-md-docs ./**/*.md README.md", "lint:md:fix": "wp-scripts lint-md-docs --fix ./**/*.md README.md", "lint:js": "wp-scripts lint-js **/*.{ts,tsx,mjs} **/.*/*.{ts,tsx,mjs}", - "lint:js:fix": "wp-scripts lint-js --resolve-plugins-relative-to ./ --fix ./**/*.{ts,tsx,mjs} ./**/.*/*.{ts,tsx,mjs}", + "lint:js:fix": "wp-scripts lint-js --resolve-plugins-relative-to ./ --fix './**/*.{ts,tsx,mjs}'", "all": "npx playwright test --workers=1 --project \"all\"" }, "eslintConfig": { From bd2f5ed47a28326d9ef321195cfb7b164d599b90 Mon Sep 17 00:00:00 2001 From: Sedat Date: Mon, 10 Feb 2025 09:52:38 +0300 Subject: [PATCH 2/5] visual test added for PCP-3908/PCP-4000 --- .../02-dashboard-ui/visual-default-ui.spec.ts | 10 +++++++ tests/qa/utils/admin/pcp-onboarding.ts | 26 ++++++++++++++----- tests/qa/utils/frontend/paypal-ui.ts | 4 ++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts b/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts index f1256eba3..3207e63c0 100644 --- a/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts +++ b/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts @@ -75,6 +75,16 @@ test.describe.serial( () => { await pcpOnboarding.page.waitForLoadState(); await percy.takeSnapshot( testInfo.title, percyConfig ); } ); + + test( 'PCP-0000 | Settings - Oboarding - Enable Sandbox mode - Default UI @percy', async ( { + pcpOnboarding, + percy, + }, testInfo ) => { + await pcpOnboarding.visit(); + await pcpOnboarding.openAdvancedOptions(); + await pcpOnboarding.enableSandboxMode(); + await percy.takeSnapshot( testInfo.title, percyConfig ); + } ); } ); test( 'PCP-0000 | Settings - Badge values per country @percy', async ( { diff --git a/tests/qa/utils/admin/pcp-onboarding.ts b/tests/qa/utils/admin/pcp-onboarding.ts index 04268a925..271aed4ce 100644 --- a/tests/qa/utils/admin/pcp-onboarding.ts +++ b/tests/qa/utils/admin/pcp-onboarding.ts @@ -36,20 +36,22 @@ export class PcpOnboarding extends PcpAdminPage { this.page.locator( 'input[type="checkbox"][value="physical"]' ); enableOptionalPaymentMethodsRadio = () => - this.page.locator( - 'input.ppcp-r__radio-value[value="true"]' - ); + this.page.locator( 'input.ppcp-r__radio-value[value="true"]' ); disableOptionalPaymentMethodsRadio = () => - this.page.locator( - 'input.ppcp-r__radio-value[value="false"]' - ); + this.page.locator( 'input.ppcp-r__radio-value[value="false"]' ); connectToPayPalButton = () => this.page.getByRole( 'button', { name: 'Connect to PayPal' } ); + enableSandboxModeLabel = () => this.page.getByText( 'Enable Sandbox Mode' ); + enableSandboxModeToggle = () => + this.page.locator( '.components-form-toggle' ).nth( 0 ); + // Actions isCurrentStep = async ( title: Pcp.Admin.Onboarding.StepTitle ) => { - await this.page.waitForFunction(() => !!document.querySelector('button.is-title')); + await this.page.waitForFunction( + () => !! document.querySelector( 'button.is-title' ) + ); return await this.pageTitle( String( title ) ).isVisible(); }; @@ -75,5 +77,15 @@ export class PcpOnboarding extends PcpAdminPage { } }; + enableSandboxMode = async () => { + const isChecked = await this.enableSandboxModeToggle().getAttribute( + 'class' + ); + const isToggleChecked = isChecked.includes( 'is-checked' ); + if ( ! isToggleChecked ) { + await this.enableSandboxModeLabel().click(); + } + }; + // Assertions } diff --git a/tests/qa/utils/frontend/paypal-ui.ts b/tests/qa/utils/frontend/paypal-ui.ts index ae16b0e60..ce0e8dbc0 100644 --- a/tests/qa/utils/frontend/paypal-ui.ts +++ b/tests/qa/utils/frontend/paypal-ui.ts @@ -489,7 +489,9 @@ export class PayPalUI { openPayPalPupup = async ( dataFundingSource: string = 'paypal' ) => { const popupPromise = this.page.waitForEvent( 'popup' ); - await expect( this.fundingSourceButton( dataFundingSource ) ).toBeVisible(); + await expect( + this.fundingSourceButton( dataFundingSource ) + ).toBeVisible(); await this.fundingSourceButton( dataFundingSource ).click(); const popup = await popupPromise; From b4d11296c0d79606024e2a5ab3caa463726e39f9 Mon Sep 17 00:00:00 2001 From: Sedat Date: Mon, 10 Feb 2025 12:35:25 +0300 Subject: [PATCH 3/5] Changes on enabling sandbox mode test Locator updated with a more generic one wait added to test script --- tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts | 1 + tests/qa/utils/admin/pcp-onboarding.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts b/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts index 3207e63c0..3ba6fbd85 100644 --- a/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts +++ b/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts @@ -83,6 +83,7 @@ test.describe.serial( () => { await pcpOnboarding.visit(); await pcpOnboarding.openAdvancedOptions(); await pcpOnboarding.enableSandboxMode(); + await pcpOnboarding.page.waitForLoadState(); await percy.takeSnapshot( testInfo.title, percyConfig ); } ); } ); diff --git a/tests/qa/utils/admin/pcp-onboarding.ts b/tests/qa/utils/admin/pcp-onboarding.ts index 271aed4ce..92465899f 100644 --- a/tests/qa/utils/admin/pcp-onboarding.ts +++ b/tests/qa/utils/admin/pcp-onboarding.ts @@ -43,9 +43,10 @@ export class PcpOnboarding extends PcpAdminPage { connectToPayPalButton = () => this.page.getByRole( 'button', { name: 'Connect to PayPal' } ); - enableSandboxModeLabel = () => this.page.getByText( 'Enable Sandbox Mode' ); + enableConnectionTypeLabel = ( label: string ) => + this.page.getByText( label ); enableSandboxModeToggle = () => - this.page.locator( '.components-form-toggle' ).nth( 0 ); + this.page.locator( '.components-form-toggle' ).first(); // Actions isCurrentStep = async ( title: Pcp.Admin.Onboarding.StepTitle ) => { @@ -83,7 +84,9 @@ export class PcpOnboarding extends PcpAdminPage { ); const isToggleChecked = isChecked.includes( 'is-checked' ); if ( ! isToggleChecked ) { - await this.enableSandboxModeLabel().click(); + await this.enableConnectionTypeLabel( + 'Enable Sandbox Mode' + ).click(); } }; From e9adeb8cd4ab433b1fa1e1d4b386d7d8a2c1e68d Mon Sep 17 00:00:00 2001 From: Sedat Date: Mon, 10 Feb 2025 14:09:36 +0300 Subject: [PATCH 4/5] requested changes has been made. Locator reverted back to its initial wait (networkidle) moved inside the function --- tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts | 3 +-- tests/qa/utils/admin/pcp-onboarding.ts | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts b/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts index 3ba6fbd85..28c99cbb8 100644 --- a/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts +++ b/tests/qa/tests/02-dashboard-ui/visual-default-ui.spec.ts @@ -76,14 +76,13 @@ test.describe.serial( () => { await percy.takeSnapshot( testInfo.title, percyConfig ); } ); - test( 'PCP-0000 | Settings - Oboarding - Enable Sandbox mode - Default UI @percy', async ( { + test( 'PCP-0000 | Settings - Onboarding - Enable Sandbox mode - Default UI @percy', async ( { pcpOnboarding, percy, }, testInfo ) => { await pcpOnboarding.visit(); await pcpOnboarding.openAdvancedOptions(); await pcpOnboarding.enableSandboxMode(); - await pcpOnboarding.page.waitForLoadState(); await percy.takeSnapshot( testInfo.title, percyConfig ); } ); } ); diff --git a/tests/qa/utils/admin/pcp-onboarding.ts b/tests/qa/utils/admin/pcp-onboarding.ts index 92465899f..b76b1e0a6 100644 --- a/tests/qa/utils/admin/pcp-onboarding.ts +++ b/tests/qa/utils/admin/pcp-onboarding.ts @@ -43,8 +43,7 @@ export class PcpOnboarding extends PcpAdminPage { connectToPayPalButton = () => this.page.getByRole( 'button', { name: 'Connect to PayPal' } ); - enableConnectionTypeLabel = ( label: string ) => - this.page.getByText( label ); + enableSandboxModeLabel = () => this.page.getByText( 'Enable Sandbox Mode' ); enableSandboxModeToggle = () => this.page.locator( '.components-form-toggle' ).first(); @@ -84,10 +83,9 @@ export class PcpOnboarding extends PcpAdminPage { ); const isToggleChecked = isChecked.includes( 'is-checked' ); if ( ! isToggleChecked ) { - await this.enableConnectionTypeLabel( - 'Enable Sandbox Mode' - ).click(); + await this.enableSandboxModeLabel().click(); } + this.page.waitForLoadState( 'networkidle' ); }; // Assertions From c6f85143f773d8eda6911b7983a30cbca2990ac9 Mon Sep 17 00:00:00 2001 From: Sedat Date: Tue, 11 Feb 2025 10:37:48 +0300 Subject: [PATCH 5/5] Requested change wait moved inside the if block --- tests/qa/utils/admin/pcp-onboarding.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qa/utils/admin/pcp-onboarding.ts b/tests/qa/utils/admin/pcp-onboarding.ts index b76b1e0a6..4981cc6ef 100644 --- a/tests/qa/utils/admin/pcp-onboarding.ts +++ b/tests/qa/utils/admin/pcp-onboarding.ts @@ -84,8 +84,8 @@ export class PcpOnboarding extends PcpAdminPage { const isToggleChecked = isChecked.includes( 'is-checked' ); if ( ! isToggleChecked ) { await this.enableSandboxModeLabel().click(); + await this.page.waitForLoadState( 'networkidle' ); } - this.page.waitForLoadState( 'networkidle' ); }; // Assertions