From c3ae088a3b7182630819d54f73231abcbe736e86 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 25 Oct 2022 09:35:04 +0400 Subject: [PATCH] Migrate Gallery tests to Playwright (#45202) * Migrate Gallery caption tests to Playwright * Fully migrate * No need to select gallery * Use editor.selectBlocks utility * Copy full body for skipped test --- .../specs/editor/blocks/gallery.test.js | 156 ---------------- test/e2e/specs/editor/blocks/gallery.spec.js | 173 ++++++++++++++++++ 2 files changed, 173 insertions(+), 156 deletions(-) delete mode 100644 packages/e2e-tests/specs/editor/blocks/gallery.test.js diff --git a/packages/e2e-tests/specs/editor/blocks/gallery.test.js b/packages/e2e-tests/specs/editor/blocks/gallery.test.js deleted file mode 100644 index 79bd8a3441d1bd..00000000000000 --- a/packages/e2e-tests/specs/editor/blocks/gallery.test.js +++ /dev/null @@ -1,156 +0,0 @@ -/** - * External dependencies - */ -import path from 'path'; -import fs from 'fs'; -import os from 'os'; -import { v4 as uuid } from 'uuid'; - -/** - * WordPress dependencies - */ -import { - insertBlock, - getEditedPostContent, - createNewPost, - clickButton, - openListView, - getListViewBlocks, - clickBlockToolbarButton, -} from '@wordpress/e2e-test-utils'; - -async function upload( selector ) { - await page.waitForSelector( selector ); - const inputElement = await page.$( selector ); - const testImagePath = path.join( - __dirname, - '..', - '..', - '..', - 'assets', - '10x10_e2e_test_image_z9T8jK.png' - ); - const filename = uuid(); - const tmpFileName = path.join( os.tmpdir(), filename + '.png' ); - fs.copyFileSync( testImagePath, tmpFileName ); - await inputElement.uploadFile( tmpFileName ); - await page.waitForSelector( - `.wp-block-gallery img[src$="${ filename }.png"]` - ); - return filename; -} - -describe( 'Gallery', () => { - beforeEach( async () => { - await createNewPost(); - } ); - - it( 'can be created using uploaded images', async () => { - await insertBlock( 'Gallery' ); - const filename = await upload( '.wp-block-gallery input[type="file"]' ); - - const regex = new RegExp( - `\\s*