Skip to content

Commit

Permalink
Autoformat e2e-tests package (#62572)
Browse files Browse the repository at this point in the history
* Remove prettier ignore for e2e-tests
* Apply autoformatting

---

Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
  • Loading branch information
3 people authored Jun 17, 2024
1 parent 4011f4b commit 9c1b097
Show file tree
Hide file tree
Showing 29 changed files with 242 additions and 196 deletions.
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ build
build-module
build-types
packages/block-serialization-spec-parser/parser.js
packages/e2e-tests/plugins
packages/react-native-editor/bundle
packages/url/src/test/fixtures
vendor
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
} );
},
} )
)
);
},
save( { attributes } ) {
return el(
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/plugins/hooks-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Button,
{
className: 'e2e-reset-block-button',
variant: "secondary",
variant: 'secondary',
onClick() {
const emptyBlock = createBlock( props.name );
props.onReplace( emptyBlock );
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/plugins/iframed-block/jquery.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
( ( $ ) => {
$.fn.test = function() {
return this.each( function() {
$.fn.test = function () {
return this.each( function () {
$( this ).text( 'Iframed Block (set with jQuery)' );
} );
};
Expand Down
1 change: 0 additions & 1 deletion packages/e2e-tests/plugins/iframed-block/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
$( '.wp-block-test-iframed-block' ).test();
} );
} )( window );

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
window.addEventListener( 'load', () => {
document.body.dataset.iframedEnqueueBlockAssetsL10n = window.iframedEnqueueBlockAssetsL10n.test;
document.body.dataset.iframedEnqueueBlockAssetsL10n =
window.iframedEnqueueBlockAssetsL10n.test;
} );
12 changes: 9 additions & 3 deletions packages/e2e-tests/plugins/iframed-masonry-block/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@

const content = [
el( 'div', { className: 'grid-item' } ),
el( 'div', { className: 'grid-item grid-item--width2 grid-item--height2' } ),
el( 'div', {
className: 'grid-item grid-item--width2 grid-item--height2',
} ),
el( 'div', { className: 'grid-item grid-item--height3' } ),
el( 'div', { className: 'grid-item grid-item--height2' } ),
el( 'div', { className: 'grid-item grid-item--width3' } ),
el( 'div', { className: 'grid-item' } ),
el( 'div', { className: 'grid-item' } ),
el( 'div', { className: 'grid-item grid-item--height2' } ),
el( 'div', { className: 'grid-item grid-item--width2 grid-item--height3' } ),
el( 'div', {
className: 'grid-item grid-item--width2 grid-item--height3',
} ),
el( 'div', { className: 'grid-item' } ),
el( 'div', { className: 'grid-item grid-item--height2' } ),
el( 'div', { className: 'grid-item' } ),
el( 'div', { className: 'grid-item grid-item--width2 grid-item--height2' } ),
el( 'div', {
className: 'grid-item grid-item--width2 grid-item--height2',
} ),
el( 'div', { className: 'grid-item grid-item--width2' } ),
el( 'div', { className: 'grid-item' } ),
el( 'div', { className: 'grid-item grid-item--height2' } ),
Expand Down
1 change: 0 additions & 1 deletion packages/e2e-tests/plugins/iframed-masonry-block/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
} );
} );
} )( window );

Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
"textdomain": "iframed-multiple-stylesheets",
"editorScript": "iframed-multiple-stylesheets-editor-script",
"editorStyle": "file:./editor.css",
"style": [ "iframed-multiple-stylesheets-style", "iframed-multiple-stylesheets-style2", "file:./style3.css" ]
"style": [
"iframed-multiple-stylesheets-style",
"iframed-multiple-stylesheets-style2",
"file:./style3.css"
]
}
16 changes: 10 additions & 6 deletions packages/e2e-tests/plugins/inner-blocks-allowed-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

const allowedBlocksWhenSingleEmptyChild = [ 'core/image', 'core/list' ];
const allowedBlocksWhenTwoChildren = [ 'core/gallery', 'core/video' ];
const allowedBlocksWhenTreeOrMoreChildren = [ 'core/gallery', 'core/video', 'core/list' ];
const allowedBlocksWhenTreeOrMoreChildren = [
'core/gallery',
'core/video',
'core/list',
];

registerBlockType( 'test/allowed-blocks-dynamic', {
apiVersion: 3,
Expand All @@ -26,28 +30,28 @@
},
[ props.clientId ]
);
const blockProps = useBlockProps({
const blockProps = useBlockProps( {
...divProps,
'data-number-of-children': numberOfChildren,
});
} );

let allowedBlocks = allowedBlocksWhenSingleEmptyChild;
if ( numberOfChildren === 2 ) {
allowedBlocks = allowedBlocksWhenTwoChildren;
} else if( numberOfChildren > 2 ){
} else if ( numberOfChildren > 2 ) {
allowedBlocks = allowedBlocksWhenTreeOrMoreChildren;
}

return el(
'div',
blockProps,
el( InnerBlocks, {
allowedBlocks
allowedBlocks,
} )
);
},
save() {
return el( 'div', divProps, el( InnerBlocks.Content ) );
}
},
} );
} )();
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
const { createElement: el } = wp.element;
const { InnerBlocks } = wp.blockEditor;

