Skip to content

Commit

Permalink
Testing: Update E2E test case to verify link display regression
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed May 13, 2019
1 parent 559bbcf commit d1843ee
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/e2e-tests/specs/__snapshots__/links.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ exports[`Links should contain a label when it should open in a new tab 1`] = `
<p>This is <a href=\\"http://w.org\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\" aria-label=\\"WordPress (opens in a new tab)\\">WordPress</a></p>
<!-- /wp:paragraph -->"
`;
exports[`Links should contain a label when it should open in a new tab 2`] = `
"<!-- wp:paragraph -->
<p>This is <a href=\\"http://wordpress.org\\">WordPress</a></p>
<!-- /wp:paragraph -->"
`;
43 changes: 43 additions & 0 deletions packages/e2e-tests/specs/links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,5 +503,48 @@ describe( 'Links', () => {
await page.keyboard.press( 'Enter' );

expect( await getEditedPostContent() ).toMatchSnapshot();

// Regression Test: This verifies that the UI is updated according to
// the expected changed values, where previously the value could have
// fallen out of sync with how the UI is displayed (specifically for
// collapsed selections).
//
// See: https://github.com/WordPress/gutenberg/pull/15573

// Collapse selection.
await page.keyboard.press( 'ArrowLeft' );
await page.keyboard.press( 'ArrowRight' );
// Edit link.
await pressKeyWithModifier( 'primary', 'k' );
await waitForAutoFocus();
await pressKeyWithModifier( 'primary', 'a' );
await page.keyboard.type( 'wordpress.org' );
// Navigate to the settings toggle.
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Tab' );
// Open settings.
await page.keyboard.press( 'Space' );
// Navigate to the "Open in New Tab" checkbox.
await page.keyboard.press( 'Tab' );
// Uncheck the checkbox.
await page.keyboard.press( 'Space' );
// Navigate back to the input field.
await page.keyboard.press( 'Tab' );
// Submit the form.
await page.keyboard.press( 'Enter' );

// Navigate back to inputs to verify appears as changed.
await pressKeyWithModifier( 'primary', 'k' );
await waitForAutoFocus();
const link = await page.evaluate( () => document.activeElement.value );
expect( link ).toBe( 'http://wordpress.org' );
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Space' );
await page.keyboard.press( 'Tab' );
const isChecked = await page.evaluate( () => document.activeElement.checked );
expect( isChecked ).toBe( false );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );

0 comments on commit d1843ee

Please sign in to comment.