Skip to content

Commit

Permalink
Merge pull request #1366 from wordpress-mobile/update/fix-store-crash
Browse files Browse the repository at this point in the history
Fix store crash with gutenberg master
  • Loading branch information
Tug authored Sep 27, 2019
2 parents c364ab4 + b55f55d commit 36fb499
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion __device-tests__/gutenberg-editor-block-insertion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 400000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

describe( 'Gutenberg Editor tests for Block insertion', () => {
let driver;
Expand Down
2 changes: 1 addition & 1 deletion __device-tests__/gutenberg-editor-heading.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 400000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

describe( 'Gutenberg Editor tests', () => {
let driver;
Expand Down
2 changes: 1 addition & 1 deletion __device-tests__/gutenberg-editor-image.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 400000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

describe( 'Gutenberg Editor Image Block tests', () => {
let driver;
Expand Down
2 changes: 1 addition & 1 deletion __device-tests__/gutenberg-editor-lists-end.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 400000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

describe( 'Gutenberg Editor tests for List block (end)', () => {
let driver;
Expand Down
4 changes: 2 additions & 2 deletions __device-tests__/gutenberg-editor-lists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 400000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

xdescribe( 'Gutenberg Editor tests for List block', () => {
describe( 'Gutenberg Editor tests for List block', () => {
let driver;
let editorPage;
let allPassed = true;
Expand Down
2 changes: 1 addition & 1 deletion __device-tests__/gutenberg-editor-paragraph.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 400000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

describe( 'Gutenberg Editor tests for Paragraph Block', () => {
let driver;
Expand Down
2 changes: 1 addition & 1 deletion __device-tests__/gutenberg-editor-paste.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 400000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

describe( 'Gutenberg Editor paste tests', () => {
// skip iOS for now
Expand Down
4 changes: 2 additions & 2 deletions __device-tests__/gutenberg-editor-rotatation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 300000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

xdescribe( 'Gutenberg Editor tests', () => {
describe( 'Gutenberg Editor tests', () => {
let driver;
let editorPage;
let allPassed = true;
Expand Down
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 782 files
1 change: 1 addition & 0 deletions jest_ui.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const main = require( './jest.config.js' );

module.exports = {
...main,
timers: 'real',
setupFiles: [],
testMatch: [ '**/__device-tests__/**/*.test.[jt]s?(x)' ],
testPathIgnorePatterns: [
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@
"node-libs-react-native": "^1.0.2",
"node-sass": "^4.12.0",
"react": "16.8.6",
"react-native": "jtreanor/react-native#v0.60.0-patched",
"react-native-dark-mode": "git+https://github.com/wordpress-mobile/react-native-dark-mode.git#f09bf1480e7b34536413ab3300f29e4375edb2c6",
"react-native": "jtreanor/react-native#v0.60.0-patched",
"react-native-dark-mode": "git+https://github.com/wordpress-mobile/react-native-dark-mode.git#f09bf1480e7b34536413ab3300f29e4375edb2c6",
"react-native-hr": "git+https://github.com/Riglerr/react-native-hr.git#2d01a5cf77212d100e8b99e0310cce5234f977b3",
"react-native-keyboard-aware-scroll-view": "git+https://github.com/wordpress-mobile/react-native-keyboard-aware-scroll-view.git#gb-v0.8.7",
"react-native-modal": "^6.5.0",
Expand Down
11 changes: 4 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* External dependencies
*/
import { AppRegistry, I18nManager, YellowBox } from 'react-native';
import { AppRegistry, I18nManager } from 'react-native';
import React from 'react';

/**
Expand All @@ -23,12 +23,8 @@ import { getTranslation } from '../i18n-cache';
import initialHtml from './initial-html';

const gutenbergSetup = () => {
const apiFetch = require( '@wordpress/api-fetch' ).default;
const wpData = require( '@wordpress/data' );

// wp-api-fetch
apiFetch.use( apiFetch.createRootURLMiddleware( 'https://public-api.wordpress.com/' ) );

// wp-data
const userId = 1;
const storageKey = 'WP_DATA_USER_' + userId;
Expand Down Expand Up @@ -82,8 +78,9 @@ export class RootComponent extends React.Component {
}

export function registerApp() {
// Disable require circle warnings showing up in the app (they will still be visible in the console)
YellowBox.ignoreWarnings( [ 'Require cycle:' ] );
// Disable warnings as they disrupt the user experience in dev mode
// eslint-disable-next-line no-console
console.disableYellowBox = true;

gutenbergSetup();

Expand Down
13 changes: 10 additions & 3 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,25 @@ describe( 'RootComponent', () => {
beforeAll( initializeEditor );

it( 'renders without crashing', () => {
jest.useFakeTimers();
const app = renderer.create( <RootComponent /> );
// Gutenberg store currently has some asynchronous parts in the store setup
// Need to run all ticks so `isReady` is true in the editor store
// See: https://github.com/wordpress-mobile/gutenberg-mobile/pull/1366#discussion_r326813061
renderer.act( () => {
jest.runAllTicks();
} );
const rendered = app.toJSON();
expect( rendered ).toBeTruthy();
app.unmount();
} );

it( 'renders without crashing with a block focused', () => {
const app = renderer.create( <RootComponent /> );
const blocks = select( 'core/block-editor' ).getBlocks();

// Methods that modify state are required to be called inside `act`
renderer.act( () => {
jest.runAllTicks();
const blocks = select( 'core/block-editor' ).getBlocks();
// Methods that modify state are required to be called inside `act`
dispatch( 'core/block-editor' ).selectBlock( blocks[ 0 ].clientId );
} );

Expand Down
1 change: 1 addition & 0 deletions symlinked-packages/@wordpress/block-directory

0 comments on commit 36fb499

Please sign in to comment.