[e2e tests] External sites - update activate-and-setup tests (#50927)

* Disable woocommerce_calc_taxes before tests start

* TEMP: Comment on expect `#setting-error-settings_updated`

* Include activate-and-setup folder into test runs for external envs

* Update core-profiler.spec.js so it's passing on Pressable and WPCOM

* Check only active plugins

* "Total sales" is missing on one of the external sites. Trying without it.

* Remove comments

* Revert to use `#submit` locator

* Revert "#setting-error-settings_updated"

* Revert "I’m just starting my business" string - check `'` sign on CI

* Revert all strings that initially contained `'` sign

* Revert "Revert "#setting-error-settings_updated""

This reverts commit ae6b72b5c4.

* Revert "Revert "I’m just starting my business" string - check `'` sign on CI"

This reverts commit e852707e06.

* Revert "Revert all strings that initially contained `'` sign"

This reverts commit f978595303.

* Reload page and check settings state instead of verifying `#setting-error-settings_updated`

* Ensure the store is not in "Coming soon" mode before basic.spec.js

* Check if store is in "Comin soon" mode - `hasText` instead of `name`

* Remove `grepInvert: /@local/`

* WPCOM - run only `basic.spec.js`

* WPCOM - run only `basic.spec.js`

* Revert default-wpcpom/playwright.config.js

* Add changefile(s) from automation for the following project(s): woocommerce

* Introduce @skip-on-default-pressable and skip `Can connect to WooCommerce.com`

* Revert "Introduce @skip-on-default-pressable and skip `Can connect to WooCommerce.com`"

This reverts commit e38abebdd2.

* Re-enable "Go to WC Home and make sure the total sales is visible"

* Introduce @skip-on-default-pressable and skip `core-profiler.spec.js`

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Ivan Stojadinov 2024-08-27 14:07:18 +02:00 committed by GitHub
parent 47ff627048
commit 3c12dd8abb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 562 additions and 488 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Update `activate-and-setup` e2e tests, so they are passing against Pressable env.

View File

@ -7,7 +7,11 @@ config = {
{
name: 'default pressable',
use: { ...devices[ 'Desktop Chrome' ] },
testMatch: '**basic.spec.js',
testMatch: [
'**/basic.spec.js',
'**/activate-and-setup/**/*.spec.js',
],
grepInvert: /@skip-on-default-pressable/,
},
],
};

View File

@ -1,10 +1,26 @@
const { test, expect } = require( '@playwright/test' );
const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default;
test.describe(
'Store owner can finish initial store setup',
{ tag: [ '@gutenberg', '@payments', '@services' ] },
() => {
test.use( { storageState: process.env.ADMINSTATE } );
test.beforeAll( async ( { baseURL } ) => {
const api = new wcApi( {
url: baseURL,
consumerKey: process.env.CONSUMER_KEY,
consumerSecret: process.env.CONSUMER_SECRET,
version: 'wc/v3',
} );
await api.put( 'settings/general/woocommerce_calc_taxes', {
data: {
value: 'no',
},
} );
} );
test( 'can enable tax rates and calculations', async ( { page } ) => {
await page.goto( 'wp-admin/admin.php?page=wc-settings' );
// Check the enable taxes checkbox
@ -28,9 +44,7 @@ test.describe(
.fill( '/product/' );
await page.locator( '#submit' ).click();
// Verify that settings have been saved
await expect(
page.locator( '#setting-error-settings_updated' )
).toContainText( 'Permalink structure updated.' );
await page.reload();
await expect( page.locator( '#permalink_structure' ) ).toHaveValue(
'/%postname%/'
);

View File

@ -1,7 +1,10 @@
const { test, expect, request } = require( '@playwright/test' );
const { setOption } = require( '../../utils/options' );
test.describe( 'Store owner can complete the core profiler', () => {
test.describe(
'Store owner can complete the core profiler',
{ tag: '@skip-on-default-pressable' },
() => {
test.use( { storageState: process.env.ADMINSTATE } );
test.beforeAll( async ( { baseURL } ) => {
@ -29,7 +32,9 @@ test.describe( 'Store owner can complete the core profiler', () => {
page.getByRole( 'heading', { name: 'Welcome to Woo!' } )
).toBeVisible();
await page
.getByRole( 'checkbox', { name: 'I agree to share my data' } )
.getByRole( 'checkbox', {
name: 'I agree to share my data',
} )
.uncheck();
await page
.getByRole( 'button', { name: 'Set up my store' } )
@ -43,8 +48,8 @@ test.describe( 'Store owner can complete the core profiler', () => {
} )
).toBeVisible();
await page
.getByRole( 'radio', { name: 'Im just starting my business' } )
.first()
.getByRole( 'radio' )
.filter( { hasText: 'just starting my business' } )
.click();
await page.getByRole( 'button', { name: 'Continue' } ).click();
} );
@ -109,10 +114,14 @@ test.describe( 'Store owner can complete the core profiler', () => {
await test.step( 'Confirm that core profiler was completed and no extensions installed', async () => {
// intermediate page shown
await expect(
page.getByRole( 'heading', { name: 'Turning on the lights' } )
page.getByRole( 'heading', {
name: 'Turning on the lights',
} )
).toBeVisible();
await expect(
page.locator( '.woocommerce-onboarding-progress-bar__filler' )
page.locator(
'.woocommerce-onboarding-progress-bar__filler'
)
).toBeVisible();
// dashboard shown
await expect(
@ -122,16 +131,23 @@ test.describe( 'Store owner can complete the core profiler', () => {
).toBeVisible();
// go to the plugins page to make sure that extensions weren't installed
await page.goto( 'wp-admin/plugins.php' );
await page.goto( 'wp-admin/plugins.php?plugin_status=active' );
await expect(
page.getByRole( 'heading', { name: 'Plugins', exact: true } )
page.getByRole( 'heading', {
name: 'Plugins',
exact: true,
} )
).toBeVisible();
// confirm that some of the optional extensions aren't present
await expect(
page.getByText( 'MailPoet for WooCommerce', { exact: true } )
page.getByText( 'MailPoet for WooCommerce', {
exact: true,
} )
).toBeHidden();
await expect(
page.getByText( 'Pinterest for WooCommerce', { exact: true } )
page.getByText( 'Pinterest for WooCommerce', {
exact: true,
} )
).toBeHidden();
await expect(
page.getByText( 'Google for WooCommerce', { exact: true } )
@ -146,7 +162,9 @@ test.describe( 'Store owner can complete the core profiler', () => {
} )
).toBeVisible();
await expect(
page.getByRole( 'textbox', { name: 'Australian dollar ($)' } )
page.getByRole( 'textbox', {
name: 'Australian dollar ($)',
} )
).toBeVisible();
await expect(
page.getByRole( 'textbox', { name: 'Left' } )
@ -157,9 +175,9 @@ test.describe( 'Store owner can complete the core profiler', () => {
await expect(
page.getByLabel( 'Decimal separator', { exact: true } )
).toHaveValue( '.' );
await expect( page.getByLabel( 'Number of decimals' ) ).toHaveValue(
'2'
);
await expect(
page.getByLabel( 'Number of decimals' )
).toHaveValue( '2' );
} );
} );
@ -175,7 +193,9 @@ test.describe( 'Store owner can complete the core profiler', () => {
page.getByRole( 'heading', { name: 'Welcome to Woo!' } )
).toBeVisible();
await page
.getByRole( 'checkbox', { name: 'I agree to share my data' } )
.getByRole( 'checkbox', {
name: 'I agree to share my data',
} )
.uncheck();
await page
.getByRole( 'button', { name: 'Set up my store' } )
@ -189,12 +209,13 @@ test.describe( 'Store owner can complete the core profiler', () => {
} )
).toBeVisible();
await page
.getByRole( 'radio', { name: 'Im already selling' } )
.first()
.getByRole( 'radio' )
.filter( { hasText: 'already selling' } )
.click();
await page.getByLabel( 'Select an option' ).click();
await page
.getByRole( 'option', { name: 'No, Im selling offline' } )
.getByRole( 'option' )
.filter( { hasText: 'selling offline' } )
.click();
await page.getByRole( 'button', { name: 'Continue' } ).click();
} );
@ -225,7 +246,9 @@ test.describe( 'Store owner can complete the core profiler', () => {
)
.last()
.click();
await page.getByRole( 'option', { name: 'Afghanistan' } ).click();
await page
.getByRole( 'option', { name: 'Afghanistan' } )
.click();
await page
.getByPlaceholder( 'wordpress@example.com' )
@ -256,7 +279,9 @@ test.describe( 'Store owner can complete the core profiler', () => {
.getByRole( 'checkbox' )
.uncheck( { timeout: 2000 } );
} catch ( e ) {
console.log( 'Checkbox not present for Jetpack AI Assistant' );
console.log(
'Checkbox not present for Jetpack AI Assistant'
);
}
try {
await page
@ -295,16 +320,16 @@ test.describe( 'Store owner can complete the core profiler', () => {
// and we want the test to complete in order for cleanup to happen
await expect
.soft(
page.getByRole( 'heading', {
name: 'Woo! Lets get your features ready',
} )
page
.getByRole( 'heading' )
.filter( { hasText: 'get your features ready' } )
)
.toBeVisible( { timeout: 30000 } );
await expect
.soft(
page.getByRole( 'heading', {
name: 'Extending your stores capabilities',
} )
page
.getByRole( 'heading' )
.filter( { hasText: 'Extending your store' } )
)
.toBeVisible( { timeout: 30000 } );
// dashboard shown
@ -314,9 +339,12 @@ test.describe( 'Store owner can complete the core profiler', () => {
} )
).toBeVisible( { timeout: 30000 } );
// go to the plugins page to make sure that extensions were installed
await page.goto( 'wp-admin/plugins.php' );
await page.goto( 'wp-admin/plugins.php?plugin_status=active' );
await expect(
page.getByRole( 'heading', { name: 'Plugins', exact: true } )
page.getByRole( 'heading', {
name: 'Plugins',
exact: true,
} )
).toBeVisible();
// confirm that the optional plugins are present
await expect(
@ -359,9 +387,9 @@ test.describe( 'Store owner can complete the core profiler', () => {
await expect(
page.getByLabel( 'Decimal separator', { exact: true } )
).toHaveValue( ',' );
await expect( page.getByLabel( 'Number of decimals' ) ).toHaveValue(
'0'
);
await expect(
page.getByLabel( 'Number of decimals' )
).toHaveValue( '0' );
} );
await test.step( 'Clean up installed extensions', async () => {
@ -411,13 +439,19 @@ test.describe( 'Store owner can complete the core profiler', () => {
await test.step( 'Confirm that the store is in coming soon mode after completing the core profiler', async () => {
await page.goto( 'wp-admin/admin.php?page=wc-admin' );
await expect(
page.getByRole( 'menuitem', { name: 'Store coming soon' } )
page
.getByRole( 'menuitem' )
.filter( { hasText: 'coming soon' } )
).toBeVisible();
} );
} );
} );
}
);
test.describe( 'Store owner can skip the core profiler', () => {
test.describe(
'Store owner can skip the core profiler',
{ tag: '@skip-on-default-pressable' },
() => {
test.use( { storageState: process.env.ADMINSTATE } );
test.beforeAll( async ( { baseURL } ) => {
@ -438,7 +472,9 @@ test.describe( 'Store owner can skip the core profiler', () => {
'wp-admin/admin.php?page=wc-admin&path=%2Fsetup-wizard'
);
await page.getByRole( 'button', { name: 'Skip guided setup' } ).click();
await page
.getByRole( 'button', { name: 'Skip guided setup' } )
.click();
await expect(
page.getByRole( 'heading', {
@ -447,9 +483,13 @@ test.describe( 'Store owner can skip the core profiler', () => {
).toBeVisible();
await page.getByLabel( 'Select country/region' ).click();
await page
.getByRole( 'option', { name: 'United States (US) — California' } )
.getByRole( 'option', {
name: 'United States (US) — California',
} )
.click();
await page
.getByRole( 'button', { name: 'Go to my store' } )
.click();
await page.getByRole( 'button', { name: 'Go to my store' } ).click();
await expect(
page.getByRole( 'heading', { name: 'Turning on the lights' } )
@ -464,7 +504,9 @@ test.describe( 'Store owner can skip the core profiler', () => {
await test.step( 'Confirm that the store is in coming soon mode after skipping the core profiler', async () => {
await page.goto( 'wp-admin/admin.php?page=wc-admin' );
await expect(
page.getByRole( 'menuitem', { name: 'Store coming soon' } )
page
.getByRole( 'menuitem' )
.filter( { hasText: 'coming soon' } )
).toBeVisible();
} );
} );
@ -506,4 +548,5 @@ test.describe( 'Store owner can skip the core profiler', () => {
).toBeVisible( { timeout: 30000 } );
} );
} );
} );
}
);

View File

@ -1,6 +1,15 @@
const { test, expect } = require( '@playwright/test' );
const { test, expect, request } = require( '@playwright/test' );
const { logIn } = require( '../utils/login' );
const { admin, customer } = require( '../test-data/data' );
const { setOption } = require( '../utils/options' );
test.beforeAll( async ( { baseURL } ) => {
try {
await setOption( request, baseURL, 'woocommerce_coming_soon', 'no' );
} catch ( error ) {
console.log( error );
}
} );
test( 'Load the home page', async ( { page } ) => {
await page.goto( '/' );