Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions assets/src/stories-editor/components/autocomplete/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Autocomplete extends OriginalAutocomplete {
tStatusQueryTooShort,
tStatusSelectedOption,
tStatusResults,
ariaLabelBy,
} = this.props;
const { focused, hovered, menuOpen, options, query, selected } = this.state;
const autoselect = this.hasAutoselect();
Expand Down Expand Up @@ -100,7 +101,7 @@ class Autocomplete extends OriginalAutocomplete {
) }

<input
aria-activedescendant={ optionFocused ? `${ id }__option--${ focused }` : false }
aria-activedescendant={ optionFocused ? `${ id }__option--${ focused }` : '' }
aria-owns={ `${ id }__listbox` }
autoComplete="off"
className={ `${ inputClassName }${ inputModifierFocused }${ inputModifierType }` }
Expand Down Expand Up @@ -132,6 +133,7 @@ class Autocomplete extends OriginalAutocomplete {
className={ `${ menuClassName } ${ menuModifierDisplayMenu } ${ menuModifierVisibility }` }
onMouseLeave={ ( event ) => this.handleListMouseLeave( event ) }
id={ `${ id }__listbox` }
aria-labelledby={ ariaLabelBy }
role="listbox"
>
{ options.map( ( option, index ) => {
Expand Down Expand Up @@ -160,7 +162,13 @@ class Autocomplete extends OriginalAutocomplete {
} ) }

{ showNoOptionsFound && (
<li className={ `${ optionClassName } ${ optionClassName }--no-results` }>{ tNoResults() }</li>
<li
className={ `${ optionClassName } ${ optionClassName }--no-results` }
role="option"
tabIndex="-1"
>
{ tNoResults() }
</li>
) }
</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Status.propTypes = {
length: PropTypes.number.isRequired,
queryLength: PropTypes.number.isRequired,
minQueryLength: PropTypes.number.isRequired,
selectedOption: PropTypes.func,
selectedOption: PropTypes.string,
selectedOptionIndex: PropTypes.number,
tQueryTooShort: PropTypes.func.isRequired,
tNoResults: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function FontFamilyPicker( {
inputValue: inputValueTemplate,
}
}
ariaLabelBy={ `${ id }__help` }
minLength={ 2 }
onConfirm={ onChange }
showAllValues={ false }
Expand Down
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@wordpress/hooks": "2.6.0",
"@wordpress/html-entities": "2.5.0",
"@wordpress/i18n": "3.6.0",
"@wordpress/jest-puppeteer-axe": "1.3.0",
"@wordpress/keycodes": "2.6.0",
"@wordpress/plugins": "2.7.0",
"@wordpress/postcss-themes": "2.2.0",
Expand Down
79 changes: 79 additions & 0 deletions tests/e2e/config/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,83 @@ function observeConsoleLogging() {
} );
}

/**
* Runs Axe tests when the story editor is found on the current page.
*
* @return {?Promise} Promise resolving once Axe texts are finished.
*/
async function runAxeTestsForStoriesEditor() {
if ( ! await page.$( '#amp-story-editor' ) ) {
return;
}

await expect( page ).toPassAxeTests( {
/**
* Rules are disabled, as there are still accessibility issues within gutenberg.
*
* See: https://github.com/WordPress/gutenberg/pull/15018 & https://github.com/WordPress/gutenberg/issues/15452
*/
disabledRules: [
'aria-allowed-role',
'aria-hidden-focus',
'button-name',
'color-contrast',
'duplicate-id',
'region',
],
exclude: [
// Ignores elements created by metaboxes.
'.edit-post-layout__metaboxes',
// Ignores elements created by TinyMCE.
'.mce-container',
// Ignore attachment close button.
'.amp-story-page-attachment-close-button',
],
} );
}

/**
* Runs Axe tests when the block editor is found on the current page.
*
* @return {?Promise} Promise resolving once Axe texts are finished.
*/
async function runAxeTestsForBlockEditor() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to runAxeTestsForStoriesEditor and use a different selector to detect it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swissspidy Why? The tests are passing for both. Any new e2e added for plugin should also run these axe tests.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The block editor and stories editor will have different configurations though. The exclude config already has a stories-specific config in it as well.

Also, eventually we should eventually add these tests for the plugin settings screen as well, where we're going to have yet another set of configuration options.

Having three separate sets would make maintenance easier.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 78161f9

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selector in runAxeTestsForStoriesEditor is still the same though.

What I meant was having separate functions with separate configurations:

  • runAxeTestsForBlockEditor with the current .block-editor selector
  • runAxeTestsForStoriesEditor with a #amp-story-editor selector
  • Eventually: runAxeTestsForSettingsScreen with a #amp-settings selector
  • Eventually: runAxeTestsForValidationScreen with a .post-type-amp_validated_url selector

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selector in runAxeTestsForStoriesEditor is still the same though.

What I meant was having separate functions with separate configurations:

  • runAxeTestsForBlockEditor with the current .block-editor selector
  • runAxeTestsForStoriesEditor with a #amp-story-editor selector
  • Eventually: runAxeTestsForSettingsScreen with a #amp-settings selector
  • Eventually: runAxeTestsForValidationScreen with a .post-type-amp_validated_url selector

What are you asking to change here? Just change the selector, like this runAxeTestsForStoriesEditor with a #amp-story-editor selector

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. And have a second function, runAxeTestsForBlockEditor, with a different selector that only targets the block editor but not the stories editor. That function would then not exclude '.amp-story-page-attachment-close-button' as it's irrelevant in the standalone block editor.

If it's unclear I can also change this myself.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And of course, let me know if you think it doesn't make sense. Then we can just do the #amp-story-editor selector change for now.

if ( ! await page.$( '.block-editor' ) ) {
Comment thread
spacedmonkey marked this conversation as resolved.
return;
}

// If amp story editor is found, don't run tests.
if ( await page.$( '#amp-story-editor' ) ) {
return;
}

await expect( page ).toPassAxeTests( {
/**
* Rules are disabled, as there are still accessibility issues within gutenberg.
*
* See: https://github.com/WordPress/gutenberg/pull/15018 & https://github.com/WordPress/gutenberg/issues/15452
*/
disabledRules: [
'aria-allowed-role',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These rules are disabled because of the errors in gutenberg. I would love for this ignored rules to be removed.

'aria-valid-attr-value',
'button-name',
'color-contrast',
'dlitem',
'duplicate-id',
'label',
'link-name',
'listitem',
'region',
],
exclude: [
// Ignores elements created by metaboxes.
'.edit-post-layout__metaboxes',
// Ignores elements created by TinyMCE.
'.mce-container',
],
} );
}

