[e2e] External sites - update /shopper tests, part 1 (#51068)

* Update shopper tests and util to fix external env compatibility

* Update WPCOM config to include shopper tests and skip one from testing

* Update WPCOM config

* Update shopper shop title deletion test to avoid false positives

* Add search and click steps to afterEach

* Update selector in test to pass across all envs

* Update external PW configs for shopper tests

* Improve existing test to use WP API for setup

---------

Co-authored-by: Ivan Stojadinov <ivan.stojadinov@automattic.com>
This commit is contained in:
Veljko V. 2024-09-06 15:34:45 +02:00 committed by GitHub
parent 63243c57a9
commit b71e6e22a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 73 additions and 96 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Update /shopper tests (first part), so they are passing against Pressable env.

View File

@ -15,23 +15,7 @@ config = {
'**/admin-tasks/**/*.spec.js',
'**/customize-store/**/*.spec.js',
'**/merchant/**/*.spec.js',
'**/shopper/checkout-create-account.spec.js',
'**/shopper/checkout-login.spec.js',
'**/shopper/checkout.spec.js',
'**/shopper/dashboard-access.spec.js',
'**/shopper/mini-cart.spec.js',
'**/shopper/my-account-addresses.spec.js',
'**/shopper/my-account-create-account.spec.js',
'**/shopper/my-account-downloads.spec.js',
'**/shopper/my-account-pay-order.spec.js',
'**/shopper/my-account.spec.js',
'**/shopper/order-email-receiving.spec.js',
'**/shopper/product-grouped.spec.js',
'**/shopper/product-simple.spec.js',
'**/shopper/product-tags-attributes.spec.js',
'**/shopper/product-variable.spec.js',
'**/shopper/shop-search-browse-sort.spec.js',
'**/shopper/shop-title-after-deletion.spec.js',
'**/shopper/**/*.spec.js',
],
grepInvert: /@skip-on-default-pressable/,
},

View File

@ -7,26 +7,7 @@ config = {
{
name: 'default wpcom',
use: { ...devices[ 'Desktop Chrome' ] },
testMatch: [
'**/basic.spec.js',
'**/shopper/checkout-create-account.spec.js',
'**/shopper/checkout-login.spec.js',
'**/shopper/checkout.spec.js',
'**/shopper/dashboard-access.spec.js',
'**/shopper/mini-cart.spec.js',
'**/shopper/my-account-addresses.spec.js',
'**/shopper/my-account-create-account.spec.js',
'**/shopper/my-account-downloads.spec.js',
'**/shopper/my-account-pay-order.spec.js',
'**/shopper/my-account.spec.js',
'**/shopper/order-email-receiving.spec.js',
'**/shopper/product-grouped.spec.js',
'**/shopper/product-simple.spec.js',
'**/shopper/product-tags-attributes.spec.js',
'**/shopper/product-variable.spec.js',
'**/shopper/shop-search-browse-sort.spec.js',
'**/shopper/shop-title-after-deletion.spec.js',
],
testMatch: [ '**/basic.spec.js', '**/shopper/**/*.spec.js' ],
grepInvert: /@skip-on-default-wpcom/,
},
],

View File

