Skip to content

Commit

Permalink
Patterns: fix issue in 16.1 with wrong sync status set in Site Editor (
Browse files Browse the repository at this point in the history
…#52229)

* Patterns: Fix setting of sync status for fully synced patterns (#51952)
* Add check for sync status of fully to account for bug in 16.1 release
* Fix phpunit failures (#51950)
* Fix phpunit failures
* Performance tests: configure as a production environment (#52016)

---------

Co-authored-by: Aaron Robertshaw <[email protected]>
Co-authored-by: Robert Anderson <[email protected]>
Co-authored-by: André <[email protected]>
  • Loading branch information
4 people authored Jul 3, 2023
1 parent 359e15d commit 2426d7d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
4 changes: 4 additions & 0 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ async function runPerformanceTests( branches, options ) {
path.join( environmentDirectory, '.wp-env.json' ),
JSON.stringify(
{
config: {
WP_DEBUG: false,
SCRIPT_DEBUG: false,
},
core: 'WordPress/WordPress',
plugins: [ path.join( environmentDirectory, 'plugin' ) ],
themes: [
Expand Down
4 changes: 3 additions & 1 deletion packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,9 @@ export const getInserterItems = createSelector(
( reusableBlock ) =>
syncStatus === reusableBlock.meta?.sync_status ||
( ! syncStatus &&
reusableBlock.meta?.sync_status === '' )
( reusableBlock.meta?.sync_status === '' ||
reusableBlock.meta?.sync_status ===
'fully' ) ) // Only reusable blocks added via site editor in release 16.1 will have sync_status of 'fully'.
)
.map( buildReusableBlockInserterItem )
: [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export default function CreatePatternModal( {
title: name || __( 'Untitled Pattern' ),
content: '',
status: 'publish',
meta: { sync_status: syncType },
meta:
syncType === SYNC_TYPES.unsynced
? { sync_status: syncType }
: undefined,
},
{ throwOnError: true }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const reusableBlockToPattern = ( reusableBlock ) => ( {
categories: reusableBlock.wp_pattern,
id: reusableBlock.id,
name: reusableBlock.slug,
syncStatus: reusableBlock.meta?.sync_status,
syncStatus: reusableBlock.meta?.sync_status || SYNC_TYPES.full,
title: reusableBlock.title.raw,
type: reusableBlock.type,
reusableBlock,
Expand Down
7 changes: 2 additions & 5 deletions packages/editor/src/components/post-sync-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ export default function PostSyncStatus() {
editPost( {
meta: {
...meta,
wp_block:
syncStatus === 'unsynced'
? { sync_status: syncStatus }
: null,
sync_status: syncStatus === 'unsynced' ? syncStatus : null,
},
} );
const syncStatus = meta?.wp_block?.sync_status;
const syncStatus = meta?.sync_status;
const isFullySynced = ! syncStatus;

return (
Expand Down
6 changes: 2 additions & 4 deletions phpunit/block-template-utils-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ class Tests_Block_Template_Utils extends WP_UnitTestCase {
public function set_up() {
parent::set_up();
switch_theme( 'emptytheme' );
}

public static function wpSetUpBeforeClass() {
register_post_type(
'custom_book',
array(
Expand All @@ -22,9 +19,10 @@ public static function wpSetUpBeforeClass() {
register_taxonomy( 'book_type', 'custom_book' );
}

public static function wpTearDownAfterClass() {
public function tear_down() {
unregister_post_type( 'custom_book' );
unregister_taxonomy( 'book_type' );
parent::tear_down();
}

public function test_get_template_hierarchy() {
Expand Down
6 changes: 6 additions & 0 deletions phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
define( 'LOCAL_WP_ENVIRONMENT_TYPE', 'local' );
}

// Pretend that these are Core unit tests. This is needed so that
// wp_theme_has_theme_json() does not cache its return value between each test.
if ( ! defined( 'WP_RUN_CORE_TESTS' ) ) {
define( 'WP_RUN_CORE_TESTS', true );
}

// Require composer dependencies.
require_once dirname( __DIR__ ) . '/vendor/autoload.php';

Expand Down

1 comment on commit 2426d7d

@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 2426d7d.
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/5440395100
📝 Reported issues:

Please sign in to comment.