Skip to content

Commit f596c50

Browse files
committed
run other tests
1 parent a64cb24 commit f596c50

File tree

5 files changed

+278
-280
lines changed

5 files changed

+278
-280
lines changed

.github/workflows/playwright.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ jobs:
7171
npm install -g @wordpress/env
7272
- name: Start wp-env
7373
run: wp-env start
74-
id: start-wp-env
7574
- name: Run playwright tests
76-
if: ${{ steps.start-wp-env.outcome != 'failure' }}
7775
id: run-playwright-tests
7876
env:
7977
WP_BASE_URL: http://localhost:8889
@@ -83,7 +81,7 @@ jobs:
8381
STACKABLE_SLUG: Stackable/plugin
8482
run: npm run test
8583
- uses: actions/upload-artifact@v4
86-
if: ${{ !cancelled() }}
84+
if: ${{ !failure() && !cancelled() }}
8785
id: artifact-upload-step
8886
with:
8987
name: playwright-report-php_${{ matrix.php_version }}-wp_${{ env.WP_VERSION }}-${{ env.VERSION_SUFFIX }}

e2e/tests/admin.spec.ts

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
// import { test, expect } from 'e2e/test-utils'
1+
import { test, expect } from 'e2e/test-utils'
22

3-
// test( 'Activating Stackable should redirect to the Getting Started Page', async ( {
4-
// page,
5-
// admin,
6-
// } ) => {
7-
// await admin.visitAdminPage( 'plugins.php' )
3+
test( 'Activating Stackable should redirect to the Getting Started Page', async ( {
4+
page,
5+
admin,
6+
} ) => {
7+
await admin.visitAdminPage( 'plugins.php' )
88

9-
// const plugin = page.locator( `[data-plugin="${ process.env.STACKABLE_SLUG }.php"]` )
10-
// // Deactivate Stackable
11-
// const deactivate = plugin.getByLabel( 'Deactivate Stackable -' )
12-
// await expect( deactivate ).toBeVisible()
13-
// await deactivate.click()
9+
const plugin = page.locator( `[data-plugin="${ process.env.STACKABLE_SLUG }.php"]` )
10+
// Deactivate Stackable
11+
const deactivate = plugin.getByLabel( 'Deactivate Stackable -' )
12+
await expect( deactivate ).toBeVisible()
13+
await deactivate.click()
1414

15-
// // Activate Stackable
16-
// const activate = plugin.getByLabel( 'Activate Stackable -' )
17-
// await expect( activate ).toBeVisible()
18-
// await activate.click()
15+
// Activate Stackable
16+
const activate = plugin.getByLabel( 'Activate Stackable -' )
17+
await expect( activate ).toBeVisible()
18+
await activate.click()
1919

20-
// try {
21-
// await expect( page ).toHaveURL( /stackable-getting-started/ )
22-
// } catch {
23-
// await expect( page ).toHaveURL( /page=stackable/ )
24-
// await expect( page.getByRole( 'link', { name: 'Activate Free Version' } ) ).toBeVisible()
25-
// await page.getByRole( 'link', { name: 'Activate Free Version' } ).click()
26-
// await page.getByRole( 'link', { name: 'Skip', exact: true } ).click()
27-
// await expect( page ).toHaveURL( /stackable-getting-started/ )
28-
// }
29-
// } )
20+
try {
21+
await expect( page ).toHaveURL( /stackable-getting-started/ )
22+
} catch {
23+
await expect( page ).toHaveURL( /page=stackable/ )
24+
await expect( page.getByRole( 'link', { name: 'Activate Free Version' } ) ).toBeVisible()
25+
await page.getByRole( 'link', { name: 'Activate Free Version' } ).click()
26+
await page.getByRole( 'link', { name: 'Skip', exact: true } ).click()
27+
await expect( page ).toHaveURL( /stackable-getting-started/ )
28+
}
29+
} )
3030

