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

Make taxonomies test relieable #14340

Merged
merged 1 commit into from
Mar 11, 2019
Merged
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
20 changes: 16 additions & 4 deletions packages/e2e-tests/specs/taxonomies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import {
publishPost,
} from '@wordpress/e2e-test-utils';

/**
* Module constants
*/
const TAG_TOKEN_SELECTOR = '.components-form-token-field__token-text span:not(.screen-reader-text)';

describe( 'Taxonomies', () => {
const canCreatTermInTaxonomy = ( taxonomy ) => {
return page.evaluate(
Expand Down Expand Up @@ -38,13 +43,13 @@ describe( 'Taxonomies', () => {

const getCurrentTags = async () => {
const tagsPanel = await findSidebarPanelWithTitle( 'Tags' );
return page.evaluate( ( node ) => {
return page.evaluate( ( node, selector ) => {
return Array.from( node.querySelectorAll(
'.components-form-token-field__token-text span:not(.screen-reader-text)'
selector
) ).map( ( field ) => {
return field.innerText;
} );
}, tagsPanel );
}, tagsPanel, TAG_TOKEN_SELECTOR );
};

it( 'should be able to open the categories panel and create a new main category if the user has the right capabilities', async () => {
Expand Down Expand Up @@ -123,6 +128,13 @@ describe( 'Taxonomies', () => {
// Open the tags panel.
await tagsPanel.click( 'button' );

// At the start there are no tag tokens
expect(
await page.$$(
TAG_TOKEN_SELECTOR
)
).toHaveLength( 0 );

const tagInput = await tagsPanel.$( '.components-form-token-field__input' );

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

await page.waitForSelector( '.components-form-token-field__token' );
await page.waitForSelector( TAG_TOKEN_SELECTOR );

// Get an array with the tags of the post.
let tags = await getCurrentTags();
Expand Down