-
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.
Visual testing - Add Sanity test suite 4
- Loading branch information
Gerardo
committed
Mar 1, 2023
1 parent
12fda0f
commit 699d17e
Showing
19 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
227 changes: 227 additions & 0 deletions
227
__device-tests__/gutenberg-editor-sanity-test-4-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,227 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
const { blockNames } = editorPage; | ||
const { toggleOrientation, selectTextFromTextInput, setClipboard } = e2eUtils; | ||
import { takeScreenshot } from './utils'; | ||
|
||
describe( 'Gutenberg Editor - Test Suite 4', () => { | ||
it( 'Spacer block - Spacer in horizontal layout works as expected', async () => { | ||
await editorPage.addNewBlock( blockNames.spacer ); | ||
|
||
await toggleOrientation( editorPage.driver ); | ||
|
||
// Wait for the device to finish rotating | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
// Visual test check for selected state | ||
let screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
const titleElement = await editorPage.getTitleElement( { | ||
autoscroll: true, | ||
} ); | ||
await titleElement.click(); | ||
|
||
await editorPage.dismissKeyboard(); | ||
|
||
// Visual test check for unselected state | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await toggleOrientation( editorPage.driver ); | ||
|
||
// Wait for the device to finish rotating | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
const spaceBlock = await editorPage.getBlockAtPosition( | ||
blockNames.spacer | ||
); | ||
await spaceBlock.click(); | ||
await editorPage.removeBlock(); | ||
} ); | ||
|
||
describe( 'Buttons block', () => { | ||
const buttonCustomColors = `<!-- wp:buttons --> | ||
<div class="wp-block-buttons"><!-- wp:button {"style":{"color":{"background":"#b1005b","text":"#ffe6f2"}}} --> | ||
<div class="wp-block-button"><a class="wp-block-button__link has-text-color has-background wp-element-button" style="color:#ffe6f2;background-color:#b1005b">Button</a></div> | ||
<!-- /wp:button --></div> | ||
<!-- /wp:buttons -->`; | ||
|
||
it( 'Render custom text and background color', async () => { | ||
await editorPage.setHtmlContent( buttonCustomColors ); | ||
|
||
const buttonsBlock = await editorPage.getBlockAtPosition( | ||
blockNames.buttons | ||
); | ||
expect( buttonsBlock ).toBeTruthy(); | ||
|
||
// Visual test check | ||
const screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await buttonsBlock.click(); | ||
await editorPage.removeBlockAtPosition( blockNames.buttons ); | ||
} ); | ||
|
||
it( 'Render gradient background color', async () => { | ||
const testData = `<!-- wp:buttons --> | ||
<div class="wp-block-buttons"><!-- wp:button {"gradient":"luminous-dusk"} --> | ||
<div class="wp-block-button"><a class="wp-block-button__link has-luminous-dusk-gradient-background has-background wp-element-button">Button</a></div> | ||
<!-- /wp:button --></div> | ||
<!-- /wp:buttons -->`; | ||
|
||
await editorPage.setHtmlContent( testData ); | ||
|
||
const buttonsBlock = await editorPage.getBlockAtPosition( | ||
blockNames.buttons | ||
); | ||
expect( buttonsBlock ).toBeTruthy(); | ||
|
||
// Visual test check | ||
const screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await buttonsBlock.click(); | ||
await editorPage.removeBlockAtPosition( blockNames.buttons ); | ||
} ); | ||
|
||
it( 'Check if selection / caret color matches font color', async () => { | ||
await editorPage.setHtmlContent( buttonCustomColors ); | ||
|
||
const buttonsBlock = await editorPage.getBlockAtPosition( | ||
blockNames.buttons | ||
); | ||
await buttonsBlock.click(); | ||
|
||
const buttonBlock = await editorPage.getBlockAtPosition( | ||
blockNames.button | ||
); | ||
await buttonBlock.click(); | ||
|
||
// Get button's block TextInput | ||
const buttonBlockTextInput = await editorPage.getButtonBlockTextInputAtPosition(); | ||
await selectTextFromTextInput( | ||
editorPage.driver, | ||
buttonBlockTextInput | ||
); | ||
|
||
// Visual test check | ||
const screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await buttonBlockTextInput.click(); | ||
|
||
await editorPage.removeBlockAtPosition( blockNames.button ); | ||
} ); | ||
|
||
it( 'Edit text styles', async () => { | ||
await editorPage.addNewBlock( blockNames.buttons ); | ||
|
||
const buttonsBlock = await editorPage.getBlockAtPosition( | ||
blockNames.buttons | ||
); | ||
|
||
const firstButtonTextInput = await editorPage.getButtonBlockTextInputAtPosition(); | ||
await editorPage.typeTextToTextBlock( | ||
firstButtonTextInput, | ||
e2eTestData.listItem2 | ||
); | ||
await selectTextFromTextInput( | ||
editorPage.driver, | ||
firstButtonTextInput | ||
); | ||
|
||
// Toggle Bold formatting for the first Button block | ||
await editorPage.toggleFormatting( 'Bold' ); | ||
|
||
// Add a second button block | ||
await editorPage.addButtonWithInlineAppender( 2 ); | ||
const secondButtonTextInput = await editorPage.getButtonBlockTextInputAtPosition( | ||
2 | ||
); | ||
await editorPage.typeTextToTextBlock( | ||
secondButtonTextInput, | ||
e2eTestData.listItem2 | ||
); | ||
await selectTextFromTextInput( | ||
editorPage.driver, | ||
secondButtonTextInput | ||
); | ||
|
||
// Toggle Italic formatting for the first Button block | ||
await editorPage.toggleFormatting( 'Italic' ); | ||
|
||
// Add a third button block | ||
await editorPage.addButtonWithInlineAppender( 3 ); | ||
const thirdButtonTextInput = await editorPage.getButtonBlockTextInputAtPosition( | ||
3 | ||
); | ||
await editorPage.typeTextToTextBlock( | ||
thirdButtonTextInput, | ||
e2eTestData.listItem2 | ||
); | ||
await selectTextFromTextInput( | ||
editorPage.driver, | ||
thirdButtonTextInput | ||
); | ||
|
||
// Toggle Strikethrough formatting for the first Button block | ||
await editorPage.toggleFormatting( 'Strikethrough' ); | ||
|
||
// Unfocus the Buttons block | ||
const titleElement = await editorPage.getTitleElement( { | ||
autoscroll: true, | ||
} ); | ||
await titleElement.click(); | ||
|
||
await editorPage.dismissKeyboard(); | ||
|
||
// Visual test check for unselected state | ||
const screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await buttonsBlock.click(); | ||
await editorPage.removeBlockAtPosition( blockNames.buttons ); | ||
} ); | ||
|
||
it( 'Link from the clipboard is presented as an option in the link picker', async () => { | ||
await editorPage.addNewBlock( blockNames.buttons ); | ||
|
||
const link = 'https://wordpress.org/'; | ||
|
||
await setClipboard( editorPage.driver, link ); | ||
|
||
await editorPage.toggleFormatting( 'Edit link' ); | ||
await editorPage.openLinkToSettings(); | ||
|
||
// Wait for the modal to open | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
// Visual test check for the "From clipboard" option | ||
let screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
const clipboardLink = await editorPage.waitForElementToBeDisplayedById( | ||
`Copy URL from the clipboard, ${ link }` | ||
); | ||
await clipboardLink.click(); | ||
|
||
// Wait for the modal to close | ||
await editorPage.driver.sleep( 2000 ); | ||
|
||
// Visual test check for link settings | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await editorPage.dismissBottomSheet(); | ||
|
||
// Wait for the modal to close | ||
await editorPage.driver.sleep( 2000 ); | ||
|
||
// Visual test check for link formatting button | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
} ); | ||
} ); | ||
} ); |
Binary file added
BIN
+41.8 KB
...4-buttons-block-check-if-selection-caret-color-matches-font-color-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
+53.8 KB
...ite-4-buttons-block-check-if-selection-caret-color-matches-font-color-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
+15 KB
...t-js-gutenberg-editor-test-suite-4-buttons-block-edit-text-styles-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
+19.6 KB
...-test-js-gutenberg-editor-test-suite-4-buttons-block-edit-text-styles-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
+35.4 KB
...k-from-the-clipboard-is-presented-as-an-option-in-the-link-picker-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
+46.1 KB
...-link-from-the-clipboard-is-presented-as-an-option-in-the-link-picker-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
+24.6 KB
...k-from-the-clipboard-is-presented-as-an-option-in-the-link-picker-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.5 KB
...-link-from-the-clipboard-is-presented-as-an-option-in-the-link-picker-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
+16.3 KB
...k-from-the-clipboard-is-presented-as-an-option-in-the-link-picker-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.9 KB
...-link-from-the-clipboard-is-presented-as-an-option-in-the-link-picker-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
+12.5 KB
...est-suite-4-buttons-block-render-custom-text-and-background-color-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
+17.9 KB
...or-test-suite-4-buttons-block-render-custom-text-and-background-color-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
+15.6 KB
...ditor-test-suite-4-buttons-block-render-gradient-background-color-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
+20.5 KB
...rg-editor-test-suite-4-buttons-block-render-gradient-background-color-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
+9.99 KB
...uite-4-spacer-block-spacer-in-horizontal-layout-works-as-expected-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
+11.8 KB
...st-suite-4-spacer-block-spacer-in-horizontal-layout-works-as-expected-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
+14.9 KB
...uite-4-spacer-block-spacer-in-horizontal-layout-works-as-expected-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
+18.1 KB
...st-suite-4-spacer-block-spacer-in-horizontal-layout-works-as-expected-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.