Skip to content

Commit 040fc31

Browse files
Transform: Use Group instead of Image in the offset tests
The offset tests now use Group for a block without a transform selector and Button for a block with one, so they do not depend on the Image block. The sanitize test uses Heading, as it already has a Group case.
1 parent f37954e commit 040fc31

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

‎packages/global-styles-engine/src/test/render.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ describe( 'global styles renderer', () => {
19201920
settings: {},
19211921
styles: {
19221922
blocks: {
1923-
'core/image': {
1923+
'core/button': {
19241924
transform: {
19251925
rotate: '5deg',
19261926
translate: { x: '10px', y: '-50%' },
@@ -1936,10 +1936,10 @@ describe( 'global styles renderer', () => {
19361936
} as unknown as GlobalStylesConfig;
19371937

19381938
const blockSelectors = {
1939-
'core/image': {
1940-
selector: '.wp-block-image',
1939+
'core/button': {
1940+
selector: '.wp-block-button',
19411941
featureSelectors: {
1942-
transform: '.wp-block-image img',
1942+
transform: '.wp-block-button .wp-block-button__link',
19431943
},
19441944
},
19451945
};
@@ -1955,7 +1955,7 @@ describe( 'global styles renderer', () => {
19551955
);
19561956

19571957
expect( result ).toEqual(
1958-
':root :where(.wp-block-image img){rotate: 5deg;translate: 10px -50%;}@media (width <= 480px){:root :where(.wp-block-image img){translate: 0 1rem;}}'
1958+
':root :where(.wp-block-button .wp-block-button__link){rotate: 5deg;translate: 10px -50%;}@media (width <= 480px){:root :where(.wp-block-button .wp-block-button__link){translate: 0 1rem;}}'
19591959
);
19601960
} );
19611961

‎phpunit/block-supports/states-test.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,8 +1791,8 @@ public function data_translation_states() {
17911791
'@media (width <= 480px){.%s .wp-block-button__link:hover{rotate:2deg !important;translate:1rem 0 !important;}}',
17921792
),
17931793
'viewport' => array(
1794-
'core/image',
1795-
'<figure class="wp-block-image"><img src="x.png" /><figcaption>Caption</figcaption></figure>',
1794+
'core/group',
1795+
'<div class="wp-block-group"><p>Text</p></div>',
17961796
array(
17971797
'@mobile' => array(
17981798
'transform' => array(
@@ -1826,7 +1826,7 @@ public function test_translation_state_replaces_the_offset( $style, $expected_cs
18261826
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
18271827
'styles' => array(
18281828
'blocks' => array(
1829-
'core/image' => array(
1829+
'core/group' => array(
18301830
'transform' => array( 'translate' => array( 'x' => '3rem' ) ),
18311831
),
18321832
),
@@ -1839,9 +1839,9 @@ public function test_translation_state_replaces_the_offset( $style, $expected_cs
18391839

18401840
try {
18411841
$actual = gutenberg_render_block_states_support(
1842-
'<figure class="wp-block-image"><img src="x.png" /></figure>',
1842+
'<div class="wp-block-group"><p>Text</p></div>',
18431843
array(
1844-
'blockName' => 'core/image',
1844+
'blockName' => 'core/group',
18451845
'attrs' => array( 'style' => $style ),
18461846
)
18471847
);

‎phpunit/class-wp-theme-json-test.php‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,7 +3420,7 @@ public function test_sanitize_keeps_transform_styles_for_blocks_and_variations_o
34203420
*/
34213421
public function test_get_stylesheet_outputs_translate_for_block_styles_states_and_variations() {
34223422
register_block_style(
3423-
'core/image',
3423+
'core/group',
34243424
array(
34253425
'name' => 'raised',
34263426
'label' => 'Raised',
@@ -3431,7 +3431,7 @@ public function test_get_stylesheet_outputs_translate_for_block_styles_states_an
34313431
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
34323432
'styles' => array(
34333433
'blocks' => array(
3434-
'core/image' => array(
3434+
'core/group' => array(
34353435
'transform' => array(
34363436
'rotate' => '5deg',
34373437
'translate' => array(
@@ -3465,11 +3465,11 @@ public function test_get_stylesheet_outputs_translate_for_block_styles_states_an
34653465
);
34663466

34673467
$css = $theme_json->get_stylesheet( array( 'styles' ), null, array( 'skip_root_layout_styles' => true ) );
3468-
unregister_block_style( 'core/image', 'raised' );
3468+
unregister_block_style( 'core/group', 'raised' );
34693469

3470-
$this->assertStringContainsString( ':root :where(.wp-block-image){rotate: 5deg;translate: 10px -50%;}', $css );
3471-
$this->assertStringContainsString( '@media (width <= 480px){:root :where(.wp-block-image){translate: 0 0;}}', $css );
3472-
$this->assertStringContainsString( ':root :where(.wp-block-image.is-style-raised){translate: 0 -1rem;}', $css );
3470+
$this->assertStringContainsString( ':root :where(.wp-block-group){rotate: 5deg;translate: 10px -50%;}', $css );
3471+
$this->assertStringContainsString( '@media (width <= 480px){:root :where(.wp-block-group){translate: 0 0;}}', $css );
3472+
$this->assertStringContainsString( ':root :where(.wp-block-group.is-style-raised){translate: 0 -1rem;}', $css );
34733473
$this->assertStringContainsString( ':root :where(.wp-block-button .wp-block-button__link:hover){translate: 0 -4px;}', $css );
34743474
$this->assertStringContainsString( '@media (width <= 480px){:root :where(.wp-block-button .wp-block-button__link:hover){translate: 2px 0;}}', $css );
34753475
$this->assertStringNotContainsString( 'transform', $css );
@@ -3534,7 +3534,7 @@ public function test_sanitize_keeps_translate_axes_only() {
35343534
'link' => array( 'transform' => array( 'translate' => array( 'x' => '1px' ) ) ),
35353535
),
35363536
'blocks' => array(
3537-
'core/image' => array(
3537+
'core/heading' => array(
35383538
'transform' => array(
35393539
'translate' => array(
35403540
'x' => '10px',
@@ -3558,7 +3558,7 @@ public function test_sanitize_keeps_translate_axes_only() {
35583558
),
35593559
'styles' => array(
35603560
'blocks' => array(
3561-
'core/image' => array(
3561+
'core/heading' => array(
35623562
'transform' => array(
35633563
'translate' => array( 'x' => '10px' ),
35643564
),

‎test/integration/theme-schema.test.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ describe( 'theme.json schema', () => {
189189
version: 3,
190190
styles: {
191191
blocks: {
192-
'core/image': {
192+
'core/group': {
193193
transform: { translate: { x: '10px', y: '-50%' } },
194194
variations: {
195195
raised: { transform: { translate: { x: '1rem' } } },
@@ -212,7 +212,7 @@ describe( 'theme.json schema', () => {
212212
const theme = {
213213
version: 3,
214214
styles: {
215-
blocks: { 'core/image': { transform: { translate } } },
215+
blocks: { 'core/group': { transform: { translate } } },
216216
},
217217
};
218218

0 commit comments

Comments
 (0)