Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: E2E Tests with Playwright #3430

Merged
merged 90 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
fa8c99a
initial commit for e2e
Jan 15, 2025
6a197a8
Merge branch 'develop' into feat/e2e-playwright
Jan 15, 2025
7fe5a11
updated readme
Jan 15, 2025
a438a05
activate only stackable for all tests
mxkae Jan 27, 2025
aa58c5a
add tsconfig
mxkae Jan 27, 2025
d543e12
add tests for settings page and editor page
mxkae Jan 27, 2025
b69b0df
Merge branch 'develop' into feat/e2e-playwright
mxkae Jan 27, 2025
497f8f3
add tests for site editor, global settings
mxkae Jan 31, 2025
3864ca4
minor change to tests for admin and block editor
mxkae Jan 31, 2025
1355de4
Merge branch 'develop' into feat/e2e-playwright
mxkae Jan 31, 2025
1ffa888
Merge branch 'develop' into feat/e2e-playwright
mxkae Jan 31, 2025
c2f4a6d
use custom test utils
mxkae Feb 5, 2025
c8252b7
Merge branch 'develop' into feat/e2e-playwright
mxkae Feb 5, 2025
19a9e06
run tests
mxkae Feb 5, 2025
d63fe72
update playwright workflows
mxkae Feb 5, 2025
0623f04
add .wp-env.json
mxkae Feb 5, 2025
70c5f33
add env
mxkae Feb 5, 2025
fa6a5d4
fix env slug
mxkae Feb 5, 2025
20da040
log plugins installed
mxkae Feb 5, 2025
8ae8947
update steps, slug
mxkae Feb 5, 2025
e32eb62
install playwright browsers
mxkae Feb 5, 2025
bd33774
comment out site editor tests, add reporter
mxkae Feb 5, 2025
2a8fda5
add try catch for newly installed plugin
mxkae Feb 5, 2025
b3606ba
update admin test
mxkae Feb 5, 2025
addf024
update stackable fixture
mxkae Feb 5, 2025
60f7890
comment on PR
mxkae Feb 5, 2025
4b895ae
fix PR comment
mxkae Feb 5, 2025
4d6ef18
add id for upload artifact, update comment body
mxkae Feb 5, 2025
3b1eaf7
update yml file
mxkae Feb 5, 2025
3820390
include site editor tests
mxkae Feb 6, 2025
b1043f8
minor update in yml file
mxkae Feb 6, 2025
57c3608
always update comment
mxkae Feb 6, 2025
a519bde
upload traces
mxkae Feb 6, 2025
abf48b9
test script
mxkae Feb 6, 2025
a3cb37d
update comment content
mxkae Feb 6, 2025
dedf6f2
get failed tests
mxkae Feb 6, 2025
3ceb2e8
use $GITHUB_OUTPUT
mxkae Feb 6, 2025
8b43484
update to multiline
mxkae Feb 6, 2025
253332e
update output name
mxkae Feb 6, 2025
e4f0924
fix failed tests content
mxkae Feb 6, 2025
66d0995
escape special characters
mxkae Feb 6, 2025
790f603
use markdown to output
mxkae Feb 6, 2025
b6706e2
run mto even on fail
mxkae Feb 6, 2025
926fdb0
strip Ansi Escapes
mxkae Feb 6, 2025
643dfee
try multiple upload
mxkae Feb 7, 2025
b15d33a
test multiple upload
mxkae Feb 7, 2025
74eda4b
use test ids and trace file path
mxkae Feb 7, 2025
7cad560
update reporter
mxkae Feb 7, 2025
1d94db4
test matrix
mxkae Feb 7, 2025
03a2c7e
update .wp-env.json and name
mxkae Feb 7, 2025
93e5821
update php version, remove unit tests
mxkae Feb 7, 2025
e40aa82
continue matrix even if one job fails
mxkae Feb 7, 2025
7bf5aa1
use different artifact name based on matrix
mxkae Feb 7, 2025
e5f53b4
try all test env
mxkae Feb 7, 2025
a2c9632
remove comments, update matrix
mxkae Feb 7, 2025
f310faa
update php version
mxkae Feb 7, 2025
aba59a7
update conditions, log wp and php version
mxkae Feb 7, 2025
1feb5d5
add quotes
mxkae Feb 7, 2025
a64cb24
update php version
mxkae Feb 7, 2025
f596c50
run other tests
mxkae Feb 7, 2025
06ec688
test custom reporter
mxkae Feb 7, 2025
5b44cef
update condition
mxkae Feb 7, 2025
a42c89e
add report to summary
mxkae Feb 7, 2025
bf2c16a
comment site editor tests temporarily
mxkae Feb 7, 2025
252ebb1
update report url
mxkae Feb 7, 2025
3585bdd
update wp version
mxkae Feb 7, 2025
0a09b08
update block editor test
mxkae Feb 10, 2025
d86d9be
use custom way to get block attributes
mxkae Feb 10, 2025
6159ea7
fix missing global settings for older wp versions
mxkae Feb 10, 2025
4ef30ce
add comments, update tests
mxkae Feb 10, 2025
c844e91
Merge branch 'develop' into feat/e2e-playwright
mxkae Feb 10, 2025
112f772
Merge branch 'fix/missing-global-settings-for-older-wp-versions' into…
mxkae Feb 10, 2025
4bd8941
update tests
mxkae Feb 10, 2025
6d032e4
test with existing post
mxkae Feb 10, 2025
210503a
update command
mxkae Feb 10, 2025
fd37885
use tests-cli
mxkae Feb 10, 2025
3dcc46a
run wp-env first
mxkae Feb 10, 2025
38bc72d
update file path
mxkae Feb 10, 2025
cdd9c62
check post content
mxkae Feb 10, 2025
b7e2482
update file path
mxkae Feb 10, 2025
c90d8f7
update file path
mxkae Feb 10, 2025
a19e21b
update reporter
mxkae Feb 10, 2025
072eb8b
update locator for global settings block defaults
mxkae Feb 10, 2025
8140949
check if settings are open in editor, correct typo
mxkae Feb 11, 2025
e67fb2d
update readme, global settings test
mxkae Feb 12, 2025
a6e52da
Merge branch 'develop' into feat/e2e-playwright
mxkae Feb 12, 2025
3ea41db
update failing tests in premium
mxkae Feb 12, 2025
59b37ed
update test to prevent flakiness
mxkae Feb 12, 2025
9c910a6
make sure global block default gets updated
mxkae Feb 12, 2025
1c3c301
update to default block page
mxkae Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions e2e/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@ WP_BASE_URL=http://local.local/
WP_AUTH_STORAGE=wp-auth.json
WP_USERNAME=admin
WP_PASSWORD=password
STACKABLE_SLUG={ STACKABLE SLUG }
WP_TEST_POSTID={ POST_ID }
WP_STK_LICENSE={ STACKABLE LICENSE }
```

In Freemius, make sure the license key is:
- new
- lifetime unlimited quota
- has an owner
- non-blocking and white-labeled

Run this command to run e2e:

```bash
Expand Down
13 changes: 13 additions & 0 deletions e2e/tests/block-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ test.describe( 'Block Editor', () => {
} )

