Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing unit tests after new Gutenberg release #7198

Merged
merged 5 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions tests/php/test-amp-gallery-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function tear_down() {
public function get_conversion_data() {
$amp_carousel_caption = '<figcaption class="amp-wp-gallery-caption"> ' . self::CAPTION_TEXT . ' </figcaption>';
$loading_attribute = version_compare( get_bloginfo( 'version' ), '5.5-alpha', '>' ) ? 'loading="lazy"' : '';
$decoding_attribute = version_compare( get_bloginfo( 'version' ), '6.0', '>' ) ? 'decoding="async"' : '';
$decoding_attribute = version_compare( get_bloginfo( 'version' ), '6.1-alpha', '>' ) ? 'decoding="async"' : '';

return [
'shortcode_with_invalid_id' => [
Expand Down Expand Up @@ -275,9 +275,6 @@ public function test__conversion( $source, $expected, $use_legacy_mode = false )
// Normalize auto-incrementing ID.
$content = preg_replace( '/\bgallery-\d+/', 'gallery-1', $content );

// Remove new decoding attribute.
$expected = str_replace( ' decoding="async"', '', $expected );

$this->assertEquals(
$this->normalize( $expected ),
$this->normalize( $content )
Expand Down
10 changes: 8 additions & 2 deletions tests/php/test-class-amp-core-block-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,14 @@ public function test_ampify_gallery_block( $original_block_content, $expected_bl
$expected = preg_replace( '/ data-id="\d+"/', '', $expected );
$actual = preg_replace( '/ data-id="\d+"/', '', $actual );

// Remove classes added in Gutenberg 12.9.
$actual = preg_replace( '/wp-container-\w+ wp-block-gallery-\w+ /', '', $actual );
// Remove `is-layout-flex` class name injected by block editor layout styles.
$actual = preg_replace( '/(?<= class=")is-layout-flex /', '', $actual );

// Remove `wp-block-gallery-` class by block_core_gallery_render()
$actual = preg_replace( '/(?<= class=")wp-block-gallery-\w+ /', '', $actual );

// Remove class name injected by gutenberg_render_layout_support_flag().
$actual = preg_replace( '/(?<= class=")wp-container-\w+ /', '', $actual );

$this->assertEqualMarkup( $expected, $actual );
}
Expand Down
5 changes: 1 addition & 4 deletions tests/php/test-class-amp-youtube-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function test_video_override() {

/** @return array */
public function get_conversion_data() {
$decoding_attribute = version_compare( get_bloginfo( 'version' ), '6.0', '>' ) ? 'decoding="async"' : '';
$decoding_attribute = version_compare( get_bloginfo( 'version' ), '6.1-alpha', '>' ) ? 'decoding="async"' : '';

return [
'no_embed' => [
Expand Down Expand Up @@ -344,9 +344,6 @@ public function test__conversion( $source, $expected, $fallback_for_expected = n

$filtered_content = apply_filters( 'the_content', $source );

// Remove new decoding attribute.
$expected = str_replace( ' decoding="async"', '', $expected );

if (
version_compare( strtok( get_bloginfo( 'version' ), '-' ), '5.1', '<' )
&& null !== $fallback_for_expected
Expand Down
3 changes: 3 additions & 0 deletions tests/php/validation/test-class-amp-validation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,9 @@ public function test_add_block_source_comments( $content, $expected, $query ) {

$rendered_block = do_blocks( AMP_Validation_Manager::add_block_source_comments( $content ) );

// Remove `is-layout-flex` class name injected by block editor layout styles.
$rendered_block = preg_replace( '/(?<= class=")is-layout-flex /', '', $rendered_block );

// Remove class name injected by gutenberg_render_layout_support_flag().
$rendered_block = preg_replace( '/(?<= class=")wp-container-\w+ /', '', $rendered_block );

Expand Down