Skip to content

Commit

Permalink
fix(web): fixed the interaction to Select
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-molak committed Sep 30, 2021
1 parent ef79d19 commit 10b7b74
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 47 deletions.
Expand Up @@ -24,7 +24,7 @@ describe('Select', () => {
static anotherCountryName = Target.the('another country name').located(by.css('#another-country-of-interest-name'));
}

describe.skip('when working with single-option selects', () => {
describe('when working with single-option selects', () => {

describe('Select.value()', () => {

Expand Down Expand Up @@ -69,7 +69,7 @@ describe('Select', () => {
});
});

describe.skip('when working with multi-option selects', () => {
describe('when working with multi-option selects', () => {

describe('Select.values()', () => {

Expand Down
46 changes: 1 addition & 45 deletions packages/web/src/screenplay/interactions/Select.ts
Expand Up @@ -280,7 +280,7 @@ class SelectValues implements Interaction {
async performAs(actor: UsesAbilities & AnswersQuestions): Promise<void> {

const target = await actor.answer(this.target);
const options: UIElementList = await target.locateAllChildElements(by.css('options'));
const options: UIElementList = await target.locateAllChildElements(by.css('option'));

const desiredValues = (await Promise.all(this.values.map(value => actor.answer(value)))).flat();

Expand All @@ -291,23 +291,6 @@ class SelectValues implements Interaction {
return option.click()
}
});
// todo: remove
// return Promise.all(this.values.map(value => actor.answer(value)))
// .then(flatten)
// .then(values => {
//
// const
// hasRequiredValue = (option: ElementFinder) =>
// Value.of(option).answeredBy(actor).then(value => !! ~values.indexOf(value));
//
// return promiseOf(
// withAnswerOf(actor, this.target, (element: ElementFinder) =>
// element.all(by.css('option'))
// .filter(optionsToSelect(hasRequiredValue))
// .each(select)
// )
// );
// });
}

toString () {
Expand All @@ -333,15 +316,6 @@ class SelectOption implements Interaction {
const option = await target.locateChildElement(by.cssContainingText('option', value));

return option.click();

// todo: remove
// return actor.answer(this.value)
// .then(value => {
// return promiseOf(withAnswerOf(actor, this.target, (element: ElementFinder) =>
// element
// .element(by.cssContainingText('option', value)))
// .click());
// });
}

toString () {
Expand Down Expand Up @@ -373,24 +347,6 @@ class SelectOptions implements Interaction {
return option.click()
}
});

// todo: remove
// return Promise.all(this.values.map(value => actor.answer(value)))
// .then(flatten)
// .then(values => {
//
// const
// hasRequiredText = (option: ElementFinder) =>
// option.getText().then(value => !! ~values.indexOf(value));
//
// return promiseOf(
// withAnswerOf(actor, this.target, (element: ElementFinder) =>
// element.all(by.css('option'))
// .filter(optionsToSelect(hasRequiredText))
// .each(select)
// )
// );
// });
}

toString () {
Expand Down

0 comments on commit 10b7b74

Please sign in to comment.