await editor.selectBlocks( editor.canvas.getByLabel( 'Block: Text' ) )

const settings = page.getByLabel( 'Settings', { exact: true } )

if ( await settings.getAttribute( 'aria-pressed' ) === 'false' ) {
await settings.click()
}

await expect( page.getByLabel( 'Layout Tab' ) ).toBeVisible()
await expect( page.getByLabel( 'Style Tab' ) ).toBeVisible()
await expect( page.getByLabel( 'Advanced Tab' ) ).toBeVisible()
Expand All @@ -52,6 +59,12 @@ test.describe( 'Block Editor', () => {
name: 'stackable/text',
} )

const settings = page.getByLabel( 'Settings', { exact: true } )

if ( await settings.getAttribute( 'aria-pressed' ) === 'false' ) {
await settings.click()
}

// Add content and color to Stackable Text Block
await editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ).fill( 'test' )
await page.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click()
Expand Down
37 changes: 25 additions & 12 deletions e2e/tests/global-settings.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { test, expect } from 'e2e/test-utils'
import { createColor, getRgb } from '~stackable/plugins/global-settings/colors/util'

test.describe( 'Global Settigs', () => {
test.describe( 'Global Settings', () => {
let pid = null

// Create Posts for testing
Expand Down Expand Up @@ -62,7 +61,15 @@ test.describe( 'Global Settigs', () => {

// Delete added Global Color
await page.getByLabel( 'Stackable Settings' ).click()
await panel.locator( `.ugb-global-settings-color-picker__color-indicators > div > div:nth-child(${ count }) > button.stk-global-settings-color-picker__delete-button` ).click()

page.on( 'dialog', async dialog => await dialog.accept() )
const deleteRequest = page.waitForResponse( response => response.url().includes( 'wp/v2/settings' ) && response.request().method() === 'POST' )

await globalColors.getByLabel( 'Delete' ).nth( count - 1 ).click()

await deleteRequest
const _count = ( await globalColors.evaluate( node => Array.from( node.childNodes ) ) ).length
expect( _count ).toBeLessThan( count )
} )

test( 'Global Typography Styles should be applied when adding a heading', async ( {
Expand Down Expand Up @@ -93,18 +100,21 @@ test.describe( 'Global Settigs', () => {

await expect( editor.canvas.locator( '[data-type="stackable/heading"] > .stk-block-heading > h2[role="textbox"]' ) ).toHaveCSS( 'font-size', '32px' )

// Reset Global Typography Styles
await page.getByLabel( 'Stackable Settings' ).click()
await page.locator( '.ugb-global-settings-typography-control' ).nth( 1 ).getByRole( 'button', { name: 'Reset' } ).click()
// Reset Global Typography Styles
await page.getByLabel( 'Stackable Settings' ).click()

const resetButton = page.locator( '.ugb-global-settings-typography-control' ).nth( 1 ).getByLabel( 'Reset' )
const deleteRequest = page.waitForResponse( response => response.url().includes( 'wp/v2/settings' ) && response.request().method() === 'POST' )
await resetButton.click()

await deleteRequest
await expect( resetButton ).not.toBeVisible()
} )

test( 'When a default block is created, adding the block should have the default block\'s attributes', async ( {
page,
editor,
} ) => {
// Generate a color
const color = createColor()

await page.getByLabel( 'Stackable Settings' ).click()
await page.getByRole( 'button', { name: 'Block Defaults' } ).click()

Expand All @@ -116,16 +126,20 @@ test.describe( 'Global Settigs', () => {

// Set a color for the default Text Block
await defaultBlockPage.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click()
await defaultBlockPage.getByLabel( 'Hex color' ).fill( color )
await defaultBlockPage.getByLabel( 'Hex color' ).fill( 'ff0000' )
await defaultBlockPage.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click()

const updateRequest = defaultBlockPage.waitForResponse( response => response.url().includes( 'update_block_style' ) && response.request().method() === 'POST' )

// In older WP versions, the button text is 'Update' instead of 'Save'
if ( await defaultBlockPage.getByRole( 'button', { name: 'Save', exact: true } ).isVisible() ) {
await defaultBlockPage.getByRole( 'button', { name: 'Save', exact: true } ).click()
} else {
await defaultBlockPage.getByRole( 'button', { name: 'Update' } ).click()
}

// Make sure default block has been updated before closing the tab
await updateRequest
await defaultBlockPage.close()

// Insert a Stackable Text Block, and check if the color is the same as the one set in the default block
Expand All @@ -137,12 +151,11 @@ test.describe( 'Global Settigs', () => {
},
} )

await expect( editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ) ).toHaveCSS( 'color', `rgb(${ getRgb( color ) })` )
await expect( editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' )

// Reset Default Block
await page.getByLabel( 'Stackable Settings' ).click()
await page.getByRole( 'button', { name: 'Block Defaults' } ).click()
await page.locator( '.components-panel__body', { hasText: 'Block Defaults' } ).locator( '.stk-block-default-control', { hasText: /^Text$/ } ).first().getByLabel( 'Reset' ).click()
} )
} )

1 change: 1 addition & 0 deletions src/components/sortable-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ const LabeledItemIndicator = props => {
) }
/>
<Button
aria-label="Delete"
className="stk-global-settings-color-picker__delete-button"
icon="trash"
isSmall
Expand Down
Loading