Refactor clicking on different menu tabs of My Account page

This commit is contained in:
Julia Amosova 2019-11-06 16:32:11 +00:00
parent 2d6b560d41
commit 937ec06900
1 changed files with 10 additions and 18 deletions

View File

@ -23,40 +23,32 @@ describe( 'My account page', () => {
} ); } );
it( 'allows customer to see orders', async () => { it( 'allows customer to see orders', async () => {
await Promise.all( [ expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Orders' } );
page.waitForNavigation( { waitUntil: 'networkidle0' } ), await page.waitForNavigation( { waitUntil: 'networkidle0' } );
expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Orders' } ),
] );
expect( page.url() ).toMatch( '/my-account/orders' ); expect( page.url() ).toMatch( '/my-account/orders' );
await expect( page ).toMatchElement( 'h1', { text: 'Orders' } ); await expect( page ).toMatchElement( 'h1', { text: 'Orders' } );
} ); } );
it( 'allows customer to see downloads', async () => { it( 'allows customer to see downloads', async () => {
await Promise.all( [ expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Downloads' } )
page.waitForNavigation( { waitUntil: 'networkidle0' } ), await page.waitForNavigation( { waitUntil: 'networkidle0' } );
expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Downloads' } ),
] );
expect( page.url() ).toMatch( '/my-account/downloads' ); expect( page.url() ).toMatch( '/my-account/downloads' );
await expect( page ).toMatchElement( 'h1', { text: 'Downloads' } ); await expect( page ).toMatchElement( 'h1', { text: 'Downloads' } );
} ); } );
it( 'allows customer to edit addresses', async () => { it( 'allows customer to see addresses', async () => {
await Promise.all( [ expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Addresses' } );
page.waitForNavigation( { waitUntil: 'networkidle0' } ), await page.waitForNavigation( { waitUntil: 'networkidle0' } );
expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Addresses' } ),
] );
expect( page.url() ).toMatch( '/my-account/edit-address' ); expect( page.url() ).toMatch( '/my-account/edit-address' );
await expect( page ).toMatchElement( 'h1', { text: 'Addresses' } ); await expect( page ).toMatchElement( 'h1', { text: 'Addresses' } );
} ); } );
it( 'allows customer to edit account details', async () => { it( 'allows customer to see account details', async () => {
await Promise.all( [ expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Account details' } );
page.waitForNavigation( { waitUntil: 'networkidle0' } ), await page.waitForNavigation( { waitUntil: 'networkidle0' } );
expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Account details' } ),
] );
expect( page.url() ).toMatch( '/my-account/edit-account' ); expect( page.url() ).toMatch( '/my-account/edit-account' );
await expect( page ).toMatchElement( 'h1', { text: 'Account details' } ); await expect( page ).toMatchElement( 'h1', { text: 'Account details' } );