|
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 | +} ) |
96 | 96 |
|
0 commit comments