@ -240,10 +240,10 @@ test.describe(
.click();
await expect(
await page
.getByText( 'Password reset email has been sent' )
.count()
).toBeGreaterThan( 0 );
page
.getByRole( 'alert' )
.getByText( 'Password reset email has been sent.' )
).toBeVisible();
} );
await test.step( 'verify that the email was sent', async () => {

View File

@ -51,6 +51,27 @@ test.describe(
version: 'wc/v3',
} );
// make sure the store address is US
await api.post( 'settings/general/batch', {
update: [
{
id: 'woocommerce_store_address',
value: 'addr 1',
},
{
id: 'woocommerce_store_city',
value: 'San Francisco',
},
{
id: 'woocommerce_default_country',
value: 'US:CA',
},
{
id: 'woocommerce_store_postcode',
value: '94107',
},
],
} );
// make sure the currency is USD
await api.put( 'settings/general/woocommerce_currency', {
value: 'USD',
@ -244,9 +265,11 @@ test.describe(
await applyCoupon( page, 'min-max-spend-individual' );
// failed because we need to have at least $50 in cart (single product is only $20)
await expect(
page.getByText(
'The minimum spend for this coupon is $50.00.'
)
page
.getByRole( 'alert' )
.getByText(
'The minimum spend for this coupon is $50.00.'
)
).toBeVisible();
// add a couple more in order to hit minimum spend

View File

@ -24,7 +24,7 @@ const newAccountEmail = `marge-${ new Date()
const newAccountEmailWithCustomPassword = `homer-${ new Date()
.getTime()
.toString() }@woocommercecoree2etestsuite.com`;
const newAccountCustomPassword = 'supersecurepassword123';
const newAccountCustomPassword = 'sup3rS3cur3P4ssw0rd!#123';
const simpleProductName = 'Very Simple Product';
const simpleProductDesc = 'Lorem ipsum dolor.';
@ -57,7 +57,7 @@ const test = baseTest.extend( {
test.describe(
'Checkout Block page',
{ tag: [ '@payments', '@services', '@hpos' ] },
{ tag: [ '@payments', '@services', '@hpos', '@skip-on-default-wpcom' ] },
() => {
test.beforeAll( async ( { baseURL } ) => {
const api = new wcApi( {

View File

@ -1,56 +1,41 @@
const { test, expect } = require( '@playwright/test' );
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
// test case for bug https://github.com/woocommerce/woocommerce/pull/46429
test.describe(
const test = baseTest.extend( {
storageState: process.env.ADMINSTATE,
page: async ( { page, wpApi }, use ) => {
const response = await wpApi.get( `/wp-json/wp/v2/pages?slug=shop`, {
data: {
_fields: [ 'id' ],
},
} );
const pages = await response.json();
const pageId = pages[ 0 ].id;
await wpApi.delete( `/wp-json/wp/v2/pages/${ pageId }`, {
data: {
force: false,
},
} );
await use( page );
await wpApi.post( `/wp-json/wp/v2/pages/${ pageId }`, {
data: {
status: 'publish',
},
} );
},
} );
test(
'Check the title of the shop page after the page has been deleted',
{ tag: [ '@payments', '@services', '@could-be-unit-test' ] },
() => {
test.use( { storageState: process.env.ADMINSTATE } );
test.beforeEach( async ( { page } ) => {
await page.goto( 'wp-admin/edit.php?post_type=page' );
await page.getByRole( 'cell', { name: '“Shop” (Edit)' } ).hover();
await page
.getByLabel( 'Move “Shop” to the Trash' )
.click( { force: true } );
await page
.getByText( 'page moved to the Trash. Undo' )
.waitFor( { state: 'visible' } );
} );
test.afterEach( async ( { page } ) => {
await page.goto(
'wp-admin/edit.php?post_status=trash&post_type=page'
);
await page
.getByRole( 'cell', { name: 'Shop — Shop Page Restore “' } )
.hover();
await page
.getByLabel( 'Restore “Shop” from the Trash' )
.click( { force: true } );
await page
.getByText( '1 page restored from the Trash.' )
.waitFor( { state: 'visible' } );
await page.goto( 'wp-admin/edit.php?post_type=page' );
await page.getByRole( 'cell', { name: '“Shop” (Edit)' } ).hover();
await page
.getByLabel( 'Quick edit “Shop” inline' )
.click( { force: true } );
await page
.getByLabel( 'Status Published Pending' )
.selectOption( 'publish', { exact: true } );
await page.getByRole( 'button', { name: 'Update' } ).click();
await page
.locator( '#a11y-speak-polite', { hasText: 'Changes saved.' } )
.waitFor();
} );
test( 'Check the title of the shop page after the page has been deleted', async ( {
page,
} ) => {
await page.goto( '/shop/' );
expect( await page.title() ).toBe(
'Shop WooCommerce Core E2E Test Suite'
);
} );
async ( { page } ) => {
await page.goto( '/shop/' );
expect( await page.title() ).toBe(
'Shop WooCommerce Core E2E Test Suite'
);
}
);