Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
8 changes: 4 additions & 4 deletions packages/e2e-test-utils-playwright/src/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class Admin {
this.pageUtils = pageUtils;
}

createNewPost = createNewPost;
getPageError = getPageError;
visitAdminPage = visitAdminPage;
visitSiteEditor = visitSiteEditor;
createNewPost = createNewPost.bind( this );
getPageError = getPageError.bind( this );
visitAdminPage = visitAdminPage.bind( this );
visitSiteEditor = visitSiteEditor.bind( this );
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { addQueryArgs } from '@wordpress/url';
*/
import type { Admin } from './';

interface SiteEditorQueryParams {
export interface SiteEditorQueryParams {
postId: string | number;
postType: string;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/e2e-test-utils-playwright/src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { publishPost } from './publish-post';
import { selectBlocks } from './select-blocks';
import { showBlockToolbar } from './show-block-toolbar';
import { saveSiteEditorEntities } from './site-editor';
import { transformBlockTo } from './transform-block-to';

type EditorConstructorProps = {
page: Page;
Expand Down Expand Up @@ -52,7 +53,6 @@ export class Editor {

return frame;
}

clickBlockOptionsMenuItem = clickBlockOptionsMenuItem.bind( this );
clickBlockToolbarButton = clickBlockToolbarButton.bind( this );
getEditedPostContent = getEditedPostContent.bind( this );
Expand All @@ -63,4 +63,5 @@ export class Editor {
saveSiteEditorEntities = saveSiteEditorEntities.bind( this );
selectBlocks = selectBlocks.bind( this );
showBlockToolbar = showBlockToolbar.bind( this );
transformBlockTo = transformBlockTo.bind( this );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Internal dependencies
*/
import type { Editor } from './index';

/**
* Clicks the default block appender.
*
* @param {Editor} this
* @param {string} name Block name.
*/
export async function transformBlockTo( this: Editor, name: string ) {
await this.page.evaluate(
( [ blockName ] ) => {
// @ts-ignore (Reason: wp isn't typed)
const clientIds = window.wp.data
.select( 'core/block-editor' )
.getSelectedBlockClientIds();
// @ts-ignore (Reason: wp isn't typed)
const blocks = window.wp.data
.select( 'core/block-editor' )
.getBlocksByClientId( clientIds );
// @ts-ignore (Reason: wp isn't typed)
window.wp.data.dispatch( 'core/block-editor' ).replaceBlocks(
clientIds,
// @ts-ignore (Reason: wp isn't typed)
window.wp.blocks.switchToBlockType( blocks, blockName )
);
},
[ name ]
);
}
10 changes: 5 additions & 5 deletions packages/e2e-test-utils-playwright/src/page-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class PageUtils {
this.browser = this.context.browser()!;
}

isCurrentURL = isCurrentURL;
pressKeyTimes = pressKeyTimes;
pressKeyWithModifier = pressKeyWithModifier;
setBrowserViewport = setBrowserViewport;
setClipboardData = setClipboardData;
isCurrentURL = isCurrentURL.bind( this );
pressKeyTimes = pressKeyTimes.bind( this );
pressKeyWithModifier = pressKeyWithModifier.bind( this );
setBrowserViewport = setBrowserViewport.bind( this );
setClipboardData = setClipboardData.bind( this );
}

export { PageUtils };
38 changes: 20 additions & 18 deletions packages/e2e-test-utils-playwright/src/request-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,27 @@ class RequestUtils {
this.baseURL = baseURL;
}

login = login;
setupRest = setupRest;
rest = rest;
getMaxBatchSize = getMaxBatchSize;
batchRest = batchRest;
getPluginsMap = getPluginsMap;
activatePlugin = activatePlugin;
deactivatePlugin = deactivatePlugin;
activateTheme = activateTheme;
login = login.bind( this );
setupRest = setupRest.bind( this );
// .bind() drops the generic types. Re-casting it to keep the type signature.
rest = rest.bind( this ) as typeof rest;
getMaxBatchSize = getMaxBatchSize.bind( this );
// .bind() drops the generic types. Re-casting it to keep the type signature.
batchRest = batchRest.bind( this ) as typeof batchRest;
getPluginsMap = getPluginsMap.bind( this );
activatePlugin = activatePlugin.bind( this );
deactivatePlugin = deactivatePlugin.bind( this );
activateTheme = activateTheme.bind( this );
deleteAllBlocks = deleteAllBlocks;
deleteAllPosts = deleteAllPosts;
deleteAllWidgets = deleteAllWidgets;
addWidgetBlock = addWidgetBlock;
deleteAllTemplates = deleteAllTemplates;
resetPreferences = resetPreferences;
listMedia = listMedia;
uploadMedia = uploadMedia;
deleteMedia = deleteMedia;
deleteAllMedia = deleteAllMedia;
deleteAllPosts = deleteAllPosts.bind( this );
deleteAllWidgets = deleteAllWidgets.bind( this );
addWidgetBlock = addWidgetBlock.bind( this );
deleteAllTemplates = deleteAllTemplates.bind( this );
resetPreferences = resetPreferences.bind( this );
listMedia = listMedia.bind( this );
uploadMedia = uploadMedia.bind( this );
deleteMedia = deleteMedia.bind( this );
deleteAllMedia = deleteAllMedia.bind( this );
}

export type { StorageState };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as fs from 'fs';
*/
import type { RequestUtils } from './index';

interface Media {
export interface Media {
id: number;
title: {
raw: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type RequestFetchOptions = Exclude<
Parameters< APIRequestContext[ 'fetch' ] >[ 1 ],
undefined
>;
interface RestOptions extends RequestFetchOptions {
export interface RestOptions extends RequestFetchOptions {
path: string;
}

Expand Down Expand Up @@ -152,7 +152,7 @@ async function getMaxBatchSize( this: RequestUtils, forceRefetch = false ) {
return this.maxBatchSize;
}

interface BatchRequest {
export interface BatchRequest {
method?: string;
path: string;
headers?: Record< string, string | string[] >;
Expand Down
Loading