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

test(angular): add timeout to avoid flaky value accessor test #25522

Merged
merged 5 commits into from
Jun 24, 2022
Merged

Conversation

sean-perkins
Copy link
Contributor

@sean-perkins sean-perkins commented Jun 22, 2022

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
    • Some docs updates need to be made in the ionic-docs repo, in a separate PR. See the contributing guide for details.
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Occasionally the Angular E2E test suite will fail when validating if setting a value changes the form status of the control.

Upon debugging this failing test, it appears to be the result of ion-select. After assigning the value, the control continues to have the ion-invalid class, which means that the value accessor never received the ionChange event.

Theory is that the value is set by Cypress before the component fully loads. By removing the safe guard, the event is still able to fire prior to the componentDidLoad resolving.

Issue URL: N/A

What is the new behavior?

  • Adds TODO statements for code that will be removed if the ionChange RFC is approved
  • Adds timeout to the e2e test to reduce the flakiness of the value accessor test

Does this introduce a breaking change?

  • Yes
  • No

Other information

@sean-perkins sean-perkins requested a review from a team as a code owner June 22, 2022 17:57
@github-actions github-actions bot added the package: core @ionic/core package label Jun 22, 2022
Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

Why was the this.didInit added in the first place? I am worried this may accidentally regress some other behavior.

@averyjohnston
Copy link
Contributor

Would it be possible to have the test wait for the component to fully load instead?

@sean-perkins
Copy link
Contributor Author

Inconclusive based on the original PR not having a description or referencing an issue.

I have two theories:

  1. Based on the changed code in the original PR, it looks to be focused around floating labels/placeholders and ion-select. Originally the .emitStyle() was also included within this check (but later refactored out: 48a2763#diff-62cbe1fafe96a79e15c9c13dbafef8698860cfb31976445de7e1773079061eb6). it is possible there was a visual issue with the parent ion-item getting the correct classes applied (fix(angular): item styling when control has value #24932 may have resolved this)
  2. There was a similar architecture followed for ion-segment, which references this issue: bug: ion-segment (ionChange) trigger is not consistent on start #19204. If the behavior described in that issue holds similar to ion-select, then the API changes to ionChange in v7 would eliminate that problem from existing.

Cypress should be able to automatically determine when the page has loaded to run the test suite. Outside of an arbitrary timeout, I don't know how to best wait for that component to be loaded here.

If we are uncomfortable with changing this behavior, it definitely can be removed in v7 with the RFC we are working on right now. In the interim, we could add a timeout + tech debt task to remove it in v7. Alternatively, the E2E test is only really checking 3 of our components for validity behavior. We could temporarily disable the ion-select.

@liamdebeasi
Copy link
Contributor

liamdebeasi commented Jun 23, 2022

Do you think the issue that the didInit tries to avoid will be resolved with our proposed ionChange revisions?

@sean-perkins
Copy link
Contributor Author

Yes, I think the checks were to work around the value accessors setting the value before the web component defineCustomElement finishes.

With our proposed changes in the RFC, setting the value from the value accessor should not emit ionChange.

@liamdebeasi
Copy link
Contributor

Can we keep the didInit patch for now and work around it in our test somehow? Then we can add a TODO to remove the didInit when the ionChange updates are merged (we can probably track these changes in the main ionChange ticket)

@github-actions github-actions bot added the package: angular @ionic/angular package label Jun 24, 2022
Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this. Don't forget to change the commit subject when merging so this doesn't get logged as a bug.

@sean-perkins sean-perkins changed the title fix(select): emit ionChange on value change chore(angular): add timeout to avoid flaky value accessor test Jun 24, 2022
@sean-perkins
Copy link
Contributor Author

Thanks for the reminder; updated title + description, will wait for Amanda's review before merge 👍

@sean-perkins sean-perkins changed the title chore(angular): add timeout to avoid flaky value accessor test test(angular): add timeout to avoid flaky value accessor test Jun 24, 2022
@sean-perkins sean-perkins merged commit b3c0528 into main Jun 24, 2022
@sean-perkins sean-perkins deleted the FW-409 branch June 24, 2022 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: angular @ionic/angular package package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants