Blocks E2E: Fix basic role-based tests (#46684)

This commit is contained in:
Bart Kalisz 2024-04-17 18:50:37 +02:00 committed by GitHub
parent 87ac3d2c85
commit 8da0396b34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 22 deletions

View File

@ -2,36 +2,49 @@
* External dependencies
*/
import { test, expect } from '@woocommerce/e2e-playwright-utils';
import { customerFile, guestFile } from '@woocommerce/e2e-utils';
/**
* Internal dependencies
*/
test.describe( 'A basic set of tests to ensure WP, wp-admin and my-account load', async () => {
test( 'Load the home page', async ( { page } ) => {
await page.goto( '/' );
const title = page
.locator( 'header' )
.locator( '.wp-block-site-title' );
await expect( title ).toHaveText( 'WooCommerce Blocks E2E Test Suite' );
} );
test.describe( 'Sign in as admin', () => {
test( 'Load wp-admin', async ( { page } ) => {
test.describe( 'Basic role-based functionality tests', async () => {
test.describe( 'As admin', () => {
// Admin is the default user, so no need to set storage state.
test( 'Load Dashboard page', async ( { page } ) => {
await page.goto( '/wp-admin' );
const title = page.locator( 'div.wrap > h1' );
await expect( title ).toHaveText( 'Dashboard' );
await expect(
page.getByRole( 'heading', { name: 'Dashboard' } )
).toHaveText( 'Dashboard' );
} );
} );
test.describe( 'Sign in as customer', () => {
test.describe( 'As customer', () => {
test.use( {
storageState: process.env.CUSTOMERSTATE,
storageState: customerFile,
} );
test( 'Load customer my account page', async ( { page } ) => {
test( 'Load My Account page', async ( { page } ) => {
await page.goto( '/my-account' );
const title = page.locator( 'h1.wp-block-post-title' );
await expect( title ).toHaveText( 'My Account' );
await expect(
page.getByRole( 'heading', { name: 'My Account' } )
).toBeVisible();
await expect(
page.getByText( 'Hello Jane Smith (not Jane Smith? Log out)' )
).toBeVisible();
} );
} );
test.describe( 'As guest', () => {
test.use( {
storageState: guestFile,
} );
test( 'Load home page', async ( { page } ) => {
await page.goto( '/' );
await expect(
page.getByRole( 'banner' ).getByRole( 'link', {
name: 'WooCommerce Blocks E2E Test',
} )
).toBeVisible();
} );
} );
} );

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Blocks E2E: Fix basic role-based functionality tests