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

Spin Button Date Picker: Fix unreliable date math test #1639

Merged
merged 2 commits into from
Dec 3, 2020

Conversation

spectranaut
Copy link
Contributor

When you get towards the end of the month and try to add a month, Javascript Date objects start to do unexpected things. This is causing failures in the CI for all regression tests run today. This is the issue:

let date = new Date('10/31/2020'); 
date.setMonth(date.getMonth + 1);

The second line increases the date by one month, resulting in date being December 1st, 2020, because there is no November 31st.

The fix is to put the day of the month to the 1st using date.setDate(1) before doing any math, because all months have the 1st of the month.

@github-actions
Copy link
Contributor

Regression test coverage:

Examples without any regression tests:

  • dialog-modal/alertdialog.html

Examples missing some regression tests:

  • dialog-modal/datepicker-dialog.html:
    • textbox-aria-describedby
  • menu-button/menu-button-actions-active-descendant.html:
    • menu-up-arrow
    • menu-down-arrow
    • menu-character
  • toolbar/toolbar.html:
    • toolbar-tab
    • toolbar-right-arrow
    • toolbar-left-arrow
    • toolbar-home
    • toolbar-end
    • toolbar-toggle-esc
    • toolbar-toggle-enter-or-space
    • toolbar-radio-enter-or-space
    • toolbar-radio-down-arrow
    • toolbar-radio-up-arrow
    • toolbar-button-enter-or-space
    • toolbar-menubutton-enter-or-space-or-down-or-up
    • toolbar-menu-enter-or-space
    • toolbar-menu-down-arrow
    • toolbar-menu-up-arrow
    • toolbar-menu-escape
    • toolbar-spinbutton-down-arrow
    • toolbar-spinbutton-up-arrow
    • toolbar-spinbutton-page-down
    • toolbar-spinbutton-page-up
    • toolbar-checkbox-space
    • toolbar-link-enter-or-space
    • toolbar-spinbutton-role

Example pages with Keyboard or Attribute table rows that do not have data-test-ids:

  • dialog-modal/alertdialog.html
    • "Keyboard Support" table(s):
      • Tab
      • Shift + Tab
      • Escape
      • Command + S
      • Control + S
    • "Attributes" table(s):
      • alertdialog
      • aria-labelledby=IDREF
      • aria-describedby=IDREF
      • aria-modal=true
      • alert

SUMMARY:

55 example pages found.
1 example pages have no regression tests.
3 example pages are missing approximately 27 out of approximately 780 tests.

ERROR - missing tests:

Please write missing tests for this report to pass.

Copy link
Contributor

@carmacleod carmacleod left a comment

Choose a reason for hiding this comment

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

+1
Makes sense.
Thanks @spectranaut !

@mcking65 mcking65 changed the title Fix unreliable date math bug Spin Button Date Picker: Fix unreliable date math test Dec 1, 2020
@mcking65 mcking65 added bug Code defects; not for inaccurate prose Example Page Related to a page containing an example implementation of a pattern labels Dec 1, 2020
@mcking65 mcking65 added this to the 1.2 Release 1 milestone Dec 1, 2020
@mcking65
Copy link
Contributor

mcking65 commented Dec 1, 2020

@spectranaut
Seems like we now have a problem with arrow key testing on day spinner

@@ -408,6 +414,7 @@ ariaTest(

ariaTest('up arrow on month', exampleFile, 'spinbutton-up-arrow', async (t) => {
let date = new Date();
date.setDate(1); // This is necessary to do the correct date math for months.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this part still needed?

@mcking65 mcking65 merged commit 5a61dfb into master Dec 3, 2020
@mcking65 mcking65 added bug Code defects; not for inaccurate prose Example Page Related to a page containing an example implementation of a pattern and removed bug Code defects; not for inaccurate prose Example Page Related to a page containing an example implementation of a pattern labels Dec 3, 2020
@mcking65 mcking65 deleted the datepicker-bug branch December 3, 2020 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Code defects; not for inaccurate prose Example Page Related to a page containing an example implementation of a pattern
Development

Successfully merging this pull request may close these issues.

4 participants