@@ -61,17 +61,22 @@ test.describe( 'Block Editor', () => {
6161
6262 await editor . saveDraft ( )
6363
64- await expect ( async ( ) => {
65- const blocks = await editor . getBlocks ( )
66- const attributes = blocks . find ( block => block . name === 'stackable/text' ) . attributes
64+ await page . waitForFunction (
65+ ( ) => window ?. wp ?. blocks && window ?. wp ?. data
66+ )
6767
68- expect ( attributes . textColor1 ) . toBe ( '#ff0000' )
69- expect ( attributes . text ) . toBe ( 'test' )
70- } ) . toPass ( { intervals : [ 1_000 , 2_000 , 5_000 ] } )
68+ const clientId = await editor . canvas . getByLabel ( 'Block: Text' ) . getAttribute ( 'data-block' )
69+
70+ const attributes = await page . evaluate ( async ( [ _clientId ] ) => {
71+ return await window . wp . data . select ( 'core/block-editor' ) . getBlockAttributes ( _clientId )
72+ } , [ clientId ] )
73+
74+ expect ( attributes ) . toHaveAttribute ( 'textColor1' , '#ff0000' )
75+ expect ( attributes ) . toHaveAttribute ( 'text' , 'test' )
7176 } )
7277
7378 test ( 'The Stackable block added in the editor should be visible in the frontend' , async ( {
74- editor,
79+ page , editor,
7580 } ) => {
7681 await editor . insertBlock ( {
7782 name : 'stackable/text' ,
@@ -81,8 +86,17 @@ test.describe( 'Block Editor', () => {
8186 } ,
8287 } )
8388
84- const blocks = await editor . getBlocks ( )
85- const uniqueId = blocks . find ( block => block . name === 'stackable/text' ) . attributes . uniqueId
89+ await page . waitForFunction (
90+ ( ) => window ?. wp ?. blocks && window ?. wp ?. data
91+ )
92+
93+ const clientId = await editor . canvas . getByLabel ( 'Block: Text' ) . getAttribute ( 'data-block' )
94+
95+ const attributes = await page . evaluate ( async ( [ _clientId ] ) => {
96+ return await window . wp . data . select ( 'core/block-editor' ) . getBlockAttributes ( _clientId )
97+ } , [ clientId ] )
98+
99+ const uniqueId = attributes . uniqueId
86100
87101 await editor . saveDraft ( )
88102
0 commit comments