Skip to content

Commit

Permalink
*WIP* fix ui-tests to pass with wdio9 and chroemdriver v120
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-cocoara-lgp committed Oct 28, 2024
1 parent 5d84185 commit e87e025
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 161 deletions.
144 changes: 72 additions & 72 deletions tests/ui/specs/DateTimePicker/DateTimePicker-specs.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions tests/ui/specs/DateTimePicker/DateTimePicker-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
const daysInMonth = ({month, year}) => new Date(year, month, 0).getDate();

const extractValues = async (picker) => {
const day = parseInt(await picker.active(picker.day).getText());
const month = parseInt(await picker.active(picker.month).getText());
const year = parseInt(await picker.active(picker.year).getText());
const hour = parseInt(await picker.active(picker.hour).getText());
const minute = parseInt(await picker.active(picker.minute).getText());
const meridiem = await picker.meridiem.isExisting() ? await picker.active(picker.meridiem).getText() : null;
const day = parseInt(await picker.dateActive('day').getText());
const month = parseInt(await picker.dateActive('month').getText());
const year = parseInt(await picker.dateActive('year').getText());
const hour = parseInt(await picker.timeActive('hour').getText());
const minute = parseInt(await picker.timeActive('minute').getText());
const meridiem = await picker.meridiem.isExisting() ? await picker.timeActive('meridiem').getText() : null;

return {day, month, year, hour, minute, meridiem};
};
Expand Down
21 changes: 15 additions & 6 deletions tests/ui/specs/DateTimePicker/DateTimePickerPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,25 @@ class DateTimePickerInterface {
return element('.TimePicker_TimePicker_minutePicker', this.self);
}

