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
  • Loading branch information
fullofcaffeine committed Feb 25, 2021
1 parent 4700919 commit 0e518ca
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/e2e-tests/specs/editor/various/rtl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,38 @@ describe( 'RTL', () => {
} );
} );

// Regression test for https://github.com/WordPress/gutenberg/issues/29250.
it( 'loads editor without errors when RTL is set at the WP admin level', async () => {
await page.evaluate( () => {
window._loadedWithoutErrors = true;

window.addEventListener( 'error', function ( event ) {
window._loadedWithoutErrors = false;
event.preventDefault();
} );

const scripts = Array.from( document.querySelectorAll( 'script' ) );
const snippetScriptEl = document.createElement( 'script' );
const newComponentsScriptEl = document.createElement( 'script' );
const head = document.head;

const componentsScriptSrc = scripts.find( ( s ) =>
s.src.match( 'components/index.js' )
).src;

snippetScriptEl.text = 'document.dir = "rtl";';
newComponentsScriptEl.src = componentsScriptSrc;

//scripts.forEach( ( script ) => script.remove() );
head.appendChild( snippetScriptEl );
head.appendChild( newComponentsScriptEl );
} );

expect(
await page.evaluate( () => window._loadedWithoutErrors )
).toBeTruthy();
} );

it( 'should arrow navigate', async () => {
await page.keyboard.press( 'Enter' );

Expand Down

0 comments on commit 0e518ca

Please sign in to comment.