Skip to content

Commit

Permalink
test: Increase editor history link test accuracy
Browse files Browse the repository at this point in the history
The targeted bug occurs when:

1. Changing a link to "Open in a new tab."
2. Performing additional changes, e.g. typing.
3. Undoing both actions.
4. Redoing both actions.

Thus, this changes the initial HTML, adds additional undo/redo
invocations, and updates inline snapshots to match the expected
outcomes.
  • Loading branch information
dcalhoun authored and derekblank committed May 23, 2023
1 parent 87dcd92 commit d0098e6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/native/integration/editor-history.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe( 'Editor History', () => {
it( 'should preserve editor history when a link has been added and configured to open in a new tab', async () => {
// Arrange
const initialHtml = `
<!-- wp:paragraph --><p>A <a href="http://wordpress.org" target="_blank" rel="noreferrer noopener">quick</a> brown fox jumps over the lazy dog.</p><!-- /wp:paragraph -->
<!-- wp:paragraph --><p>A <a href="http://wordpress.org">quick</a> brown fox jumps over the lazy dog.</p><!-- /wp:paragraph -->
`;
const screen = await initializeEditor( {
initialHtml,
Expand All @@ -201,7 +201,7 @@ describe( 'Editor History', () => {

typeInRichText(
paragraphTextInput,
'A quick brown fox jumps over the lazy dog.'
' A quick brown fox jumps over the lazy dog.'
);

// Assert
Expand All @@ -213,21 +213,23 @@ describe( 'Editor History', () => {

// Act
fireEvent.press( screen.getByLabelText( 'Undo' ) );
fireEvent.press( screen.getByLabelText( 'Undo' ) );

// Assert
expect( getEditorHtml() ).toMatchInlineSnapshot( `
"<!-- wp:paragraph -->
<p></p>
<p>A <a href="http://wordpress.org">quick</a> brown fox jumps over the lazy dog.</p>
<!-- /wp:paragraph -->"
` );

// Act
fireEvent.press( screen.getByLabelText( 'Redo' ) );
fireEvent.press( screen.getByLabelText( 'Redo' ) );

// Assert
expect( getEditorHtml() ).toMatchInlineSnapshot( `
"<!-- wp:paragraph -->
<p>A <a href="http://wordpress.org" target="_blank" rel="noreferrer noopener">quick</a> brown fox jumps over the lazy dog.</p>
<p>A <a href="http://wordpress.org" target="_blank" rel="noreferrer noopener">quick</a> brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.</p>
<!-- /wp:paragraph -->"
` );
} );
Expand Down

0 comments on commit d0098e6

Please sign in to comment.