|
1 | | -import { test, expect } from 'e2e/test-utils' |
2 | | - |
3 | | -test.describe( 'Site Editor', () => { |
4 | | - let pid = null |
5 | | - let postContentBlock = null |
6 | | - |
7 | | - test.beforeEach( async ( { |
8 | | - page, admin, editor, |
9 | | - } ) => { |
10 | | - await admin.createNewPost( { title: 'Site Editor Test', postType: 'page' } ) |
11 | | - await editor.saveDraft() |
12 | | - const postQuery = new URL( editor.page.url() ).search |
13 | | - pid = new URLSearchParams( postQuery ).get( 'post' ) |
14 | | - |
15 | | - await admin.visitSiteEditor( { |
16 | | - canvas: 'edit', postType: 'page', postId: pid, showWelcomeGuide: false, |
17 | | - } ) |
18 | | - |
19 | | - if ( await page.getByRole( 'heading', { name: 'Choose a pattern' } ).isVisible() ) { |
20 | | - await page.getByLabel( 'Close', { exact: true } ).click() |
21 | | - } |
22 | | - |
23 | | - postContentBlock = ( await editor.getBlocks( { full: true } ) ) |
24 | | - .filter( block => block.attributes?.tagName === 'main' )[ 0 ].innerBlocks |
25 | | - .filter( block => block.name === 'core/post-content' )[ 0 ] |
26 | | - } ) |
27 | | - |
28 | | - test.afterEach( async ( { requestUtils } ) => { |
29 | | - await requestUtils.deletePost( pid, 'pages' ) |
30 | | - } ) |
31 | | - |
32 | | - test( 'Stackable blocks can be added in the site editor', async ( { |
33 | | - page, |
34 | | - editor, |
35 | | - } ) => { |
36 | | - await page.getByLabel( 'Toggle block inserterx' ).click() |
37 | | - await page.locator( '.editor-block-list-item-stackable-text' ).click() |
38 | | - |
39 | | - const blocks = await editor.getBlocks( { clientId: postContentBlock.clientId } ) |
40 | | - |
41 | | - expect( blocks.find( block => block.name === 'stackable/text' ) ).toBeTruthy() |
42 | | - } ) |
43 | | - |
44 | | - test( 'Stackable Inspector Controls should show up upon clicking a Stackable block', async ( { |
45 | | - page, |
46 | | - editor, |
47 | | - } ) => { |
48 | | - await editor.insertBlock( { |
49 | | - name: 'stackable/text', |
50 | | - }, { clientId: postContentBlock.clientId } ) |
51 | | - |
52 | | - await editor.selectBlocks( editor.canvas.getByLabel( 'Block: Text' ) ) |
53 | | - await expect( page.getByLabel( 'Layout Tabx' ) ).toBeVisible() |
54 | | - await expect( page.getByLabel( 'Style Tab' ) ).toBeVisible() |
55 | | - await expect( page.getByLabel( 'Advanced Tab' ) ).toBeVisible() |
56 | | - } ) |
57 | | - |
58 | | - // test( 'A Stackable block\'s attributes should update when settings are changed in the Inspector Controls.', async ( { |
59 | | - // page, |
60 | | - // editor, |
61 | | - // } ) => { |
62 | | - // await editor.insertBlock( { |
63 | | - // name: 'stackable/text', |
64 | | - // }, { clientId: postContentBlock.clientId } ) |
65 | | - // await editor.canvas.getByLabel( 'Type / to choose a block' ).fill( 'test' ) |
66 | | - // await expect( page.locator( '#inspector-textarea-control-0' ) ).toContainText( 'test' ) |
67 | | - // await page.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click() |
68 | | - // await page.getByLabel( 'Hex color' ).fill( 'ff0000' ) |
69 | | - // await editor.canvas.locator( 'body' ).click() |
70 | | - |
71 | | - // await expect( editor.canvas.locator( '[data-type="stackable/text"]' ) ).toContainText( 'test' ) |
72 | | - // await expect( editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' ) |
73 | | - |
74 | | - // await editor.saveDraft() |
75 | | - |
76 | | - // const blocks = await editor.getBlocks( { clientId: postContentBlock.clientId } ) |
77 | | - // const textBlock = blocks.find( block => block.name === 'stackable/text' ) |
78 | | - // expect( textBlock.attributes.text ).toBe( 'test' ) |
79 | | - // expect( textBlock.attributes.textColor1 ).toBe( '#ff0000' ) |
80 | | - // } ) |
81 | | - |
82 | | - // test( 'The Stackable block added in the site editor should be visible in the frontend', async ( { |
83 | | - // editor, |
84 | | - // } ) => { |
85 | | - // await editor.insertBlock( { |
86 | | - // name: 'stackable/text', |
87 | | - // attributes: { |
88 | | - // text: 'test', |
89 | | - // textColor1: '#ff0000', |
90 | | - // }, |
91 | | - // }, { clientId: postContentBlock.clientId } ) |
92 | | - |
93 | | - // const blocks = await editor.getBlocks( { clientId: postContentBlock.clientId } ) |
94 | | - // const uniqueId = blocks.find( block => block.name === 'stackable/text' ).attributes.uniqueId |
95 | | - |
96 | | - // await editor.saveDraft() |
97 | | - |
98 | | - // const preview = await editor.openPreviewPage() |
99 | | - |
100 | | - // await expect( preview.locator( `[data-block-id="${ uniqueId }"]` ) ).toBeVisible() |
101 | | - // await expect( preview.locator( `[data-block-id="${ uniqueId }"]` ) ).toContainText( 'test' ) |
102 | | - // await expect( preview.locator( `[data-block-id="${ uniqueId }"] p` ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' ) |
103 | | - // } ) |
104 | | -} ) |
| 1 | +// import { test, expect } from 'e2e/test-utils' |
| 2 | + |
| 3 | +// test.describe( 'Site Editor', () => { |
| 4 | +// let pid = null |
| 5 | +// let postContentBlock = null |
| 6 | + |
| 7 | +// test.beforeEach( async ( { |
| 8 | +// page, admin, editor, |
| 9 | +// } ) => { |
| 10 | +// await admin.createNewPost( { title: 'Site Editor Test', postType: 'page' } ) |
| 11 | +// await editor.saveDraft() |
| 12 | +// const postQuery = new URL( editor.page.url() ).search |
| 13 | +// pid = new URLSearchParams( postQuery ).get( 'post' ) |
| 14 | + |
| 15 | +// await admin.visitSiteEditor( { |
| 16 | +// canvas: 'edit', postType: 'page', postId: pid, showWelcomeGuide: false, |
| 17 | +// } ) |
| 18 | + |
| 19 | +// if ( await page.getByRole( 'heading', { name: 'Choose a pattern' } ).isVisible() ) { |
| 20 | +// await page.getByLabel( 'Close', { exact: true } ).click() |
| 21 | +// } |
| 22 | + |
| 23 | +// postContentBlock = ( await editor.getBlocks( { full: true } ) ) |
| 24 | +// .filter( block => block.attributes?.tagName === 'main' )[ 0 ].innerBlocks |
| 25 | +// .filter( block => block.name === 'core/post-content' )[ 0 ] |
| 26 | +// } ) |
| 27 | + |
| 28 | +// test.afterEach( async ( { requestUtils } ) => { |
| 29 | +// await requestUtils.deletePost( pid, 'pages' ) |
| 30 | +// } ) |
| 31 | + |
| 32 | +// test( 'Stackable blocks can be added in the site editor', async ( { |
| 33 | +// page, |
| 34 | +// editor, |
| 35 | +// } ) => { |
| 36 | +// await page.getByLabel( 'Toggle block inserterx' ).click() |
| 37 | +// await page.locator( '.editor-block-list-item-stackable-text' ).click() |
| 38 | + |
| 39 | +// const blocks = await editor.getBlocks( { clientId: postContentBlock.clientId } ) |
| 40 | + |
| 41 | +// expect( blocks.find( block => block.name === 'stackable/text' ) ).toBeTruthy() |
| 42 | +// } ) |
| 43 | + |
| 44 | +// test( 'Stackable Inspector Controls should show up upon clicking a Stackable block', async ( { |
| 45 | +// page, |
| 46 | +// editor, |
| 47 | +// } ) => { |
| 48 | +// await editor.insertBlock( { |
| 49 | +// name: 'stackable/text', |
| 50 | +// }, { clientId: postContentBlock.clientId } ) |
| 51 | + |
| 52 | +// await editor.selectBlocks( editor.canvas.getByLabel( 'Block: Text' ) ) |
| 53 | +// await expect( page.getByLabel( 'Layout Tabx' ) ).toBeVisible() |
| 54 | +// await expect( page.getByLabel( 'Style Tab' ) ).toBeVisible() |
| 55 | +// await expect( page.getByLabel( 'Advanced Tab' ) ).toBeVisible() |
| 56 | +// } ) |
| 57 | + |
| 58 | +// test( 'A Stackable block\'s attributes should update when settings are changed in the Inspector Controls.', async ( { |
| 59 | +// page, |
| 60 | +// editor, |
| 61 | +// } ) => { |
| 62 | +// await editor.insertBlock( { |
| 63 | +// name: 'stackable/text', |
| 64 | +// }, { clientId: postContentBlock.clientId } ) |
| 65 | +// await editor.canvas.getByLabel( 'Type / to choose a block' ).fill( 'test' ) |
| 66 | +// await expect( page.locator( '#inspector-textarea-control-0' ) ).toContainText( 'test' ) |
| 67 | +// await page.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click() |
| 68 | +// await page.getByLabel( 'Hex color' ).fill( 'ff0000' ) |
| 69 | +// await editor.canvas.locator( 'body' ).click() |
| 70 | + |
| 71 | +// await expect( editor.canvas.locator( '[data-type="stackable/text"]' ) ).toContainText( 'test' ) |
| 72 | +// await expect( editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' ) |
| 73 | + |
| 74 | +// await editor.saveDraft() |
| 75 | + |
| 76 | +// const blocks = await editor.getBlocks( { clientId: postContentBlock.clientId } ) |
| 77 | +// const textBlock = blocks.find( block => block.name === 'stackable/text' ) |
| 78 | +// expect( textBlock.attributes.text ).toBe( 'test' ) |
| 79 | +// expect( textBlock.attributes.textColor1 ).toBe( '#ff0000' ) |
| 80 | +// } ) |
| 81 | + |
| 82 | +// test( 'The Stackable block added in the site editor should be visible in the frontend', async ( { |
| 83 | +// editor, |
| 84 | +// } ) => { |
| 85 | +// await editor.insertBlock( { |
| 86 | +// name: 'stackable/text', |
| 87 | +// attributes: { |
| 88 | +// text: 'test', |
| 89 | +// textColor1: '#ff0000', |
| 90 | +// }, |
| 91 | +// }, { clientId: postContentBlock.clientId } ) |
| 92 | + |
| 93 | +// const blocks = await editor.getBlocks( { clientId: postContentBlock.clientId } ) |
| 94 | +// const uniqueId = blocks.find( block => block.name === 'stackable/text' ).attributes.uniqueId |
| 95 | + |
| 96 | +// await editor.saveDraft() |
| 97 | + |
| 98 | +// const preview = await editor.openPreviewPage() |
| 99 | + |
| 100 | +// await expect( preview.locator( `[data-block-id="${ uniqueId }"]` ) ).toBeVisible() |
| 101 | +// await expect( preview.locator( `[data-block-id="${ uniqueId }"]` ) ).toContainText( 'test' ) |
| 102 | +// await expect( preview.locator( `[data-block-id="${ uniqueId }"] p` ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' ) |
| 103 | +// } ) |
| 104 | +// } ) |
105 | 105 |
|
0 commit comments