31-
// test( 'Stackable settings should be saved', async ( {
32-
// page,
33-
// admin,
34-
// stackable,
35-
// } ) => {
36-
// // Start waiting for Stackable Settings JSON Response before visiting the page
37-
// let settings = null
38-
// settings = stackable.waitForSettings()
31+
test( 'Stackable settings should be saved', async ( {
32+
page,
33+
admin,
34+
stackable,
35+
} ) => {
36+
// Start waiting for Stackable Settings JSON Response before visiting the page
37+
let settings = null
38+
settings = stackable.waitForSettings()
3939

40-
// await admin.visitAdminPage( 'options-general.php?page=stackable' )
41-
// // Make sure all Stackable settings are loaded
42-
// await settings
40+
await admin.visitAdminPage( 'options-general.php?page=stackable' )
41+
// Make sure all Stackable settings are loaded
42+
await settings
4343

44-
// // Retrieves the value of the first option, toggles it and check if the value changed
45-
// const option = page.locator( '.ugb-admin-toggle-setting' ).first().getByRole( 'switch' )
46-
// const val = await option.getAttribute( 'aria-checked' )
44+
// Retrieves the value of the first option, toggles it and check if the value changed
45+
const option = page.locator( '.ugb-admin-toggle-setting' ).first().getByRole( 'switch' )
46+
const val = await option.getAttribute( 'aria-checked' )
4747

48-
// await option.click()
49-
// const newVal = await option.getAttribute( 'aria-checked' )
48+
await option.click()
49+
const newVal = await option.getAttribute( 'aria-checked' )
5050

51-
// expect( newVal ).not.toBe( val )
52-
// await page.getByRole( 'button', { name: 'Save Changes' } ).click()
51+
expect( newVal ).not.toBe( val )
52+
await page.getByRole( 'button', { name: 'Save Changes' } ).click()
5353

54-
// // Check if the value is correct after reloading
55-
// settings = stackable.waitForSettings()
56-
// await page.reload()
57-
// await settings
54+
// Check if the value is correct after reloading
55+
settings = stackable.waitForSettings()
56+
await page.reload()
57+
await settings
5858

59-
// const _option = page.locator( '.ugb-admin-toggle-setting' ).first().getByRole( 'switch' )
59+
const _option = page.locator( '.ugb-admin-toggle-setting' ).first().getByRole( 'switch' )
6060

61-
// await expect( _option ).toHaveAttribute( 'aria-checked', newVal )
61+
await expect( _option ).toHaveAttribute( 'aria-checked', newVal )
6262

63-
// // Revert back the settings to the original value
64-
// await _option.click()
65-
// await page.getByRole( 'button', { name: 'Save Changes' } ).click()
66-
// await expect( _option ).toHaveAttribute( 'aria-checked', val )
67-
// } )
63+
// Revert back the settings to the original value
64+
await _option.click()
65+
await page.getByRole( 'button', { name: 'Save Changes' } ).click()
66+
await expect( _option ).toHaveAttribute( 'aria-checked', val )
67+
} )

e2e/tests/block-editor.spec.ts

