react-code-dataset / wp-calypso /packages /calypso-e2e /src /lib /components /block-widget-editor-component.ts
react-code-dataset / wp-calypso /packages /calypso-e2e /src /lib /components /block-widget-editor-component.ts
Download wp-calypso/packages/calypso-e2e/src/lib/components/block-widget-editor-component.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/calypso-e2e/src/lib/components/block-widget-editor-component.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/calypso-e2e/src/lib/components/block-widget-editor-component.ts
-
curl -L -o block-widget-editor-component.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/calypso-e2e/src/lib/components/block-widget-editor-component.ts
1.39 kB
| import { Page } from 'playwright'; | |
| const selectors = { | |
| editor: '#widgets-editor', | |
| // Welcome Guide and Welcome Tour | |
| welcomeModalDismissButton: 'div.components-modal__header > button', // Instead of aria-label, which changes depending on English UK/US. | |
| welcomeTourDismissButton: 'button[aria-label="Close Tour"]', | |
| // Block Widget editor | |
| addBlockButton: 'button[aria-label="Add block"]', | |
| blockSearch: 'input[placeholder="Search"]', | |
| }; | |
| /** | |
| * Component for the block-based Widget editor in Appearance > Widgets. | |
| */ | |
| export class BlockWidgetEditorComponent { | |
| private page: Page; | |
| /** | |
| * Constructs an instance of the component. | |
| * | |
| * @param {Page} page The underlying page. | |
| */ | |
| constructor( page: Page ) { | |
| this.page = page; | |
| } | |
| /** | |
| * Dismiss any welcome modals that appear. | |
| * | |
| * These include: | |
| * - Welcome modal | |
| * - Welcome Tour | |
| */ | |
| async dismissModals(): Promise< void > { | |
| await this.page.waitForLoadState( 'networkidle' ); | |
| const locators = [ | |
| this.page.locator( selectors.welcomeModalDismissButton ), | |
| this.page.locator( selectors.welcomeTourDismissButton ), | |
| ]; | |
| for await ( const locator of locators ) { | |
| try { | |
| // Whether Welcome Tour appears is not deterministic. | |
| // If it is not present, exit early. | |
| if ( ( await locator.count() ) === 0 ) { | |
| return; | |
| } | |
| await locator.click(); | |
| } catch { | |
| //noop | |
| } | |
| } | |
| } | |
| } | |