Download wp-calypso/packages/calypso-e2e/src/lib/blocks/logos-block.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/calypso-e2e/src/lib/blocks/logos-block.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/calypso-e2e/src/lib/blocks/logos-block.ts
-
curl -L -o logos-block.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/calypso-e2e/src/lib/blocks/logos-block.ts
1.59 kB
| import { Page, ElementHandle } from 'playwright'; | |
| const selectors = { | |
| block: '.wp-block-coblocks-logos', | |
| fileInput: '.components-form-file-upload input[type="file"]', | |
| imageTitleData: ( filename: string ) => | |
| `${ selectors.block } img[data-image-title*="${ filename }" i]`, | |
| }; | |
| /** | |
| * Represents the Logos coblock. | |
| */ | |
| export class LogosBlock { | |
| static blockName = 'Logos'; | |
| static blockEditorSelector = '[aria-label="Block: Logos"]'; | |
| block: ElementHandle; | |
| /** | |
| * Constructs an instance of this block. | |
| * | |
| * @param {ElementHandle} block Handle referencing the block as inserted on the Gutenberg editor. | |
| */ | |
| constructor( block: ElementHandle ) { | |
| this.block = block; | |
| } | |
| /** | |
| * Uplaods the target file at the supplied path to WPCOM. | |
| * | |
| * @param {string} filePath Path to the file on disk. | |
| */ | |
| async upload( filePath: string ): Promise< void > { | |
| const input = await this.block.waitForSelector( selectors.fileInput, { state: 'attached' } ); | |
| await input.setInputFiles( filePath ); | |
| await Promise.all( [ | |
| this.block.waitForSelector( 'img:not([src^="blob:"])' ), | |
| this.block.waitForElementState( 'stable' ), | |
| ] ); | |
| } | |
| /** | |
| * Validates block on the page. | |
| * | |
| * @param {Page} page Page on which to verify the presence of the block. | |
| * @param {string} contents Contents used to validate the block. | |
| * @returns {Promise<void>} No return value. | |
| */ | |
| static async validatePublishedContent( page: Page, contents: string[] ): Promise< void > { | |
| for await ( const content of contents ) { | |
| await page.waitForSelector( selectors.imageTitleData( content ) ); | |
| } | |
| } | |
| } | |