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

Add regression test for editor JS crash caused by rtlcss parsing exception, take 2 #29598

Merged
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
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