Lines changed: 95 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,96 @@
1-
// import { test, expect } from 'e2e/test-utils'
2-
3-
// test.describe( 'Block Editor', () => {
4-
// let pid = null
5-
6-
// // Create Posts for testing
7-
// test.beforeEach( async ( { editor, admin } ) => {
8-
// await admin.createNewPost( { title: 'Block Editor Test' } )
9-
// await editor.saveDraft()
10-
// const postQuery = new URL( editor.page.url() ).search
11-
// pid = new URLSearchParams( postQuery ).get( 'post' )
12-
// } )
13-
14-
// // Delete created post
15-
// test.afterEach( async ( { requestUtils } ) => {
16-
// await requestUtils.deletePost( pid )
17-
// } )
18-
19-
// test( 'Stackable blocks can be added in the editor', async ( {
20-
// page,
21-
22-
// editor,
23-
// } ) => {
24-
// await page.getByLabel( 'Toggle block inserter' ).click()
25-
26-
// await page.locator( '.editor-block-list-item-stackable-text' ).click()
27-
28-
// const blocks = await editor.getBlocks()
29-
30-
// expect( blocks[ 0 ].name ).toContain( 'stackable/text' )
31-
// } )
32-
33-
// test( 'Stackable Inspector Controls should show up upon clicking a Stackable block', async ( {
34-
// page,
35-
// editor,
36-
// } ) => {
37-
// await editor.insertBlock( {
38-
// name: 'stackable/text',
39-
// } )
40-
41-
// await editor.selectBlocks( editor.canvas.getByLabel( 'Block: Text' ) )
42-
// await expect( page.getByLabel( 'Layout Tab' ) ).toBeVisible()
43-
// await expect( page.getByLabel( 'Style Tab' ) ).toBeVisible()
44-
// await expect( page.getByLabel( 'Advanced Tab' ) ).toBeVisible()
45-
// } )
46-
47-
// test( 'A Stackable block\'s attributes should update when settings are changed in the Inspector Controls.', async ( {
48-
// page,
49-
// editor,
50-
// } ) => {
51-
// await editor.insertBlock( {
52-
// name: 'stackable/text',
53-
// } )
54-
55-
// // Add content and color to Stackable Text Block
56-
// await editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ).fill( 'test' )
57-
// await page.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click()
58-
// await page.getByLabel( 'Hex color' ).fill( 'ff0000' )
59-
// await editor.canvas.locator( 'body' ).click()
60-
61-
// await expect( editor.canvas.locator( '[data-type="stackable/text"]' ) ).toContainText( 'test' )
62-
// await expect( editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' )
63-
64-
// await editor.saveDraft()
65-
66-
// const blocks = await editor.getBlocks()
67-
// const attributes = blocks[ 0 ].attributes
68-
69-
// expect( attributes.textColor1 ).toBe( '#ff0000' )
70-
// expect( attributes.text ).toBe( 'test' )
71-
// } )
72-
73-
// test( 'The Stackable block added in the editor should be visible in the frontend', async ( {
74-
// editor,
75-
// } ) => {
76-
// await editor.insertBlock( {
77-
// name: 'stackable/text',
78-
// attributes: {
79-
// text: 'test',
80-
// textColor1: '#ff0000',
81-
// },
82-
// } )
83-
84-
// const blocks = await editor.getBlocks()
85-
// const uniqueId = blocks[ 0 ].attributes.uniqueId
86-
87-
// await editor.saveDraft()
88-
89-
// const preview = await editor.openPreviewPage()
90-
91-
// await expect( preview.locator( `[data-block-id="${ uniqueId }"]` ) ).toBeVisible()
92-
// await expect( preview.locator( `[data-block-id="${ uniqueId }"]` ) ).toContainText( 'test' )
93-
// await expect( preview.locator( `[data-block-id="${ uniqueId }"] p` ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' )
94-
// } )
95-
// } )
1+
import { test, expect } from 'e2e/test-utils'
2+
3+
test.describe( 'Block Editor', () => {
4+
let pid = null
5+
6+
// Create Posts for testing
7+
test.beforeEach( async ( { editor, admin } ) => {
8+
await admin.createNewPost( { title: 'Block Editor Test' } )
9+
await editor.saveDraft()
10+
const postQuery = new URL( editor.page.url() ).search
11+
pid = new URLSearchParams( postQuery ).get( 'post' )
12+
} )
13+
14+
// Delete created post
15+
test.afterEach( async ( { requestUtils } ) => {
16+
await requestUtils.deletePost( pid )
17+
} )
18+
19+
test( 'Stackable blocks can be added in the editor', async ( {
20+
page,
21+
22+
editor,
23+
} ) => {
24+
await page.getByLabel( 'Toggle block inserter' ).click()
25+
26+
await page.locator( '.editor-block-list-item-stackable-text' ).click()
27+
28+
const blocks = await editor.getBlocks()
29+
30+
expect( blocks[ 0 ].name ).toContain( 'stackable/text' )
31+
} )
32+
33+
test( 'Stackable Inspector Controls should show up upon clicking a Stackable block', async ( {
34+
page,
35+
editor,
36+
} ) => {
37+
await editor.insertBlock( {
38+
name: 'stackable/text',
39+
} )
40+
41+
await editor.selectBlocks( editor.canvas.getByLabel( 'Block: Text' ) )
42+
await expect( page.getByLabel( 'Layout Tab' ) ).toBeVisible()
43+
await expect( page.getByLabel( 'Style Tab' ) ).toBeVisible()
44+
await expect( page.getByLabel( 'Advanced Tab' ) ).toBeVisible()
45+
} )
46+
47+
test( 'A Stackable block\'s attributes should update when settings are changed in the Inspector Controls.', async ( {
48+
page,
49+
editor,
50+
} ) => {
51+
await editor.insertBlock( {
52+
name: 'stackable/text',
53+
} )
54+
55+
// Add content and color to Stackable Text Block
56+
await editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ).fill( 'test' )
57+
await page.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click()
58+
await page.getByLabel( 'Hex color' ).fill( 'ff0000' )
59+
await editor.canvas.locator( 'body' ).click()
60+
61+
await expect( editor.canvas.locator( '[data-type="stackable/text"]' ) ).toContainText( 'test' )
62+
await expect( editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' )
63+
64+
await editor.saveDraft()
65+
66+
const blocks = await editor.getBlocks()
67+
const attributes = blocks[ 0 ].attributes
68+
69+
expect( attributes.textColor1 ).toBe( '#ff0000' )
70+
expect( attributes.text ).toBe( 'test' )
71+
} )
72+
73+
test( 'The Stackable block added in the editor should be visible in the frontend', async ( {
74+
editor,
75+
} ) => {
76+
await editor.insertBlock( {
77+
name: 'stackable/text',
78+
attributes: {
79+
text: 'test',
80+
textColor1: '#ff0000',
81+
},
82+
} )
83+
84+
const blocks = await editor.getBlocks()
85+
const uniqueId = blocks[ 0 ].attributes.uniqueId
86+
87+
await editor.saveDraft()
88+
89+
const preview = await editor.openPreviewPage()
90+
91+
await expect( preview.locator( `[data-block-id="${ uniqueId }"]` ) ).toBeVisible()
92+
await expect( preview.locator( `[data-block-id="${ uniqueId }"]` ) ).toContainText( 'test' )
93+
await expect( preview.locator( `[data-block-id="${ uniqueId }"] p` ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' )
94+
} )
95+
} )
9696

0 commit comments

Comments
 (0)