const divProps = {
const divProps = {
className: 'product',
style: { outline: '1px solid gray', padding: 5 },
};

// without a placeholder within the inner blocks it can be difficult to select the block using e2e tests
// especially using Puppeteer, so we use an image block which has a placeholder.
const template = [
[ 'core/image' ],
];
// without a placeholder within the inner blocks it can be difficult to select the block using e2e tests
// especially using Puppeteer, so we use an image block which has a placeholder.
const template = [ [ 'core/image' ] ];

const save = function () {
return el( 'div', divProps, el( InnerBlocks.Content ) );
Expand All @@ -38,11 +36,11 @@
'div',
divProps,
el( InnerBlocks, {
template,
template,
prioritizedInserterBlocks: [
'core/audio',
'core/audio',
'core/spacer',
'core/code',
'core/code',
],
} )
);
Expand All @@ -51,32 +49,34 @@
save,
} );

registerBlockType( 'test/prioritized-inserter-blocks-set-with-conflicting-allowed-blocks', {
title: 'Prioritized Inserter Blocks Set With Conflicting Allowed Blocks',
icon: 'carrot',
category: 'text',
edit() {
return el(
'div',
divProps,
el( InnerBlocks, {
template,
allowedBlocks: [
'core/spacer',
'core/code',
'core/paragraph',
'core/heading'
],
prioritizedInserterBlocks: [
'core/audio', // this is **not** in the allowedBlocks list
'core/spacer',
'core/code',
],
} )
);
},

save,
} );
registerBlockType(
'test/prioritized-inserter-blocks-set-with-conflicting-allowed-blocks',
{
title: 'Prioritized Inserter Blocks Set With Conflicting Allowed Blocks',
icon: 'carrot',
category: 'text',
edit() {
return el(
'div',
divProps,
el( InnerBlocks, {
template,
allowedBlocks: [
'core/spacer',
'core/code',
'core/paragraph',
'core/heading',
],
prioritizedInserterBlocks: [
'core/audio', // this is **not** in the allowedBlocks list
'core/spacer',
'core/code',
],
} )
);
},

save,
}
);
} )();
103 changes: 63 additions & 40 deletions packages/e2e-tests/plugins/inner-blocks-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@
category: 'text',

edit: function InnerBlocksNoLockingEdit() {
return el( 'div', useBlockProps(), el( InnerBlocks, {
template: TEMPLATE,
} ) );
return el(
'div',
useBlockProps(),
el( InnerBlocks, {
template: TEMPLATE,
} )
);
},

save,
Expand All @@ -68,10 +72,14 @@
category: 'text',

edit: function InnerBlocksBlocksLockingAllEdit() {
return el( 'div', useBlockProps(), el( InnerBlocks, {
template: TEMPLATE,
templateLock: 'all',
} ) );
return el(
'div',
useBlockProps(),
el( InnerBlocks, {
template: TEMPLATE,
templateLock: 'all',
} )
);
},

save,
Expand All @@ -92,7 +100,9 @@

edit: function InnerBlocksUpdateLockedTemplateEdit( props ) {
const hasUpdatedTemplated = props.attributes.hasUpdatedTemplate;
return el( 'div', null,
return el(
'div',
null,
el(
'button',
{
Expand All @@ -102,12 +112,16 @@
},
'Update template'
),
el( 'div', useBlockProps(), el( InnerBlocks, {
template: hasUpdatedTemplated
? TEMPLATE_TWO_PARAGRAPHS
: TEMPLATE,
templateLock: 'all',
} ) ),
el(
'div',
useBlockProps(),
el( InnerBlocks, {
template: hasUpdatedTemplated
? TEMPLATE_TWO_PARAGRAPHS
: TEMPLATE,
templateLock: 'all',
} )
)
);
},

Expand All @@ -121,10 +135,14 @@
category: 'text',

edit: function InnerBlocksParagraphPlaceholderEdit() {
return el( 'div', useBlockProps(), el( InnerBlocks, {
template: TEMPLATE_PARAGRAPH_PLACEHOLDER,
templateInsertUpdatesSelection: true,
} ) );
return el(
'div',
useBlockProps(),
el( InnerBlocks, {
template: TEMPLATE_PARAGRAPH_PLACEHOLDER,
templateInsertUpdatesSelection: true,
} )
);
},

save,
Expand Down Expand Up @@ -171,36 +189,41 @@
},

edit: function InnerBlocksTransformerTargetEdit() {
return el( 'div', useBlockProps(), el( InnerBlocks, {
template: TEMPLATE,
} ) );
return el(
'div',
useBlockProps(),
el( InnerBlocks, {
template: TEMPLATE,
} )
);
},

save,
} );

registerBlockType(
'test/test-inner-blocks-async-template',
{
apiVersion: 3,
title: 'Test Inner Blocks Async Template',
icon: 'cart',
category: 'text',
registerBlockType( 'test/test-inner-blocks-async-template', {
apiVersion: 3,
title: 'Test Inner Blocks Async Template',
icon: 'cart',
category: 'text',

edit: function InnerBlocksAsyncTemplateEdit() {
const [ template, setTemplate ] = useState( [] );
edit: function InnerBlocksAsyncTemplateEdit() {
const [ template, setTemplate ] = useState( [] );

setInterval( () => {
setTemplate( TEMPLATE_TWO_PARAGRAPHS );
}, 1000 );
setInterval( () => {
setTemplate( TEMPLATE_TWO_PARAGRAPHS );
}, 1000 );

return el('div', useBlockProps(), el( InnerBlocks, {
return el(
'div',
useBlockProps(),
el( InnerBlocks, {
template,
} ) );
},
} )
);
},

// Purposely do not save inner blocks so that it's possible to test template resolution.
save() {},
}
);
// Purposely do not save inner blocks so that it's possible to test template resolution.
save() {},
} );
} )();
Loading

1 comment on commit 9c1b097

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 9c1b097.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9543530261
📝 Reported issues:

Please sign in to comment.