Skip to content

Commit

Permalink
add bool filter Behat test
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed May 8, 2023
1 parent 5cd0fa9 commit 4b613da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Behat/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public function iClickUsingSelector(string $selector): void
*/
public function iClickPaginatorPage(string $pageNumber): void
{
$element = $this->findElement(null, 'a.item[data-page=' . $pageNumber . ']');
$element = $this->findElement(null, 'a.item[data-page="' . $pageNumber . '"]');
$element->click();
}

Expand Down Expand Up @@ -542,16 +542,18 @@ public function iSearchGridFor(string $text): void
*/
public function iSelectValueInLookup(string $value, string $inputName): void
{
$isXpath = $this->parseSelector($inputName)[0] === 'xpath';

// get dropdown item from Fomantic-UI which is direct parent of input html element
$lookupElem = $this->findElement(null, '//input[@name="' . $inputName . '"]/parent::div');
$lookupElem = $this->findElement(null, ($isXpath ? $inputName : '//input[@name="' . $inputName . '"]') . '/parent::div');

// open dropdown and wait till fully opened (just a click is not triggering it)
$this->getSession()->executeScript('$(arguments[0]).dropdown(\'show\')', [$lookupElem]);
$this->jqueryWait('$(arguments[0]).hasClass(\'visible\')', [$lookupElem]);

// select value
$valueElem = $this->findElement($lookupElem, '//div[text()="' . $value . '"]');
$this->getSession()->executeScript('$(arguments[0]).dropdown(\'set selected\', ' . $valueElem->getAttribute('data-value') . ');', [$lookupElem]);
$this->getSession()->executeScript('$(arguments[0]).dropdown(\'set selected\', arguments[1]);', [$lookupElem, $valueElem->getAttribute('data-value')]);
$this->jqueryWait();

// hide dropdown and wait till fully closed
Expand Down
8 changes: 8 additions & 0 deletions tests-behat/filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ Feature: Table Filter
When I click using selector "//div.popup[5]//div[text()='Clear']"
Then I should not see "No records"
Then I should see "United Kingdom"
Then I click filter column name "is_uk"
Then I select value "Is No" in lookup "//div.popup[6]//input[@name='op']"
When I click using selector "//div.popup[6]//div[text()='Set']"
Then I should see "No records"
Then I click filter column name "is_uk"
Then I select value "Is Yes" in lookup "//div.popup[6]//input[@name='op']"
When I click using selector "//div.popup[6]//div[text()='Set']"
Then I should see "United Kingdom"
Then I press menu button "Clear Filters" using selector ".ui.menu.atk-grid-menu"
Then I should not see "United Kingdom"
Then I should see "Australia"

0 comments on commit 4b613da

Please sign in to comment.