Update Playwright to 1.44.1 from 1.41.1 (#48291)
Co-authored-by: Jon Lane <jon.lane@automattic.com> Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com> Co-authored-by: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
This commit is contained in:
parent
e64f7b31bc
commit
e5e51a41b8
|
@ -94,7 +94,7 @@ jobs:
|
||||||
id: 'setup-monorepo'
|
id: 'setup-monorepo'
|
||||||
with:
|
with:
|
||||||
install: '${{ matrix.projectName }}...'
|
install: '${{ matrix.projectName }}...'
|
||||||
build: false
|
build: '${{ matrix.projectName }}'
|
||||||
|
|
||||||
- name: 'Lint'
|
- name: 'Lint'
|
||||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}'
|
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}'
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
"packages": [
|
"packages": [
|
||||||
"**"
|
"**"
|
||||||
],
|
],
|
||||||
"pinVersion": "^1.40.1"
|
"pinVersion": "^1.44.1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|
|
@ -122,7 +122,7 @@
|
||||||
"@bartekbp/typescript-checkstyle": "5.0.0",
|
"@bartekbp/typescript-checkstyle": "5.0.0",
|
||||||
"@octokit/action": "5.0.2",
|
"@octokit/action": "5.0.2",
|
||||||
"@octokit/graphql": "5.0.5",
|
"@octokit/graphql": "5.0.5",
|
||||||
"@playwright/test": "^1.40.1",
|
"@playwright/test": "^1.44.1",
|
||||||
"@storybook/addon-a11y": "7.5.2",
|
"@storybook/addon-a11y": "7.5.2",
|
||||||
"@storybook/addon-actions": "^7.6.4",
|
"@storybook/addon-actions": "^7.6.4",
|
||||||
"@storybook/addon-docs": "^7.6.4",
|
"@storybook/addon-docs": "^7.6.4",
|
||||||
|
|
|
@ -40,35 +40,24 @@ export class FrontendUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
async goToCheckout() {
|
async goToCheckout() {
|
||||||
await this.page.goto( '/checkout', {
|
await this.page.goto( '/checkout' );
|
||||||
waitUntil: 'domcontentloaded',
|
|
||||||
} );
|
|
||||||
|
|
||||||
await this.page.locator( '#email' ).waitFor();
|
await this.page.locator( '#email' ).waitFor();
|
||||||
}
|
}
|
||||||
|
|
||||||
async goToCart() {
|
async goToCart() {
|
||||||
await this.page.goto( '/cart', {
|
await this.page.goto( '/cart' );
|
||||||
waitUntil: 'commit',
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async goToCartShortcode() {
|
async goToCartShortcode() {
|
||||||
await this.page.goto( '/cart-shortcode', {
|
await this.page.goto( '/cart-shortcode' );
|
||||||
waitUntil: 'commit',
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async goToMiniCart() {
|
async goToMiniCart() {
|
||||||
await this.page.goto( '/mini-cart', {
|
await this.page.goto( '/mini-cart' );
|
||||||
waitUntil: 'domcontentloaded',
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async goToShop() {
|
async goToShop() {
|
||||||
await this.page.goto( '/shop', {
|
await this.page.goto( '/shop' );
|
||||||
waitUntil: 'commit',
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async emptyCart() {
|
async emptyCart() {
|
||||||
|
@ -101,8 +90,6 @@ export class FrontendUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
async gotoMyAccount() {
|
async gotoMyAccount() {
|
||||||
await this.page.goto( '/my-account', {
|
await this.page.goto( '/my-account' );
|
||||||
waitUntil: 'commit',
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,13 @@ export class MiniCartUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
async openMiniCart() {
|
async openMiniCart() {
|
||||||
const block = await this.frontendUtils.getBlockByName(
|
const miniCartButton = this.page.locator(
|
||||||
'woocommerce/mini-cart'
|
'.wc-block-mini-cart__button'
|
||||||
);
|
);
|
||||||
await block.click();
|
// The mini cart button scripts are loaded when the button is either
|
||||||
|
// hovered or focused. The click event alone does not trigger neither of
|
||||||
|
// those actions so we need to perform one explicitly.
|
||||||
|
await miniCartButton.hover();
|
||||||
|
await miniCartButton.click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Update Playwright from 1.41.1 to 1.44.1 (latest) and fixed tests
|
|
@ -558,7 +558,7 @@
|
||||||
"@babel/core": "7.12.9",
|
"@babel/core": "7.12.9",
|
||||||
"@babel/preset-env": "7.12.7",
|
"@babel/preset-env": "7.12.7",
|
||||||
"@babel/register": "7.12.1",
|
"@babel/register": "7.12.1",
|
||||||
"@playwright/test": "^1.40.1",
|
"@playwright/test": "^1.44.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||||
"@typescript-eslint/experimental-utils": "^5.62.0",
|
"@typescript-eslint/experimental-utils": "^5.62.0",
|
||||||
"@typescript-eslint/parser": "^5.62.0",
|
"@typescript-eslint/parser": "^5.62.0",
|
||||||
|
|
|
@ -7,12 +7,12 @@ const {
|
||||||
publishPage,
|
publishPage,
|
||||||
} = require( '../../utils/editor' );
|
} = require( '../../utils/editor' );
|
||||||
|
|
||||||
baseTest.describe( 'Transform Classic Cart To Cart Block', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
testPageTitlePrefix: 'Transformed cart',
|
||||||
testPageTitlePrefix: 'Transformed cart',
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
|
test.describe( 'Transform Classic Cart To Cart Block', () => {
|
||||||
test( 'can transform classic cart to cart block', async ( {
|
test( 'can transform classic cart to cart block', async ( {
|
||||||
page,
|
page,
|
||||||
testPage,
|
testPage,
|
||||||
|
|
|
@ -13,12 +13,12 @@ const singleProductPrice = '999.00';
|
||||||
|
|
||||||
let productId, shippingZoneId;
|
let productId, shippingZoneId;
|
||||||
|
|
||||||
baseTest.describe( 'Transform Classic Checkout To Checkout Block', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
testPageTitlePrefix: 'Transformed checkout',
|
||||||
testPageTitlePrefix: 'Transformed checkout',
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
|
test.describe( 'Transform Classic Checkout To Checkout Block', () => {
|
||||||
test.beforeAll( async ( { api } ) => {
|
test.beforeAll( async ( { api } ) => {
|
||||||
// enable COD
|
// enable COD
|
||||||
await api.put( 'payment_gateways/cod', {
|
await api.put( 'payment_gateways/cod', {
|
||||||
|
|
|
@ -1,45 +1,45 @@
|
||||||
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
|
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
|
||||||
|
|
||||||
baseTest.describe( 'Coupon management', () => {
|
const couponData = {
|
||||||
const couponData = {
|
fixedCart: {
|
||||||
fixedCart: {
|
code: `fixedCart-${ Date.now() }`,
|
||||||
code: `fixedCart-${ Date.now() }`,
|
description: 'Simple fixed cart discount',
|
||||||
description: 'Simple fixed cart discount',
|
amount: '25',
|
||||||
amount: '25',
|
},
|
||||||
},
|
fixedProduct: {
|
||||||
fixedProduct: {
|
code: `fixedProduct-${ Date.now() }`,
|
||||||
code: `fixedProduct-${ Date.now() }`,
|
description: 'Simple fixed product discount',
|
||||||
description: 'Simple fixed product discount',
|
amount: '5',
|
||||||
amount: '5',
|
},
|
||||||
},
|
percentage: {
|
||||||
percentage: {
|
code: `percentage-${ Date.now() }`,
|
||||||
code: `percentage-${ Date.now() }`,
|
description: 'Simple percentage discount',
|
||||||
description: 'Simple percentage discount',
|
amount: '10',
|
||||||
amount: '10',
|
},
|
||||||
},
|
expiryDate: {
|
||||||
expiryDate: {
|
code: `expiryDate-${ Date.now() }`,
|
||||||
code: `expiryDate-${ Date.now() }`,
|
description: 'Simple expiry date discount',
|
||||||
description: 'Simple expiry date discount',
|
amount: '15',
|
||||||
amount: '15',
|
expiryDate: '2023-12-31',
|
||||||
expiryDate: '2023-12-31',
|
},
|
||||||
},
|
freeShipping: {
|
||||||
freeShipping: {
|
code: `freeShipping-${ Date.now() }`,
|
||||||
code: `freeShipping-${ Date.now() }`,
|
description: 'Simple free shipping discount',
|
||||||
description: 'Simple free shipping discount',
|
amount: '1',
|
||||||
amount: '1',
|
freeShipping: true,
|
||||||
freeShipping: true,
|
},
|
||||||
},
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const test = baseTest.extend( {
|
const test = baseTest.extend( {
|
||||||
storageState: process.env.ADMINSTATE,
|
storageState: process.env.ADMINSTATE,
|
||||||
coupon: async ( { api }, use ) => {
|
coupon: async ( { api }, use ) => {
|
||||||
const coupon = {};
|
const coupon = {};
|
||||||
await use( coupon );
|
await use( coupon );
|
||||||
await api.delete( `coupons/${ coupon.id }`, { force: true } );
|
await api.delete( `coupons/${ coupon.id }`, { force: true } );
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
test.describe( 'Coupon management', () => {
|
||||||
for ( const couponType of Object.keys( couponData ) ) {
|
for ( const couponType of Object.keys( couponData ) ) {
|
||||||
test( `can create new ${ couponType } coupon`, async ( {
|
test( `can create new ${ couponType } coupon`, async ( {
|
||||||
page,
|
page,
|
||||||
|
|
|
@ -6,11 +6,11 @@ const {
|
||||||
publishPage,
|
publishPage,
|
||||||
} = require( '../../utils/editor' );
|
} = require( '../../utils/editor' );
|
||||||
|
|
||||||
baseTest.describe( 'Can create a new page', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
|
test.describe( 'Can create a new page', () => {
|
||||||
// eslint-disable-next-line playwright/expect-expect
|
// eslint-disable-next-line playwright/expect-expect
|
||||||
test( 'can create new page', async ( { page, testPage } ) => {
|
test( 'can create new page', async ( { page, testPage } ) => {
|
||||||
await goToPageEditor( { page } );
|
await goToPageEditor( { page } );
|
||||||
|
|
|
@ -6,11 +6,11 @@ const {
|
||||||
publishPage,
|
publishPage,
|
||||||
} = require( '../../utils/editor' );
|
} = require( '../../utils/editor' );
|
||||||
|
|
||||||
baseTest.describe( 'Can create a new post', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
|
test.describe( 'Can create a new post', () => {
|
||||||
// eslint-disable-next-line playwright/expect-expect
|
// eslint-disable-next-line playwright/expect-expect
|
||||||
test( 'can create new post', async ( { page, testPost } ) => {
|
test( 'can create new post', async ( { page, testPost } ) => {
|
||||||
await goToPostEditor( { page } );
|
await goToPostEditor( { page } );
|
||||||
|
|
|
@ -1,104 +1,102 @@
|
||||||
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
|
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
|
||||||
|
|
||||||
baseTest.describe( 'Restricted coupon management', () => {
|
const couponData = {
|
||||||
const couponData = {
|
minimumSpend: {
|
||||||
minimumSpend: {
|
code: `minSpend-${ new Date().getTime().toString() }`,
|
||||||
code: `minSpend-${ new Date().getTime().toString() }`,
|
description: 'Minimum spend coupon',
|
||||||
description: 'Minimum spend coupon',
|
amount: '10',
|
||||||
amount: '10',
|
minSpend: '100',
|
||||||
minSpend: '100',
|
},
|
||||||
},
|
maximumSpend: {
|
||||||
maximumSpend: {
|
code: `maxSpend-${ new Date().getTime().toString() }`,
|
||||||
code: `maxSpend-${ new Date().getTime().toString() }`,
|
description: 'Maximum spend coupon',
|
||||||
description: 'Maximum spend coupon',
|
amount: '20',
|
||||||
amount: '20',
|
maxSpend: '100',
|
||||||
maxSpend: '100',
|
},
|
||||||
},
|
individualUse: {
|
||||||
individualUse: {
|
code: `individualUse-${ new Date().getTime().toString() }`,
|
||||||
code: `individualUse-${ new Date().getTime().toString() }`,
|
description: 'Individual use coupon',
|
||||||
description: 'Individual use coupon',
|
amount: '30',
|
||||||
amount: '30',
|
individualUse: true,
|
||||||
individualUse: true,
|
},
|
||||||
},
|
excludeSaleItems: {
|
||||||
excludeSaleItems: {
|
code: `excludeSaleItems-${ new Date().getTime().toString() }`,
|
||||||
code: `excludeSaleItems-${ new Date().getTime().toString() }`,
|
description: 'Exclude sale items coupon',
|
||||||
description: 'Exclude sale items coupon',
|
amount: '40',
|
||||||
amount: '40',
|
excludeSaleItems: true,
|
||||||
excludeSaleItems: true,
|
},
|
||||||
},
|
productCategories: {
|
||||||
productCategories: {
|
code: `productCategories-${ new Date().getTime().toString() }`,
|
||||||
code: `productCategories-${ new Date().getTime().toString() }`,
|
description: 'Product categories coupon',
|
||||||
description: 'Product categories coupon',
|
amount: '50',
|
||||||
amount: '50',
|
productCategories: [ 'Uncategorized' ],
|
||||||
productCategories: [ 'Uncategorized' ],
|
},
|
||||||
},
|
excludeProductCategories: {
|
||||||
excludeProductCategories: {
|
code: `excludeProductCategories-${ new Date().getTime().toString() }`,
|
||||||
code: `excludeProductCategories-${ new Date()
|
description: 'Exclude product categories coupon',
|
||||||
.getTime()
|
amount: '60',
|
||||||
.toString() }`,
|
excludeProductCategories: [ 'Uncategorized' ],
|
||||||
description: 'Exclude product categories coupon',
|
},
|
||||||
amount: '60',
|
products: {
|
||||||
excludeProductCategories: [ 'Uncategorized' ],
|
code: `products-${ new Date().getTime().toString() }`,
|
||||||
},
|
description: 'Products coupon',
|
||||||
products: {
|
amount: '70',
|
||||||
code: `products-${ new Date().getTime().toString() }`,
|
products: [ 'Product' ],
|
||||||
description: 'Products coupon',
|
},
|
||||||
amount: '70',
|
excludeProducts: {
|
||||||
products: [ 'Product' ],
|
code: `excludeProducts-${ new Date().getTime().toString() }`,
|
||||||
},
|
description: 'Exclude products coupon',
|
||||||
excludeProducts: {
|
amount: '80',
|
||||||
code: `excludeProducts-${ new Date().getTime().toString() }`,
|
excludeProducts: [ 'Product' ],
|
||||||
description: 'Exclude products coupon',
|
},
|
||||||
amount: '80',
|
allowedEmails: {
|
||||||
excludeProducts: [ 'Product' ],
|
code: `allowedEmails-${ new Date().getTime().toString() }`,
|
||||||
},
|
description: 'Allowed emails coupon',
|
||||||
allowedEmails: {
|
amount: '90',
|
||||||
code: `allowedEmails-${ new Date().getTime().toString() }`,
|
allowedEmails: [ 'allowed@example.com' ],
|
||||||
description: 'Allowed emails coupon',
|
},
|
||||||
amount: '90',
|
usageLimitPerCoupon: {
|
||||||
allowedEmails: [ 'allowed@example.com' ],
|
code: `usageLimit-${ new Date().getTime().toString() }`,
|
||||||
},
|
description: 'Usage limit coupon',
|
||||||
usageLimitPerCoupon: {
|
amount: '100',
|
||||||
code: `usageLimit-${ new Date().getTime().toString() }`,
|
usageLimit: '1',
|
||||||
description: 'Usage limit coupon',
|
},
|
||||||
amount: '100',
|
usageLimitPerUser: {
|
||||||
usageLimit: '1',
|
code: `usageLimitPerUser-${ new Date().getTime().toString() }`,
|
||||||
},
|
description: 'Usage limit per user coupon',
|
||||||
usageLimitPerUser: {
|
amount: '110',
|
||||||
code: `usageLimitPerUser-${ new Date().getTime().toString() }`,
|
usageLimitPerUser: '2',
|
||||||
description: 'Usage limit per user coupon',
|
},
|
||||||
amount: '110',
|
};
|
||||||
usageLimitPerUser: '2',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const test = baseTest.extend( {
|
const test = baseTest.extend( {
|
||||||
storageState: process.env.ADMINSTATE,
|
storageState: process.env.ADMINSTATE,
|
||||||
coupon: async ( { api }, use ) => {
|
coupon: async ( { api }, use ) => {
|
||||||
const coupon = {};
|
const coupon = {};
|
||||||
await use( coupon );
|
await use( coupon );
|
||||||
await api.delete( `coupons/${ coupon.id }`, { force: true } );
|
await api.delete( `coupons/${ coupon.id }`, { force: true } );
|
||||||
},
|
},
|
||||||
|
|
||||||
product: async ( { api }, use ) => {
|
product: async ( { api }, use ) => {
|
||||||
let product = {};
|
let product = {};
|
||||||
|
|
||||||
await api
|
await api
|
||||||
.post( 'products', {
|
.post( 'products', {
|
||||||
name: 'Product',
|
name: 'Product',
|
||||||
regular_price: '100',
|
regular_price: '100',
|
||||||
} )
|
} )
|
||||||
.then( ( response ) => {
|
.then( ( response ) => {
|
||||||
product = response.data;
|
product = response.data;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
await use( product );
|
await use( product );
|
||||||
|
|
||||||
// Product cleanup
|
// Product cleanup
|
||||||
await api.delete( `products/${ product.id }`, { force: true } );
|
await api.delete( `products/${ product.id }`, { force: true } );
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
test.describe( 'Restricted coupon management', () => {
|
||||||
for ( const couponType of Object.keys( couponData ) ) {
|
for ( const couponType of Object.keys( couponData ) ) {
|
||||||
test( `can create new ${ couponType } coupon`, async ( {
|
test( `can create new ${ couponType } coupon`, async ( {
|
||||||
page,
|
page,
|
||||||
|
@ -379,7 +377,9 @@ baseTest.describe( 'Restricted coupon management', () => {
|
||||||
} )
|
} )
|
||||||
.click();
|
.click();
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole( 'listitem', { name: 'Uncategorized' } )
|
page.getByRole( 'listitem', {
|
||||||
|
name: 'Uncategorized',
|
||||||
|
} )
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,9 @@ baseTest.describe( 'Restricted coupon management', () => {
|
||||||
} )
|
} )
|
||||||
.click();
|
.click();
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole( 'listitem', { name: 'Uncategorized' } )
|
page.getByRole( 'listitem', {
|
||||||
|
name: 'Uncategorized',
|
||||||
|
} )
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,12 +43,12 @@ const blocks = [
|
||||||
|
|
||||||
let productId, shippingZoneId, productTagId, attributeId, productCategoryId;
|
let productId, shippingZoneId, productTagId, attributeId, productCategoryId;
|
||||||
|
|
||||||
baseTest.describe( 'Add WooCommerce Blocks Into Page', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
testPageTitlePrefix: 'Woocommerce Blocks',
|
||||||
testPageTitlePrefix: 'Woocommerce Blocks',
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
|
test.describe( 'Add WooCommerce Blocks Into Page', () => {
|
||||||
test.beforeAll( async ( { api } ) => {
|
test.beforeAll( async ( { api } ) => {
|
||||||
// add product attribute
|
// add product attribute
|
||||||
await api
|
await api
|
||||||
|
@ -159,7 +159,10 @@ baseTest.describe( 'Add WooCommerce Blocks Into Page', () => {
|
||||||
.check();
|
.check();
|
||||||
await canvas
|
await canvas
|
||||||
.locator( '.wc-block-reviews-by-product' )
|
.locator( '.wc-block-reviews-by-product' )
|
||||||
.getByRole( 'button', { name: 'Done', exact: true } )
|
.getByRole( 'button', {
|
||||||
|
name: 'Done',
|
||||||
|
exact: true,
|
||||||
|
} )
|
||||||
.click();
|
.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,12 @@ const wooPatterns = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
baseTest.describe( 'Add WooCommerce Patterns Into Page', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
testPageTitlePrefix: 'Woocommerce Patterns',
|
||||||
testPageTitlePrefix: 'Woocommerce Patterns',
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
|
test.describe( 'Add WooCommerce Patterns Into Page', () => {
|
||||||
test( 'can insert WooCommerce patterns into page', async ( {
|
test( 'can insert WooCommerce patterns into page', async ( {
|
||||||
page,
|
page,
|
||||||
testPage,
|
testPage,
|
||||||
|
|
|
@ -58,26 +58,26 @@ const customerData = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
baseTest.describe( 'Merchant > Customer List', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
customers: async ( { api }, use ) => {
|
||||||
customers: async ( { api }, use ) => {
|
const customers = [];
|
||||||
const customers = [];
|
|
||||||
|
|
||||||
for ( const customer of Object.values( customerData ) ) {
|
for ( const customer of Object.values( customerData ) ) {
|
||||||
await api.post( 'customers', customer ).then( ( response ) => {
|
await api.post( 'customers', customer ).then( ( response ) => {
|
||||||
customers.push( response.data );
|
customers.push( response.data );
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
await use( customers );
|
|
||||||
|
|
||||||
await api.post( `customers/batch`, {
|
|
||||||
delete: customers.map( ( customer ) => customer.id ),
|
|
||||||
} );
|
} );
|
||||||
},
|
}
|
||||||
} );
|
|
||||||
|
|
||||||
|
await use( customers );
|
||||||
|
|
||||||
|
await api.post( `customers/batch`, {
|
||||||
|
delete: customers.map( ( customer ) => customer.id ),
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
} );
|
||||||
|
|
||||||
|
test.describe( 'Merchant > Customer List', () => {
|
||||||
test.beforeEach( async ( { context } ) => {
|
test.beforeEach( async ( { context } ) => {
|
||||||
// prevents the column picker from saving state between tests
|
// prevents the column picker from saving state between tests
|
||||||
await context.route( '**/users/**', ( route ) => route.abort() );
|
await context.route( '**/users/**', ( route ) => route.abort() );
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
|
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
|
||||||
|
|
||||||
baseTest.describe( 'Products > Delete Product', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
product: async ( { api }, use ) => {
|
||||||
product: async ( { api }, use ) => {
|
let product = {
|
||||||
let product = {
|
id: 0,
|
||||||
id: 0,
|
name: `Product ${ Date.now() }`,
|
||||||
name: `Product ${ Date.now() }`,
|
type: 'simple',
|
||||||
type: 'simple',
|
regular_price: '12.99',
|
||||||
regular_price: '12.99',
|
};
|
||||||
};
|
|
||||||
|
|
||||||
await api.post( 'products', product ).then( ( response ) => {
|
await api.post( 'products', product ).then( ( response ) => {
|
||||||
product = response.data;
|
product = response.data;
|
||||||
|
} );
|
||||||
|
|
||||||
|
await use( product );
|
||||||
|
|
||||||
|
// permanently delete the product if it still exists
|
||||||
|
const r = await api.get( `products/${ product.id }` );
|
||||||
|
if ( r.status !== 404 ) {
|
||||||
|
await api.delete( `products/${ product.id }`, {
|
||||||
|
force: true,
|
||||||
} );
|
} );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
page: async ( { page, wcAdminApi }, use ) => {
|
||||||
|
// Disable the task list reminder bar, it can interfere with the quick actions
|
||||||
|
await wcAdminApi.post( 'options', {
|
||||||
|
woocommerce_task_list_reminder_bar_hidden: 'yes',
|
||||||
|
} );
|
||||||
|
|
||||||
await use( product );
|
await use( page );
|
||||||
|
},
|
||||||
// permanently delete the product if it still exists
|
} );
|
||||||
const r = await api.get( `products/${ product.id }` );
|
|
||||||
if ( r.status !== 404 ) {
|
|
||||||
await api.delete( `products/${ product.id }`, {
|
|
||||||
force: true,
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
page: async ( { page, wcAdminApi }, use ) => {
|
|
||||||
// Disable the task list reminder bar, it can interfere with the quick actions
|
|
||||||
await wcAdminApi.post( 'options', {
|
|
||||||
woocommerce_task_list_reminder_bar_hidden: 'yes',
|
|
||||||
} );
|
|
||||||
|
|
||||||
await use( page );
|
|
||||||
},
|
|
||||||
} );
|
|
||||||
|
|
||||||
|
test.describe( 'Products > Delete Product', () => {
|
||||||
test( 'can delete a product from edit view', async ( {
|
test( 'can delete a product from edit view', async ( {
|
||||||
page,
|
page,
|
||||||
product,
|
product,
|
||||||
|
|
|
@ -11,67 +11,67 @@ async function addImageFromLibrary( page, imageName, actionButtonName ) {
|
||||||
return dataId;
|
return dataId;
|
||||||
}
|
}
|
||||||
|
|
||||||
baseTest.describe( 'Products > Product Images', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
product: async ( { api }, use ) => {
|
||||||
product: async ( { api }, use ) => {
|
let product = {
|
||||||
let product = {
|
id: 0,
|
||||||
id: 0,
|
name: `Product ${ Date.now() }`,
|
||||||
name: `Product ${ Date.now() }`,
|
type: 'simple',
|
||||||
type: 'simple',
|
regular_price: '12.99',
|
||||||
regular_price: '12.99',
|
sale_price: '11.59',
|
||||||
sale_price: '11.59',
|
};
|
||||||
};
|
|
||||||
|
|
||||||
await api.post( 'products', product ).then( ( response ) => {
|
await api.post( 'products', product ).then( ( response ) => {
|
||||||
product = response.data;
|
product = response.data;
|
||||||
|
} );
|
||||||
|
|
||||||
|
await use( product );
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
await api.delete( `products/${ product.id }`, { force: true } );
|
||||||
|
},
|
||||||
|
productWithImage: async ( { api, product }, use ) => {
|
||||||
|
let productWithImage;
|
||||||
|
await api
|
||||||
|
.put( `products/${ product.id }`, {
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
} )
|
||||||
|
.then( ( response ) => {
|
||||||
|
productWithImage = response.data;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
await use( product );
|
await use( productWithImage );
|
||||||
|
},
|
||||||
|
productWithGallery: async ( { api, product }, use ) => {
|
||||||
|
let productWithGallery;
|
||||||
|
await api
|
||||||
|
.put( `products/${ product.id }`, {
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
} )
|
||||||
|
.then( ( response ) => {
|
||||||
|
productWithGallery = response.data;
|
||||||
|
} );
|
||||||
|
|
||||||
// Cleanup
|
await use( productWithGallery );
|
||||||
await api.delete( `products/${ product.id }`, { force: true } );
|
},
|
||||||
},
|
} );
|
||||||
productWithImage: async ( { api, product }, use ) => {
|
|
||||||
let productWithImage;
|
|
||||||
await api
|
|
||||||
.put( `products/${ product.id }`, {
|
|
||||||
images: [
|
|
||||||
{
|
|
||||||
src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
} )
|
|
||||||
.then( ( response ) => {
|
|
||||||
productWithImage = response.data;
|
|
||||||
} );
|
|
||||||
|
|
||||||
await use( productWithImage );
|
|
||||||
},
|
|
||||||
productWithGallery: async ( { api, product }, use ) => {
|
|
||||||
let productWithGallery;
|
|
||||||
await api
|
|
||||||
.put( `products/${ product.id }`, {
|
|
||||||
images: [
|
|
||||||
{
|
|
||||||
src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
} )
|
|
||||||
.then( ( response ) => {
|
|
||||||
productWithGallery = response.data;
|
|
||||||
} );
|
|
||||||
|
|
||||||
await use( productWithGallery );
|
|
||||||
},
|
|
||||||
} );
|
|
||||||
|
|
||||||
|
test.describe( 'Products > Product Images', () => {
|
||||||
test( 'can set product image', async ( { page, product } ) => {
|
test( 'can set product image', async ( { page, product } ) => {
|
||||||
await test.step( 'Navigate to product edit page', async () => {
|
await test.step( 'Navigate to product edit page', async () => {
|
||||||
await page.goto(
|
await page.goto(
|
||||||
|
@ -192,7 +192,9 @@ baseTest.describe( 'Products > Product Images', () => {
|
||||||
|
|
||||||
for ( const image of images ) {
|
for ( const image of images ) {
|
||||||
await page
|
await page
|
||||||
.getByRole( 'link', { name: 'Add product gallery images' } )
|
.getByRole( 'link', {
|
||||||
|
name: 'Add product gallery images',
|
||||||
|
} )
|
||||||
.click();
|
.click();
|
||||||
const dataId = await addImageFromLibrary(
|
const dataId = await addImageFromLibrary(
|
||||||
page,
|
page,
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
|
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
|
||||||
|
|
||||||
baseTest.describe( 'Products > Related products', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
products: async ( { api }, use ) => {
|
||||||
products: async ( { api }, use ) => {
|
const keys = [ 'main', 'linked1', 'linked2' ];
|
||||||
const keys = [ 'main', 'linked1', 'linked2' ];
|
const products = {};
|
||||||
const products = {};
|
|
||||||
|
|
||||||
for ( const key of Object.values( keys ) ) {
|
for ( const key of Object.values( keys ) ) {
|
||||||
await api
|
await api
|
||||||
.post( 'products', {
|
.post( 'products', {
|
||||||
name: `${ key } ${ Date.now() }`,
|
name: `${ key } ${ Date.now() }`,
|
||||||
type: 'simple',
|
type: 'simple',
|
||||||
regular_price: '12.99',
|
regular_price: '12.99',
|
||||||
} )
|
} )
|
||||||
.then( ( response ) => {
|
.then( ( response ) => {
|
||||||
products[ key ] = response.data;
|
products[ key ] = response.data;
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
await use( products );
|
await use( products );
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
for ( const product of Object.values( products ) ) {
|
for ( const product of Object.values( products ) ) {
|
||||||
await api.delete( `products/${ product.id }`, { force: true } );
|
await api.delete( `products/${ product.id }`, { force: true } );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
test.describe( 'Products > Related products', () => {
|
||||||
async function navigate( page, productId ) {
|
async function navigate( page, productId ) {
|
||||||
await test.step( 'Navigate to product edit page', async () => {
|
await test.step( 'Navigate to product edit page', async () => {
|
||||||
await page.goto(
|
await page.goto(
|
||||||
|
@ -44,7 +44,10 @@ baseTest.describe( 'Products > Related products', () => {
|
||||||
await test.step( 'update the product', async () => {
|
await test.step( 'update the product', async () => {
|
||||||
// extra click somewhere in the page as a workaround for update button click not always working
|
// extra click somewhere in the page as a workaround for update button click not always working
|
||||||
await page
|
await page
|
||||||
.getByRole( 'heading', { name: 'Edit product', exact: true } )
|
.getByRole( 'heading', {
|
||||||
|
name: 'Edit product',
|
||||||
|
exact: true,
|
||||||
|
} )
|
||||||
.click();
|
.click();
|
||||||
await page.getByRole( 'button', { name: 'Update' } ).click();
|
await page.getByRole( 'button', { name: 'Update' } ).click();
|
||||||
await expect( page.getByText( 'Product updated.' ) ).toBeVisible();
|
await expect( page.getByText( 'Product updated.' ) ).toBeVisible();
|
||||||
|
@ -140,7 +143,9 @@ baseTest.describe( 'Products > Related products', () => {
|
||||||
await page.keyboard.press( 'Backspace' );
|
await page.keyboard.press( 'Backspace' );
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole( 'listitem', { name: products.linked1.name } )
|
page.getByRole( 'listitem', {
|
||||||
|
name: products.linked1.name,
|
||||||
|
} )
|
||||||
).toBeHidden();
|
).toBeHidden();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -247,7 +252,9 @@ baseTest.describe( 'Products > Related products', () => {
|
||||||
await page.keyboard.press( 'Backspace' );
|
await page.keyboard.press( 'Backspace' );
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole( 'listitem', { name: products.linked1.name } )
|
page.getByRole( 'listitem', {
|
||||||
|
name: products.linked1.name,
|
||||||
|
} )
|
||||||
).toBeHidden();
|
).toBeHidden();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -1,53 +1,53 @@
|
||||||
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
|
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
|
||||||
|
|
||||||
baseTest.describe( 'Product Reviews > Edit Product Review', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
reviews: async ( { api }, use ) => {
|
||||||
reviews: async ( { api }, use ) => {
|
const timestamp = Date.now().toString();
|
||||||
const timestamp = Date.now().toString();
|
const products = [];
|
||||||
const products = [];
|
const reviews = [];
|
||||||
const reviews = [];
|
|
||||||
|
|
||||||
// Create the products
|
// Create the products
|
||||||
for ( let i = 0; i < 2; i++ ) {
|
for ( let i = 0; i < 2; i++ ) {
|
||||||
await api
|
await api
|
||||||
.post( 'products', {
|
.post( 'products', {
|
||||||
name: `Product ${ i } ${ timestamp }`,
|
name: `Product ${ i } ${ timestamp }`,
|
||||||
type: 'simple',
|
type: 'simple',
|
||||||
regular_price: '9.99',
|
regular_price: '9.99',
|
||||||
} )
|
} )
|
||||||
.then( ( response ) => {
|
.then( ( response ) => {
|
||||||
products.push( response.data );
|
products.push( response.data );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the product reviews
|
// Create the product reviews
|
||||||
for ( const product of products ) {
|
for ( const product of products ) {
|
||||||
await api
|
await api
|
||||||
.post( 'products/reviews', {
|
.post( 'products/reviews', {
|
||||||
product_id: product.id,
|
product_id: product.id,
|
||||||
review: `Nice product ${ product.name }, at ${ timestamp }`,
|
review: `Nice product ${ product.name }, at ${ timestamp }`,
|
||||||
reviewer: 'John Doe',
|
reviewer: 'John Doe',
|
||||||
reviewer_email: `john.doe.${ timestamp }@example.com`,
|
reviewer_email: `john.doe.${ timestamp }@example.com`,
|
||||||
rating: ( Math.random() * ( 5 - 1 ) + 1 ).toFixed( 0 ),
|
rating: ( Math.random() * ( 5 - 1 ) + 1 ).toFixed( 0 ),
|
||||||
} )
|
} )
|
||||||
.then( ( response ) => {
|
.then( ( response ) => {
|
||||||
reviews.push( response.data );
|
reviews.push( response.data );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
await use( reviews );
|
await use( reviews );
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
await api.delete( `products/reviews/batch`, {
|
await api.delete( `products/reviews/batch`, {
|
||||||
delete: reviews.map( ( review ) => review.id ),
|
delete: reviews.map( ( review ) => review.id ),
|
||||||
} );
|
} );
|
||||||
await api.post( `products/batch`, {
|
await api.post( `products/batch`, {
|
||||||
delete: products.map( ( product ) => product.id ),
|
delete: products.map( ( product ) => product.id ),
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
test.describe( 'Product Reviews > Edit Product Review', () => {
|
||||||
test( 'can view products reviews list', async ( { page, reviews } ) => {
|
test( 'can view products reviews list', async ( { page, reviews } ) => {
|
||||||
await page.goto(
|
await page.goto(
|
||||||
`wp-admin/edit.php?post_type=product&page=product-reviews`
|
`wp-admin/edit.php?post_type=product&page=product-reviews`
|
||||||
|
|
|
@ -479,13 +479,11 @@ test.describe( 'Update variations', () => {
|
||||||
await test.step( 'Expect the default attributes to be pre-selected', async () => {
|
await test.step( 'Expect the default attributes to be pre-selected', async () => {
|
||||||
for ( const attribute of defaultVariation ) {
|
for ( const attribute of defaultVariation ) {
|
||||||
await test.step( `Expect "${ attribute.option }" is selected as the default "${ attribute.name }"`, async () => {
|
await test.step( `Expect "${ attribute.option }" is selected as the default "${ attribute.name }"`, async () => {
|
||||||
const defaultSelectedAttribute = page
|
const defaultSelectedAttribute = page.getByLabel(
|
||||||
.getByRole( 'row', {
|
attribute.name
|
||||||
name: attribute.name,
|
);
|
||||||
} )
|
|
||||||
.locator( 'option[selected]' );
|
|
||||||
|
|
||||||
await expect( defaultSelectedAttribute ).toHaveText(
|
await expect( defaultSelectedAttribute ).toContainText(
|
||||||
attribute.option
|
attribute.option
|
||||||
);
|
);
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -18,20 +18,20 @@ const shippingCountryNL = 'NL';
|
||||||
const shippingZoneNamePT = 'Portugal Flat Local';
|
const shippingZoneNamePT = 'Portugal Flat Local';
|
||||||
const shippingCountryPT = 'PT';
|
const shippingCountryPT = 'PT';
|
||||||
|
|
||||||
baseTest.describe( 'Cart Block Calculate Shipping', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
testPageTitlePrefix: 'Cart Block',
|
||||||
testPageTitlePrefix: 'Cart Block',
|
cartBlockPage: async ( { page, testPage }, use ) => {
|
||||||
cartBlockPage: async ( { page, testPage }, use ) => {
|
await goToPageEditor( { page } );
|
||||||
await goToPageEditor( { page } );
|
await fillPageTitle( page, testPage.title );
|
||||||
await fillPageTitle( page, testPage.title );
|
await insertBlockByShortcut( page, 'Cart' );
|
||||||
await insertBlockByShortcut( page, 'Cart' );
|
await publishPage( page, testPage.title );
|
||||||
await publishPage( page, testPage.title );
|
|
||||||
|
|
||||||
await use( testPage );
|
await use( testPage );
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
test.describe( 'Cart Block Calculate Shipping', () => {
|
||||||
let product1Id, product2Id, shippingZoneNLId, shippingZonePTId;
|
let product1Id, product2Id, shippingZoneNLId, shippingZonePTId;
|
||||||
|
|
||||||
test.beforeAll( async ( { api } ) => {
|
test.beforeAll( async ( { api } ) => {
|
||||||
|
|
|
@ -34,28 +34,28 @@ const customerBilling = {
|
||||||
|
|
||||||
let productId, orderId, limitedCouponId;
|
let productId, orderId, limitedCouponId;
|
||||||
|
|
||||||
baseTest.describe( 'Cart Block Applying Coupons', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
testPageTitlePrefix: 'Cart Block',
|
||||||
testPageTitlePrefix: 'Cart Block',
|
page: async ( { context, page, testPage }, use ) => {
|
||||||
page: async ( { context, page, testPage }, use ) => {
|
await goToPageEditor( { page } );
|
||||||
await goToPageEditor( { page } );
|
await fillPageTitle( page, testPage.title );
|
||||||
await fillPageTitle( page, testPage.title );
|
await insertBlockByShortcut( page, 'Cart' );
|
||||||
await insertBlockByShortcut( page, 'Cart' );
|
await publishPage( page, testPage.title );
|
||||||
await publishPage( page, testPage.title );
|
|
||||||
|
|
||||||
await context.clearCookies();
|
await context.clearCookies();
|
||||||
|
|
||||||
await addAProductToCart( page, productId );
|
await addAProductToCart( page, productId );
|
||||||
await page.goto( testPage.slug );
|
await page.goto( testPage.slug );
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole( 'heading', { name: testPage.title } )
|
page.getByRole( 'heading', { name: testPage.title } )
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
|
||||||
await use( page );
|
await use( page );
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
test.describe( 'Cart Block Applying Coupons', () => {
|
||||||
const couponBatchId = [];
|
const couponBatchId = [];
|
||||||
|
|
||||||
test.beforeAll( async ( { api } ) => {
|
test.beforeAll( async ( { api } ) => {
|
||||||
|
|
|
@ -21,12 +21,12 @@ const singleProductWithCrossSellProducts =
|
||||||
|
|
||||||
let product1Id, product2Id, product3Id;
|
let product1Id, product2Id, product3Id;
|
||||||
|
|
||||||
baseTest.describe( 'Cart Block page', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
testPageTitlePrefix: 'Cart Block',
|
||||||
testPageTitlePrefix: 'Cart Block',
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
|
test.describe( 'Cart Block page', () => {
|
||||||
test.beforeAll( async ( { api } ) => {
|
test.beforeAll( async ( { api } ) => {
|
||||||
// make sure the currency is USD
|
// make sure the currency is USD
|
||||||
await api.put( 'settings/general/woocommerce_currency', {
|
await api.put( 'settings/general/woocommerce_currency', {
|
||||||
|
|
|
@ -35,28 +35,28 @@ const customerBilling = {
|
||||||
|
|
||||||
let productId, orderId, limitedCouponId;
|
let productId, orderId, limitedCouponId;
|
||||||
|
|
||||||
baseTest.describe( 'Checkout Block Applying Coupons', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
testPageTitlePrefix: 'Checkout Block',
|
||||||
testPageTitlePrefix: 'Checkout Block',
|
page: async ( { context, page, testPage }, use ) => {
|
||||||
page: async ( { context, page, testPage }, use ) => {
|
await goToPageEditor( { page } );
|
||||||
await goToPageEditor( { page } );
|
await fillPageTitle( page, testPage.title );
|
||||||
await fillPageTitle( page, testPage.title );
|
await insertBlockByShortcut( page, 'Checkout' );
|
||||||
await insertBlockByShortcut( page, 'Checkout' );
|
await publishPage( page, testPage.title );
|
||||||
await publishPage( page, testPage.title );
|
|
||||||
|
|
||||||
await context.clearCookies();
|
await context.clearCookies();
|
||||||
|
|
||||||
await addAProductToCart( page, productId );
|
await addAProductToCart( page, productId );
|
||||||
await page.goto( testPage.slug );
|
await page.goto( testPage.slug );
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole( 'heading', { name: testPage.title } )
|
page.getByRole( 'heading', { name: testPage.title } )
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
|
||||||
await use( page );
|
await use( page );
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
test.describe( 'Checkout Block Applying Coupons', () => {
|
||||||
const couponBatchId = [];
|
const couponBatchId = [];
|
||||||
|
|
||||||
test.beforeAll( async ( { api } ) => {
|
test.beforeAll( async ( { api } ) => {
|
||||||
|
|
|
@ -34,22 +34,22 @@ let guestOrderId1,
|
||||||
productId,
|
productId,
|
||||||
shippingZoneId;
|
shippingZoneId;
|
||||||
|
|
||||||
baseTest.describe( 'Checkout Block page', () => {
|
const test = baseTest.extend( {
|
||||||
const test = baseTest.extend( {
|
storageState: process.env.ADMINSTATE,
|
||||||
storageState: process.env.ADMINSTATE,
|
testPageTitlePrefix: 'Checkout Block',
|
||||||
testPageTitlePrefix: 'Checkout Block',
|
page: async ( { context, page, testPage }, use ) => {
|
||||||
page: async ( { context, page, testPage }, use ) => {
|
await goToPageEditor( { page } );
|
||||||
await goToPageEditor( { page } );
|
await fillPageTitle( page, testPage.title );
|
||||||
await fillPageTitle( page, testPage.title );
|
await insertBlockByShortcut( page, 'Checkout' );
|
||||||
await insertBlockByShortcut( page, 'Checkout' );
|
await publishPage( page, testPage.title );
|
||||||
await publishPage( page, testPage.title );
|
|
||||||
|
|
||||||
await context.clearCookies();
|
await context.clearCookies();
|
||||||
|
|
||||||
await use( page );
|
await use( page );
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
test.describe( 'Checkout Block page', () => {
|
||||||
test.beforeAll( async ( { baseURL } ) => {
|
test.beforeAll( async ( { baseURL } ) => {
|
||||||
const api = new wcApi( {
|
const api = new wcApi( {
|
||||||
url: baseURL,
|
url: baseURL,
|
||||||
|
@ -139,7 +139,9 @@ baseTest.describe( 'Checkout Block page', () => {
|
||||||
`Customer with email ${ newAccountEmail } exists! Deleting it before starting test...`
|
`Customer with email ${ newAccountEmail } exists! Deleting it before starting test...`
|
||||||
);
|
);
|
||||||
|
|
||||||
await api.delete( `customers/${ customerId }`, { force: true } );
|
await api.delete( `customers/${ customerId }`, {
|
||||||
|
force: true,
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
// make sure our customer user has a pre-defined billing/shipping address
|
// make sure our customer user has a pre-defined billing/shipping address
|
||||||
await api.put( `customers/2`, {
|
await api.put( `customers/2`, {
|
||||||
|
@ -201,13 +203,19 @@ baseTest.describe( 'Checkout Block page', () => {
|
||||||
);
|
);
|
||||||
// delete the orders we created
|
// delete the orders we created
|
||||||
if ( guestOrderId1 ) {
|
if ( guestOrderId1 ) {
|
||||||
await api.delete( `orders/${ guestOrderId1 }`, { force: true } );
|
await api.delete( `orders/${ guestOrderId1 }`, {
|
||||||
|
force: true,
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
if ( guestOrderId2 ) {
|
if ( guestOrderId2 ) {
|
||||||
await api.delete( `orders/${ guestOrderId2 }`, { force: true } );
|
await api.delete( `orders/${ guestOrderId2 }`, {
|
||||||
|
force: true,
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
if ( customerOrderId ) {
|
if ( customerOrderId ) {
|
||||||
await api.delete( `orders/${ customerOrderId }`, { force: true } );
|
await api.delete( `orders/${ customerOrderId }`, {
|
||||||
|
force: true,
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
if ( newAccountOrderId ) {
|
if ( newAccountOrderId ) {
|
||||||
await api.delete( `orders/${ newAccountOrderId }`, {
|
await api.delete( `orders/${ newAccountOrderId }`, {
|
||||||
|
|
|
@ -15,12 +15,13 @@ const simpleProductName = 'AAA Filter Products';
|
||||||
|
|
||||||
let product1Id, product2Id, product3Id;
|
let product1Id, product2Id, product3Id;
|
||||||
|
|
||||||
baseTest.describe( 'Filter items in the shop by product price', () => {
|
// Extend the baseTest object
|
||||||
const test = baseTest.extend( {
|
const test = baseTest.extend( {
|
||||||
storageState: process.env.ADMINSTATE,
|
storageState: process.env.ADMINSTATE,
|
||||||
testPageTitlePrefix: 'Products filter',
|
testPageTitlePrefix: 'Products filter',
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
test.describe( 'Filter items in the shop by product price', () => {
|
||||||
test.beforeAll( async ( { api } ) => {
|
test.beforeAll( async ( { api } ) => {
|
||||||
// add products
|
// add products
|
||||||
await api
|
await api
|
||||||
|
|
|
@ -136,7 +136,11 @@ test.describe( 'Search, browse by categories and sort items in the shop', () =>
|
||||||
await page.goto( 'shop/' );
|
await page.goto( 'shop/' );
|
||||||
|
|
||||||
// sort by price high to low
|
// sort by price high to low
|
||||||
await page.locator( '.orderby' ).selectOption( 'price-desc' );
|
await page.getByLabel( 'Shop order' ).selectOption( 'price-desc' );
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByText( 'Add to cart View cart' ).nth( 2 )
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
// Check that the priciest appears before the cheapest in the list
|
// Check that the priciest appears before the cheapest in the list
|
||||||
const highToLowList = await page
|
const highToLowList = await page
|
||||||
|
@ -154,7 +158,11 @@ test.describe( 'Search, browse by categories and sort items in the shop', () =>
|
||||||
);
|
);
|
||||||
|
|
||||||
// sort by price low to high
|
// sort by price low to high
|
||||||
await page.locator( '.orderby' ).selectOption( 'price' );
|
await page.getByLabel( 'Shop order' ).selectOption( 'price' );
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByText( 'Add to cart View cart' ).nth( 2 )
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
// Check that the cheapest appears before the priciest in the list
|
// Check that the cheapest appears before the priciest in the list
|
||||||
const lowToHighList = await page
|
const lowToHighList = await page
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
const {
|
|
||||||
ADMINSTATE,
|
|
||||||
GITHUB_TOKEN,
|
|
||||||
PLUGIN_NAME,
|
|
||||||
PLUGIN_REPOSITORY,
|
|
||||||
PLUGIN_SLUG,
|
|
||||||
} = process.env;
|
|
||||||
const { test, expect } = require( '@playwright/test' );
|
|
||||||
const { admin } = require( '../../test-data/data' );
|
|
||||||
const {
|
|
||||||
deletePlugin,
|
|
||||||
deleteZip,
|
|
||||||
downloadZip,
|
|
||||||
installPluginThruWpCli,
|
|
||||||
} = require( '../../utils/plugin-utils' );
|
|
||||||
|
|
||||||
const skipMessage = 'Skipping this test because PLUGIN_REPOSITORY is undefined';
|
|
||||||
const deletePluginFromSite = async ( { request, baseURL } ) => {
|
|
||||||
await deletePlugin( {
|
|
||||||
request,
|
|
||||||
baseURL,
|
|
||||||
slug: PLUGIN_SLUG,
|
|
||||||
username: admin.username,
|
|
||||||
password: admin.password,
|
|
||||||
} );
|
|
||||||
};
|
|
||||||
|
|
||||||
let pluginPath;
|
|
||||||
|
|
||||||
test.skip( () => {
|
|
||||||
const shouldSkip = ! PLUGIN_REPOSITORY;
|
|
||||||
|
|
||||||
if ( shouldSkip ) {
|
|
||||||
console.log( skipMessage );
|
|
||||||
}
|
|
||||||
|
|
||||||
return shouldSkip;
|
|
||||||
}, skipMessage );
|
|
||||||
|
|
||||||
test.describe( `${ PLUGIN_NAME } plugin can be uploaded and activated`, () => {
|
|
||||||
test.use( { storageState: ADMINSTATE } );
|
|
||||||
|
|
||||||
test.beforeAll( async ( { playwright, baseURL } ) => {
|
|
||||||
pluginPath =
|
|
||||||
await test.step( `Download ${ PLUGIN_NAME } plugin zip`, async () => {
|
|
||||||
return downloadZip( {
|
|
||||||
repository: PLUGIN_REPOSITORY,
|
|
||||||
authorizationToken: GITHUB_TOKEN,
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( "Delete plugin from test site if it's installed.", async () => {
|
|
||||||
await deletePluginFromSite( {
|
|
||||||
request: playwright.request,
|
|
||||||
baseURL,
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
test.afterAll( async ( { playwright, baseURL } ) => {
|
|
||||||
await test.step( "Delete plugin from test site if it's installed.", async () => {
|
|
||||||
await deletePluginFromSite( {
|
|
||||||
request: playwright.request,
|
|
||||||
baseURL,
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( 'Delete the downloaded zip', async () => {
|
|
||||||
await deleteZip( pluginPath );
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( `can upload and activate "${ PLUGIN_NAME }"`, async ( { page } ) => {
|
|
||||||
await test.step( `Install "${ PLUGIN_NAME }" through WP CLI`, async () => {
|
|
||||||
await installPluginThruWpCli( pluginPath );
|
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( 'Go to the "Installed Plugins" page', async () => {
|
|
||||||
await page.goto( 'wp-admin/plugins.php' );
|
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( `Expect "${ PLUGIN_NAME }" to be listed and active.`, async () => {
|
|
||||||
await expect(
|
|
||||||
page.getByLabel( `Deactivate ${ PLUGIN_NAME }` )
|
|
||||||
).toBeVisible();
|
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( 'Expect the shop to load successfully.', async () => {
|
|
||||||
const shopHeading = page.getByRole( 'heading', {
|
|
||||||
name: 'Shop',
|
|
||||||
} );
|
|
||||||
|
|
||||||
await page.goto( '/shop' );
|
|
||||||
await expect( shopHeading ).toBeVisible();
|
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( 'Expect the WooCommerce Homepage to load successfully.', async () => {
|
|
||||||
const statsOverviewHeading = page.getByText( 'Stats overview' );
|
|
||||||
const skipSetupStoreLink = page.getByRole( 'button', {
|
|
||||||
name: 'Set up my store',
|
|
||||||
} );
|
|
||||||
|
|
||||||
await page.goto( '/wp-admin/admin.php?page=wc-admin' );
|
|
||||||
await expect(
|
|
||||||
statsOverviewHeading.or( skipSetupStoreLink )
|
|
||||||
).toBeVisible();
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
} );
|
|
2828
pnpm-lock.yaml
2828
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue