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
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: 13 additions & 7 deletions test/tests/spinbutton_datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,23 @@ ariaTest(
exampleFile,
'spinbutton-down-arrow',
async (t) => {
let control = parseInt(ex.dayNow);
let daysInMonth = parseInt(ex.dayMax);
let control = 31;

// Set to December for a 31 day month
let monthSpinner = await t.context.session.findElement(
By.css(ex.monthSelector)
);
await monthSpinner.sendKeys(Key.END);

// Send down arrow to day date spinner
let daySpinner = await t.context.session.findElement(
By.css(ex.daySelector)
);
await daySpinner.sendKeys(Key.ARROW_DOWN);

// Subtract a day to the control
control = (control - 1) % daysInMonth;
// Set to first of month
await daySpinner.sendKeys(Key.HOME);

await daySpinner.sendKeys(Key.ARROW_DOWN);

t.is(
parseInt(await daySpinner.getText()),
Expand All @@ -395,7 +401,7 @@ ariaTest(
}

// Subtract 30 days to the control
control = daysInMonth + ((control - 30) % daysInMonth);
control -= 30;

t.is(
parseInt(await daySpinner.getText()),
Expand All @@ -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?


let monthSpinner = await t.context.session.findElement(
By.css(ex.monthSelector)
Expand All @@ -417,7 +424,6 @@ ariaTest('up arrow on month', exampleFile, 'spinbutton-up-arrow', async (t) => {
for (let i = 1; i <= 12; i++) {
await monthSpinner.sendKeys(Key.ARROW_UP);
const index = new Date(date.setMonth(date.getMonth() + 1)).getMonth();
console.log(index);
t.is(
await monthSpinner.getText(),
valuesMonth[index],
Expand Down