Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add Sanity Test Suite 1 #5548

Merged
merged 29 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1c3980e
build: Update Gutenberg ref
dcalhoun Mar 9, 2023
7cf9638
test: Add Columns block placeholder test
dcalhoun Mar 9, 2023
f4c0a36
test: Add Columns block display test
dcalhoun Mar 9, 2023
abc76ce
build: Update Gutenberg ref
dcalhoun Mar 9, 2023
ae74f0d
test: Reset orientation after Columns block tests
dcalhoun Mar 9, 2023
bfd7518
test: Add Columns block mover buttons test
dcalhoun Mar 9, 2023
3da06dd
test: Await modal closure for existing Columns block tests
dcalhoun Mar 9, 2023
4be2879
test: Add Columns block dark mode test
dcalhoun Mar 9, 2023
4a79f29
build: Update Gutenberg ref
dcalhoun Mar 9, 2023
2303324
test: Add Columns proportionate fill previews test
dcalhoun Mar 10, 2023
0487003
refactor: Fix typo
dcalhoun Mar 13, 2023
d0d091a
test: Dismiss bottom sheet with existing helper
dcalhoun Mar 13, 2023
1d717a8
test: Use toggleDarkMode e2e mobile test helper
dcalhoun Mar 13, 2023
7d25930
test: Dismiss bottom sheet with existing helper
dcalhoun Mar 17, 2023
671a06c
test: Fix Android block appender button query
dcalhoun Mar 17, 2023
c0284e6
test: Fix Android dark mode toggling
dcalhoun Mar 17, 2023
25fb1b2
test: Add initial Android snapshot images
dcalhoun Mar 17, 2023
1c615de
test: Columns slider interactions rely upon element coordinates
dcalhoun Mar 17, 2023
7a58ad3
fix: Remove unused import
dcalhoun Mar 17, 2023
b2e07f7
test: Adjust slider test scroll position
dcalhoun Mar 17, 2023
7e90f2c
test: Decrease slider test failure threshold
dcalhoun Mar 17, 2023
51f8823
refactor: Rename for clarity
dcalhoun Mar 17, 2023
8c44141
refactor: Leverage updated addNewBlock test helper
dcalhoun Mar 17, 2023
040e78e
build: Update Gutenberg ref
dcalhoun Mar 17, 2023
d7df0fc
build: Update Gutenberg ref
dcalhoun Mar 17, 2023
139c069
Merge branch 'trunk' of github.com:wordpress-mobile/gutenberg-mobile …
dcalhoun Mar 17, 2023
e8ebc0f
test: Fix test description typo
dcalhoun Mar 24, 2023
f3b8d07
build: Update Gutenberg ref
dcalhoun Mar 27, 2023
a102203
Merge branch 'trunk' of github.com:wordpress-mobile/gutenberg-mobile …
dcalhoun Mar 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
307 changes: 307 additions & 0 deletions __device-tests__/gutenberg-editor-sanity-test-1-visual.test.js
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 4', () => {
dcalhoun marked this conversation as resolved.
Show resolved Hide resolved
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();
} );
} );
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.