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] - Support Visual Regression testing #47845

Merged
merged 5 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion packages/react-native-editor/__device-tests__/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
module.exports = {
extends: '../.eslintrc.js',
globals: {
editorPage: true, // Defined in 'jest_ui_test_environment.js'
// Defined in 'jest_ui_test_environment.js'
editorPage: true,
e2eTestData: true,
e2eUtils: true,
},
rules: {
'jest/expect-expect': 'off',
Expand Down
19 changes: 19 additions & 0 deletions packages/react-native-editor/__device-tests__/helpers/test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,22 @@ exports.lettersInParagraphBlock = `<!-- wp:paragraph -->
exports.spacerBlock = `<!-- wp:spacer -->
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->`;

exports.galleryBlock = `<!-- wp:gallery {"columns":8,"linkTo":"none","className":"alignfull"} -->
<figure class="wp-block-gallery has-nested-images columns-8 is-cropped alignfull"><!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon.png" alt=""/><figcaption class="wp-element-caption">Paragraph</figcaption></figure>
<!-- /wp:image -->
<!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Heading.png" alt=""/><figcaption class="wp-element-caption">Heading</figcaption></figure>
<!-- /wp:image -->
<!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Subheading.png" alt=""/><figcaption class="wp-element-caption">Subheading</figcaption></figure>
<!-- /wp:image -->
<!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Quote.png" alt=""/><figcaption class="wp-element-caption">Quote</figcaption></figure>
<!-- /wp:image -->
<!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Image.png" alt=""/><figcaption class="wp-element-caption">Image</figcaption></figure>
<!-- /wp:image -->
</figure>
<!-- /wp:gallery -->`;
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ const blockNames = {
spacer: 'Spacer',
verse: 'Verse',
shortcode: 'Shortcode',
group: 'Group',
};

module.exports = { initializeEditorPage, blockNames };
6 changes: 6 additions & 0 deletions packages/react-native-editor/jest_ui_test_environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
*/
const {
initializeEditorPage,
blockNames,
} = require( './__device-tests__/pages/editor-page' );
const utils = require( './__device-tests__/helpers/utils' );
const testData = require( './__device-tests__/helpers/test-data' );

/**
* External dependencies
Expand All @@ -16,6 +19,9 @@ class CustomEnvironment extends JSDOMEnvironment {
try {
await super.setup();
this.global.editorPage = await initializeEditorPage();
this.global.editorPage.blockNames = blockNames;
this.global.e2eUtils = utils;
this.global.e2eTestData = testData;
} catch ( error ) {
// eslint-disable-next-line no-console
console.error( 'E2E setup exception:', error );
Expand Down