/**
* Before every test suite run, delete all content created by the test. This ensures
* other posts/comments/etc. aren't dirtying tests and tests don't depend on
Expand All @@ -140,6 +217,8 @@ beforeAll( async () => {
// eslint-disable-next-line jest/require-top-level-describe
afterEach( async () => {
await clearLocalStorage();
await runAxeTestsForStoriesEditor();
await runAxeTestsForBlockEditor();
await setBrowserViewport( 'large' );
} );

Expand Down
1 change: 1 addition & 0 deletions tests/e2e/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
],
setupFilesAfterEnv: [
'<rootDir>/config/bootstrap.js',
'@wordpress/jest-puppeteer-axe',
'expect-puppeteer',
],
testPathIgnorePatterns: [
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/specs/stories-editor/block-position-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe( 'Block Position Controls', () => {

// Since the selected block is already at the back, the 'Back' and 'Backward' buttons should be disabled.
expect( page ).toMatchElement( '.amp-story-controls-send-back[aria-disabled="true"]' );
expect( page ).toMatchElement( '.amp-story-controls-send-backward[aria-disabled="true"]' );
expect( page ).toMatchElement( '.amp-story-controls-send-backwards[aria-disabled="true"]' );
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fix for e2e to pass. Not sure how this was passing before.

} );
} );
} );