Resolve additional conflict with migration branch
This commit is contained in:
parent
3a7aeb04e6
commit
d65c3c76c3
|
@ -9,10 +9,6 @@ import { switchUserToTest } from '@wordpress/e2e-test-utils';
|
|||
import { CustomerFlow } from "../../utils/flows";
|
||||
|
||||
describe( 'My account page', () => {
|
||||
beforeAll( async () => {
|
||||
await switchUserToTest();
|
||||
} );
|
||||
|
||||
it( 'allows customer to login', async () => {
|
||||
await expect( page ).toMatch( 'Hello' );
|
||||
await expect( page ).toMatchElement( '.woocommerce-MyAccount-navigation-link', { text: 'Dashboard' } );
|
||||
|
@ -25,25 +21,25 @@ describe( 'My account page', () => {
|
|||
|
||||
it( 'allows customer to see orders', async () => {
|
||||
await CustomerFlow.goToOrders();
|
||||
await expect( page.url() ).toMatch( '/my-account/orders' );
|
||||
await expect( page.url() ).toMatch( 'my-account/orders' );
|
||||
await expect( page ).toMatchElement( 'h1', { text: 'Orders' } );
|
||||
} );
|
||||
|
||||
it( 'allows customer to see downloads', async () => {
|
||||
await CustomerFlow.goToDownloads();
|
||||
expect( page.url() ).toMatch( '/my-account/downloads' );
|
||||
expect( page.url() ).toMatch( 'my-account/downloads' );
|
||||
await expect( page ).toMatchElement( 'h1', { text: 'Downloads' } );
|
||||
} );
|
||||
|
||||
it( 'allows customer to see addresses', async () => {
|
||||
await CustomerFlow.goToAddresses();
|
||||
expect( page.url() ).toMatch( '/my-account/edit-address' );
|
||||
expect( page.url() ).toMatch( 'my-account/edit-address' );
|
||||
await expect( page ).toMatchElement( 'h1', { text: 'Addresses' } );
|
||||
} );
|
||||
|
||||
it( 'allows customer to see account details', async () => {
|
||||
await CustomerFlow.goToAccountDetails();
|
||||
expect( page.url() ).toMatch( '/my-account/edit-account' );
|
||||
expect( page.url() ).toMatch( 'my-account/edit-account' );
|
||||
await expect( page ).toMatchElement( 'h1', { text: 'Account details' } );
|
||||
} );
|
||||
} );
|
|
@ -20,8 +20,14 @@ const WP_ADMIN_NEW_PRODUCT = baseUrl + 'wp-admin/post-new.php?post_type=product'
|
|||
const WP_ADMIN_WC_SETTINGS = baseUrl + 'wp-admin/admin.php?page=wc-settings&tab=';
|
||||
const WP_ADMIN_PERMALINK_SETTINGS = baseUrl + 'wp-admin/options-permalink.php';
|
||||
|
||||
const SHOP_PRODUCT = baseUrl + '?p=';
|
||||
const SHOP_PRODUCT_PAGE = baseUrl + '?p=';
|
||||
const SHOP_CART_PAGE = baseUrl + 'cart/';
|
||||
const SHOP_MY_ACCOUNT_PAGE = baseUrl + 'my-account/';
|
||||
|
||||
const MY_ACCOUNT_ORDERS = baseUrl + '/my-account/orders/';
|
||||
const MY_ACCOUNT_DOWNLOADS = baseUrl + '/my-account/downloads/';
|
||||
const MY_ACCOUNT_ADDRESSES = baseUrl + '/my-account/edit-address/';
|
||||
const MY_ACCOUNT_ACCOUNT_DETAILS = baseUrl + '/my-account/edit-account/';
|
||||
|
||||
const getProductColumnExpression = ( productTitle ) => (
|
||||
'td[@class="product-name" and ' +
|
||||
|
@ -65,41 +71,6 @@ const CustomerFlow = {
|
|||
] );
|
||||
},
|
||||
|
||||
removeFromCart: async ( productTitle ) => {
|
||||
const cartItemXPath = getCartItemExpression( productTitle );
|
||||
const removeItemXPath = cartItemXPath + '//' + getRemoveExpression();
|
||||
|
||||
const [ removeButton ] = await page.$x( removeItemXPath );
|
||||
await removeButton.click();
|
||||
},
|
||||
|
||||
goToProduct: async ( postID ) => {
|
||||
await page.goto( SHOP_PRODUCT + postID, {
|
||||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
},
|
||||
|
||||
goToCart: async () => {
|
||||
await page.goto( SHOP_CART_PAGE, {
|
||||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
},
|
||||
|
||||
productIsInCart: async ( productTitle, quantity = null ) => {
|
||||
const cartItemArgs = quantity ? { qty: quantity } : {};
|
||||
const cartItemXPath = getCartItemExpression( productTitle, cartItemArgs );
|
||||
|
||||
await expect( page.$x( cartItemXPath ) ).resolves.toHaveLength( 1 );
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
const MY_ACCOUNT_ORDERS = baseUrl + '/my-account/orders/';
|
||||
const MY_ACCOUNT_DOWNLOADS = baseUrl + '/my-account/downloads/';
|
||||
const MY_ACCOUNT_ADDRESSES = baseUrl + '/my-account/edit-address/';
|
||||
const MY_ACCOUNT_ACCOUNT_DETAILS = baseUrl + '/my-account/edit-account/';
|
||||
|
||||
const CustomerFlow = {
|
||||
goToOrders: async () => {
|
||||
await page.goto( MY_ACCOUNT_ORDERS, {
|
||||
waitUntil: 'networkidle0',
|
||||
|
@ -123,6 +94,49 @@ const CustomerFlow = {
|
|||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
},
|
||||
|
||||
goToProduct: async ( postID ) => {
|
||||
await page.goto( SHOP_PRODUCT_PAGE + postID, {
|
||||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
},
|
||||
|
||||
goToCart: async () => {
|
||||
await page.goto( SHOP_CART_PAGE, {
|
||||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
},
|
||||
|
||||
login: async () => {
|
||||
await page.goto( SHOP_MY_ACCOUNT_PAGE, {
|
||||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
|
||||
await expect( page.title() ).resolves.toMatch( 'My account' );
|
||||
|
||||
await page.type( '#username', config.get( 'users.customer.username' ) );
|
||||
await page.type( '#password', config.get( 'users.customer.password' ) );
|
||||
|
||||
await Promise.all( [
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
page.click( 'button[name="login"]' ),
|
||||
] );
|
||||
},
|
||||
|
||||
productIsInCart: async ( productTitle, quantity = null ) => {
|
||||
const cartItemArgs = quantity ? { qty: quantity } : {};
|
||||
const cartItemXPath = getCartItemExpression( productTitle, cartItemArgs );
|
||||
|
||||
await expect( page.$x( cartItemXPath ) ).resolves.toHaveLength( 1 );
|
||||
},
|
||||
|
||||
removeFromCart: async ( productTitle ) => {
|
||||
const cartItemXPath = getCartItemExpression( productTitle );
|
||||
const removeItemXPath = cartItemXPath + '//' + getRemoveExpression();
|
||||
|
||||
const [ removeButton ] = await page.$x( removeItemXPath );
|
||||
await removeButton.click();
|
||||
},
|
||||
};
|
||||
|
||||
const StoreOwnerFlow = {
|
||||
|
|
Loading…
Reference in New Issue