-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Visual E2E testing for Paragraph, Heading and List blocks
- Loading branch information
Gerardo
committed
May 19, 2023
1 parent
ba42293
commit 1e3aac8
Showing
65 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
237 changes: 237 additions & 0 deletions
237
__device-tests__/gutenberg-editor-functionality-test-themes-visual.test.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,237 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
const { blockNames } = editorPage; | ||
const { setThemeJSONFromClipboard, isAndroid } = e2eUtils; | ||
import { fetchTheme, takeScreenshot } from './utils'; | ||
|
||
const THEMES = [ | ||
{ name: 'stewart' }, | ||
{ name: 'pixl' }, | ||
{ name: 'masu' }, | ||
{ name: 'twentytwentythree', isWordPressTheme: true }, | ||
]; | ||
|
||
describe( 'Block-based themes', () => { | ||
const THEMES_DATA = {}; | ||
|
||
beforeAll( async () => { | ||
for ( const theme of THEMES ) { | ||
try { | ||
const themeData = await fetchTheme( theme ); | ||
THEMES_DATA[ theme.name ] = themeData; | ||
} catch ( error ) { | ||
// eslint-disable-next-line no-console | ||
console.error( | ||
`Failed to fetch data for theme ${ theme.name }:`, | ||
error | ||
); | ||
} | ||
} | ||
} ); | ||
|
||
test.each( THEMES )( | ||
'$name renders colors and font-size for paragraph and heading blocks', | ||
async ( currentTheme ) => { | ||
// Set theme | ||
await setThemeJSONFromClipboard( | ||
editorPage.driver, | ||
THEMES_DATA[ currentTheme.name ] | ||
); | ||
|
||
await editorPage.addNewBlock( blockNames.paragraph ); | ||
const paragraphBlockElement = await editorPage.getTextBlockAtPosition( | ||
blockNames.paragraph | ||
); | ||
await editorPage.typeTextToTextBlock( | ||
paragraphBlockElement, | ||
e2eTestData.mediumText | ||
); | ||
|
||
const titleElement = await editorPage.getTitleElement(); | ||
await titleElement.click(); | ||
await editorPage.dismissKeyboard(); | ||
|
||
// Visual test check | ||
let screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
// Remove block | ||
const paragraphBlock = await editorPage.getBlockAtPosition( | ||
blockNames.paragraph | ||
); | ||
await paragraphBlock.click(); | ||
await editorPage.removeBlock(); | ||
|
||
// Add Heading blockº | ||
await editorPage.addNewBlock( blockNames.heading ); | ||
|
||
const headingBlockElement = await editorPage.getTextBlockAtPosition( | ||
blockNames.heading | ||
); | ||
await editorPage.typeTextToTextBlock( | ||
headingBlockElement, | ||
e2eTestData.shortText | ||
); | ||
|
||
// Test Heading block level 1 | ||
await changeHeadingLevel( 1 ); | ||
|
||
// Visual test check | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
// Test Heading block level 2 | ||
await headingBlockElement.click(); | ||
await changeHeadingLevel( 2 ); | ||
|
||
// Visual test check | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
// Test Heading block level 3 | ||
await headingBlockElement.click(); | ||
await changeHeadingLevel( 3 ); | ||
|
||
// Visual test check | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
// Test Heading block level 4 | ||
await headingBlockElement.click(); | ||
await changeHeadingLevel( 4 ); | ||
|
||
// Visual test check | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
// Remove blocks | ||
await headingBlockElement.click(); | ||
await editorPage.removeBlock(); | ||
} | ||
); | ||
|
||
test.each( THEMES )( | ||
'$name renders colors and font-size for a list block', | ||
async ( currentTheme ) => { | ||
// Set theme | ||
await setThemeJSONFromClipboard( | ||
editorPage.driver, | ||
THEMES_DATA[ currentTheme.name ] | ||
); | ||
|
||
await editorPage.addNewBlock( blockNames.list ); | ||
let listItemBlockElement = await editorPage.getListItemBlockTextInputAtPosition(); | ||
await editorPage.typeTextToTextBlock( | ||
listItemBlockElement, | ||
e2eTestData.shortText + '\n', | ||
false | ||
); | ||
|
||
listItemBlockElement = await editorPage.getListItemBlockTextInputAtPosition( | ||
2 | ||
); | ||
await editorPage.typeTextToTextBlock( | ||
listItemBlockElement, | ||
e2eTestData.listItem1 + '\n', | ||
false | ||
); | ||
|
||
listItemBlockElement = await editorPage.getListItemBlockTextInputAtPosition( | ||
3 | ||
); | ||
await editorPage.typeTextToTextBlock( | ||
listItemBlockElement, | ||
e2eTestData.listItem2 | ||
); | ||
|
||
let titleElement = await editorPage.getTitleElement(); | ||
await titleElement.click(); | ||
await editorPage.dismissKeyboard(); | ||
|
||
// Visual test check | ||
let screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await selectListBlock(); | ||
|
||
// Change font-size | ||
await editorPage.openBlockSettings(); | ||
const fontSizeLocator = isAndroid() | ||
? 'Custom, Navigates to select Custom' | ||
: 'Custom'; | ||
const fontSizeButton = await editorPage.waitForElementToBeDisplayedById( | ||
fontSizeLocator | ||
); | ||
await fontSizeButton.click(); | ||
|
||
// Wait for screen transition | ||
await editorPage.driver.sleep( 2000 ); | ||
|
||
// Visual test check | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
const fontSizeElementLocator = isAndroid() | ||
? '//android.widget.Button[5][contains(@content-desc, "Double tap to select font size")]' | ||
: '//XCUIElementTypeOther[starts-with(@name, "Selected")]//XCUIElementTypeButton[5]'; | ||
const newFontSizeElement = await editorPage.waitForElementToBeDisplayedByXPath( | ||
fontSizeElementLocator | ||
); | ||
await newFontSizeElement.click(); | ||
|
||
// Wait for new font to be re-rendered | ||
await editorPage.driver.sleep( 2000 ); | ||
|
||
await editorPage.dismissBottomSheet(); | ||
|
||
// Wait for the modal to close | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
titleElement = await editorPage.getTitleElement(); | ||
await titleElement.click(); | ||
await editorPage.dismissKeyboard(); | ||
|
||
// Visual test check | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await selectListBlock(); | ||
await editorPage.removeBlock(); | ||
} | ||
); | ||
} ); | ||
|
||
async function changeHeadingLevel( level ) { | ||
const changeHeadingLevelButton = await editorPage.waitForElementToBeDisplayedById( | ||
'Change heading level' | ||
); | ||
await changeHeadingLevelButton.click(); | ||
|
||
const headingLevelButton = await editorPage.waitForElementToBeDisplayedById( | ||
`Heading ${ level }` | ||
); | ||
await headingLevelButton.click(); | ||
|
||
// Wait for font to be re-rendered | ||
await editorPage.driver.sleep( 2000 ); | ||
|
||
const titleElement = await editorPage.getTitleElement( { | ||
autoscroll: true, | ||
} ); | ||
await titleElement.click(); | ||
|
||
// Wait for the scrollbar to hide | ||
await editorPage.driver.sleep( 3000 ); | ||
await editorPage.dismissKeyboard(); | ||
} | ||
|
||
async function selectListBlock() { | ||
const listBlockElement = await editorPage.getBlockAtPosition( | ||
blockNames.list | ||
); | ||
await listBlockElement.click(); | ||
|
||
editorPage.moveBlockSelectionUp(); | ||
await editorPage.driver.sleep( 2000 ); | ||
} |
Binary file added
BIN
+21.7 KB
...k-based-themes-masu-renders-colors-and-font-size-for-a-list-block-1-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+31.7 KB
...block-based-themes-masu-renders-colors-and-font-size-for-a-list-block-1-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.7 KB
...k-based-themes-masu-renders-colors-and-font-size-for-a-list-block-2-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+68.9 KB
...block-based-themes-masu-renders-colors-and-font-size-for-a-list-block-2-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.3 KB
...k-based-themes-masu-renders-colors-and-font-size-for-a-list-block-3-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.7 KB
...block-based-themes-masu-renders-colors-and-font-size-for-a-list-block-3-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.1 KB
...asu-renders-colors-and-font-size-for-paragraph-and-heading-blocks-1-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+50.5 KB
...es-masu-renders-colors-and-font-size-for-paragraph-and-heading-blocks-1-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.3 KB
...asu-renders-colors-and-font-size-for-paragraph-and-heading-blocks-2-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+56.2 KB
...es-masu-renders-colors-and-font-size-for-paragraph-and-heading-blocks-2-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.3 KB
...asu-renders-colors-and-font-size-for-paragraph-and-heading-blocks-3-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.3 KB
...es-masu-renders-colors-and-font-size-for-paragraph-and-heading-blocks-3-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30 KB
...asu-renders-colors-and-font-size-for-paragraph-and-heading-blocks-4-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.7 KB
...es-masu-renders-colors-and-font-size-for-paragraph-and-heading-blocks-4-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.7 KB
...asu-renders-colors-and-font-size-for-paragraph-and-heading-blocks-5-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.6 KB
...es-masu-renders-colors-and-font-size-for-paragraph-and-heading-blocks-5-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.6 KB
...k-based-themes-pixl-renders-colors-and-font-size-for-a-list-block-1-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.2 KB
...block-based-themes-pixl-renders-colors-and-font-size-for-a-list-block-1-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+32.7 KB
...k-based-themes-pixl-renders-colors-and-font-size-for-a-list-block-2-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+55.1 KB
...block-based-themes-pixl-renders-colors-and-font-size-for-a-list-block-2-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.1 KB
...k-based-themes-pixl-renders-colors-and-font-size-for-a-list-block-3-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.3 KB
...block-based-themes-pixl-renders-colors-and-font-size-for-a-list-block-3-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.4 KB
...ixl-renders-colors-and-font-size-for-paragraph-and-heading-blocks-1-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.2 KB
...es-pixl-renders-colors-and-font-size-for-paragraph-and-heading-blocks-1-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.2 KB
...ixl-renders-colors-and-font-size-for-paragraph-and-heading-blocks-2-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+31.8 KB
...es-pixl-renders-colors-and-font-size-for-paragraph-and-heading-blocks-2-ios.png
Oops, something went wrong.
Binary file added
BIN
+18.4 KB
...ixl-renders-colors-and-font-size-for-paragraph-and-heading-blocks-3-android.png
Oops, something went wrong.
Binary file added
BIN
+29.2 KB
...es-pixl-renders-colors-and-font-size-for-paragraph-and-heading-blocks-3-ios.png
Oops, something went wrong.
Binary file added
BIN
+17.3 KB
...ixl-renders-colors-and-font-size-for-paragraph-and-heading-blocks-4-android.png
Oops, something went wrong.
Binary file added
BIN
+27.6 KB
...es-pixl-renders-colors-and-font-size-for-paragraph-and-heading-blocks-4-ios.png
Oops, something went wrong.
Binary file added
BIN
+17.4 KB
...ixl-renders-colors-and-font-size-for-paragraph-and-heading-blocks-5-android.png
Oops, something went wrong.
Binary file added
BIN
+27.6 KB
...es-pixl-renders-colors-and-font-size-for-paragraph-and-heading-blocks-5-ios.png
Oops, something went wrong.
Binary file added
BIN
+19.7 KB
...ased-themes-stewart-renders-colors-and-font-size-for-a-list-block-1-android.png
Oops, something went wrong.
Binary file added
BIN
+33.4 KB
...ck-based-themes-stewart-renders-colors-and-font-size-for-a-list-block-1-ios.png
Oops, something went wrong.
Binary file added
BIN
+40.5 KB
...ased-themes-stewart-renders-colors-and-font-size-for-a-list-block-2-android.png
Oops, something went wrong.
Binary file added
BIN
+69.8 KB
...ck-based-themes-stewart-renders-colors-and-font-size-for-a-list-block-2-ios.png
Oops, something went wrong.
Binary file added
BIN
+22.5 KB
...ased-themes-stewart-renders-colors-and-font-size-for-a-list-block-3-android.png
Oops, something went wrong.
Binary file added
BIN
+36.9 KB
...ck-based-themes-stewart-renders-colors-and-font-size-for-a-list-block-3-ios.png
Oops, something went wrong.
Binary file added
BIN
+31.3 KB
...art-renders-colors-and-font-size-for-paragraph-and-heading-blocks-1-android.png
Oops, something went wrong.
Binary file added
BIN
+54.1 KB
...stewart-renders-colors-and-font-size-for-paragraph-and-heading-blocks-1-ios.png
Oops, something went wrong.
Binary file added
BIN
+31.1 KB
...art-renders-colors-and-font-size-for-paragraph-and-heading-blocks-2-android.png
Oops, something went wrong.
Binary file added
BIN
+56.1 KB
...stewart-renders-colors-and-font-size-for-paragraph-and-heading-blocks-2-ios.png
Oops, something went wrong.
Binary file added
BIN
+26.6 KB
...art-renders-colors-and-font-size-for-paragraph-and-heading-blocks-3-android.png
Oops, something went wrong.
Binary file added
BIN
+45.4 KB
...stewart-renders-colors-and-font-size-for-paragraph-and-heading-blocks-3-ios.png
Oops, something went wrong.
Binary file added
BIN
+24.2 KB
...art-renders-colors-and-font-size-for-paragraph-and-heading-blocks-4-android.png
Oops, something went wrong.
Binary file added
BIN
+42.2 KB
...stewart-renders-colors-and-font-size-for-paragraph-and-heading-blocks-4-ios.png
Oops, something went wrong.
Binary file added
BIN
+20.4 KB
...art-renders-colors-and-font-size-for-paragraph-and-heading-blocks-5-android.png
Oops, something went wrong.
Binary file added
BIN
+33.4 KB
...stewart-renders-colors-and-font-size-for-paragraph-and-heading-blocks-5-ios.png
Oops, something went wrong.
Binary file added
BIN
+19.7 KB
...s-twentytwentythree-renders-colors-and-font-size-for-a-list-block-1-android.png
Oops, something went wrong.
Binary file added
BIN
+26.8 KB
...hemes-twentytwentythree-renders-colors-and-font-size-for-a-list-block-1-ios.png
Oops, something went wrong.
Binary file added
BIN
+38.9 KB
...s-twentytwentythree-renders-colors-and-font-size-for-a-list-block-2-android.png
Oops, something went wrong.
Binary file added
BIN
+56.8 KB
...hemes-twentytwentythree-renders-colors-and-font-size-for-a-list-block-2-ios.png
Oops, something went wrong.
Binary file added
BIN
+31.5 KB
...s-twentytwentythree-renders-colors-and-font-size-for-a-list-block-3-android.png
Oops, something went wrong.
Binary file added
BIN
+40.6 KB
...hemes-twentytwentythree-renders-colors-and-font-size-for-a-list-block-3-ios.png
Oops, something went wrong.
Binary file added
BIN
+30.2 KB
...ree-renders-colors-and-font-size-for-paragraph-and-heading-blocks-1-android.png
Oops, something went wrong.
Binary file added
BIN
+39.9 KB
...tythree-renders-colors-and-font-size-for-paragraph-and-heading-blocks-1-ios.png
Oops, something went wrong.
Binary file added
BIN
+36.4 KB
...ree-renders-colors-and-font-size-for-paragraph-and-heading-blocks-2-android.png
Oops, something went wrong.
Binary file added
BIN
+46.9 KB
...tythree-renders-colors-and-font-size-for-paragraph-and-heading-blocks-2-ios.png
Oops, something went wrong.
Binary file added
BIN
+29.5 KB
...ree-renders-colors-and-font-size-for-paragraph-and-heading-blocks-3-android.png
Oops, something went wrong.
Binary file added
BIN
+39.4 KB
...tythree-renders-colors-and-font-size-for-paragraph-and-heading-blocks-3-ios.png
Oops, something went wrong.
Binary file added
BIN
+27.3 KB
...ree-renders-colors-and-font-size-for-paragraph-and-heading-blocks-4-android.png
Oops, something went wrong.
Binary file added
BIN
+35.3 KB
...tythree-renders-colors-and-font-size-for-paragraph-and-heading-blocks-4-ios.png
Oops, something went wrong.
Binary file added
BIN
+24.1 KB
...ree-renders-colors-and-font-size-for-paragraph-and-heading-blocks-5-android.png
Oops, something went wrong.
Binary file added
BIN
+31.2 KB
...tythree-renders-colors-and-font-size-for-paragraph-and-heading-blocks-5-ios.png
Oops, something went wrong.