Skip to content

Commit

Permalink
Tests: Clean up skipped e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Oct 17, 2019
1 parent a284f26 commit 7c0bb77
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export async function findSidebarPanelWithTitle( panelTitle ) {
const classSelect = ( className ) => `[contains(concat(" ", @class, " "), " ${ className } ")]`;
const buttonSelector = `//div${ classSelect( 'edit-post-sidebar' ) }//button${ classSelect( 'components-button' ) }${ classSelect( 'components-panel__body-toggle' ) }[contains(text(),"${ panelTitle }")]`;
const panelSelector = `${ buttonSelector }/ancestor::*[contains(concat(" ", @class, " "), " components-panel__body ")]`;
return first( await await page.$x( panelSelector ) );
return first( await await page.waitForXPath( panelSelector ) );
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import {
publishPost,
} from '@wordpress/e2e-test-utils';

// This test isn't reliable on Travis and fails from time to time.
// See: https://github.com/WordPress/gutenberg/pull/15211.
describe.skip( 'WP Editor Meta Boxes', () => {
describe( 'WP Editor Meta Boxes', () => {
beforeAll( async () => {
await activatePlugin( 'gutenberg-test-plugin-wp-editor-meta-box' );
await createNewPost();
Expand All @@ -25,15 +23,16 @@ describe.skip( 'WP Editor Meta Boxes', () => {
await page.type( '.editor-post-title__input', 'Hello Meta' );

// Type something
await page.click( '#test_tinymce_id-html' );
await expect( page ).toClick( '#test_tinymce_id-html' );
await page.type( '#test_tinymce_id', 'Typing in a metabox' );
await page.click( '#test_tinymce_id-tmce' );

await publishPost();

await page.reload();

await page.click( '#test_tinymce_id-html' );
await expect( page ).toClick( '#test_tinymce_id-html' );
await page.waitForSelector( '#test_tinymce_id' );
const content = await page.$eval(
'#test_tinymce_id',
( textarea ) => textarea.value
Expand Down
29 changes: 0 additions & 29 deletions packages/e2e-tests/specs/editor/various/embedding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,33 +271,4 @@ describe( 'Embedding content', () => {
// Check the block has become a WordPress block.
await page.waitForSelector( '.wp-block-embed-wordpress' );
} );

it.skip( 'should transform from video to embed block when YouTube URL is pasted', async () => {
await clickBlockAppender();
await insertBlock( 'Video' );
await page.click( '.editor-media-placeholder__url-input-container button' );
await page.keyboard.type( 'https://www.youtube.com/watch?v=lXMskKTw3Bc' );
await page.keyboard.press( 'Enter' );
await page.waitForSelector( '.wp-block-embed-youtube' );
} );

it.skip( 'should transform from image to embed block when Instagram URL is pasted', async () => {
await clickBlockAppender();
await page.keyboard.type( '/image' );
await page.keyboard.press( 'Enter' );
await page.click( '.editor-media-placeholder__url-input-container button' );
await page.keyboard.type( 'https://www.instagram.com/p/Bvl97o2AK6x/' );
await page.keyboard.press( 'Enter' );
await page.waitForSelector( '.wp-block-embed-instagram' );
} );

it.skip( 'should transform from audio to embed block when Soundcloud URL is pasted', async () => {
await clickBlockAppender();
await page.keyboard.type( '/audio' );
await page.keyboard.press( 'Enter' );
await page.click( '.editor-media-placeholder__url-input-container button' );
await page.keyboard.type( 'https://soundcloud.com/a-boogie-wit-da-hoodie/swervin' );
await page.keyboard.press( 'Enter' );
await page.waitForSelector( '.wp-block-embed-soundcloud' );
} );
} );
81 changes: 0 additions & 81 deletions packages/e2e-tests/specs/editor/various/links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,87 +266,6 @@ describe( 'Links', () => {
return page.evaluate( () => document.querySelector( '.post-publish-panel__postpublish-post-address input' ).value );
};

// Test for regressions of https://github.com/WordPress/gutenberg/issues/10496.
it.skip( 'allows autocomplete suggestions to be selected with the mouse', async () => {
// First create a post that we can search for using the link autocompletion.
const titleText = 'Test post mouse';
const postURL = await createPostWithTitle( titleText );

// Now create a new post and try to select the post created previously
// from the autocomplete suggestions.
await createNewPost();
await clickBlockAppender();
await page.keyboard.type( 'This is Gutenberg' );
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
await page.click( 'button[aria-label="Link"]' );

// Wait for the URL field to auto-focus
await waitForAutoFocus();

await page.keyboard.type( titleText );
const suggestionXPath = `//*[contains(@class, "block-editor-url-input__suggestion")]//button[contains(text(), '${ titleText }')]`;
await page.waitForXPath( suggestionXPath );
const autocompleteSuggestions = await page.$x( suggestionXPath );

// Expect there to be some autocomplete suggestions.
expect( autocompleteSuggestions ).toHaveLength( 1 );

const firstSuggestion = autocompleteSuggestions[ 0 ];

// Expect that clicking on the autocomplete suggestion doesn't dismiss the link popover.
await firstSuggestion.click();
expect( await page.$( '.block-editor-url-popover' ) ).not.toBeNull();

// Expect the url input value to have been updated with the post url.
const inputValue = await page.evaluate( () => document.querySelector( '.block-editor-url-input input[aria-label="URL"]' ).value );
expect( inputValue ).toEqual( postURL );

// Expect the link to apply correctly.
// Note - have avoided using snapshots here since the link url can't be determined ahead of time.
await page.click( 'button[aria-label="Apply"]' );
const linkHref = await page.evaluate( () => document.querySelector( '.block-editor-format-toolbar__link-container-value' ).href );
expect( linkHref ).toEqual( postURL );
} );

// Test for regressions of https://github.com/WordPress/gutenberg/issues/10496.
// This test isn't reliable on Travis and fails from time to time.
// See: https://github.com/WordPress/gutenberg/pull/15211.
it.skip( 'allows autocomplete suggestions to be navigated with the keyboard', async () => {
const titleText = 'Test post keyboard';
const postURL = await createPostWithTitle( titleText );

await createNewPost();
await clickBlockAppender();

// Now in a new post and try to create a link from an autocomplete suggestion using the keyboard.
await page.keyboard.type( 'This is Gutenberg' );
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );

// Press Cmd+K to insert a link
await pressKeyWithModifier( 'primary', 'K' );

// Wait for the URL field to auto-focus
await waitForAutoFocus();

await page.keyboard.type( titleText );
await page.waitForSelector( '.block-editor-url-input__suggestion' );
const autocompleteSuggestions = await page.$x( `//*[contains(@class, "block-editor-url-input__suggestion")]//button[contains(text(), '${ titleText }')]` );

// Expect there to be some autocomplete suggestions.
expect( autocompleteSuggestions ).toHaveLength( 1 );

// Expect the the first suggestion to be selected when pressing the down arrow.
await page.keyboard.press( 'ArrowDown' );
const isSelected = await page.evaluate( () => document.querySelector( '.block-editor-url-input__suggestion' ).getAttribute( 'aria-selected' ) );
expect( isSelected ).toBe( 'true' );

// Expect the link to apply correctly when pressing Enter.
// Note - have avoided using snapshots here since the link url can't be determined ahead of time.
await page.keyboard.press( 'Enter' );
const linkHref = await page.evaluate( () => document.querySelector( '.block-editor-format-toolbar__link-container-value' ).href );
expect( linkHref ).toEqual( postURL );
} );

it( 'allows use of escape key to dismiss the url popover', async () => {
const titleText = 'Test post escape';
await createPostWithTitle( titleText );
Expand Down
70 changes: 0 additions & 70 deletions packages/e2e-tests/specs/editor/various/nux.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
* WordPress dependencies
*/
import {
clickBlockAppender,
clickOnMoreMenuItem,
createNewPost,
saveDraft,
toggleScreenOption,
} from '@wordpress/e2e-test-utils';

Expand Down Expand Up @@ -110,71 +107,4 @@ describe( 'New User Experience (NUX)', () => {
areTipsEnabled = await getTipsEnabled( page );
expect( areTipsEnabled ).toEqual( true );
} );

// TODO: This test should be enabled once
// https://github.com/WordPress/gutenberg/issues/7458 is fixed.
it.skip( 'should show tips as disabled if all tips have been shown', async () => {
await clickAllTips( page );

// Open the "More" menu to check the "Show Tips" element.
await page.click( '.edit-post-more-menu [aria-label="More tools & options"]' );
const showTipsButton = await page.$x( '//button[contains(text(), "Show Tips")][@aria-pressed="false"]' );

expect( showTipsButton ).toHaveLength( 1 );
} );

// TODO: This test should be enabled once
// https://github.com/WordPress/gutenberg/issues/7458 is fixed.
it.skip( 'should reset tips if all tips have been shown and show tips was unchecked', async () => {
const { numberOfTips } = await clickAllTips( page );

// Click again to re-enable tips; they should appear.
await clickOnMoreMenuItem( 'Show Tips' );

// Open the "More" menu to check the "Show Tips" element.
await page.click( '.edit-post-more-menu [aria-label="More tools & options"]' );
const showTipsButton = await page.$x( '//button[contains(text(), "Show Tips")][@aria-pressed="true"]' );

expect( showTipsButton ).toHaveLength( 1 );

// Tips should re-appear on the page.
const nuxTipElements = await page.$$( '.nux-dot-tip' );
expect( nuxTipElements ).toHaveLength( 1 );

// Tips should be enabled again.
const areTipsEnabled = await getTipsEnabled( page );
expect( areTipsEnabled ).toEqual( true );

// Dismissed tips should be reset and ready to be shown again.
const resetTips = await getTips( page );
const newNumberOfTips = resetTips.tipIds.length;
expect( newNumberOfTips ).toHaveLength( numberOfTips );
} );

// TODO: This test should be enabled once
// https://github.com/WordPress/gutenberg/issues/7753 is fixed.
// See: https://github.com/WordPress/gutenberg/issues/7753#issuecomment-403952816
it.skip( 'should show tips if "Show tips" was disabled on a draft and then enabled', async () => {
// Click the "Show tips" button (enabled by default) to disable tips.
await clickOnMoreMenuItem( 'Show Tips' );

// Let's type something so there's content in this post.
await page.click( '.editor-post-title__input' );
await page.keyboard.type( 'Post title' );
await clickBlockAppender();
await page.keyboard.type( 'Post content goes here.' );
await saveDraft();

// Refresh the page; tips should be disabled.
await page.reload();
let nuxTipElements = await page.$$( '.nux-dot-tip' );
expect( nuxTipElements ).toHaveLength( 0 );

// Clicking should re-enable tips.
await clickOnMoreMenuItem( 'Show Tips' );

// Tips should re-appear on the page.
nuxTipElements = await page.$$( '.nux-dot-tip' );
expect( nuxTipElements ).toHaveLength( 1 );
} );
} );
28 changes: 14 additions & 14 deletions packages/e2e-tests/specs/editor/various/taxonomies.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { random } from 'lodash';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -108,25 +113,18 @@ describe( 'Taxonomies', () => {
expect( selectedCategories[ 0 ] ).toEqual( 'z rand category 1' );
} );

// This test isn't reliable locally because repeated execution of the test triggers 400 network
// because of the tag's duplication. Also, it randomly doesn't add a new tag after pressing enter.
// See: https://github.com/WordPress/gutenberg/pull/15211.
it.skip( 'should be able to open the tags panel and create a new tag if the user has the right capabilities', async () => {
it( 'should be able to open the tags panel and create a new tag if the user has the right capabilities', async () => {
await createNewPost();

await openDocumentSettingsSidebar();

const tagsPanel = await findSidebarPanelWithTitle( 'Tags' );

//expect( await page.evaluate( ( el ) => el.outerHTML, tagsPanel ) ).toEqual( 'tag1 ok' );
expect( tagsPanel ).toBeDefined();

// If the user has no permission to add a new tag finish the test.
if ( ! ( await canCreatTermInTaxonomy( 'tags' ) ) ) {
return;
}

await openDocumentSettingsSidebar();

// Open the tags panel.
const tagsPanel = await findSidebarPanelWithTitle( 'Tags' );
await tagsPanel.click( 'button' );

// At the start there are no tag tokens
Expand All @@ -141,8 +139,10 @@ describe( 'Taxonomies', () => {
// Click the tag input field.
await tagInput.click();

const tagName = 'tag-' + random( 1, Number.MAX_SAFE_INTEGER );

// Type the category name in the field.
await tagInput.type( 'tag1' );
await tagInput.type( tagName );

// Press enter to create a new tag.
await tagInput.press( 'Enter' );
Expand All @@ -154,7 +154,7 @@ describe( 'Taxonomies', () => {

// The post should only contain the tag we added.
expect( tags ).toHaveLength( 1 );
expect( tags[ 0 ] ).toEqual( 'tag1' );
expect( tags[ 0 ] ).toEqual( tagName );

// Type something in the title so we can publish the post.
await page.type( '.editor-post-title__input', 'Hello World' );
Expand All @@ -172,6 +172,6 @@ describe( 'Taxonomies', () => {

// The tag selection was persisted after the publish process.
expect( tags ).toHaveLength( 1 );
expect( tags[ 0 ] ).toEqual( 'tag1' );
expect( tags[ 0 ] ).toEqual( tagName );
} );
} );

0 comments on commit 7c0bb77

Please sign in to comment.