Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { applyFilters } from '@wordpress/hooks';
import customClassName from '../custom-class-name';

describe( 'custom className', () => {
const blockSettings = {
const getBlockSettings = () => ( {
save: () => <div className="default" />,
category: 'text',
title: 'block title',
};
} );

describe( 'addAttribute()', () => {
const addAttribute = applyFilters.bind(
Expand All @@ -17,7 +17,7 @@ describe( 'custom className', () => {

it( 'should do nothing if the block settings disable custom className support', () => {
const settings = addAttribute( {
...blockSettings,
...getBlockSettings(),
supports: {
customClassName: false,
},
Expand All @@ -27,7 +27,7 @@ describe( 'custom className', () => {
} );

it( 'should assign a new custom className attribute', () => {
const settings = addAttribute( blockSettings );
const settings = addAttribute( getBlockSettings() );

expect( settings.attributes ).toHaveProperty( 'className' );
} );
Expand All @@ -39,7 +39,7 @@ describe( 'custom className', () => {
const extraProps = customClassName.addSaveProps(
{},
{
...blockSettings,
...getBlockSettings(),
supports: {
customClassName: false,
},
Expand All @@ -54,7 +54,7 @@ describe( 'custom className', () => {
const attributes = { className: 'bar' };
const extraProps = customClassName.addSaveProps(
{ className: 'foo' },
blockSettings,
getBlockSettings(),
attributes
);

Expand Down
9 changes: 8 additions & 1 deletion packages/block-editor/src/hooks/test/style.jsdom.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,14 @@ describe( 'addSaveProps', () => {
};

const applySkipSerialization = ( features ) => {
const updatedSettings = { ...blockSettings };
const updatedSettings = {
...blockSettings,
supports: {
spacing: { ...blockSettings.supports.spacing },
color: { ...blockSettings.supports.color },
typography: { ...blockSettings.supports.typography },
},
};
Object.keys( features ).forEach( ( key ) => {
updatedSettings.supports[ key ].__experimentalSkipSerialization =
features[ key ];
Expand Down
12 changes: 9 additions & 3 deletions packages/block-editor/src/store/test/performance.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest';
import { beforeAll, describe, expect, it } from 'vitest';
import reducer from '../reducer';

describe( 'performance', () => {
Expand All @@ -13,13 +13,19 @@ describe( 'performance', () => {
}

let preparedState;
beforeAll( () => {
preparedState = reducer( state, {
type: 'RESET_BLOCKS',
blocks,
} );
}, 60_000 );

it( 'should reset blocks', () => {
preparedState = reducer( state, {
const updatedState = reducer( state, {
type: 'RESET_BLOCKS',
blocks,
} );
expect( preparedState ).toBeDefined();
expect( updatedState ).toBeDefined();
}, 60_000 );

it( 'should update blocks', () => {
Expand Down
18 changes: 9 additions & 9 deletions packages/block-editor/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4254,7 +4254,7 @@ describe( 'state', () => {

describe( 'edit mode', () => {
let initialState;
beforeAll( () => {
beforeEach( () => {
initialState = dispatchActions(
[
{
Expand Down Expand Up @@ -4308,7 +4308,7 @@ describe( 'state', () => {

describe( 'synced patterns', () => {
let initialState;
beforeAll( () => {
beforeEach( () => {
// Simulates how the editor typically inserts controlled blocks,
// - first the pattern is inserted with no inner blocks.
// - next the pattern is marked as a controlled block.
Expand Down Expand Up @@ -4873,7 +4873,7 @@ describe( 'state', () => {

describe( 'contentOnly template locking', () => {
let initialState;
beforeAll( () => {
beforeEach( () => {
initialState = dispatchActions(
[
{
Expand Down Expand Up @@ -5131,7 +5131,7 @@ describe( 'state', () => {
describe( 'zoom out mode', () => {
let initialState;

beforeAll( () => {
beforeEach( () => {
initialState = dispatchActions(
[
{
Expand Down Expand Up @@ -5322,7 +5322,7 @@ describe( 'state', () => {

describe( 'unsynced patterns', () => {
let initialState;
beforeAll( () => {
beforeEach( () => {
initialState = dispatchActions(
[
{
Expand Down Expand Up @@ -5484,7 +5484,7 @@ describe( 'state', () => {

describe( 'unsynced patterns with disableContentOnlyForUnsyncedPatterns enabled', () => {
let initialState;
beforeAll( () => {
beforeEach( () => {
initialState = dispatchActions(
[
{
Expand Down Expand Up @@ -5592,7 +5592,7 @@ describe( 'state', () => {

describe( 'isIsolatedEditor setting', () => {
let stateWithUnsyncedPatternAndTemplatePart;
beforeAll( () => {
beforeEach( () => {
// Set up a state with both an unsynced pattern and a template part.
stateWithUnsyncedPatternAndTemplatePart = dispatchActions(
[
Expand Down Expand Up @@ -5762,7 +5762,7 @@ describe( 'state', () => {

describe( 'template parts', () => {
let initialState;
beforeAll( () => {
beforeEach( () => {
// Simulates how the editor typically inserts controlled blocks,
// - first the template part is inserted with no inner blocks.
// - next the template part is marked as a controlled block.
Expand Down Expand Up @@ -5876,7 +5876,7 @@ describe( 'state', () => {

describe( 'template parts with disableContentOnlyForTemplateParts enabled', () => {
let initialState;
beforeAll( () => {
beforeEach( () => {
initialState = dispatchActions(
[
{
Expand Down
115 changes: 59 additions & 56 deletions packages/block-editor/src/store/test/selectors.jsdom.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4658,64 +4658,67 @@ describe( 'selectors', () => {
} );

describe( 'getActiveBlockIdByBlockName', () => {
const state = {
selection: {
selectionStart: {
clientId: 'client-id-04',
},
selectionEnd: {
clientId: 'client-id-04',
let state;
beforeEach( () => {
state = {
selection: {
selectionStart: {
clientId: 'client-id-04',
},
selectionEnd: {
clientId: 'client-id-04',
},
},
},
blocks: {
parents: new Map(
Object.entries( {
'client-id-01': '',
'client-id-02': 'client-id-01',
'client-id-03': 'client-id-02',
'client-id-04': 'client-id-03',
'client-id-05': 'client-id-03',
} )
),
byClientId: new Map(
Object.entries( {
'client-id-01': {
clientId: 'client-id-01',
name: 'core/columns',
},
'client-id-02': {
clientId: 'client-id-02',
name: 'core/navigation',
},
'client-id-03': {
clientId: 'client-id-03',
name: 'core/navigation-link',
},
'client-id-04': {
clientId: 'client-id-04',
name: 'core/navigation-link',
},
'client-id-05': {
clientId: 'client-id-05',
name: 'core/navigation-link',
},
} )
),
cache: {
'client-id-01': {},
'client-id-02': {},
'client-id-03': {},
'client-id-04': {},
'client-id-05': {},
blocks: {
parents: new Map(
Object.entries( {
'client-id-01': '',
'client-id-02': 'client-id-01',
'client-id-03': 'client-id-02',
'client-id-04': 'client-id-03',
'client-id-05': 'client-id-03',
} )
),
byClientId: new Map(
Object.entries( {
'client-id-01': {
clientId: 'client-id-01',
name: 'core/columns',
},
'client-id-02': {
clientId: 'client-id-02',
name: 'core/navigation',
},
'client-id-03': {
clientId: 'client-id-03',
name: 'core/navigation-link',
},
'client-id-04': {
clientId: 'client-id-04',
name: 'core/navigation-link',
},
'client-id-05': {
clientId: 'client-id-05',
name: 'core/navigation-link',
},
} )
),
cache: {
'client-id-01': {},
'client-id-02': {},
'client-id-03': {},
'client-id-04': {},
'client-id-05': {},
},
order: new Map(
Object.entries( {
'client-id-03': [ 'client-id-04', 'client-id-05' ],
} )
),
controlledInnerBlocks: new Set(),
},
order: new Map(
Object.entries( {
'client-id-03': [ 'client-id-04', 'client-id-05' ],
} )
),
controlledInnerBlocks: new Set(),
},
};
};
} );
it( 'Should return first active matching block (including self) when single block selected', () => {
expect(
getActiveBlockIdByBlockNames( state, [
Expand Down
4 changes: 4 additions & 0 deletions packages/blocks/src/api/test/registration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ describe( 'blocks', () => {
unlock( select( blocksStore ) ).getUnprocessedBlockTypes()
);
dispatch( blocksStore ).removeBlockTypes( registeredNames );
Object.keys( select( blocksStore ).getCollections() ).forEach(
unregisterBlockCollection
);
setFreeformContentHandlerName( undefined );
setUnregisteredTypeHandlerName( undefined );
setDefaultBlockName( undefined );
setGroupingBlockName( undefined );

// Reset deprecation logging to ensure we properly track warnings.
for ( const key in logged ) {
Expand Down
Loading
Loading