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

E2E test: Only expand the post summary section if it exists since the summary section will no longer be expansible #90736

Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -133,6 +133,28 @@ export class EditorSettingsSidebarComponent {
await expandedLocator.waitFor();
}

/**
* Expands a collapsed section of the sidebar if the section exists in the first place.
* The `Summary` section is no longer collapsible in recent GB iterations
* @see https://github.com/WordPress/gutenberg/commit/201099408131e2abe3cd094f7a1e7e539a350c12
* @deprecated To discourage the adoption of this function
* @todo Remove when all platforms have eventually been migrated
*
* If the section is already open, this method will pass.
*
* @param {string} name Name of section to be expanded.
*/
async expandSectionIfExists( name: string ): Promise< void > {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not saying this approach is wrong, but I'm still curious if you considered adding something like an expandSummary method for this specific case? I'm guessing we don't foresee any specific opportunities to reuse expandSectionIfExists, and having a dedicated expandSummary method might clarify that it can be removed in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I'm still curious if you considered adding something like an expandSummary method for this specific case?

Sounds more to-the-point. I like it.

const editorParent = await this.editor.parent();
const sectionLocator = editorParent.locator( selectors.section( name ) );

if ( ! ( await sectionLocator.isVisible() ) ) {
return;
}

this.expandSection( name );
}

/**
* Given a selector, determines whether the target button/toggle is
* in an expanded state.
Expand Down
6 changes: 3 additions & 3 deletions packages/calypso-e2e/src/lib/pages/editor-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ export class EditorPage {
this.editorSettingsSidebarComponent.clickTab( 'Post' ),
] );

await this.editorSettingsSidebarComponent.expandSection( 'Summary' );
await this.editorSettingsSidebarComponent.expandSectionIfExists( 'Summary' );
await this.editorSettingsSidebarComponent.openVisibilityOptions();
await this.editorSettingsSidebarComponent.selectVisibility( visibility, {
password: password,
Expand Down Expand Up @@ -637,7 +637,7 @@ export class EditorPage {
this.editorSettingsSidebarComponent.clickTab( 'Page' ),
this.editorSettingsSidebarComponent.clickTab( 'Post' ),
] );
await this.editorSettingsSidebarComponent.expandSection( 'Summary' );
await this.editorSettingsSidebarComponent.expandSectionIfExists( 'Summary' );
await this.editorSettingsSidebarComponent.enterUrlSlug( slug );
}

Expand Down Expand Up @@ -753,7 +753,7 @@ export class EditorPage {
this.editorSettingsSidebarComponent.clickTab( 'Post' ),
] );

await this.editorSettingsSidebarComponent.expandSection( 'Summary' );
await this.editorSettingsSidebarComponent.expandSectionIfExists( 'Summary' );
await this.editorSettingsSidebarComponent.openSchedule();
await this.editorSettingsSidebarComponent.setScheduleDetails( date );
await this.editorSettingsSidebarComponent.closeSchedule();
Expand Down
Loading