Change the way navigation between My Account pages is done

This commit is contained in:
Julia Amosova 2019-11-21 16:52:29 +00:00
parent 937ec06900
commit 5e083cfdbf
5 changed files with 56 additions and 23 deletions

14
package-lock.json generated
View File

@ -8287,9 +8287,9 @@
}
},
"https-proxy-agent": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz",
"integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==",
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz",
"integrity": "sha512-+ML2Rbh6DAuee7d07tYGEKOEi2voWPUGan+ExdPbPW6Z3svq+JCqr0v8WmKPOkz1vOVykPCBSuobe7G8GJUtVg==",
"dev": true,
"requires": {
"agent-base": "^4.3.0",
@ -13169,14 +13169,14 @@
"dev": true
},
"puppeteer": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.20.0.tgz",
"integrity": "sha512-bt48RDBy2eIwZPrkgbcwHtb51mj2nKvHOPMaSH2IsWiv7lOG9k9zhaRzpDZafrk05ajMc3cu+lSQYYOfH2DkVQ==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-2.0.0.tgz",
"integrity": "sha512-t3MmTWzQxPRP71teU6l0jX47PHXlc4Z52sQv4LJQSZLq1ttkKS2yGM3gaI57uQwZkNaoGd0+HPPMELZkcyhlqA==",
"dev": true,
"requires": {
"debug": "^4.1.0",
"extract-zip": "^1.6.6",
"https-proxy-agent": "^2.2.1",
"https-proxy-agent": "^3.0.0",
"mime": "^2.0.3",
"progress": "^2.0.1",
"proxy-from-env": "^1.0.0",

View File

@ -61,7 +61,7 @@
"mocha": "6.2.2",
"node-sass": "4.12.0",
"prettier": "github:automattic/calypso-prettier#c56b4251",
"puppeteer": "1.20.0",
"puppeteer": "2.0.0",
"stylelint": "11.1.1",
"stylelint-config-wordpress": "15.0.0"
},

View File

@ -6,6 +6,7 @@
* External dependencies
*/
import { switchUserToTest } from '@wordpress/e2e-test-utils';
import { CustomerFlow } from "../../utils/flows";
describe( 'My account page', () => {
beforeAll( async () => {
@ -23,33 +24,25 @@ describe( 'My account page', () => {
} );
it( 'allows customer to see orders', async () => {
expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Orders' } );
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
expect( page.url() ).toMatch( '/my-account/orders' );
await CustomerFlow.goToOrders();
await expect( page.url() ).toMatch( '/my-account/orders' );
await expect( page ).toMatchElement( 'h1', { text: 'Orders' } );
} );
it( 'allows customer to see downloads', async () => {
expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Downloads' } )
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
await CustomerFlow.goToDownloads();
expect( page.url() ).toMatch( '/my-account/downloads' );
await expect( page ).toMatchElement( 'h1', { text: 'Downloads' } );
} );
it( 'allows customer to see addresses', async () => {
expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Addresses' } );
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
await CustomerFlow.goToAddresses();
expect( page.url() ).toMatch( '/my-account/edit-address' );
await expect( page ).toMatchElement( 'h1', { text: 'Addresses' } );
} );
it( 'allows customer to see account details', async () => {
expect( page ).toClick( '.woocommerce-MyAccount-navigation-link', { text: 'Account details' } );
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
await CustomerFlow.goToAccountDetails();
expect( page.url() ).toMatch( '/my-account/edit-account' );
await expect( page ).toMatchElement( 'h1', { text: 'Account details' } );
} );

View File

@ -33,7 +33,7 @@ const verifyPublishAndTrash = async () => {
await expect( page ).toMatchElement( '.updated.notice', { text: '1 product moved to the Trash.' } );
};
describe( 'Add New Product Page', () => {
describe( 'Add New Simple Product Page', () => {
beforeAll( async () => {
await activatePlugin( 'woocommerce' );
} );
@ -53,6 +53,12 @@ describe( 'Add New Product Page', () => {
await verifyPublishAndTrash();
} );
} );
describe( 'Add New Variable Product Page', () => {
beforeAll( async () => {
await activatePlugin( 'woocommerce' );
} );
it( 'can create product with variations', async () => {
// Go to "add product" page
@ -149,16 +155,19 @@ describe( 'Add New Product Page', () => {
] );
await expect( page ).toClick( '.woocommerce_variation:nth-of-type(2) .handlediv' );
await page.waitFor( 2000 );
await page.focus( 'input[name="variable_is_virtual[0]"]' );
await expect( page ).toClick( 'input[name="variable_is_virtual[0]"]' );
await expect( page ).toFill( 'input[name="variable_regular_price[0]"]', '9.99' );
await expect( page ).toClick( '.woocommerce_variation:nth-of-type(3) .handlediv' );
await page.waitFor( 2000 );
await page.focus( 'input[name="variable_is_virtual[1]"]' );
await expect( page ).toClick( 'input[name="variable_is_virtual[1]"]' );
await expect( page ).toFill( 'input[name="variable_regular_price[1]"]', '11.99' );
await expect( page ).toClick( '.woocommerce_variation:nth-of-type(4) .handlediv' );
await page.waitFor( 2000 );
await page.focus( 'input[name="variable_manage_stock[2]"]' );
await expect( page ).toClick( 'input[name="variable_manage_stock[2]"]' );
await expect( page ).toFill( 'input[name="variable_regular_price[2]"]', '20' );

View File

@ -6,6 +6,37 @@ const baseUrl = process.env.WP_BASE_URL;
const WP_ADMIN_NEW_PRODUCT = baseUrl + '/wp-admin/post-new.php?post_type=product';
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',
} );
},
goToDownloads: async () => {
await page.goto( MY_ACCOUNT_DOWNLOADS, {
waitUntil: 'networkidle0',
} );
},
goToAddresses: async () => {
await page.goto( MY_ACCOUNT_ADDRESSES, {
waitUntil: 'networkidle0',
} );
},
goToAccountDetails: async () => {
await page.goto( MY_ACCOUNT_ACCOUNT_DETAILS, {
waitUntil: 'networkidle0',
} );
},
};
const StoreOwnerFlow = {
openNewProduct: async () => {
await page.goto( WP_ADMIN_NEW_PRODUCT, {
@ -14,4 +45,4 @@ const StoreOwnerFlow = {
},
};
export { StoreOwnerFlow };
export { CustomerFlow, StoreOwnerFlow };