Skip to content

(test): add e2e tests for autocomplete (#4491) #9077

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

Closed
wants to merge 1 commit into from

Conversation

Ann40a
Copy link

@Ann40a Ann40a commented Dec 20, 2017

No description provided.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 20, 2017
@Ann40a
Copy link
Author

Ann40a commented Dec 20, 2017

Please, help me, whom should I add to CODEOWNERS? Should it really be myself as I did or someone from your team?

@@ -129,6 +129,7 @@

# E2E app
/e2e/* @jelbourn
/e2e/components/autocomplete-e2e.spec.ts @ann40a
Copy link
Member

Choose a reason for hiding this comment

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

Can you mark crisbeto as the code owner here as he is the code owner for the component.


class AutocompletePage {
constructor() { browser.get('/autocomplete'); }
autocompleteInput = () => element(by.id('autocomplete-input'));
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I don't know that its strictly necessary to have a class to manage retrieving the elements as you have here. If you would like to keep the class, rather than assigning these are attributes which are functions, can you use typical method declaration?

class AutocompletePage {
  constructor() {
    browser.get('/autocomplete');
  }

  autocompleteInput() {
    return element(by.id('autocomplete-input'));
  }
...
}

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. I don't think we have that many tests where setups like this start making sense.

Copy link
Author

Choose a reason for hiding this comment

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

Personally, I prefer to user page objects, because it separates the test logic and elements selection. I've seen this pattern in menu-e2e.spec.ts and decided that it is acceptable to use it. I should remove this class, right?

Copy link
Member

Choose a reason for hiding this comment

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

We haven't been super consistent about when we use page objects (IIRC only the menu tests have them). Let's keep it for now and we can decide later on whether we want to remove it or switch all of the other e2e tests to use page objects as well.

@@ -104,7 +104,7 @@ export function getMatAutocompleteMissingPanelError(): Error {
'aria-autocomplete': 'list',
'[attr.aria-activedescendant]': 'activeOption?.id',
'[attr.aria-expanded]': 'panelOpen.toString()',
'[attr.aria-owns]': 'autocomplete?.id',
'[attr.aria-owns]': '(autocomplete && autocomplete._isOpen) ? autocomplete.id : null',
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this logic into a getter method on the class and then use the attribute in the host binding?

Copy link
Member

Choose a reason for hiding this comment

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

I remember having issues with NVDA not reading out some options when I tried doing this for mat-select. That being said, I couldn't hear any difference when I did it for autocomplete. Still it might be better to do this in a separate PR since this one is primarily for the tests.

Copy link
Author

Choose a reason for hiding this comment

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

I did this, because I had received ARIA attributes must conform to valid values error from axe-protractor plugin. Do I understand properly, that I need to revert this change, create a ticket for the error and wait until it is done? Or it is ok to ignore this error, because, as I see now, after rebase on master the number of axe errors increased.

Copy link
Member

Choose a reason for hiding this comment

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

I think that we can still do it, but it should be done as a separate PR, because it needs a unit test and this PR is primarily focused on adding e2e tests to the autocomplete.



describe('autocomplete', () => {
const autocompletePanelSelector = '.mat-autocomplete-panel.mat-autocomplete-visible';
Copy link
Member

Choose a reason for hiding this comment

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

The .mat-autocomplete-visible here shouldn't be necessary, the only time an autocomplete is in the DOM and doesn't have that class is when there are no results.


class AutocompletePage {
constructor() { browser.get('/autocomplete'); }
autocompleteInput = () => element(by.id('autocomplete-input'));
Copy link
Member

Choose a reason for hiding this comment

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

Agreed. I don't think we have that many tests where setups like this start making sense.

@@ -104,7 +104,7 @@ export function getMatAutocompleteMissingPanelError(): Error {
'aria-autocomplete': 'list',
'[attr.aria-activedescendant]': 'activeOption?.id',
'[attr.aria-expanded]': 'panelOpen.toString()',
'[attr.aria-owns]': 'autocomplete?.id',
'[attr.aria-owns]': '(autocomplete && autocomplete._isOpen) ? autocomplete.id : null',
Copy link
Member

Choose a reason for hiding this comment

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

I remember having issues with NVDA not reading out some options when I tried doing this for mat-select. That being said, I couldn't hear any difference when I did it for autocomplete. Still it might be better to do this in a separate PR since this one is primarily for the tests.

@@ -0,0 +1,11 @@
<section>
Copy link
Member

Choose a reason for hiding this comment

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

One thing that's not clear in the code by itself is that we're trying to move away from standalone e2e test pages. Instead, new e2e tests are based on the examples we publish to material.angular.io. Check out #5735 for an example of adding e2e tests for cards based on the published examples.

@jelbourn
Copy link
Member

jelbourn commented May 9, 2018

Closing since this seems pretty stale now.

@jelbourn jelbourn closed this May 9, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants