@wordpress/e2e-test-utils-playwright 1.48.0 → 1.48.2-next.v.202606191442.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/admin/create-new-post.js +31 -0
- package/build/admin/create-new-post.js.map +1 -0
- package/build/admin/edit-post.js +20 -0
- package/build/admin/edit-post.js.map +1 -0
- package/{src/admin/get-page-error.ts → build/admin/get-page-error.js} +9 -12
- package/build/admin/get-page-error.js.map +1 -0
- package/build/admin/index.js +40 -0
- package/build/admin/index.js.map +1 -0
- package/build/admin/visit-admin-page.js +32 -0
- package/build/admin/visit-admin-page.js.map +1 -0
- package/build/admin/visit-site-editor.js +45 -0
- package/build/admin/visit-site-editor.js.map +1 -0
- package/build/admin/wait-for-site-editor.js +41 -0
- package/build/admin/wait-for-site-editor.js.map +1 -0
- package/build/config.js +13 -0
- package/build/config.js.map +1 -0
- package/build/editor/click-block-options-menu-item.js +17 -0
- package/build/editor/click-block-options-menu-item.js.map +1 -0
- package/build/editor/click-block-toolbar-button.js +16 -0
- package/build/editor/click-block-toolbar-button.js.map +1 -0
- package/build/editor/get-blocks.js +45 -0
- package/build/editor/get-blocks.js.map +1 -0
- package/build/editor/get-edited-post-content.js +15 -0
- package/build/editor/get-edited-post-content.js.map +1 -0
- package/build/editor/index.js +75 -0
- package/build/editor/index.js.map +1 -0
- package/build/editor/insert-block.js +23 -0
- package/build/editor/insert-block.js.map +1 -0
- package/build/editor/open-document-settings-sidebar.js +27 -0
- package/build/editor/open-document-settings-sidebar.js.map +1 -0
- package/build/editor/preview.js +21 -0
- package/build/editor/preview.js.map +1 -0
- package/build/editor/publish-post.js +45 -0
- package/build/editor/publish-post.js.map +1 -0
- package/build/editor/save-draft.js +18 -0
- package/build/editor/save-draft.js.map +1 -0
- package/build/editor/select-blocks.js +28 -0
- package/build/editor/select-blocks.js.map +1 -0
- package/build/editor/set-content.js +17 -0
- package/build/editor/set-content.js.map +1 -0
- package/build/editor/set-is-fixed-toolbar.js +18 -0
- package/build/editor/set-is-fixed-toolbar.js.map +1 -0
- package/build/editor/set-preferences.js +21 -0
- package/build/editor/set-preferences.js.map +1 -0
- package/build/editor/show-block-toolbar.js +19 -0
- package/build/editor/show-block-toolbar.js.map +1 -0
- package/build/editor/site-editor.js +44 -0
- package/build/editor/site-editor.js.map +1 -0
- package/build/editor/switch-editor-tool.js +33 -0
- package/build/editor/switch-editor-tool.js.map +1 -0
- package/build/editor/switch-to-legacy-canvas.js +18 -0
- package/build/editor/switch-to-legacy-canvas.js.map +1 -0
- package/build/editor/transform-block-to.js +24 -0
- package/build/editor/transform-block-to.js.map +1 -0
- package/build/index.js +19 -0
- package/build/index.js.map +1 -0
- package/build/lighthouse/index.js +61 -0
- package/build/lighthouse/index.js.map +1 -0
- package/build/metrics/index.js +314 -0
- package/build/metrics/index.js.map +1 -0
- package/build/page-utils/drag-files.js +119 -0
- package/build/page-utils/drag-files.js.map +1 -0
- package/build/page-utils/emulate-network-conditions.js +71 -0
- package/build/page-utils/emulate-network-conditions.js.map +1 -0
- package/build/page-utils/index.js +37 -0
- package/build/page-utils/index.js.map +1 -0
- package/build/page-utils/is-current-url.js +21 -0
- package/build/page-utils/is-current-url.js.map +1 -0
- package/build/page-utils/keycodes.js +41 -0
- package/build/page-utils/keycodes.js.map +1 -0
- package/build/page-utils/press-keys.js +141 -0
- package/build/page-utils/press-keys.js.map +1 -0
- package/{src → build}/page-utils/set-browser-viewport.js +12 -14
- package/build/page-utils/set-browser-viewport.js.map +1 -0
- package/build/request-utils/blocks.js +40 -0
- package/build/request-utils/blocks.js.map +1 -0
- package/build/request-utils/comments.js +52 -0
- package/build/request-utils/comments.js.map +1 -0
- package/build/request-utils/gutenberg-experiments.js +47 -0
- package/build/request-utils/gutenberg-experiments.js.map +1 -0
- package/build/request-utils/index.js +196 -0
- package/build/request-utils/index.js.map +1 -0
- package/build/request-utils/login.js +21 -0
- package/build/request-utils/login.js.map +1 -0
- package/build/request-utils/media.js +106 -0
- package/build/request-utils/media.js.map +1 -0
- package/build/request-utils/menus.js +116 -0
- package/build/request-utils/menus.js.map +1 -0
- package/build/request-utils/pages.js +53 -0
- package/build/request-utils/pages.js.map +1 -0
- package/build/request-utils/patterns.js +27 -0
- package/build/request-utils/patterns.js.map +1 -0
- package/build/request-utils/plugins.js +85 -0
- package/build/request-utils/plugins.js.map +1 -0
- package/build/request-utils/posts.js +42 -0
- package/build/request-utils/posts.js.map +1 -0
- package/build/request-utils/preferences.js +54 -0
- package/build/request-utils/preferences.js.map +1 -0
- package/{src/request-utils/records.ts → build/request-utils/records.js} +10 -15
- package/build/request-utils/records.js.map +1 -0
- package/build/request-utils/rest.js +181 -0
- package/build/request-utils/rest.js.map +1 -0
- package/build/request-utils/site-settings.js +33 -0
- package/build/request-utils/site-settings.js.map +1 -0
- package/build/request-utils/templates.js +54 -0
- package/build/request-utils/templates.js.map +1 -0
- package/build/request-utils/themes.js +69 -0
- package/build/request-utils/themes.js.map +1 -0
- package/build/request-utils/users.js +81 -0
- package/build/request-utils/users.js.map +1 -0
- package/build/request-utils/widgets.js +61 -0
- package/build/request-utils/widgets.js.map +1 -0
- package/build/test.js +189 -0
- package/build/test.js.map +1 -0
- package/build/types.js +3 -0
- package/build/types.js.map +1 -0
- package/package.json +8 -5
- package/src/admin/create-new-post.ts +0 -47
- package/src/admin/edit-post.ts +0 -24
- package/src/admin/index.ts +0 -52
- package/src/admin/visit-admin-page.ts +0 -43
- package/src/admin/visit-site-editor.ts +0 -62
- package/src/admin/wait-for-site-editor.ts +0 -52
- package/src/config.ts +0 -12
- package/src/editor/click-block-options-menu-item.ts +0 -18
- package/src/editor/click-block-toolbar-button.ts +0 -21
- package/src/editor/get-blocks.ts +0 -75
- package/src/editor/get-edited-post-content.ts +0 -19
- package/src/editor/index.ts +0 -95
- package/src/editor/insert-block.ts +0 -54
- package/src/editor/open-document-settings-sidebar.ts +0 -31
- package/src/editor/preview.ts +0 -32
- package/src/editor/publish-post.ts +0 -51
- package/src/editor/save-draft.ts +0 -20
- package/src/editor/select-blocks.ts +0 -48
- package/src/editor/set-content.ts +0 -24
- package/src/editor/set-is-fixed-toolbar.ts +0 -20
- package/src/editor/set-preferences.ts +0 -37
- package/src/editor/show-block-toolbar.ts +0 -20
- package/src/editor/site-editor.ts +0 -55
- package/src/editor/switch-editor-tool.ts +0 -34
- package/src/editor/switch-to-legacy-canvas.ts +0 -20
- package/src/editor/transform-block-to.ts +0 -34
- package/src/index.ts +0 -8
- package/src/lighthouse/index.ts +0 -75
- package/src/metrics/index.ts +0 -441
- package/src/page-utils/drag-files.ts +0 -173
- package/src/page-utils/emulate-network-conditions.ts +0 -101
- package/src/page-utils/index.ts +0 -54
- package/src/page-utils/is-current-url.ts +0 -20
- package/src/page-utils/keycodes.ts +0 -48
- package/src/page-utils/press-keys.ts +0 -195
- package/src/request-utils/blocks.ts +0 -58
- package/src/request-utils/comments.ts +0 -80
- package/src/request-utils/gutenberg-experiments.ts +0 -62
- package/src/request-utils/index.ts +0 -222
- package/src/request-utils/login.ts +0 -34
- package/src/request-utils/media.ts +0 -102
- package/src/request-utils/menus.ts +0 -145
- package/src/request-utils/pages.ts +0 -75
- package/src/request-utils/patterns.ts +0 -31
- package/src/request-utils/plugins.ts +0 -103
- package/src/request-utils/posts.ts +0 -69
- package/src/request-utils/preferences.ts +0 -63
- package/src/request-utils/rest.ts +0 -222
- package/src/request-utils/site-settings.ts +0 -58
- package/src/request-utils/templates.ts +0 -83
- package/src/request-utils/themes.ts +0 -110
- package/src/request-utils/users.ts +0 -125
- package/src/request-utils/widgets.js +0 -68
- package/src/test.ts +0 -204
- package/src/types.ts +0 -13
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import type { RequestUtils } from './index';
|
|
5
|
-
|
|
6
|
-
export interface User {
|
|
7
|
-
id: number;
|
|
8
|
-
name: string;
|
|
9
|
-
email: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface UserData {
|
|
13
|
-
username: string;
|
|
14
|
-
email: string;
|
|
15
|
-
firstName?: string;
|
|
16
|
-
lastName?: string;
|
|
17
|
-
password?: string;
|
|
18
|
-
roles?: string[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface UserRequestData {
|
|
22
|
-
username: string;
|
|
23
|
-
email: string;
|
|
24
|
-
first_name?: string;
|
|
25
|
-
last_name?: string;
|
|
26
|
-
password?: string;
|
|
27
|
-
roles?: string[];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* List all users.
|
|
32
|
-
*
|
|
33
|
-
* @see https://developer.wordpress.org/rest-api/reference/users/#list-users
|
|
34
|
-
* @param this
|
|
35
|
-
*/
|
|
36
|
-
async function listUsers( this: RequestUtils ) {
|
|
37
|
-
const response = await this.rest< User[] >( {
|
|
38
|
-
method: 'GET',
|
|
39
|
-
path: '/wp/v2/users',
|
|
40
|
-
params: {
|
|
41
|
-
per_page: 100,
|
|
42
|
-
},
|
|
43
|
-
} );
|
|
44
|
-
|
|
45
|
-
return response;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Add a test user.
|
|
50
|
-
*
|
|
51
|
-
* @see https://developer.wordpress.org/rest-api/reference/users/#create-a-user
|
|
52
|
-
* @param this
|
|
53
|
-
* @param user User data to create.
|
|
54
|
-
*/
|
|
55
|
-
async function createUser( this: RequestUtils, user: UserData ) {
|
|
56
|
-
const userData: UserRequestData = {
|
|
57
|
-
username: user.username,
|
|
58
|
-
email: user.email,
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
if ( user.firstName ) {
|
|
62
|
-
userData.first_name = user.firstName;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if ( user.lastName ) {
|
|
66
|
-
userData.last_name = user.lastName;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if ( user.password ) {
|
|
70
|
-
userData.password = user.password;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if ( user.roles ) {
|
|
74
|
-
userData.roles = user.roles;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const response = await this.rest< User >( {
|
|
78
|
-
method: 'POST',
|
|
79
|
-
path: '/wp/v2/users',
|
|
80
|
-
data: userData,
|
|
81
|
-
} );
|
|
82
|
-
|
|
83
|
-
return response;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Delete a user.
|
|
88
|
-
*
|
|
89
|
-
* @see https://developer.wordpress.org/rest-api/reference/users/#delete-a-user
|
|
90
|
-
* @param this
|
|
91
|
-
* @param userId The ID of the user.
|
|
92
|
-
*/
|
|
93
|
-
async function deleteUser( this: RequestUtils, userId: number ) {
|
|
94
|
-
const response = await this.rest( {
|
|
95
|
-
method: 'DELETE',
|
|
96
|
-
path: `/wp/v2/users/${ userId }`,
|
|
97
|
-
params: { force: true, reassign: 1 },
|
|
98
|
-
} );
|
|
99
|
-
|
|
100
|
-
return response;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Delete all users except main root user.
|
|
105
|
-
*
|
|
106
|
-
* @param this
|
|
107
|
-
*/
|
|
108
|
-
async function deleteAllUsers( this: RequestUtils ) {
|
|
109
|
-
const users = await listUsers.bind( this )();
|
|
110
|
-
|
|
111
|
-
// The users endpoint doesn't support batch request yet.
|
|
112
|
-
const responses = await Promise.all(
|
|
113
|
-
users
|
|
114
|
-
// Do not delete neither root user nor the current user.
|
|
115
|
-
.filter(
|
|
116
|
-
( user: User ) =>
|
|
117
|
-
user.id !== 1 && user.name !== this.user.username
|
|
118
|
-
)
|
|
119
|
-
.map( ( user: User ) => deleteUser.bind( this )( user.id ) )
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
return responses;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export { createUser, deleteAllUsers };
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delete all the widgets in the widgets screen.
|
|
3
|
-
*
|
|
4
|
-
* @this {import('./index').RequestUtils}
|
|
5
|
-
*/
|
|
6
|
-
export async function deleteAllWidgets() {
|
|
7
|
-
const [ widgets, sidebars ] = await Promise.all( [
|
|
8
|
-
this.rest( { path: '/wp/v2/widgets' } ),
|
|
9
|
-
this.rest( { path: '/wp/v2/sidebars' } ),
|
|
10
|
-
] );
|
|
11
|
-
|
|
12
|
-
await this.batchRest(
|
|
13
|
-
widgets.map( ( widget ) => ( {
|
|
14
|
-
method: 'DELETE',
|
|
15
|
-
path: `/wp/v2/widgets/${ widget.id }?force=true`,
|
|
16
|
-
} ) )
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
// The endpoint doesn't support batch requests yet.
|
|
20
|
-
await Promise.all(
|
|
21
|
-
sidebars.map( ( sidebar ) =>
|
|
22
|
-
this.rest( {
|
|
23
|
-
method: 'POST',
|
|
24
|
-
path: `/wp/v2/sidebars/${ sidebar.id }`,
|
|
25
|
-
data: { id: sidebar.id, widgets: [] },
|
|
26
|
-
} )
|
|
27
|
-
)
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Add a widget block to the widget area.
|
|
33
|
-
*
|
|
34
|
-
* @this {import('./index').RequestUtils}
|
|
35
|
-
* @param {string} serializedBlock The serialized content of the inserted block HTML.
|
|
36
|
-
* @param {string} widgetAreaId The ID of the widget area.
|
|
37
|
-
*/
|
|
38
|
-
export async function addWidgetBlock( serializedBlock, widgetAreaId ) {
|
|
39
|
-
const { id: blockId } = await this.rest( {
|
|
40
|
-
method: 'POST',
|
|
41
|
-
path: '/wp/v2/widgets',
|
|
42
|
-
data: {
|
|
43
|
-
id_base: 'block',
|
|
44
|
-
sidebar: widgetAreaId,
|
|
45
|
-
instance: {
|
|
46
|
-
raw: { content: serializedBlock },
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
} );
|
|
50
|
-
|
|
51
|
-
const { widgets } = await this.rest( {
|
|
52
|
-
path: `/wp/v2/sidebars/${ widgetAreaId }`,
|
|
53
|
-
} );
|
|
54
|
-
|
|
55
|
-
const updatedWidgets = new Set( widgets );
|
|
56
|
-
// Remove duplicate.
|
|
57
|
-
updatedWidgets.delete( blockId );
|
|
58
|
-
// Add to last block.
|
|
59
|
-
updatedWidgets.add( blockId );
|
|
60
|
-
|
|
61
|
-
await this.rest( {
|
|
62
|
-
method: 'PUT',
|
|
63
|
-
path: `/wp/v2/sidebars/${ widgetAreaId }`,
|
|
64
|
-
data: {
|
|
65
|
-
widgets: [ ...updatedWidgets ],
|
|
66
|
-
},
|
|
67
|
-
} );
|
|
68
|
-
}
|
package/src/test.ts
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
// Playwright fixtures use `use()` which is not a React hook.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import * as path from 'path';
|
|
7
|
-
import { test as base, expect, chromium } from '@playwright/test';
|
|
8
|
-
import type { ConsoleMessage } from '@playwright/test';
|
|
9
|
-
import getPort from 'get-port';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import {
|
|
15
|
-
Admin,
|
|
16
|
-
Editor,
|
|
17
|
-
PageUtils,
|
|
18
|
-
RequestUtils,
|
|
19
|
-
Metrics,
|
|
20
|
-
Lighthouse,
|
|
21
|
-
} from './index';
|
|
22
|
-
|
|
23
|
-
const STORAGE_STATE_PATH =
|
|
24
|
-
process.env.STORAGE_STATE_PATH ||
|
|
25
|
-
path.join( process.cwd(), 'artifacts/storage-states/admin.json' );
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Set of console logging types observed to protect against unexpected yet
|
|
29
|
-
* handled (i.e. not catastrophic) errors or warnings. Each key corresponds
|
|
30
|
-
* to the Playwright ConsoleMessage type, its value the corresponding function
|
|
31
|
-
* on the console global object.
|
|
32
|
-
*/
|
|
33
|
-
const OBSERVED_CONSOLE_MESSAGE_TYPES = [ 'warn', 'error' ] as const;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Adds a page event handler to emit uncaught exception to process if one of
|
|
37
|
-
* the observed console logging types is encountered.
|
|
38
|
-
*
|
|
39
|
-
* @param message The console message.
|
|
40
|
-
*/
|
|
41
|
-
function observeConsoleLogging( message: ConsoleMessage ) {
|
|
42
|
-
const type = message.type();
|
|
43
|
-
if (
|
|
44
|
-
! OBSERVED_CONSOLE_MESSAGE_TYPES.includes(
|
|
45
|
-
type as ( typeof OBSERVED_CONSOLE_MESSAGE_TYPES )[ number ]
|
|
46
|
-
)
|
|
47
|
-
) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const text = message.text();
|
|
52
|
-
|
|
53
|
-
// An exception is made for _blanket_ deprecation warnings: Those
|
|
54
|
-
// which log regardless of whether a deprecated feature is in use.
|
|
55
|
-
if ( text.includes( 'This is a global warning' ) ) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// A chrome advisory warning about SameSite cookies is informational
|
|
60
|
-
// about future changes, tracked separately for improvement in core.
|
|
61
|
-
//
|
|
62
|
-
// See: https://core.trac.wordpress.org/ticket/37000
|
|
63
|
-
// See: https://www.chromestatus.com/feature/5088147346030592
|
|
64
|
-
// See: https://www.chromestatus.com/feature/5633521622188032
|
|
65
|
-
if (
|
|
66
|
-
text.includes( 'A cookie associated with a cross-site resource' ) ||
|
|
67
|
-
text.includes(
|
|
68
|
-
'https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite'
|
|
69
|
-
)
|
|
70
|
-
) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Viewing posts on the front end can result in this error, which
|
|
75
|
-
// has nothing to do with Gutenberg.
|
|
76
|
-
if ( text.includes( 'net::ERR_UNKNOWN_URL_SCHEME' ) ) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// TODO: Not implemented yet.
|
|
81
|
-
// Network errors are ignored only if we are intentionally testing
|
|
82
|
-
// offline mode.
|
|
83
|
-
// if (
|
|
84
|
-
// text.includes( 'net::ERR_INTERNET_DISCONNECTED' ) &&
|
|
85
|
-
// isOfflineMode()
|
|
86
|
-
// ) {
|
|
87
|
-
// return;
|
|
88
|
-
// }
|
|
89
|
-
|
|
90
|
-
// As of WordPress 5.3.2 in Chrome 79, navigating to the block editor
|
|
91
|
-
// (Posts > Add New) will display a console warning about
|
|
92
|
-
// non - unique IDs.
|
|
93
|
-
// See: https://core.trac.wordpress.org/ticket/23165
|
|
94
|
-
if ( text.includes( 'elements with non-unique id #_wpnonce' ) ) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Ignore all JQMIGRATE (jQuery migrate) deprecation warnings.
|
|
99
|
-
if ( text.includes( 'JQMIGRATE' ) ) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=1404468
|
|
104
|
-
if (
|
|
105
|
-
text.includes( 'Layout was forced before the page was fully loaded' )
|
|
106
|
-
) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Deprecated warnings coming from the third-party libraries.
|
|
111
|
-
if ( text.includes( 'MouseEvent.moz' ) ) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const logFunction =
|
|
116
|
-
type as ( typeof OBSERVED_CONSOLE_MESSAGE_TYPES )[ number ];
|
|
117
|
-
|
|
118
|
-
// Disable reason: We intentionally bubble up the console message
|
|
119
|
-
// which, unless the test explicitly anticipates the logging via
|
|
120
|
-
// @wordpress/jest-console matchers, will cause the intended test
|
|
121
|
-
// failure.
|
|
122
|
-
// eslint-disable-next-line no-console
|
|
123
|
-
console[ logFunction ]( text );
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const test = base.extend<
|
|
127
|
-
{
|
|
128
|
-
admin: Admin;
|
|
129
|
-
editor: Editor;
|
|
130
|
-
pageUtils: PageUtils;
|
|
131
|
-
snapshotConfig: void;
|
|
132
|
-
metrics: Metrics;
|
|
133
|
-
lighthouse: Lighthouse;
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
requestUtils: RequestUtils;
|
|
137
|
-
lighthousePort: number;
|
|
138
|
-
}
|
|
139
|
-
>( {
|
|
140
|
-
admin: async ( { page, pageUtils, editor }, use ) => {
|
|
141
|
-
await use( new Admin( { page, pageUtils, editor } ) );
|
|
142
|
-
},
|
|
143
|
-
editor: async ( { page }, use ) => {
|
|
144
|
-
await use( new Editor( { page } ) );
|
|
145
|
-
},
|
|
146
|
-
page: async ( { page }, use ) => {
|
|
147
|
-
page.on( 'console', observeConsoleLogging );
|
|
148
|
-
|
|
149
|
-
await use( page );
|
|
150
|
-
|
|
151
|
-
// Clear local storage after each test.
|
|
152
|
-
// This needs to be wrapped with a try/catch because it can fail when
|
|
153
|
-
// the test is skipped (e.g. via fixme).
|
|
154
|
-
try {
|
|
155
|
-
await page.evaluate( () => {
|
|
156
|
-
window.localStorage.clear();
|
|
157
|
-
} );
|
|
158
|
-
} catch {
|
|
159
|
-
// noop.
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
await page.close();
|
|
163
|
-
},
|
|
164
|
-
pageUtils: async ( { page, browserName }, use ) => {
|
|
165
|
-
await use( new PageUtils( { page, browserName } ) );
|
|
166
|
-
},
|
|
167
|
-
requestUtils: [
|
|
168
|
-
async ( {}, use, workerInfo ) => {
|
|
169
|
-
const requestUtils = await RequestUtils.setup( {
|
|
170
|
-
baseURL: workerInfo.project.use.baseURL,
|
|
171
|
-
storageStatePath: STORAGE_STATE_PATH,
|
|
172
|
-
} );
|
|
173
|
-
|
|
174
|
-
await use( requestUtils );
|
|
175
|
-
},
|
|
176
|
-
{ scope: 'worker', auto: true },
|
|
177
|
-
],
|
|
178
|
-
// Spins up a new browser for use by the Lighthouse fixture
|
|
179
|
-
// so that Lighthouse can connect to the debugging port.
|
|
180
|
-
// As a worker-scoped fixture, this will only launch 1
|
|
181
|
-
// instance for the whole test worker, so multiple tests
|
|
182
|
-
// will share the same instance with the same port.
|
|
183
|
-
lighthousePort: [
|
|
184
|
-
async ( {}, use ) => {
|
|
185
|
-
const port = await getPort();
|
|
186
|
-
const browser = await chromium.launch( {
|
|
187
|
-
args: [ `--remote-debugging-port=${ port }` ],
|
|
188
|
-
} );
|
|
189
|
-
|
|
190
|
-
await use( port );
|
|
191
|
-
|
|
192
|
-
await browser.close();
|
|
193
|
-
},
|
|
194
|
-
{ scope: 'worker' },
|
|
195
|
-
],
|
|
196
|
-
lighthouse: async ( { page, lighthousePort }, use ) => {
|
|
197
|
-
await use( new Lighthouse( { page, port: lighthousePort } ) );
|
|
198
|
-
},
|
|
199
|
-
metrics: async ( { page }, use ) => {
|
|
200
|
-
await use( new Metrics( { page } ) );
|
|
201
|
-
},
|
|
202
|
-
} );
|
|
203
|
-
|
|
204
|
-
export { test, expect };
|
package/src/types.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
declare global {
|
|
5
|
-
interface Window {
|
|
6
|
-
// Silence the warning for `window.wp` in Playwright's evaluate functions.
|
|
7
|
-
wp: any;
|
|
8
|
-
// Helper function added by Metrics fixture for web-vitals.js.
|
|
9
|
-
__reportVitals__: ( data: string ) => void;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export {};
|