Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
ISAICP-6575: Change tests class.
Browse files Browse the repository at this point in the history
  • Loading branch information
saidatom committed Oct 21, 2021
1 parent 5ba961a commit 4838fc5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions tests/src/Context/JoinupContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ public function assertContentOgMembership($parent, $parent_bundle, $content_bund
* @Then I (should )see the :heading tile
*/
public function assertTilePresent($heading) {
$results = $this->getSession()->getPage()->findAll('css', '.card .card-title, article.tile h2');
$results = $this->getSession()->getPage()->findAll('css', '.listing__item--tile .listing__title, .card .card-title, article.tile h2');
foreach ($results as $result) {
/** @var \Behat\Mink\Element\Element $result */
if ($result->getText() === $heading) {
Expand All @@ -1156,7 +1156,7 @@ public function assertTilePresent($heading) {
* @Then I (should )see :number tile(s)
*/
public function assertTileCount($number) {
$results = $this->getSession()->getPage()->findAll('css', '.card .card-title, article.tile h2');
$results = $this->getSession()->getPage()->findAll('css', '.listing__item--tile .listing__title, .card .card-title, article.tile h2');
$nr_found = count($results);
if ($nr_found != $number) {
throw new \Exception("Found $nr_found tiles, expected $number");
Expand All @@ -1177,7 +1177,7 @@ public function assertTileCount($number) {
public function assertTileNotPresent($heading) {
// We target the heading with "h2" instead of ".listing__title" because both
// unstyled and styled tiles use h2 as element for their titles.
$results = $this->getSession()->getPage()->findAll('css', '.card h5, article.tile h2');
$results = $this->getSession()->getPage()->findAll('css', '.listing__item--tile h2, .card h5, article.tile h2');
foreach ($results as $result) {
/** @var \Behat\Mink\Element\Element $result */
if ($result->getText() === $heading) {
Expand Down
11 changes: 7 additions & 4 deletions tests/src/Traits/TraversingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,12 @@ protected function getTiles($region = NULL): array {
}

$result = [];

foreach ($regionObj->findAll('css', '.card, article.tile') as $element) {
$title_element = $element->find('css', ' .card-title, h2 a');
// @todo The `.listing__item--tile` selector is part of the original Joinup
// theme and can be removed once we have fully migrated to the new theme.
foreach ($regionObj->findAll('css', '.listing__item--tile, .card, article.tile') as $element) {
// @todo The `.listing__title` selector is part of the original Joinup
// theme and can be removed once we migrated to the new theme.
$title_element = $element->find('css', ' .listing__title, .card-title, h2 a');
// Some tiles don't have a title, like the one to create a new collection
// in the collections page.
if ($title_element) {
Expand Down Expand Up @@ -291,7 +294,7 @@ protected function getListingByHeading(string $type, string $heading): NodeEleme
// @todo This can be removed once we are fully migrated to the new theme.
$xpath = '//*[@class and contains(concat(" ", normalize-space(@class), " "), " ' . $type . ' ")]';
// That have a heading with the specified text.
$xpath .= '[.//*[@class and contains(concat(" ", normalize-space(@class), " "), " listing__title ")][normalize-space()="' . $heading . '"]]';
$xpath .= '[.//*[@class and contains(concat(" ", normalize-space(@class), " "), " listing__title ") or contains(concat(" ", normalize-space(@class), " "), " card-title ")][normalize-space()="' . $heading . '"]]';

$item = $this->getSession()->getPage()->find('xpath', $xpath);

Expand Down

0 comments on commit 4838fc5

Please sign in to comment.