mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
93 lines
2.9 KiB
TypeScript
93 lines
2.9 KiB
TypeScript
/**
|
|
* Internal dependencies
|
|
*/
|
|
import { Pcp } from '../../resources';
|
|
import { PcpAdminPage } from './pcp-admin-page';
|
|
import urls from '../urls';
|
|
|
|
export class PcpOnboarding extends PcpAdminPage {
|
|
url = urls.admin.pcp.onboarding;
|
|
|
|
// Locators
|
|
saveAndExitButton = () =>
|
|
this.navigationPanel().getByRole( 'button', { name: 'Save and exit' } );
|
|
continueButton = () =>
|
|
this.navigationPanel().getByRole( 'button', { name: 'Continue' } );
|
|
|
|
activatePayPalPaymentsButton = () =>
|
|
this.page.getByRole( 'button', { name: 'Activate PayPal Payments' } );
|
|
|
|
advancedOptionsSection = () => this.page.locator( '#advanced-options' );
|
|
seeAdvancedOptionsButton = () =>
|
|
this.advancedOptionsSection().getByRole( 'button', {
|
|
name: 'See advanced options',
|
|
} );
|
|
advancedOptionsContent = () =>
|
|
this.advancedOptionsSection().locator( '.ppcp-r-accordion__content' );
|
|
|
|
businessRadio = () =>
|
|
this.page.locator( 'input.ppcp-r__radio-value[value="business"]' );
|
|
personalAccountRadio = () =>
|
|
this.page.locator( 'input.ppcp-r__radio-value[value="casual_seller"]' );
|
|
|
|
virtualCheckbox = () =>
|
|
this.page.locator( 'input[type="checkbox"][value="virtual"]' );
|
|
physicalGoodsCheckbox = () =>
|
|
this.page.locator( 'input[type="checkbox"][value="physical"]' );
|
|
|
|
enableOptionalPaymentMethodsRadio = () =>
|
|
this.page.locator( 'input.ppcp-r__radio-value[value="true"]' );
|
|
disableOptionalPaymentMethodsRadio = () =>
|
|
this.page.locator( 'input.ppcp-r__radio-value[value="false"]' );
|
|
|
|
connectToPayPalButton = () =>
|
|
this.page.getByRole( 'button', { name: 'Connect to PayPal' } );
|
|
|
|
enableManuallyConnectLabel = () =>
|
|
this.page.getByText( 'Manually Connect' );
|
|
|
|
enableManuallyConnectToggle = () =>
|
|
this.page.locator( '.components-form-toggle' ).nth( 1 );
|
|
|
|
// Actions
|
|
isCurrentStep = async ( title: Pcp.Admin.Onboarding.StepTitle ) => {
|
|
await this.page.waitForFunction(
|
|
() => !! document.querySelector( 'button.is-title' )
|
|
);
|
|
return await this.pageTitle( String( title ) ).isVisible();
|
|
};
|
|
|
|
gotoInitialOnboardingPage = async () => {
|
|
if ( ! ( await this.isCurrentStep( 'PayPal Payments' ) ) ) {
|
|
await this.backButton().click();
|
|
await this.page.waitForLoadState();
|
|
await this.gotoInitialOnboardingPage();
|
|
}
|
|
};
|
|
|
|
openAdvancedOptions = async () => {
|
|
await this.gotoInitialOnboardingPage();
|
|
if ( ! ( await this.advancedOptionsContent().isVisible() ) ) {
|
|
await this.seeAdvancedOptionsButton().click();
|
|
}
|
|
};
|
|
|
|
closeAdvancedOptions = async () => {
|
|
await this.gotoInitialOnboardingPage();
|
|
if ( await this.advancedOptionsContent().isVisible() ) {
|
|
await this.seeAdvancedOptionsButton().click();
|
|
}
|
|
};
|
|
|
|
disableManuallyConnect = async () => {
|
|
const isChecked = await this.enableManuallyConnectToggle().getAttribute(
|
|
'class'
|
|
);
|
|
const isToggleChecked = isChecked.includes( 'is-checked' );
|
|
if ( isToggleChecked ) {
|
|
await this.enableManuallyConnectLabel().click();
|
|
}
|
|
};
|
|
|
|
// Assertions
|
|
}
|