-
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.
Merge pull request #5548 from wordpress-mobile/test/add-sanity-test-s…
…uite-1 test: Add Sanity Test Suite 1
- Loading branch information
Showing
20 changed files
with
308 additions
and
1 deletion.
There are no files selected for viewing
307 changes: 307 additions & 0 deletions
307
__device-tests__/gutenberg-editor-sanity-test-1-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,307 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
const { blockNames } = editorPage; | ||
import { takeScreenshot } from './utils'; | ||
const { | ||
toggleOrientation, | ||
isAndroid, | ||
swipeFromTo, | ||
toggleDarkMode, | ||
isEditorVisible, | ||
} = e2eUtils; | ||
|
||
describe( 'Gutenberg Editor - Test Suite 1', () => { | ||
describe( 'Columns block', () => { | ||
it( 'displays placeholders when unselected', async () => { | ||
await editorPage.addNewBlock( blockNames.columns ); | ||
// Wait for the modal to open | ||
await editorPage.driver.sleep( 3000 ); | ||
// Dismiss columns layout picker | ||
await editorPage.dismissBottomSheet(); | ||
// Wait for the modal to close | ||
await editorPage.driver.sleep( 3000 ); | ||
// Select title to unfocus the block | ||
const titleElement = await editorPage.getTitleElement(); | ||
await titleElement.click(); | ||
await editorPage.dismissKeyboard(); | ||
|
||
// Visual test check for portrait orientation | ||
let screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await toggleOrientation( editorPage.driver ); | ||
// Wait for the device to finish rotating | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
// Visual test check for landscape orientation | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await toggleOrientation( editorPage.driver ); | ||
// Wait for the device to finish rotating | ||
await editorPage.driver.sleep( 3000 ); | ||
const columnsBlock = await editorPage.getBlockAtPosition( | ||
blockNames.columns | ||
); | ||
await columnsBlock.click(); | ||
await editorPage.removeBlock(); | ||
} ); | ||
|
||
it( 'displays correctly in portrait and landscape orientations', async () => { | ||
await editorPage.addNewBlock( blockNames.columns ); | ||
// Wait for the modal to open | ||
await editorPage.driver.sleep( 3000 ); | ||
// Dismiss columns layout picker | ||
await editorPage.dismissBottomSheet(); | ||
// Wait for the modal to close | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
// Click the block appender within the first column | ||
if ( isAndroid() ) { | ||
await editorPage.driver | ||
.elementByAccessibilityId( 'Column Block. Row 1' ) | ||
.click(); | ||
const appenderButton = await editorPage.waitForElementToBeDisplayedByXPath( | ||
'(//android.view.ViewGroup[@content-desc="block-list"])[2]/android.widget.Button' | ||
); | ||
await appenderButton.click(); | ||
} else { | ||
await editorPage.driver | ||
.elementByAccessibilityId( 'Column Block. Row 1' ) | ||
.click() | ||
.click(); | ||
} | ||
|
||
await editorPage.addNewBlock( blockNames.columns, { | ||
skipInserterOpen: true, | ||
} ); | ||
|
||
// Wait for the modal to open | ||
await editorPage.driver.sleep( 3000 ); | ||
// Dismiss columns layout picker | ||
await editorPage.dismissBottomSheet(); | ||
// Wait for the modal to close | ||
await editorPage.driver.sleep( 3000 ); | ||
// Navigate upwards in block hierarchy | ||
await editorPage.driver | ||
.elementByAccessibilityId( 'Navigate Up' ) | ||
.click() | ||
.click(); | ||
await editorPage.driver.sleep( 1000 ); | ||
|
||
// Visual test check for portrait orientation | ||
let screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await toggleOrientation( editorPage.driver ); | ||
// Wait for the device to finish rotating | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
// Visual test check for landscape orientation | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await toggleOrientation( editorPage.driver ); | ||
// Wait for the device to finish rotating | ||
await editorPage.driver.sleep( 3000 ); | ||
await editorPage.removeBlock(); | ||
} ); | ||
|
||
it( 'mover buttons display in the correct positions', async () => { | ||
await editorPage.addNewBlock( blockNames.columns ); | ||
// Wait for the modal to open | ||
await editorPage.driver.sleep( 3000 ); | ||
// Dismiss columns layout picker | ||
await editorPage.dismissBottomSheet(); | ||
// Wait for the modal to close | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
// Click the block appender within the first column | ||
if ( isAndroid() ) { | ||
await editorPage.driver | ||
.elementByAccessibilityId( 'Column Block. Row 1' ) | ||
.click(); | ||
const appenderButton = await editorPage.waitForElementToBeDisplayedByXPath( | ||
'(//android.view.ViewGroup[@content-desc="block-list"])[2]/android.widget.Button' | ||
); | ||
await appenderButton.click(); | ||
} else { | ||
await editorPage.driver | ||
.elementByAccessibilityId( 'Column Block. Row 1' ) | ||
.click() | ||
.click(); | ||
} | ||
|
||
await editorPage.addNewBlock( blockNames.columns, { | ||
skipInserterOpen: true, | ||
} ); | ||
|
||
// Wait for the modal to open | ||
await editorPage.driver.sleep( 3000 ); | ||
// Dismiss columns layout picker | ||
await editorPage.dismissBottomSheet(); | ||
await toggleOrientation( editorPage.driver ); | ||
// Wait for the device to finish rotating | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
// Visual test check for landscape orientation | ||
let screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
// Navigate upwards in block hierarchy | ||
await editorPage.driver | ||
.elementByAccessibilityId( 'Navigate Up' ) | ||
.click(); | ||
await editorPage.driver.sleep( 1000 ); | ||
|
||
// Visual test check for landscape orientation | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await toggleOrientation( editorPage.driver ); | ||
// Wait for the device to finish rotating | ||
await editorPage.driver.sleep( 3000 ); | ||
// Navigate upwards in block hierarchy | ||
await editorPage.driver | ||
.elementByAccessibilityId( 'Navigate Up' ) | ||
.click(); | ||
await editorPage.driver.sleep( 1000 ); | ||
await editorPage.removeBlock(); | ||
} ); | ||
|
||
it( 'displays with correct colors with dark mode enabled', async () => { | ||
await toggleDarkMode( editorPage.driver, true ); | ||
|
||
// The Android editor requires a restart to apply dark mode | ||
if ( isAndroid() ) { | ||
await editorPage.driver.resetApp(); | ||
await isEditorVisible( editorPage.driver ); | ||
} | ||
|
||
await editorPage.addNewBlock( blockNames.columns ); | ||
// Wait for the modal to open | ||
await editorPage.driver.sleep( 3000 ); | ||
// Dismiss columns layout picker | ||
await editorPage.dismissBottomSheet(); | ||
// Wait for the modal to close | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
// Visual test check for placeholders | ||
let screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
// Click the block appender within the first column | ||
if ( isAndroid() ) { | ||
await editorPage.driver | ||
.elementByAccessibilityId( 'Column Block. Row 1' ) | ||
.click(); | ||
const appenderButton = await editorPage.waitForElementToBeDisplayedByXPath( | ||
'(//android.view.ViewGroup[@content-desc="block-list"])[2]/android.widget.Button' | ||
); | ||
await appenderButton.click(); | ||
} else { | ||
await editorPage.driver | ||
.elementByAccessibilityId( 'Column Block. Row 1' ) | ||
.click() | ||
.click(); | ||
} | ||
|
||
// Append a Preformatted block | ||
const blockButton = await editorPage.findBlockButton( | ||
blockNames.preformatted | ||
); | ||
if ( isAndroid() ) { | ||
await blockButton.click(); | ||
} else { | ||
await editorPage.driver.execute( 'mobile: tap', { | ||
element: blockButton, | ||
x: 10, | ||
y: 10, | ||
} ); | ||
} | ||
|
||
// TODO: determine a way to type a text block nested within a Columns block | ||
|
||
// Wait for the modal to close | ||
await editorPage.driver.sleep( 3000 ); | ||
// Navigate upwards in block hierarchy | ||
await editorPage.driver | ||
.elementByAccessibilityId( 'Navigate Up' ) | ||
.click() | ||
.click(); | ||
await editorPage.waitForKeyboardToBeHidden(); | ||
|
||
// Visual test check for nested content | ||
screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot(); | ||
|
||
await editorPage.removeBlock(); | ||
await toggleDarkMode( editorPage.driver, false ); | ||
|
||
// The Android editor requires a restart to apply dark mode | ||
if ( isAndroid() ) { | ||
await editorPage.driver.resetApp(); | ||
await isEditorVisible( editorPage.driver ); | ||
} | ||
} ); | ||
} ); | ||
|
||
it( 'sliders display proportionate fill level previews', async () => { | ||
await editorPage.addNewBlock( blockNames.columns ); | ||
// Wait for the modal to open | ||
await editorPage.driver.sleep( 3000 ); | ||
await editorPage.dismissBottomSheet(); | ||
await editorPage.openBlockSettings(); | ||
// Wait for the modal to open | ||
await editorPage.driver.sleep( 3000 ); | ||
|
||
const cellId = isAndroid() | ||
? 'Column 1. Width is 50 Percent (%)., double-tap to change unit' | ||
: 'Column 1. Width is 50 Percent (%).'; | ||
const cell = await editorPage.driver.elementByAccessibilityId( cellId ); | ||
const cellSize = await cell.getSize(); | ||
const cellLocation = await cell.getLocation(); | ||
const scrollOffset = isAndroid() ? 350 : 100; | ||
|
||
// Reveal default column width cells | ||
await swipeFromTo( | ||
editorPage.driver, | ||
{ | ||
x: cellLocation.x + cellSize.width / 2, | ||
y: cellLocation.y + cellSize.height / 2, | ||
}, | ||
{ | ||
x: cellLocation.x + cellSize.width / 2, | ||
y: cellLocation.y + cellSize.height / 2 - scrollOffset, | ||
}, | ||
1000 | ||
); | ||
// Shrink the first column | ||
await swipeFromTo( | ||
editorPage.driver, | ||
{ | ||
x: cellLocation.x + cellSize.width * 0.42, | ||
y: cellLocation.y - scrollOffset + cellSize.height * 0.69, | ||
}, | ||
{ | ||
x: | ||
cellLocation.x + | ||
cellSize.width * 0.42 - | ||
cellSize.width * 0.15, | ||
y: cellLocation.y - scrollOffset + cellSize.height * 0.69, | ||
}, | ||
1000 | ||
); | ||
|
||
// Visual test check for adjusted columns | ||
const screenshot = await takeScreenshot(); | ||
expect( screenshot ).toMatchImageSnapshot( { | ||
// Detect minute differences in column preview sizes | ||
failureThreshold: 0, // 0% | ||
} ); | ||
|
||
await editorPage.dismissBottomSheet(); | ||
await editorPage.removeBlock(); | ||
} ); | ||
} ); |
Binary file added
BIN
+29.5 KB
...s-block-displays-correctly-in-portrait-and-landscape-orientations-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
+44.1 KB
...lumns-block-displays-correctly-in-portrait-and-landscape-orientations-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.2 KB
...s-block-displays-correctly-in-portrait-and-landscape-orientations-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.2 KB
...lumns-block-displays-correctly-in-portrait-and-landscape-orientations-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
+19.7 KB
...-test-suite-4-columns-block-displays-placeholders-when-unselected-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
+28.1 KB
...itor-test-suite-4-columns-block-displays-placeholders-when-unselected-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
+16.9 KB
...-test-suite-4-columns-block-displays-placeholders-when-unselected-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
+20.5 KB
...itor-test-suite-4-columns-block-displays-placeholders-when-unselected-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
+22.6 KB
...columns-block-displays-with-correct-colors-with-dark-mode-enabled-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
+27.7 KB
...e-4-columns-block-displays-with-correct-colors-with-dark-mode-enabled-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
+26.1 KB
...columns-block-displays-with-correct-colors-with-dark-mode-enabled-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
+32 KB
...e-4-columns-block-displays-with-correct-colors-with-dark-mode-enabled-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
+21.8 KB
...te-4-columns-block-mover-buttons-display-in-the-correct-positions-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
+28.6 KB
...-suite-4-columns-block-mover-buttons-display-in-the-correct-positions-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.8 KB
...te-4-columns-block-mover-buttons-display-in-the-correct-positions-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.3 KB
...-suite-4-columns-block-mover-buttons-display-in-the-correct-positions-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
+38.5 KB
...or-test-suite-4-sliders-display-proportionate-fill-level-previews-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
+55 KB
...editor-test-suite-4-sliders-display-proportionate-fill-level-previews-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.