Skip to content

Commit

Permalink
e2e test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chad1008 committed Dec 13, 2023
1 parent 40b412c commit 530c9b1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
22 changes: 8 additions & 14 deletions packages/e2e-tests/specs/site-editor/settings-sidebar.test.js
Expand Up @@ -19,8 +19,8 @@ async function toggleSidebar() {

async function getActiveTabLabel() {
return await page.$eval(
'.edit-site-sidebar-edit-mode__panel-tab.is-active',
( element ) => element.getAttribute( 'aria-label' )
'div[aria-label="Editor settings"] [role="tab"][aria-selected="true"]',
( element ) => element.textContent
);
}

Expand Down Expand Up @@ -57,9 +57,7 @@ describe( 'Settings sidebar', () => {
it( 'should open template tab by default if no block is selected', async () => {
await toggleSidebar();

expect( await getActiveTabLabel() ).toEqual(
'Template (selected)'
);
expect( await getActiveTabLabel() ).toEqual( 'Template' );
} );

it( "should show the currently selected template's title and description", async () => {
Expand Down Expand Up @@ -93,30 +91,26 @@ describe( 'Settings sidebar', () => {

await toggleSidebar();

expect( await getActiveTabLabel() ).toEqual( 'Block (selected)' );
expect( await getActiveTabLabel() ).toEqual( 'Block' );
} );
} );

describe( 'Tab switch based on selection', () => {
it( 'should switch to block tab if we select a block, when Template is selected', async () => {
await toggleSidebar();
expect( await getActiveTabLabel() ).toEqual(
'Template (selected)'
);
expect( await getActiveTabLabel() ).toEqual( 'Template' );
// By inserting the block is also selected.
await insertBlock( 'Heading' );
expect( await getActiveTabLabel() ).toEqual( 'Block (selected)' );
expect( await getActiveTabLabel() ).toEqual( 'Block' );
} );
it( 'should switch to Template tab when a block was selected and we select the Template', async () => {
await insertBlock( 'Heading' );
await toggleSidebar();
expect( await getActiveTabLabel() ).toEqual( 'Block (selected)' );
expect( await getActiveTabLabel() ).toEqual( 'Block' );
await page.evaluate( () => {
wp.data.dispatch( 'core/block-editor' ).clearSelectedBlock();
} );
expect( await getActiveTabLabel() ).toEqual(
'Template (selected)'
);
expect( await getActiveTabLabel() ).toEqual( 'Template' );
} );
} );
} );
4 changes: 2 additions & 2 deletions test/e2e/specs/site-editor/template-revert.spec.js
Expand Up @@ -294,12 +294,12 @@ class TemplateRevertUtils {
await this.editor.openDocumentSettingsSidebar();
const isTemplateTabVisible = await this.page
.locator(
'role=region[name="Editor settings"i] >> role=button[name="Template"i]'
'role=region[name="Editor settings"i] >> role=tab[name="Template"i]'
)
.isVisible();
if ( isTemplateTabVisible ) {
await this.page.click(
'role=region[name="Editor settings"i] >> role=button[name="Template"i]'
'role=region[name="Editor settings"i] >> role=tab[name="Template"i]'
);
}
await this.page.click(
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/specs/site-editor/writing-flow.spec.js
Expand Up @@ -65,9 +65,9 @@ test.describe( 'Site editor writing flow', () => {

// Tab to the inspector, tabbing three times to go past the two resize handles.
await pageUtils.pressKeys( 'Tab', { times: 3 } );
const inspectorTemplateTab = page.locator(
'role=region[name="Editor settings"i] >> role=button[name="Template part"i]'
const inspectorBlockTab = page.locator(
'role=region[name="Editor settings"i] >> role=tab[name="Block"i]'
);
await expect( inspectorTemplateTab ).toBeFocused();
await expect( inspectorBlockTab ).toBeFocused();
} );
} );

0 comments on commit 530c9b1

Please sign in to comment.