Skip to content

Commit

Permalink
EWPP-3345: Fix behat step for asserting CCK usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergepavle committed Sep 8, 2023
1 parent d2218d6 commit aeccab5
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tests/Behat/WebtoolsCookieConsentContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Exception\DriverException;
use Behat\Mink\Exception\UnsupportedDriverActionException;
use Composer\Semver\Semver;
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Drupal\media\Entity\Media;

Expand Down Expand Up @@ -111,7 +112,14 @@ public function iVisitTheRemoteVideoEntityPage(TableNode $mediasTable): void {
*/
public function assertOembedIframeWithCckUsage(): void {
$iframe_url = $this->getSession()->getPage()->find('css', $this->getSelector('oembed_video'))->getAttribute('src');
$this->visitPath(str_replace(rtrim($this->getDrupalParameter('drupal')['drupal_root'], '/'), '', $iframe_url));
// @see https://www.drupal.org/project/drupal/issues/3311469.
if (Semver::satisfies(\Drupal::VERSION, '^10.1.3')) {
$base_url = $this->getMinkParameter('base_url');
}
else {
$base_url = $this->getDrupalParameter('drupal')['drupal_root'];
}
$this->visitPath(str_replace(rtrim($base_url, '/'), '', $iframe_url));
$this->assertSession()->elementExists('css', "iframe[src^='" . OE_WEBTOOLS_COOKIE_CONSENT_EMBED_COOKIE_URL . "?oriurl=']");
}

Expand All @@ -122,7 +130,14 @@ public function assertOembedIframeWithCckUsage(): void {
*/
public function assertNoOembedIframeWithCckUsage(): void {
$iframe_url = $this->getSession()->getPage()->find('css', $this->getSelector('oembed_video'))->getAttribute('src');
$this->visitPath(str_replace(rtrim($this->getDrupalParameter('drupal')['drupal_root'], '/'), '', $iframe_url));
// @see https://www.drupal.org/project/drupal/issues/3311469.
if (Semver::satisfies(\Drupal::VERSION, '^10.1.3')) {
$base_url = $this->getMinkParameter('base_url');
}
else {
$base_url = $this->getDrupalParameter('drupal')['drupal_root'];
}
$this->visitPath(str_replace(rtrim($base_url, '/'), '', $iframe_url));
$this->assertSession()->elementNotExists('css', "iframe[src^='" . OE_WEBTOOLS_COOKIE_CONSENT_EMBED_COOKIE_URL . "?oriurl=']");
}

Expand Down

0 comments on commit aeccab5

Please sign in to comment.