decrementer (picker) {
return element('.internal_Picker_Picker_itemDecrement', picker);
dateDecrementer (type) {
return $(`#${this.id} .DatePicker_DatePicker_${type} > .internal_Picker_Picker_itemDecrement`);
}
timeDecrementer (type) {
return $(`#${this.id} .TimePicker_TimePicker_${type}Picker > .internal_Picker_Picker_itemDecrement`);
}

incrementer (picker) {
return element('.internal_Picker_Picker_itemIncrement', picker);
dateIncrementer (type) {
return $(`#${this.id} .DatePicker_DatePicker_${type} > .internal_Picker_Picker_itemIncrement`);
}
timeIncrementer (type) {
return $(`#${this.id} .TimePicker_TimePicker_${type}Picker > .internal_Picker_Picker_itemIncrement`);
}

active (picker) {
return element('.internal_Picker_Picker_active', picker);
dateActive (type) {
return $(`#${this.id} .DatePicker_DatePicker_${type} > .internal_Picker_Picker_active`);
}
timeActive (type) {
return $(`#${this.id} .TimePicker_TimePicker_${type}Picker > .internal_Picker_Picker_active`);
}
}

Expand Down
52 changes: 26 additions & 26 deletions tests/ui/specs/Picker/Picker-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ describe('Picker', function () {

describe('5-way', function () {
it('should change the value forward when incrementing the picker', async function () {
expect(await picker.incrementer(picker.self).isFocused()).toBe(true);
expect(await picker.incrementer().isFocused()).toBe(true);
await Page.spotlightSelect();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe('Banana');
});

it('should change the value backward when decrementing the picker', async function () {
expect(await picker.incrementer(picker.self).isFocused()).toBe(true);
expect(await picker.incrementer().isFocused()).toBe(true);
await Page.spotlightSelect();
await Page.spotlightUp();
expect(await picker.decrementer(picker.self).isFocused()).toBe(true);
expect(await picker.decrementer().isFocused()).toBe(true);
await Page.spotlightSelect();
await browser.pause(500);
const newValue = await extractValue(picker);
Expand All @@ -35,16 +35,16 @@ describe('Picker', function () {

describe('pointer', function () {
it('should increase the value when incrementing the picker', async function () {
await picker.incrementer(picker.self).click();
await picker.incrementer().click();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe('Banana');
});

it('should decrease the value when decrementing the picker', async function () {
await picker.incrementer(picker.self).click();
expect(await picker.incrementer(picker.self).isFocused()).toBe(true);
await picker.decrementer(picker.self).click();
await picker.incrementer().click();
expect(await picker.incrementer().isFocused()).toBe(true);
await picker.decrementer().click();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe('Apple');
Expand Down Expand Up @@ -79,15 +79,15 @@ describe('Picker', function () {
describe('pointer', function () {
it('should not increase the value when clicking the incrementer', async function () {
const oldValue = await extractValue(picker);
await picker.incrementer(picker.self).click();
await picker.incrementer().click();
browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe(oldValue);
});

it('should not decrease the value when clicking the decrementer', async function () {
const oldValue = await extractValue(picker);
await picker.decrementer(picker.self).click();
await picker.decrementer().click();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe(oldValue);
Expand Down Expand Up @@ -129,16 +129,16 @@ describe('Picker', function () {

describe('pointer', function () {
it('should increase the value when incrementing the picker', async function () {
await picker.incrementer(picker.self).click();
await picker.incrementer().click();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe('Banana');
});

it('should decrease the value when decrementing the picker', async function () {
await picker.incrementer(picker.self).click();
expect(await picker.incrementer(picker.self).isFocused()).toBe(true);
await picker.decrementer(picker.self).click();
await picker.incrementer().click();
expect(await picker.incrementer().isFocused()).toBe(true);
await picker.decrementer().click();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe('Apple');
Expand Down Expand Up @@ -177,15 +177,15 @@ describe('Picker', function () {
describe('pointer', function () {
it('should not increase the value when clicking the incrementer', async function () {
const oldValue = await extractValue(picker);
await picker.incrementer(picker.self).click();
await picker.incrementer().click();
browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe(oldValue);
});

it('should not decrease the value when decrementing the picker', async function () {
const oldValue = await extractValue(picker);
await picker.decrementer(picker.self).click();
await picker.decrementer().click();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe(oldValue);
Expand All @@ -205,18 +205,18 @@ describe('Picker', function () {

describe('5-way', function () {
it('should change the value forward when incrementing the picker', async function () {
expect(await picker.incrementer(picker.self).isFocused()).toBe(true);
expect(await picker.incrementer().isFocused()).toBe(true);
await Page.spotlightSelect();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe('Banana');
});

it('should change the value backward when decrementing the picker', async function () {
expect(await picker.incrementer(picker.self).isFocused()).toBe(true);
expect(await picker.incrementer().isFocused()).toBe(true);
await Page.spotlightSelect();
await Page.spotlightUp();
expect(await picker.decrementer(picker.self).isFocused()).toBe(true);
expect(await picker.decrementer().isFocused()).toBe(true);
await Page.spotlightSelect();
await browser.pause(500);
const newValue = await extractValue(picker);
Expand All @@ -226,16 +226,16 @@ describe('Picker', function () {

describe('pointer', function () {
it('should increase the value when incrementing the picker', async function () {
await picker.incrementer(picker.self).click();
await picker.incrementer().click();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe('Banana');
});

it('should decrease the value when decrementing the picker', async function () {
await picker.incrementer(picker.self).click();
expect(await picker.incrementer(picker.self).isFocused()).toBe(true);
await picker.decrementer(picker.self).click();
await picker.incrementer().click();
expect(await picker.incrementer().isFocused()).toBe(true);
await picker.decrementer().click();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe('Apple');
Expand Down Expand Up @@ -275,16 +275,16 @@ describe('Picker', function () {

describe('pointer', function () {
it('should increase the value when incrementing the picker', async function () {
await picker.incrementer(picker.self).click();
await picker.incrementer().click();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe('Banana');
});

it('should decrease the value when decrementing the picker', async function () {
await picker.incrementer(picker.self).click();
expect(await picker.incrementer(picker.self).isFocused()).toBe(true);
await picker.decrementer(picker.self).click();
await picker.incrementer().click();
expect(await picker.incrementer().isFocused()).toBe(true);
await picker.decrementer().click();
await browser.pause(500);
const newValue = await extractValue(picker);
expect(newValue).toBe('Apple');
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/specs/Picker/Picker-utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Utility methods for testing

const extractValue = async (picker) => {
return (await picker.active(picker.self)).getText();
return (await picker.active()).getText();
};

module.exports = {
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/specs/Picker/PickerPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ class PickerInterface {
return element('.internal_Picker_Picker_picker', this.self);
}

decrementer (picker) {
return element('.internal_Picker_Picker_itemDecrement', picker);
decrementer () {
return $(`#${this.id} .internal_Picker_Picker_itemDecrement`);
}

incrementer (picker) {
return element('.internal_Picker_Picker_itemIncrement', picker);
incrementer () {
return $(`#${this.id} .internal_Picker_Picker_itemIncrement`);
}

active (picker) {
return element('.internal_Picker_Picker_active', picker);
active () {
return $(`#${this.id} .internal_Picker_Picker_active`);
}
}

Expand Down
Loading

0 comments on commit e87e025

Please sign in to comment.