From ac597d220a3a3960c14da4e089376726b5503b9f Mon Sep 17 00:00:00 2001
From: Lily Yan <l26yan@uwaterloo.ca>
Date: Thu, 19 Dec 2024 14:52:20 -0500
Subject: [PATCH] ISTWCMS-7189 Add switchtoIFrame to make
 WcmsTestsBlocksEmbedsCest work

---
 acceptance/WcmsTestsBlocksEmbedsCest.php | 38 +++++++++++++++++-------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/acceptance/WcmsTestsBlocksEmbedsCest.php b/acceptance/WcmsTestsBlocksEmbedsCest.php
index 88db328..187f314 100644
--- a/acceptance/WcmsTestsBlocksEmbedsCest.php
+++ b/acceptance/WcmsTestsBlocksEmbedsCest.php
@@ -1,7 +1,5 @@
 <?php
 
-use Codeception\Util\Locator;
-
 /**
  * Class WcmsTestsBlocksEmbedsCest.
  *
@@ -55,6 +53,9 @@ class WcmsTestsBlocksEmbedsCest {
     $i->click('Google Maps');
     $i->waitForText('Configure block');
 
+    // Switch the block form iframe.
+    $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]');
+
     // Get the settings for Google Maps.
     $title = $i->uwRandomString();
     $gm_url = 'https://www.google.com/maps/embed?pb=' . $i->uwRandomString();
@@ -67,8 +68,10 @@ class WcmsTestsBlocksEmbedsCest {
 
     // Click on add block and ensure it is on the screen.
     $i->click('Add block');
-    $i->waitForElement(Locator::contains('div[class="uw-admin-label"]', 'Google Maps'));
-    $i->seeElement(Locator::contains('div[class="uw-admin-label"]', 'Google Maps'));
+
+    $i->switchtoIFrame();
+    $i->waitForElement('div[class="uw-google-maps"]');
+    $i->seeElement('div[class="uw-google-maps"]');
 
     // Check for elements on the page.
     $i->see($title);
@@ -108,6 +111,9 @@ class WcmsTestsBlocksEmbedsCest {
     $i->click('PowerBI');
     $i->waitForText('Configure block');
 
+    // Switch the block form iframe.
+    $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]');
+
     // Get the settings for the block.
     $title = $i->uwRandomString();
     $url = 'https://app.powerbi.com/' . $i->uwRandomString();
@@ -118,8 +124,10 @@ class WcmsTestsBlocksEmbedsCest {
 
     // Click on add block and ensure it is on the screen.
     $i->click('Add block');
-    $i->waitForElement(Locator::contains('div[class="uw-admin-label"]', 'PowerBI'));
-    $i->seeElement(Locator::contains('div[class="uw-admin-label"]', 'PowerBI'));
+
+    $i->switchToIFrame();
+    $i->waitForElement('div[class="uw-powerbi"]');
+    $i->seeElement('div[class="uw-powerbi"]');
 
     // Ensure elements are on the page.
     $i->see($title);
@@ -159,6 +167,9 @@ class WcmsTestsBlocksEmbedsCest {
     $i->click('Social Intents');
     $i->waitForText('Configure block');
 
+    // Switch the block form iframe.
+    $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]');
+
     // Get the settings we are going to use.
     $title = $i->uwRandomString();
     $username = 'uwist';
@@ -169,8 +180,10 @@ class WcmsTestsBlocksEmbedsCest {
 
     // Click on add block and ensure it is on the screen.
     $i->click('Add block');
-    $i->waitForElement(Locator::contains('div[class="uw-admin-label"]', 'Social Intents'));
-    $i->seeElement(Locator::contains('div[class="uw-admin-label"]', 'Social Intents'));
+
+    $i->switchToIFrame();
+    $i->waitForElement('div[class="uw-social-intents"]');
+    $i->seeElement('div[class="uw-social-intents"]');
 
     // Ensure elements appear on the page.
     $i->see($title);
@@ -209,6 +222,9 @@ class WcmsTestsBlocksEmbedsCest {
     $i->click('Tableau visualization');
     $i->waitForText('Configure block');
 
+    // Switch the block form iframe.
+    $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]');
+
     // Get the settings we are going to use.
     $title = $i->uwRandomString();
     $height = rand(100, 1000);
@@ -225,8 +241,10 @@ class WcmsTestsBlocksEmbedsCest {
 
     // Click on add block and ensure it is on the screen.
     $i->click('Add block');
-    $i->waitForElement(Locator::contains('div[class="uw-admin-label"]', 'Tableau visualization'));
-    $i->seeElement(Locator::contains('div[class="uw-admin-label"]', 'Tableau visualization'));
+
+    $i->switchToIFrame();
+    $i->waitForElement('div[class="uw-tableau"]');
+    $i->seeElement('div[class="uw-tableau"]');
 
     // Ensure elements appear on the page.
     $i->see($title);
-- 
GitLab