Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 19cc6a9

Browse files
oprsamueljseay
authored andcommitted
Move cart widget tests to playwright and ensure classic/block theme configs are executed correctly (#10669)
1 parent 544010a commit 19cc6a9

File tree

12 files changed

+108
-62
lines changed

12 files changed

+108
-62
lines changed

.github/workflows/playwright.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
matrix:
1515
config: [
1616
{ name: Normal, file: playwright.config.ts, resultPath: test-results },
17+
{ name: Classic, file: playwright.classic-theme.config.ts, resultPath: test-results-classic-theme },
1718
{ name: SideEffects, file: playwright.side-effects.config.ts, resultPath: test-results-side-effects },
1819
]
1920
steps:

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
"test:e2e:report": "sh ./bin/check-env.sh && npx playwright test --config=tests/e2e/playwright.config.ts --reporter=html",
8484
"test:e2e:side-effects": "npm run test:e2e -- --config=tests/e2e/playwright.side-effects.config.ts",
8585
"test:e2e:side-effects:report": "npm run test:e2e:report -- --config=tests/e2e/playwright.side-effects.config.ts",
86+
"test:e2e:classic-theme": "npm run test:e2e -- --config=tests/e2e/playwright.classic-theme.config.ts",
87+
"test:e2e:classic-theme:report": "npm run test:e2e:report -- --config=tests/e2e/playwright.classic-theme.config.ts",
8688
"test:e2e:jest": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e-jest/config/jest-puppeteer.config.js NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js",
8789
"test:e2e:jest:dev": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e-jest/config/jest-puppeteer.config-dev.js NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js",
8890
"test:e2e:jest:dev-watch": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e-jest/config/jest-puppeteer.config-dev.js NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js --watch",

tests/e2e-jest/specs/backend/cart.test.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

tests/e2e/block-theme.setup.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
/**
22
* External dependencies
33
*/
4-
import { BLOCK_THEME_SLUG, cli } from '@woocommerce/e2e-utils';
4+
import {
5+
BLOCK_THEME_NAME,
6+
BLOCK_THEME_SLUG,
7+
cli,
8+
} from '@woocommerce/e2e-utils';
9+
import { test as setup, expect } from '@woocommerce/e2e-playwright-utils';
510

6-
cli( `npm run wp-env run tests-cli "wp theme activate ${ BLOCK_THEME_SLUG }` );
11+
setup( 'Sets up the block theme', async ( { admin } ) => {
12+
await cli(
13+
`npm run wp-env run tests-cli "wp theme install ${ BLOCK_THEME_SLUG } --activate"`
14+
);
15+
await admin.page.goto( '/wp-admin/themes.php' );
16+
await expect(
17+
admin.page.getByText( `Active: ${ BLOCK_THEME_NAME }` )
18+
).toBeVisible();
19+
} );

tests/e2e/classic-theme.setup.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
/**
22
* External dependencies
33
*/
4-
import { CLASSIC_THEME_SLUG, cli } from '@woocommerce/e2e-utils';
4+
import {
5+
CLASSIC_THEME_NAME,
6+
CLASSIC_THEME_SLUG,
7+
cli,
8+
} from '@woocommerce/e2e-utils';
9+
import { test as setup, expect } from '@woocommerce/e2e-playwright-utils';
510

6-
cli(
7-
`npm run wp-env run tests-cli "wp theme activate ${ CLASSIC_THEME_SLUG }`
8-
);
11+
setup( 'Sets up the classic theme', async ( { admin } ) => {
12+
await cli(
13+
`npm run wp-env run tests-cli "wp theme install ${ CLASSIC_THEME_SLUG } --activate"`
14+
);
15+
await admin.page.goto( '/wp-admin/themes.php' );
16+
await expect(
17+
admin.page.getByText( `Active: ${ CLASSIC_THEME_NAME }` )
18+
).toBeVisible();
19+
} );
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { defineConfig } from '@playwright/test';
5+
import path from 'path';
6+
7+
/**
8+
* Internal dependencies
9+
*/
10+
import config from './playwright.config';
11+
12+
export default defineConfig( {
13+
...config,
14+
outputDir: path.join(
15+
process.cwd(),
16+
'artifacts/test-results-side-effects'
17+
),
18+
fullyParallel: false,
19+
workers: 1,
20+
projects: [
21+
{
22+
name: 'classicThemeConfiguration',
23+
testDir: '.',
24+
testMatch: /classic-theme.setup.ts/,
25+
},
26+
{
27+
name: 'classicTheme',
28+
testMatch: /.*.classic_theme.spec.ts/,
29+
dependencies: [ 'classicThemeConfiguration' ],
30+
},
31+
],
32+
} );

tests/e2e/playwright.config.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,14 @@ const config: ExtendedPlaywrightTestConfig = {
4444
projects: [
4545
{
4646
name: 'blockThemeConfiguration',
47+
testDir: '.',
4748
testMatch: /block-theme.setup.ts/,
4849
},
4950
{
5051
name: 'blockTheme',
5152
testMatch: /.*.block_theme.spec.ts/,
5253
dependencies: [ 'blockThemeConfiguration' ],
5354
},
54-
{
55-
name: 'classicThemeConfiguration',
56-
testMatch: /classic-theme.setup.ts/,
57-
},
58-
{
59-
name: 'classicTheme',
60-
testMatch: /.*.classic_theme.spec.ts/,
61-
dependencies: [ 'classicThemeConfiguration' ],
62-
},
6355
],
6456
};
6557

tests/e2e/playwright.side-effects.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default defineConfig( {
2020
projects: [
2121
{
2222
name: 'blockThemeConfiguration',
23+
testDir: '.',
2324
testMatch: /block-theme.setup.ts/,
2425
},
2526
{
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { test, expect } from '@woocommerce/e2e-playwright-utils';
5+
6+
test.describe( 'Merchant → Cart', () => {
7+
test.describe( 'in widget editor', () => {
8+
test( "can't be inserted in a widget area", async ( {
9+
editorUtils,
10+
page,
11+
} ) => {
12+
await page.goto( '/wp-admin/widgets.php' );
13+
await editorUtils.closeModalByName( 'Welcome to block Widgets' );
14+
15+
await editorUtils.openGlobalBlockInserter();
16+
await editorUtils.page
17+
.getByLabel( 'Search for blocks and patterns' )
18+
.fill( 'woocommerce/cart' );
19+
const cartButton = editorUtils.page.getByRole( 'option', {
20+
name: 'Cart',
21+
exact: true,
22+
} );
23+
await expect( cartButton ).toBeHidden();
24+
} );
25+
} );
26+
} );

tests/e2e/utils/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import path from 'path';
55

66
export const BLOCK_THEME_SLUG = 'twentytwentythree';
7-
export const CLASSIC_THEME_SLUG = 'twentytwentyone';
7+
export const BLOCK_THEME_NAME = 'Twenty Twenty-Three';
8+
export const CLASSIC_THEME_SLUG = 'storefront';
9+
export const CLASSIC_THEME_NAME = 'Storefront';
810
export const BASE_URL = 'http://localhost:8889';
911
export const STORAGE_STATE_PATH = path.join(
1012
process.cwd(),

0 commit comments

Comments
 (0)