Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 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,35 @@
/**
* External dependencies
*/
import { test, expect, Page } from '@playwright/test';

Check warning on line 4 in tests/e2e-pw/specs/merchant/woopay-setup.spec.ts

View workflow job for this annotation

GitHub Actions / JS linting

'expect' is defined but never used
/**
* Internal dependencies
*/
import { getMerchant, getShopper } from '../../utils/helpers';
import { activateWooPay, deactivateWooPay } from '../../utils/merchant';

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

test.beforeAll( async ( { browser } ) => {
shopperPage = ( await getShopper( browser ) ).shopperPage;

Check warning on line 17 in tests/e2e-pw/specs/merchant/woopay-setup.spec.ts

View workflow job for this annotation

GitHub Actions / JS linting

'shopperPage' is assigned a value but never used
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Removed in 9e8355e

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 );
};
Loading