woocommerce-paypal-payments/tests/qa/utils/admin/pcp-onboarding.ts
Sedat ce14200370
Visual test- Enable manually connection
Visual test for enabling manual connection added
2025-02-10 14:21:07 +03:00

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
}