Skip to content

Commit

Permalink
Merge pull request #5723 from Automattic/staging
Browse files Browse the repository at this point in the history
Production release v20240716.0
  • Loading branch information
luiztiago authored Jul 16, 2024
2 parents d1c81e0 + dd1ee0f commit a92c5a8
Show file tree
Hide file tree
Showing 22 changed files with 465 additions and 447 deletions.
50 changes: 25 additions & 25 deletions __tests__/e2e/lib/components/wp-admin-sidebar-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,50 @@ const selectors = {
};

export class WPAdminSidebarComponent {
readonly page: Page;
private readonly page: Page;

/**
* Constructs an instance of the component.
*
* @param { Page } page The underlying page
*/
* Constructs an instance of the component.
*
* @param { Page } page The underlying page
*/
constructor( page: Page ) {
this.page = page;
}

/**
* Hover over sidebar menu item
*
* @param {string} itemName Name of the item to be hovered over
*/
hoverMenuItem( itemName: string ): Promise<void> {
* Hover over sidebar menu item
*
* @param {string} itemName Name of the item to be hovered over
*/
public hoverMenuItem( itemName: string ): Promise<void> {
return this.page.hover( selectors.menuItem( itemName ) );
}

/**
* Click sidebar menu item
*
* @param {string} itemName Name of the item to be clicked
*/
clickMenuItem( itemName: string ): Promise<void> {
* Click sidebar menu item
*
* @param {string} itemName Name of the item to be clicked
*/
public clickMenuItem( itemName: string ): Promise<void> {
return this.page.click( selectors.menuItem( itemName ) );
}

/**
* Hover over sidebar submenu item
*
* @param {string} itemName Name of the item to be hovered over
*/
hoverSubMenuItem( itemName: string ): Promise<void> {
* Hover over sidebar submenu item
*
* @param {string} itemName Name of the item to be hovered over
*/
public hoverSubMenuItem( itemName: string ): Promise<void> {
return this.page.hover( selectors.submenuItem( itemName ) );
}

/**
* Click sidebar submenu item
*
* @param {string} itemName Name of the item to be clicked
*/
clickSubMenuItem( itemName: string ): Promise<void> {
* Click sidebar submenu item
*
* @param {string} itemName Name of the item to be clicked
*/
public clickSubMenuItem( itemName: string ): Promise<void> {
return this.page.click( selectors.submenuItem( itemName ) );
}
}
6 changes: 3 additions & 3 deletions __tests__/e2e/lib/pages/media-upload-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const selectors = {
};

export class MediaUploadPage {
readonly page: Page;
private readonly page: Page;

/**
* Constructs an instance of the component.
Expand All @@ -23,7 +23,7 @@ export class MediaUploadPage {
*
* @param { string } mediaFile Media file name
*/
async uploadFile( mediaFile: string ): Promise<void> {
public async uploadFile( mediaFile: string ): Promise<void> {
const [ fileChooser ] = await Promise.all( [
// It is important to call waitForEvent before click to set up waiting.
this.page.waitForEvent( 'filechooser' ),
Expand All @@ -38,7 +38,7 @@ export class MediaUploadPage {
*
* @return { Promise<string | null> } Url of uploaded media
*/
async getMediaUrl(): Promise<string | null> {
public async getMediaUrl(): Promise<string | null> {
return this.page.locator( selectors.copyURLButton ).getAttribute( 'data-clipboard-text' );
}
}
6 changes: 3 additions & 3 deletions __tests__/e2e/lib/pages/page-list-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const selectors = {
};

export class PageListPage {
readonly page: Page;
private readonly page: Page;

/**
* Constructs an instance of the component.
Expand All @@ -19,7 +19,7 @@ export class PageListPage {
/**
* Navigate to Page List page
*/
visit(): Promise<unknown> {
public visit(): Promise<unknown> {
return this.page.goto( '/wp-admin/edit.php?post_type=page' );
}

Expand All @@ -28,7 +28,7 @@ export class PageListPage {
*
* @param { string } pageID ID of the page to be edited
*/
editPageByID( pageID: string ): Promise<void> {
public editPageByID( pageID: string ): Promise<void> {
return this.page.click( selectors.pageLink( pageID ) );
}
}
6 changes: 3 additions & 3 deletions __tests__/e2e/lib/pages/post-list-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const selectors = {
};

export class PostListPage {
readonly page: Page;
private readonly page: Page;

/**
* Constructs an instance of the component.
Expand All @@ -19,7 +19,7 @@ export class PostListPage {
/**
* Navigate to Post List page
*/
visit(): Promise<unknown> {
public visit(): Promise<unknown> {
return this.page.goto( '/wp-admin/edit.php' );
}

Expand All @@ -28,7 +28,7 @@ export class PostListPage {
*
* @param {string} postID ID of the post to be edited
*/
editPostByID( postID: string ): Promise<void> {
public editPostByID( postID: string ): Promise<void> {
return this.page.click( selectors.postLink( postID ) );
}
}
4 changes: 2 additions & 2 deletions __tests__/e2e/lib/pages/published-page-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class PublishedPagePage {
*
* @param {string} text Text to search for in the page
*/
async validateTextInPost( text: string ): Promise<void> {
public async validateTextInPost( text: string ): Promise<void> {
// If text isn't found the first time, reload and check again up to 2 more times.
let postTry = 0;
/* eslint-disable no-await-in-loop */
Expand All @@ -46,7 +46,7 @@ export class PublishedPagePage {
*
* @return {Promise<boolean>} True if image is found, otherwise false
*/
isImageDisplayed(): Promise<boolean> {
public isImageDisplayed(): Promise<boolean> {
return this.page.isVisible( selectors.pageImage );
}
}
4 changes: 2 additions & 2 deletions __tests__/e2e/lib/pages/published-post-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class PublishedPostPage {
*
* @param {string} text Text to search for in post page
*/
async validateTextInPost( text: string ): Promise<void> {
public async validateTextInPost( text: string ): Promise<void> {
// If text isn't found the first time, reload and check again up to 2 more times.
let pageTry = 0;
/* eslint-disable no-await-in-loop */
Expand All @@ -46,7 +46,7 @@ export class PublishedPostPage {
*
* @return {Promise<boolean>} True if image is found, otherwise false
*/
isImageDisplayed(): Promise<boolean> {
public isImageDisplayed(): Promise<boolean> {
return this.page.isVisible( selectors.postImage );
}
}
26 changes: 13 additions & 13 deletions __tests__/e2e/lib/pages/search-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class SearchPage {
* @param {string} searchTerm Search term
* @return {Promise<*>} Resolves after DOMContentLoaded event fires
*/
visit( searchTerm: string ): Promise<unknown> {
public visit( searchTerm: string ): Promise<unknown> {
return this.page.goto( `/?s=${ encodeURIComponent( searchTerm ) }`, { waitUntil: 'domcontentloaded' } );
}

Expand All @@ -74,7 +74,7 @@ export class SearchPage {
*
* @return {Promise<*>} Resolves when Search DevTools panel is visible
*/
async openSearchDevTools(): Promise<unknown> {
public async openSearchDevTools(): Promise<unknown> {
await this.devToolsMenuLocator.click();
return expect( this.devToolsContainerLocator ).toBeVisible();
}
Expand All @@ -84,7 +84,7 @@ export class SearchPage {
*
* @return {Promise<number>} Resolves with the number of queries or -1 if the number is unavailable
*/
async getNumberOfQueries(): Promise<number> {
public async getNumberOfQueries(): Promise<number> {
const text = ( await this.queryCountLocator.innerText() ).trim();
const matches = /^(\d+)/.exec( text );
return matches ? Number( matches[ 1 ] ) : -1;
Expand All @@ -95,7 +95,7 @@ export class SearchPage {
*
* @return {Promise<number>} Resolves with the number of results or -1 if the number is unavailable
*/
async getNumberOfFirstResults(): Promise<number> {
public async getNumberOfFirstResults(): Promise<number> {
const text = ( await this.resultCountLocator.first().innerText() ).trim();
const matches = /^(\d+)/.exec( text );
return matches ? Number( matches[ 1 ] ) : -1;
Expand All @@ -106,7 +106,7 @@ export class SearchPage {
*
* @return {Promise<boolean>} Whether the panel has been shown
*/
async expandFirstResults(): Promise<boolean> {
public async expandFirstResults(): Promise<boolean> {
const queryHandleLocator = this.queryHandleLocator.first();

let classes = await getClassList( this.queryWrapLocator );
Expand All @@ -126,7 +126,7 @@ export class SearchPage {
*
* @return {Promise<string>} Parameters as a string
*/
getWPQuery(): Promise<string> {
public getWPQuery(): Promise<string> {
return this.getQueryExtrasHelper( 0 );
}

Expand All @@ -135,7 +135,7 @@ export class SearchPage {
*
* @return {Promise<string>} Backtrace as a string
*/
getTrace(): Promise<string> {
public getTrace(): Promise<string> {
return this.getQueryExtrasHelper( 1 );
}

Expand All @@ -144,7 +144,7 @@ export class SearchPage {
*
* @return {Promise<string>} Query
*/
getQuery(): Promise<string> {
public getQuery(): Promise<string> {
return this.sourceQueryLocator.inputValue();
}

Expand All @@ -154,7 +154,7 @@ export class SearchPage {
* @param {string} newQuery New Query
* @return {Promise<*>} Resolves on success
*/
editQuery( newQuery: string ): Promise<unknown> {
public editQuery( newQuery: string ): Promise<unknown> {
return this.sourceQueryLocator.fill( newQuery );
}

Expand All @@ -163,7 +163,7 @@ export class SearchPage {
*
* @return {Promise<string>} Original query
*/
async resetQuery(): Promise<string> {
public async resetQuery(): Promise<string> {
await this.queryActionsLocator.nth( 1 ).click();
return this.getQuery();
}
Expand All @@ -173,7 +173,7 @@ export class SearchPage {
*
* @return {Promise<*>} Result of the query
*/
async runQuery(): Promise<unknown> {
public async runQuery(): Promise<unknown> {
const [ response ] = await Promise.all( [
this.page.waitForResponse( ( resp ) => resp.url().endsWith( '/wp-json/vip/v1/search/dev-tools' ) && resp.request().method() === 'POST' && resp.status() === 200 ),
this.queryActionsLocator.first().click(),
Expand All @@ -188,7 +188,7 @@ export class SearchPage {
* @param {string} substring Substring to check
* @return {Promise<*>} Resolves on success
*/
ensureQueryResponse( substring: string ): Promise<unknown> {
public ensureQueryResponse( substring: string ): Promise<unknown> {
return expect( this.queryResultLocator.getByText( substring ) ).toBeVisible();
}

Expand All @@ -197,7 +197,7 @@ export class SearchPage {
*
* @return {Promise<*>} Resolves on success
*/
closeSearchDevTools(): Promise<unknown> {
public closeSearchDevTools(): Promise<unknown> {
return this.devToolsCloseButtonLocator.click();
}

Expand Down
8 changes: 4 additions & 4 deletions __tests__/e2e/lib/pages/settings-writing-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const selectors = {
};

export class SettingsWritingPage {
readonly page: Page;
private readonly page: Page;

/**
* Constructs an instance of the component.
Expand All @@ -21,7 +21,7 @@ export class SettingsWritingPage {
/**
* Navigate to Writing Settings page
*/
visit(): Promise<unknown> {
public visit(): Promise<unknown> {
return this.page.goto( '/wp-admin/options-writing.php' );
}

Expand All @@ -30,15 +30,15 @@ export class SettingsWritingPage {
*
* @return { Promise<boolean> } Whether classic editor settings are visible
*/
hasClassicEditor(): Promise<boolean> {
public hasClassicEditor(): Promise<boolean> {
const editorSettings = this.page.locator( selectors.classicEditorBlock );
return editorSettings.isVisible();
}

/**
* Select settings to allow either block or classic editor
*/
async allowBothEditors(): Promise<void> {
public async allowBothEditors(): Promise<void> {
await this.page.click( selectors.classicEditorBlock );
await this.page.click( selectors.classicEditorAllow );
await this.page.click( selectors.saveButton );
Expand Down
6 changes: 3 additions & 3 deletions __tests__/e2e/lib/pages/wp-admin-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const selectors = {
};

export class WPAdminPage {
readonly page: Page;
readonly adminBar: Locator;
private readonly page: Page;
public readonly adminBar: Locator;

/**
* Constructs an instance of the component.
Expand All @@ -21,7 +21,7 @@ export class WPAdminPage {
/**
* Navigate to WP Admin
*/
visit(): Promise<unknown> {
public visit(): Promise<unknown> {
return this.page.goto( '/wp-admin' );
}
}
Loading

0 comments on commit a92c5a8

Please sign in to comment.