Skip to content

Commit

Permalink
Merge branch 'develop' into fix/9304-fix-alignment-issue-with-link-lo…
Browse files Browse the repository at this point in the history
…go-in-settings
  • Loading branch information
brettshumaker authored Nov 13, 2024
2 parents 488971c + dbcc4ba commit ac38e70
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog/dev-update-pw-screenshots
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Update snapshots for E2E Playwright screenshots
5 changes: 5 additions & 0 deletions changelog/fix-improve-woopay-test-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Minor improvements to automated tests around WooPay


5 changes: 5 additions & 0 deletions changelog/update-9600-readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: update
Comment: No need changelog entry for this change as there has been one that encapsulate all the payout rename changes.


Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ describe( 'CheckoutPageSaveUser', () => {
'Securely save my information for 1-click checkout'
)
).not.toBeChecked();
expect(
screen.queryAllByLabelText(
'Securely save my information for 1-click checkout'
)
).toHaveLength( 1 );
} );

it( 'should not render checkbox for saving WooPay user when user is already registered', () => {
Expand All @@ -184,7 +189,7 @@ describe( 'CheckoutPageSaveUser', () => {
).not.toBeInTheDocument();
} );

it( 'should render checkbox for saving WooPay user when selected payment method is not card', () => {
it( 'should not render checkbox for saving WooPay user when selected payment method is not card', () => {
useSelectedPaymentMethod.mockImplementation( () => ( {
isWCPayChosen: false,
} ) );
Expand Down Expand Up @@ -235,6 +240,7 @@ describe( 'CheckoutPageSaveUser', () => {

expect( label ).toBeChecked();
expect( screen.queryByTestId( 'save-user-form' ) ).toBeInTheDocument();
expect( screen.getAllByTestId( 'save-user-form' ) ).toHaveLength( 1 );
} );

it( 'should not call `request` on classic checkout when checkbox is clicked', () => {
Expand Down
1 change: 1 addition & 0 deletions client/settings/express-checkout/woopay-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const WooPayExpressCheckoutItem = (): React.ReactElement => {
) }
checked={ isWooPayEnabled }
onChange={ updateIsWooPayEnabled }
data-testid="woopay-toggle"
/>
) }
</div>
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Please note that our support for the checkout block is still experimental and th

1. View Transactions
2. View Transaction Details
3. Track Deposits
3. Track Payouts
4. Manage Disputes

== Changelog ==
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions tests/e2e-pw/specs/merchant/woopay-setup.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* External dependencies
*/
import { test, Page } from '@playwright/test';
/**
* Internal dependencies
*/
import { getMerchant } from '../../utils/helpers';
import { activateWooPay, deactivateWooPay } from '../../utils/merchant';

test.describe( 'WooPay setup', () => {
let merchantPage: Page;
let wasWooPayEnabled: boolean;

test.beforeAll( async ( { browser } ) => {
merchantPage = ( await getMerchant( browser ) ).merchantPage;
wasWooPayEnabled = await activateWooPay( merchantPage );
} );

test.afterAll( async () => {
if ( ! wasWooPayEnabled ) {
await deactivateWooPay( merchantPage );
}
} );

test( 'can disable the WooPay feature', async () => {
await deactivateWooPay( merchantPage );
} );

test( 'can enable the WooPay feature', async () => {
await activateWooPay( merchantPage );
} );
} );
28 changes: 28 additions & 0 deletions tests/e2e-pw/utils/merchant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,31 @@ export const disablePaymentMethods = async (

await saveWooPaymentsSettings( page );
};

export const isWooPayEnabled = async ( page: Page ) => {
await navigation.goToWooPaymentsSettings( page );

const checkboxTestId = 'woopay-toggle';
const isEnabled = await page.getByTestId( checkboxTestId ).isChecked();

return isEnabled;
};

export const activateWooPay = async ( page: Page ) => {
await navigation.goToWooPaymentsSettings( page );

const checkboxTestId = 'woopay-toggle';
const wasInitiallyEnabled = await isWooPayEnabled( page );

if ( ! wasInitiallyEnabled ) {
await page.getByTestId( checkboxTestId ).check();
await saveWooPaymentsSettings( page );
}
return wasInitiallyEnabled;
};

export const deactivateWooPay = async ( page: Page ) => {
await navigation.goToWooPaymentsSettings( page );
await page.getByTestId( 'woopay-toggle' ).uncheck();
await saveWooPaymentsSettings( page );
};

0 comments on commit ac38e70

Please sign in to comment.