Skip to content

Commit

Permalink
[Mobile] - Support Visual Regression testing (#47845)
Browse files Browse the repository at this point in the history
* Mobile - Support Visual regression testing

* Mobile - Jest UI Config - Rename E2E globals to keep consistency

* Mobile - Update eslintrc config
  • Loading branch information
geriux committed Feb 23, 2023
1 parent 626362e commit 5e2269a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
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

1 comment on commit 5e2269a

@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 5e2269a.
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/4255366737
📝 Reported issues:

Please sign in to comment.