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

[Mobile] - Update E2E tests organization and helpers #48026

Merged
merged 9 commits into from
Feb 15, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
usePreferredColorScheme,
usePreferredColorSchemeStyle,
} from '@wordpress/compose';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -154,6 +155,7 @@ export default function BlockTypesList( {
<SectionList
onLayout={ onLayout }
testID={ `InserterUI-${ name }` }
accessibilityLabel={ __( 'Blocks menu' ) }
fluiddot marked this conversation as resolved.
Show resolved Hide resolved
keyboardShouldPersistTaps="always"
sections={ sections }
initialNumToRender={ initialNumToRender }
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.

This file was deleted.

Loading