-
Notifications
You must be signed in to change notification settings - Fork 21
ISAICP-6577: Topic select to use SlimSelect. #2592
base: EPIC-6572
Are you sure you want to change the base?
Conversation
0ccd98b
to
1459abc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before doing a detailed QA, we need to fix:
- Looking to mockups, at https://citnet.tech.ec.europa.eu/CITnet/jira/browse/ISAICP-6572 (multiselect - Desktop.pdf), I see there is a multiselect Slim Select. But here we have a single select. Should be fixed.
- Tests are failing. I tried locally and failed for me too, but in a different line. We should find out why and fix. The fact that it passes locally and failing in CPHP cannot be explained generically with "infrastructure issue". It's new test coverage and should pass.
0ab9f82
to
9d9f31e
Compare
9d9f31e
to
75647eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the inline remarks, we need to test multi-select.
* | ||
* @When I select :option option(s) from the :label Slim Select | ||
*/ | ||
public function iSelectAnOptionFromSlimSelect(string $option, string $label): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a/iSelectAnOptionFromSlimSelect/iSelectOptionsFromSlimSelect
$facet_id = self::getFacetIdFromAlias($label); | ||
$session = $this->getSession(); | ||
$xpath = '//div[contains(concat(" ", normalize-space(@class), " "), " block-facets-form ")]//select[@data-drupal-selector="' . $facet_id . '"]'; | ||
$slim_select = $session->getPage()->find('xpath', $xpath); | ||
if (!$slim_select) { | ||
throw new \Exception("The Slim Select '$label' was not found in the page."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of abstracting the Slim Select search/find into a protected method was not implemented. Also we have here hadcoded references to Facets Form. We need a generic step definition that work not only for Facets Form but for any Slim Select on the site. Should be only searchable by its label: get the native select > (wait to be rendered) > get the Slim Select.
$facet_id = self::getFacetIdFromAlias($select); | ||
$region = $this->getSession()->getPage(); | ||
$slim_select = $region->find('xpath', "//*[@data-drupal-selector='{$facet_id}']"); | ||
|
||
if (!$slim_select) { | ||
throw new \Exception(sprintf('The select "%s" was not found in the page %s', $select, $this->getSession()->getCurrentUrl())); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. Need abstraction.
$facet_id = self::getFacetIdFromAlias($select); | ||
$region = $this->getSession()->getPage(); | ||
$xpath = "//*[@data-drupal-selector='{$facet_id}']"; | ||
$page = $this->getSession()->getPage(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. Abstraction
public function iClickActionsInFacetsForm(string $name) { | ||
public function iClickSearchInFacetsForm(string $name) { | ||
$region = $this->getSession()->getPage(); | ||
$element = $region->find('xpath', "//input[@value='{$name}']"); | ||
$element->click(); | ||
$xpath = '//div[contains(concat(" ", normalize-space(@class), " "), " block-facets-form ")]//div[@data-drupal-selector="edit-actions"]'; | ||
$actions = $region->find('xpath', $xpath); | ||
|
||
$element = $actions->find('css', "input[value|='{$name}']"); | ||
$element->submit(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this. Use When I press "Search"
.
$slim_select = $region->find('xpath', "//*[@data-drupal-selector='{$facet_id}']"); | ||
|
||
if (!$slim_select) { | ||
throw new \Exception(sprintf('The select "%s" was not found in the page %s', $select, $this->getSession()->getCurrentUrl())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ElementNotFoundException everywhere it applies.
$xpath = '//div[contains(concat(" ", normalize-space(@class), " "), " block-facets-form ")]//div[contains(concat(" ", normalize-space(@class), " "), "' . $slim_select->getAttribute('data-ssid') . '")]'; | ||
$select = $session->getPage()->waitFor(5, function () use ($session, $xpath) { | ||
return $session->getPage()->find('xpath', $xpath); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this into the new findSlimSelect()
methods so it applies everywhere we need to get the Slim Select.
throw new \Exception(sprintf('The select "%s" was not found in the page %s', $select, $this->getSession()->getCurrentUrl())); | ||
} | ||
|
||
if ($this->browserSupportsJavaScript()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All Slim Select step definitions should only work with Selenium tests. Use \Drupal\joinup\Traits\MaterialDesignTrait::selectMaterialDesignRadioButton()
as an example on how to enforce this.
For the test that runs w/o JS (tests/features/homepage.feature
) use the @Then the option with text :option from select :select is selected
step def.
No description provided.