-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
247 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: dev | ||
|
||
Add the Playwright Pay for Order spec and remove the equivalent Puppeteer spec. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: dev | ||
|
||
Update the PHP version and the Xdebug version used in the E2E testing environment. |
5 changes: 5 additions & 0 deletions
5
changelog/dev-9967-convert-merchant-payment-settings-manual-capture-spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: dev | ||
Comment: Converted a puppeteer spec to playwright | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: fix | ||
|
||
Update WordPress.org readme.txt file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: fix | ||
Comment: fix: ensure the "add to cart" ECE call is completed before other calls are made. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/e2e-pw/specs/merchant/merchant-payment-settings-manual-capture.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { test, expect } from '@playwright/test'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { useMerchant } from '../../utils/helpers'; | ||
import { goToWooPaymentsSettings } from '../../utils/merchant-navigation'; | ||
|
||
test.describe( | ||
'As a merchant, I should be prompted a confirmation modal when I try to activate the manual capture', | ||
() => { | ||
useMerchant(); | ||
|
||
test.beforeEach( async ( { page } ) => { | ||
await goToWooPaymentsSettings( page ); | ||
await page.getByTestId( 'capture-later-checkbox' ).click(); | ||
} ); | ||
|
||
test( 'should show the confirmation dialog when enabling the manual capture', async ( { | ||
page, | ||
} ) => { | ||
await expect( | ||
page.getByText( | ||
'Payments must be captured within 7 days or the authorization will expire and money will be returned to the shopper' | ||
) | ||
).toBeVisible( { | ||
timeout: 10000, | ||
} ); | ||
} ); | ||
|
||
test( 'should not show the confirmation dialog when disabling the manual capture', async ( { | ||
page, | ||
} ) => { | ||
await page | ||
.getByRole( 'button', { name: 'Enable manual capture' } ) | ||
.click(); | ||
await page.getByTestId( 'capture-later-checkbox' ).click(); | ||
await expect( page.locator( '.wcpay-modal' ) ).not.toBeVisible(); | ||
} ); | ||
|
||
test( 'should show the non-card methods disabled when manual capture is enabled', async ( { | ||
page, | ||
} ) => { | ||
await page | ||
.getByRole( 'button', { name: 'Enable manual capture' } ) | ||
.click(); | ||
const paymentMethodWarningIconElement = await page | ||
.getByTestId( 'loadable-checkbox-icon-warning' ) | ||
.first(); | ||
await expect( paymentMethodWarningIconElement ).toHaveText( | ||
/cannot be enabled at checkout/ | ||
); | ||
} ); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { config } from '../../config/default'; | ||
import * as shopper from '../../utils/shopper'; | ||
import * as shopperNavigation from '../../utils/shopper-navigation'; | ||
import * as devtools from '../../utils/devtools'; | ||
import { getMerchant, getShopper } from '../../utils/helpers'; | ||
|
||
const cardTestingPreventionStates = [ | ||
{ cardTestingPreventionEnabled: false }, | ||
{ cardTestingPreventionEnabled: true }, | ||
]; | ||
|
||
test.describe( 'Shopper > Pay for Order', () => { | ||
cardTestingPreventionStates.forEach( | ||
( { cardTestingPreventionEnabled } ) => { | ||
test( `should be able to pay for a failed order with card testing protection ${ cardTestingPreventionEnabled }`, async ( { | ||
browser, | ||
} ) => { | ||
const { merchantPage } = await getMerchant( browser ); | ||
const { shopperPage } = await getShopper( browser ); | ||
|
||
// Enable or disable card testing protection. | ||
if ( ! cardTestingPreventionEnabled ) { | ||
await devtools.disableCardTestingProtection( merchantPage ); | ||
} else { | ||
await devtools.enableCardTestingProtection( merchantPage ); | ||
} | ||
|
||
// Attempt to pay with a declined card. | ||
await shopper.addCartProduct( shopperPage ); | ||
await shopper.setupCheckout( | ||
shopperPage, | ||
config.addresses.customer.billing | ||
); | ||
await shopper.fillCardDetails( | ||
shopperPage, | ||
config.cards.declined | ||
); | ||
await shopper.placeOrder( shopperPage ); | ||
|
||
await expect( | ||
shopperPage.getByText( 'Your card was declined' ).first() | ||
).toBeVisible(); | ||
|
||
// Go to the orders page and pay with a basic card. | ||
await shopperNavigation.goToOrders( shopperPage ); | ||
|
||
const payForOrderButton = shopperPage | ||
.locator( '.woocommerce-button.button.pay', { | ||
hasText: 'Pay', | ||
} ) | ||
.first(); | ||
await payForOrderButton.click(); | ||
await shopper.fillCardDetails( | ||
shopperPage, | ||
config.cards.basic | ||
); | ||
|
||
// Check for the fraud prevenction token presence. | ||
const token = await shopperPage.evaluate( () => { | ||
return ( window as any ).wcpayFraudPreventionToken; | ||
} ); | ||
|
||
if ( cardTestingPreventionEnabled ) { | ||
expect( token ).not.toBeUndefined(); | ||
} else { | ||
expect( token ).toBeUndefined(); | ||
} | ||
|
||
// Click the pay for order button. | ||
await shopper.placeOrder( shopperPage ); | ||
|
||
await expect( | ||
shopperPage.getByText( 'Order received' ).first() | ||
).toBeVisible(); | ||
|
||
// Disable card testing protection if necessary. | ||
if ( cardTestingPreventionEnabled ) { | ||
await devtools.disableCardTestingProtection( merchantPage ); | ||
} | ||
} ); | ||
} | ||
); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { Page, expect } from '@playwright/test'; | ||
|
||
const goToDevToolsSettings = ( page: Page ) => | ||
page.goto( 'wp-admin/admin.php?page=wcpaydev', { | ||
waitUntil: 'load', | ||
} ); | ||
|
||
const saveDevToolsSettings = async ( page: Page ) => { | ||
await page.getByRole( 'button', { name: 'Save Changes' } ).click(); | ||
expect( page.getByText( /Settings saved/ ) ).toBeVisible(); | ||
}; | ||
|
||
const getIsCardTestingProtectionEnabled = ( page: Page ) => | ||
page.getByLabel( 'Card testing mitigations enabled' ).isChecked(); | ||
|
||
const toggleCardTestingProtection = ( page: Page ) => | ||
page | ||
.locator( 'label[for="wcpaydev_force_card_testing_protection_on"]' ) | ||
.click(); | ||
|
||
export const enableCardTestingProtection = async ( page: Page ) => { | ||
await goToDevToolsSettings( page ); | ||
|
||
if ( ! ( await getIsCardTestingProtectionEnabled( page ) ) ) { | ||
await toggleCardTestingProtection( page ); | ||
await saveDevToolsSettings( page ); | ||
} | ||
}; | ||
|
||
export const disableCardTestingProtection = async ( page: Page ) => { | ||
await goToDevToolsSettings( page ); | ||
|
||
if ( await getIsCardTestingProtectionEnabled( page ) ) { | ||
await toggleCardTestingProtection( page ); | ||
await saveDevToolsSettings( page ); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.