-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate utils into PageUtils and RequestUtils
- Loading branch information
1 parent
3f34fa2
commit 9851ff3
Showing
37 changed files
with
695 additions
and
490 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...est-utils-playwright/src/shared/config.js → ...s/e2e-test-utils-playwright/src/config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
packages/e2e-test-utils-playwright/src/deactivate-plugin.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,5 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { Browser, Page, BrowserContext } from '@playwright/test'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { activatePlugin } from './activate-plugin'; | ||
import { activateTheme } from './activate-theme'; | ||
import { deleteAllBlocks } from './blocks'; | ||
import { clickBlockToolbarButton } from './click-block-toolbar-button'; | ||
import { createNewPost } from './create-new-post'; | ||
import { createURL } from './create-url'; | ||
import { deactivatePlugin } from './deactivate-plugin'; | ||
import { getCurrentUser } from './get-current-user'; | ||
import { getPageError } from './get-page-error'; | ||
import { isCurrentURL } from './is-current-url'; | ||
import { loginUser } from './login-user'; | ||
import { deleteAllPosts } from './posts'; | ||
import { | ||
rest as __experimentalRest, | ||
batch as __experimentalBatch, | ||
} from './rest-api'; | ||
import { showBlockToolbar } from './show-block-toolbar'; | ||
import { switchUserToAdmin } from './switch-user-to-admin'; | ||
import { switchUserToTest } from './switch-user-to-test'; | ||
import { visitAdminPage } from './visit-admin-page'; | ||
import { deleteAllWidgets } from './widgets'; | ||
|
||
class TestUtils { | ||
browser: Browser; | ||
page: Page; | ||
context: BrowserContext; | ||
|
||
constructor( page: Page ) { | ||
this.page = page; | ||
this.context = page.context(); | ||
this.browser = this.context.browser()!; | ||
} | ||
|
||
activatePlugin = activatePlugin; | ||
activateTheme = activateTheme; | ||
clickBlockToolbarButton = clickBlockToolbarButton; | ||
createNewPost = createNewPost; | ||
createURL = createURL; | ||
deactivatePlugin = deactivatePlugin; | ||
deleteAllBlocks = deleteAllBlocks; | ||
deleteAllPosts = deleteAllPosts; | ||
getCurrentUser = getCurrentUser; | ||
getPageError = getPageError; | ||
isCurrentURL = isCurrentURL; | ||
loginUser = loginUser; | ||
showBlockToolbar = showBlockToolbar; | ||
switchUserToAdmin = switchUserToAdmin; | ||
switchUserToTest = switchUserToTest; | ||
visitAdminPage = visitAdminPage; | ||
deleteAllWidgets = deleteAllWidgets; | ||
__experimentalRest = __experimentalRest; | ||
__experimentalBatch = __experimentalBatch; | ||
} | ||
|
||
export { TestUtils }; | ||
export { PageUtils } from './page'; | ||
export { RequestUtils } from './request'; |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ywright/src/click-block-toolbar-button.js → ...ht/src/page/click-block-toolbar-button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...-utils-playwright/src/get-current-user.js → ...s-playwright/src/page/get-current-user.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { Browser, Page, BrowserContext } from '@playwright/test'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { clickBlockToolbarButton } from './click-block-toolbar-button'; | ||
import { createNewPost } from './create-new-post'; | ||
import { getCurrentUser } from './get-current-user'; | ||
import { getPageError } from './get-page-error'; | ||
import { isCurrentURL } from './is-current-url'; | ||
import { loginUser } from './login-user'; | ||
import { showBlockToolbar } from './show-block-toolbar'; | ||
import { switchUserToAdmin } from './switch-user-to-admin'; | ||
import { switchUserToTest } from './switch-user-to-test'; | ||
import { visitAdminPage } from './visit-admin-page'; | ||
|
||
class PageUtils { | ||
browser: Browser; | ||
page: Page; | ||
context: BrowserContext; | ||
|
||
constructor( page: Page ) { | ||
this.page = page; | ||
this.context = page.context(); | ||
this.browser = this.context.browser()!; | ||
} | ||
|
||
clickBlockToolbarButton = clickBlockToolbarButton; | ||
createNewPost = createNewPost; | ||
getCurrentUser = getCurrentUser; | ||
getPageError = getPageError; | ||
isCurrentURL = isCurrentURL; | ||
loginUser = loginUser; | ||
showBlockToolbar = showBlockToolbar; | ||
switchUserToAdmin = switchUserToAdmin; | ||
switchUserToTest = switchUserToTest; | ||
visitAdminPage = visitAdminPage; | ||
} | ||
|
||
export { PageUtils }; |
18 changes: 18 additions & 0 deletions
18
packages/e2e-test-utils-playwright/src/page/is-current-url.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { WP_BASE_URL } from '../config'; | ||
|
||
/** | ||
* Checks if current URL is a WordPress path. | ||
* | ||
* @this {import('./').PageUtils} | ||
* @param {string} WPPath String to be serialized as pathname. | ||
* @return {boolean} Boolean represents whether current URL is or not a WordPress path. | ||
*/ | ||
export function isCurrentURL( WPPath ) { | ||
const currentURL = new URL( this.page.url() ); | ||
const expectedURL = new URL( WPPath, WP_BASE_URL ); | ||
|
||
return expectedURL.pathname === currentURL.pathname; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.