Skip to content

Commit

Permalink
[Mobile] - Update E2E tests organization and helpers (#48026)
Browse files Browse the repository at this point in the history
* Mobile - Update E2E tests

* Mobile - Merge media tests into one

* Mobile - E2E - Remove block return await

* Mobile - Package remove extra space

* Mobile - Combine more E2E tests into one file

* Mobile - E2E helpers - Update helpers to use waitForElementToBeDisplayedById

* Mobile - Media Blocks E2E - Update comments

* Mobile - Set accessibility label prop for BlockTypesList instances
  • Loading branch information
geriux committed Feb 15, 2023
1 parent 3bcfbfe commit 9d37dbc
Show file tree
Hide file tree
Showing 22 changed files with 421 additions and 413 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function BlockTypesList( {
name,
sections,
onSelect,
label,
listProps,
initialNumToRender = 3,
} ) {
Expand Down Expand Up @@ -154,6 +155,7 @@ export default function BlockTypesList( {
<SectionList
onLayout={ onLayout }
testID={ `InserterUI-${ name }` }
accessibilityLabel={ label }
keyboardShouldPersistTaps="always"
sections={ sections }
initialNumToRender={ initialNumToRender }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { useMemo } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -66,6 +67,7 @@ function BlockTypesTab( { onSelect, rootClientId, listProps } ) {
sections={ sections }
onSelect={ handleSelect }
listProps={ listProps }
label={ __( 'Blocks menu' ) }
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -31,6 +32,7 @@ function ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {
sections={ sections }
onSelect={ onSelect }
listProps={ listProps }
label={ __( 'Reusable blocks' ) }
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -54,6 +55,7 @@ function InserterSearchResults( {
sections={ [ createInserterSection( { key: 'search', items } ) ] }
onSelect={ handleSelect }
listProps={ listProps }
label={ __( 'Blocks' ) }
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function getAutoCompleterUI( autocompleter ) {
<Animated.View style={ contentStyles }>
<BackgroundView>
<ScrollView
testID="autocompleter"
ref={ scrollViewRef }
horizontal
contentContainerStyle={
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/post-title/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class PostTitle extends Component {

return (
<View
testID="post-title"
style={ [
styles.titleContainer,
borderStyle,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,97 @@
*/
import { blockNames } from './pages/editor-page';
import { isAndroid } from './helpers/utils';
import { slashInserter, shortText } from './helpers/test-data';
import testData, { slashInserter, shortText } from './helpers/test-data';

describe( 'Gutenberg Editor tests for Block insertion', () => {
it( 'should be able to insert multi-paragraph text, and text to another paragraph block in between', async () => {
await editorPage.addNewBlock( blockNames.paragraph );
let paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
await paragraphBlockElement.click();
}

await editorPage.sendTextToParagraphBlock( 1, testData.longText );
// Should have 3 paragraph blocks at this point.

paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph,
2
);
await paragraphBlockElement.click();

await editorPage.addNewBlock( blockNames.paragraph );

paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph,
3
);
await paragraphBlockElement.click();
await editorPage.sendTextToParagraphBlock( 3, testData.mediumText );

const html = await editorPage.getHtmlContent();

expect( html.toLowerCase() ).toBe(
testData.blockInsertionHtml.toLowerCase()
);

for ( let i = 4; i > 0; i-- ) {
paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
await paragraphBlockElement.click();
await editorPage.removeBlock();
}
} );

it( 'should be able to insert block at the beginning of post from the title', async () => {
await editorPage.addNewBlock( blockNames.paragraph );
let paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
if ( isAndroid() ) {
await paragraphBlockElement.click();
}

await editorPage.sendTextToParagraphBlock( 1, testData.longText );
// Should have 3 paragraph blocks at this point.

if ( isAndroid() ) {
await editorPage.dismissKeyboard();
}

const titleElement = await editorPage.getTitleElement( {
autoscroll: true,
} );
await titleElement.click();

await editorPage.addNewBlock( blockNames.paragraph );
const emptyParagraphBlock = await editorPage.getBlockAtPosition(
blockNames.paragraph
);
expect( emptyParagraphBlock ).toBeTruthy();
const emptyParagraphBlockElement =
await editorPage.getTextBlockAtPosition( blockNames.paragraph );
expect( emptyParagraphBlockElement ).toBeTruthy();

await editorPage.sendTextToParagraphBlock( 1, testData.mediumText );
const html = await editorPage.getHtmlContent();
expect( html.toLowerCase() ).toBe(
testData.blockInsertionHtmlFromTitle.toLowerCase()
);

// Remove blocks
for ( let i = 4; i > 0; i-- ) {
paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
await paragraphBlockElement.click();
await editorPage.removeBlock();
}
} );
} );

describe( 'Gutenberg Editor Slash Inserter tests', () => {
it( 'should show the menu after typing /', async () => {
Expand Down Expand Up @@ -42,9 +132,10 @@ describe( 'Gutenberg Editor Slash Inserter tests', () => {
true
);
} else {
await paragraphBlockElement.type( '\b' );
await editorPage.typeTextToTextBlock(
paragraphBlockElement,
`\b ${ shortText }`,
`${ shortText }`,
false
);
}
Expand Down

This file was deleted.

1 comment on commit 9d37dbc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 9d37dbc.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4183765877
📝 Reported issues:

Please sign in to comment.