Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Nov 18, 2024
1 parent e5901d1 commit e499429
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 62 deletions.
145 changes: 87 additions & 58 deletions packages/block-editor/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4615,68 +4615,97 @@ describe( 'getBlockEditingMode', () => {
).toBe( 'contentOnly' );
} );

it( 'in navigation mode, the root section container is default', () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', 'navigation' );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337'
)
).toBe( 'default' );
} );
describe( 'navigation mode', () => {
const writeModeExperiment = window.__experimentalEditorWriteMode;
beforeAll( () => {
window.__experimentalEditorWriteMode = true;
} );
afterAll( () => {
window.__experimentalEditorWriteMode = writeModeExperiment;
} );
it( 'in navigation mode, the root section container is default', () => {
dispatch( preferencesStore ).set(
'core',
'editorTool',
'navigation'
);
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337'
)
).toBe( 'default' );
} );

it( 'in navigation mode, anything outside the section container is disabled', () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', 'navigation' );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'6cf70164-9097-4460-bcbf-200560546988'
)
).toBe( 'disabled' );
} );
it( 'in navigation mode, anything outside the section container is disabled', () => {
dispatch( preferencesStore ).set(
'core',
'editorTool',
'navigation'
);
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'6cf70164-9097-4460-bcbf-200560546988'
)
).toBe( 'disabled' );
} );

it( 'in navigation mode, sections are contentOnly', () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', 'navigation' );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'b26fc763-417d-4f01-b81c-2ec61e14a972'
)
).toBe( 'contentOnly' );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f'
)
).toBe( 'contentOnly' );
} );
it( 'in navigation mode, sections are contentOnly', () => {
dispatch( preferencesStore ).set(
'core',
'editorTool',
'navigation'
);
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'b26fc763-417d-4f01-b81c-2ec61e14a972'
)
).toBe( 'contentOnly' );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f'
)
).toBe( 'contentOnly' );
} );

it( 'in navigation mode, blocks with content attributes within sections are contentOnly', () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', 'navigation' );
hasContentRoleAttribute.mockReturnValueOnce( true );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'b3247f75-fd94-4fef-97f9-5bfd162cc416'
)
).toBe( 'contentOnly' );
it( 'in navigation mode, blocks with content attributes within sections are contentOnly', () => {
dispatch( preferencesStore ).set(
'core',
'editorTool',
'navigation'
);
hasContentRoleAttribute.mockReturnValueOnce( true );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'b3247f75-fd94-4fef-97f9-5bfd162cc416'
)
).toBe( 'contentOnly' );

hasContentRoleAttribute.mockReturnValueOnce( true );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c'
)
).toBe( 'contentOnly' );
} );
hasContentRoleAttribute.mockReturnValueOnce( true );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c'
)
).toBe( 'contentOnly' );
} );

it( 'in navigation mode, blocks without content attributes within sections are disabled', () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', 'navigation' );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'9b9c5c3f-2e46-4f02-9e14-9fed515b958s'
)
).toBe( 'disabled' );
it( 'in navigation mode, blocks without content attributes within sections are disabled', () => {
dispatch( preferencesStore ).set(
'core',
'editorTool',
'navigation'
);
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
'9b9c5c3f-2e46-4f02-9e14-9fed515b958s'
)
).toBe( 'disabled' );
} );
} );
} );
8 changes: 4 additions & 4 deletions test/e2e/specs/editor/various/write-design-mode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ test.describe( 'Write/Design mode', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'emptytheme' );
} );

test.beforeEach( async ( { admin } ) => {
test.beforeEach( async ( { admin, page } ) => {
await page.addInitScript( () => {
window.__experimentalEditorWriteMode = true;
} );
await admin.visitSiteEditor( {
postId: 'emptytheme//index',
postType: 'wp_template',
canvas: 'edit',
} );
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );

test( 'Should prevent selecting intermediary blocks', async ( {
editor,
page,
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/specs/site-editor/style-book.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ test.describe( 'Style Book', () => {
} );

test.beforeEach( async ( { admin, editor, styleBook, page } ) => {
await page.addInitScript( () => {
window.__experimentalEditorWriteMode = true;
} );
await admin.visitSiteEditor();
await editor.canvas.locator( 'body' ).click();
await styleBook.open();
Expand Down

0 comments on commit e499429

Please sign in to comment.