Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: small e2e test update


Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test.describe( 'Connection', () => {

test( 'Classic', async ( { page } ) => {
await test.step( 'Can start classic connection', async () => {
await doClassicConnection( page, true );
await doClassicConnection( page );
} );

await test.step( 'Can assert that site is connected', async () => {
Expand Down
6 changes: 3 additions & 3 deletions tools/e2e-commons/flows/jetpack-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import { expect } from '@playwright/test';

const cardCredentials = config.get( 'testCardCredentials' );

export async function doClassicConnection( page, freePlan = true ) {
export async function doClassicConnection( page, plan = 'free' ) {
const jetpackPage = await JetpackPage.init( page );
await jetpackPage.connect();
await ( await AuthorizePage.init( page ) ).approve();

if ( freePlan ) {
if ( plan === 'free' ) {
await ( await PickAPlanPage.init( page ) ).select( 'free' );
await RecommendationsPage.init( page );
} else {
await ( await PickAPlanPage.init( page ) ).select( 'complete' );
await ( await PickAPlanPage.init( page ) ).select( plan );
await ( await CheckoutPage.init( page ) ).processPurchase( cardCredentials );
await ( await ThankYouPage.init( page ) ).waitForSetupAndProceed();
}
Expand Down
19 changes: 5 additions & 14 deletions tools/e2e-commons/pages/wpcom/pick-a-plan.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import WpPage from '../wp-page.js';
import logger from '../../logger.cjs';

export default class PickAPlanPage extends WpPage {
constructor( page ) {
Expand All @@ -10,22 +11,12 @@ export default class PickAPlanPage extends WpPage {

async select( product = 'free' ) {
switch ( product ) {
case 'complete':
return await this.selectComplete();
case 'free':
const freePlanButton = '.jetpack-product-store__jetpack-free a';
await this.click( freePlanButton );
break;
default:
return await this.selectFreePlan();
logger.error( `Selecting plan '${ product }' is not implemented! Add it yourself?` );
}
}

async selectFreePlan() {
const freePlanButton = '.jetpack-product-store__jetpack-free a';
return await this.click( freePlanButton );
}

async selectComplete() {
const buttonSelector =
'div[data-e2e-product-slug="jetpack_complete"] [class*="summary"] button';
return await this.click( buttonSelector );
}
}