Introduce postID after creating simple and variable products
This commit is contained in:
parent
bef04b37f4
commit
ddbd688bd4
|
@ -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",
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"build-watch": "grunt watch",
|
||||
"lint:js": "eslint assets/js --ext=js",
|
||||
"test:e2e": "./tests/bin/e2e-test-integration.js",
|
||||
"test:e2e-dev": "./tests/bin/e2e-test-integration.js --dev",
|
||||
"makepot": "grunt makepot",
|
||||
"git:update-hooks": "rm -r .git/hooks && mkdir -p .git/hooks && node ./node_modules/husky/husky.js install"
|
||||
},
|
||||
|
@ -61,7 +62,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"
|
||||
},
|
||||
|
|
|
@ -10,21 +10,23 @@ import { activatePlugin } from '@wordpress/e2e-test-utils';
|
|||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { createSimpleProduct, createVariableProduct } from "../../utils/components";
|
||||
import { CustomerFlow, StoreOwnerFlow } from "../../utils/flows";
|
||||
import { createSimpleProduct, createVariableProduct } from '../../utils/components';
|
||||
import { CustomerFlow, StoreOwnerFlow } from '../../utils/flows';
|
||||
import { uiUnblocked } from '../../utils';
|
||||
|
||||
let simplePostIdValue;
|
||||
let variablePostIdValue;
|
||||
|
||||
describe( 'Single Product Page', () => {
|
||||
beforeAll( async () => {
|
||||
await activatePlugin( 'woocommerce' );
|
||||
await createSimpleProduct();
|
||||
await createVariableProduct();
|
||||
simplePostIdValue = await createSimpleProduct();
|
||||
await StoreOwnerFlow.logout();
|
||||
} );
|
||||
|
||||
it( 'should be able to add simple products to the cart', async () => {
|
||||
// Add 5 simple products to cart
|
||||
await CustomerFlow.goToProduct( 'simple-product' );
|
||||
await CustomerFlow.goToProduct( simplePostIdValue );
|
||||
await expect( page ).toFill( 'div.quantity input.qty', '5' );
|
||||
await CustomerFlow.addToCart();
|
||||
await expect( page ).toMatchElement( '.woocommerce-message', { text: 'have been added to your cart.' } );
|
||||
|
@ -38,10 +40,18 @@ describe( 'Single Product Page', () => {
|
|||
await uiUnblocked();
|
||||
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
|
||||
} );
|
||||
} );
|
||||
|
||||
describe( 'Variable Product Page', () => {
|
||||
beforeAll( async () => {
|
||||
await activatePlugin( 'woocommerce' );
|
||||
variablePostIdValue = await createVariableProduct();
|
||||
await StoreOwnerFlow.logout();
|
||||
} );
|
||||
|
||||
it( 'should be able to add variation products to the cart', async () => {
|
||||
// Add a product with one set of variations to cart
|
||||
await CustomerFlow.goToProduct( 'variable-product-with-two-variations' );
|
||||
await CustomerFlow.goToProduct( variablePostIdValue );
|
||||
await expect( page ).toSelect( '#attr-1', 'val1' );
|
||||
await expect( page ).toSelect( '#attr-2', 'val1' );
|
||||
await expect( page ).toSelect( '#attr-3', 'val1' );
|
||||
|
@ -50,10 +60,10 @@ describe( 'Single Product Page', () => {
|
|||
|
||||
// Verify cart contents
|
||||
await CustomerFlow.goToCart();
|
||||
await CustomerFlow.productIsInCart( 'Variable Product with Two Variations' );
|
||||
await CustomerFlow.productIsInCart( 'Variable Product with Three Variations' );
|
||||
|
||||
// Remove items from cart
|
||||
await CustomerFlow.removeFromCart( 'Variable Product with Two Variations' );
|
||||
await CustomerFlow.removeFromCart( 'Variable Product with Three Variations' );
|
||||
await uiUnblocked();
|
||||
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
|
||||
} );
|
||||
|
|
|
@ -28,16 +28,20 @@ const createSimpleProduct = async () => {
|
|||
await StoreOwnerFlow.openNewProduct();
|
||||
|
||||
// Make sure we're on the add order page
|
||||
await expect(page.title()).resolves.toMatch('Add new product');
|
||||
await expect( page.title() ).resolves.toMatch( 'Add new product' );
|
||||
|
||||
// Set product data
|
||||
await expect(page).toFill('#title', 'Simple product');
|
||||
await expect(page).toClick('#_virtual');
|
||||
await clickTab('General');
|
||||
await expect(page).toFill('#_regular_price', '9.99');
|
||||
await expect( page ).toFill( '#title', 'Simple product' );
|
||||
await expect( page ).toClick( '#_virtual' );
|
||||
await clickTab( 'General' );
|
||||
await expect( page ).toFill( '#_regular_price', '9.99' );
|
||||
|
||||
await verifyAndPublish();
|
||||
};
|
||||
|
||||
const simplePostId = await page.$( '#post_ID' );
|
||||
let simplePostIdValue = ( await ( await simplePostId.getProperty( 'value' ) ).jsonValue() );
|
||||
return simplePostIdValue;
|
||||
} ;
|
||||
|
||||
/**
|
||||
* Create variable product.
|
||||
|
@ -50,7 +54,7 @@ const createVariableProduct = async () => {
|
|||
await expect( page.title() ).resolves.toMatch( 'Add new product' );
|
||||
|
||||
// Set product data
|
||||
await expect( page ).toFill( '#title', 'Variable Product with Two Variations' );
|
||||
await expect( page ).toFill( '#title', 'Variable Product with Three Variations' );
|
||||
await expect( page ).toSelect( '#product-type', 'Variable product' );
|
||||
|
||||
// Create attributes for variations
|
||||
|
@ -102,17 +106,55 @@ const createVariableProduct = async () => {
|
|||
|
||||
await page.waitForSelector( '.woocommerce_variation .handlediv' );
|
||||
|
||||
await expect( page ).toClick( '.woocommerce_variation:nth-of-type(1) .handlediv' );
|
||||
// Verify that variations were created
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[0]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[0]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[0]"]', { text: 'val1' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[1]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[1]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[1]"]', { text: 'val2' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[2]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[2]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[2]"]', { text: 'val1' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[3]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[3]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[3]"]', { text: 'val2' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[4]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[4]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[4]"]', { text: 'val1' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[5]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[5]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[5]"]', { text: 'val2' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[6]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[6]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[6]"]', { text: 'val1' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[7]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[7]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[7]"]', { text: 'val2' } ),
|
||||
] );
|
||||
|
||||
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(2) .handlediv' );
|
||||
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(3) .handlediv' );
|
||||
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' );
|
||||
|
@ -125,6 +167,10 @@ const createVariableProduct = async () => {
|
|||
await expect( page ).toClick( 'button.save-variation-changes', { text: 'Save changes' } );
|
||||
|
||||
await verifyAndPublish();
|
||||
|
||||
const variablePostId = await page.$( '#post_ID' );
|
||||
let variablePostIdValue = ( await ( await variablePostId.getProperty( 'value' ) ).jsonValue() );
|
||||
return variablePostIdValue;
|
||||
};
|
||||
|
||||
export { createSimpleProduct, createVariableProduct };
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { clickTab } from "./index";
|
||||
|
||||
/**
|
||||
* @format
|
||||
*/
|
||||
|
@ -9,7 +11,7 @@ const WP_ADMIN_NEW_ORDER = baseUrl + '/wp-admin/post-new.php?post_type=shop_orde
|
|||
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 SHOP_PRODUCT = baseUrl + '/product/';
|
||||
const SHOP_PRODUCT = baseUrl + '/?p=';
|
||||
const SHOP_CART_PAGE = baseUrl + '/cart/';
|
||||
|
||||
const getProductColumnExpression = ( productTitle ) => (
|
||||
|
@ -46,7 +48,6 @@ const getRemoveExpression = () => (
|
|||
'td[@class="product-remove"]//a[@class="remove"]'
|
||||
);
|
||||
|
||||
|
||||
const CustomerFlow = {
|
||||
addToCart: async () => {
|
||||
await Promise.all( [
|
||||
|
@ -63,8 +64,8 @@ const CustomerFlow = {
|
|||
await removeButton.click();
|
||||
},
|
||||
|
||||
goToProduct: async ( productSlug ) => {
|
||||
await page.goto( SHOP_PRODUCT + productSlug, {
|
||||
goToProduct: async ( postID ) => {
|
||||
await page.goto( SHOP_PRODUCT + postID, {
|
||||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue