Skip to content

Commit

Permalink
Add regression test for editor JS crash caused by rtlcss parsing exce…
Browse files Browse the repository at this point in the history
…ption, take 2 (WordPress#29598)

* Switch to RTL dir using a server-side plugin as a way to simplify and regress-test issues in rtlcss

* Fix lint

Co-authored-by: Bernie Reiter <[email protected]>
  • Loading branch information
fullofcaffeine and ockham authored Mar 8, 2021
1 parent 5f1413d commit db16de9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
25 changes: 25 additions & 0 deletions packages/e2e-tests/plugins/rtl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Plugin Name: Gutenberg Test Plugin, Activate RTL
* Plugin URI: https://github.com/WordPress/gutenberg
* Author: Gutenberg Team / Yoav Farhi
*
* Based on the code from http://wordpress.org/extend/plugins/rtl-tester/.
*
* @package gutenberg-test-plugin-activate-rtl
*/

/**
* Set the locale's and styles' text direction to RTL.
*/
function gutenberg_test_plugin_activate_rtl_set_direction() {
global $wp_locale, $wp_styles;

$wp_locale->text_direction = 'rtl';
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
$wp_styles = new WP_Styles();
}
$wp_styles->text_direction = 'rtl';
}

add_action( 'init', 'gutenberg_test_plugin_activate_rtl_set_direction' );
14 changes: 10 additions & 4 deletions packages/e2e-tests/specs/editor/various/rtl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
createNewPost,
getEditedPostContent,
pressKeyWithModifier,
activatePlugin,
deactivatePlugin,
} from '@wordpress/e2e-test-utils';

// Avoid using three, as it looks too much like two with some fonts.
Expand All @@ -13,12 +15,16 @@ const ARABIC_ONE = '١';
const ARABIC_TWO = '٢';

describe( 'RTL', () => {
beforeAll( async () => {
await activatePlugin( 'gutenberg-test-plugin-activate-rtl' );
} );

beforeEach( async () => {
await createNewPost();
await page.evaluate( () => {
document.querySelector( '.is-root-container' ).dir = 'rtl';
wp.i18n.isRTL = () => true;
} );
} );

afterAll( async () => {
await deactivatePlugin( 'gutenberg-test-plugin-activate-rtl' );
} );

it( 'should arrow navigate', async () => {
Expand Down

0 comments on commit db16de9

Please sign in to comment.