From 3d997d2cc2b8078be6e846342bd2a8f5469673d0 Mon Sep 17 00:00:00 2001 From: Lily Yan <l26yan@uwaterloo.ca> Date: Wed, 8 Jan 2025 14:51:00 -0500 Subject: [PATCH] ISTWCMS-7189 Add switchToIFrame to make WcmsTestsBlocksListingsCest work --- acceptance/WcmsTestsBlocksListingsCest.php | 183 ++++++++++++++++----- 1 file changed, 142 insertions(+), 41 deletions(-) diff --git a/acceptance/WcmsTestsBlocksListingsCest.php b/acceptance/WcmsTestsBlocksListingsCest.php index 75c25107..c686d0f8 100644 --- a/acceptance/WcmsTestsBlocksListingsCest.php +++ b/acceptance/WcmsTestsBlocksListingsCest.php @@ -75,6 +75,9 @@ class WcmsTestsBlocksListingsCest { $i->click('Multi-type list'); $i->waitForText('Configure block'); + // Switch the block form iframe. + $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]'); + // Ensure title options are present. $i->see('Title'); $i->seeElement('input[id^="edit-settings-label"]'); @@ -106,12 +109,15 @@ class WcmsTestsBlocksListingsCest { $i->checkOption('input[id^="edit-settings-show-view-all"]'); // Click on add block and ensure it is on the screen. - $i->click('Add block'); - $i->waitForElement(Locator::contains('div[class="uw-admin-label"]', 'Multi-type list')); - $i->seeElement(Locator::contains('div[class="uw-admin-label"]', 'Multi-type list')); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); + + $i->waitForText('Multi-type list'); + $i->see('Multi-type list'); // Click on save layout (List tabs cannot be navigated in layout editor). - $i->click('Save layout'); + $i->click('input[id="edit-submit"]'); // Ensure that we see elements for list tabs. $i->seeElement('div[class="uw-tabs"]'); @@ -122,23 +128,31 @@ class WcmsTestsBlocksListingsCest { $i->seeElement(Locator::contains('button[id*="tab-"]', 'Opportunities')); // Navigate to 'News' tab and check news elements. - $i->click('News', '.uw-tab'); + $i->scrollTo('.uw-tab'); + $i->waitForElementClickable('.uw-tab button[aria-controls="News"]', 10); + $i->executeJS("document.querySelector('.uw-tab button[aria-controls=\"News\"]').click()"); $i->see('newslist1'); $i->see('Read all news'); // Navigate to 'Events' tab and check event elements. - $i->click('Events', '.uw-tab'); + $i->scrollTo('.uw-tab button[aria-controls="Events"]'); + $i->waitForElementClickable('.uw-tab button[aria-controls="Events"]', 10); + $i->executeJS("document.querySelector('.uw-tab button[aria-controls=\"Events\"]').click()"); $i->see('eventslist1'); $i->see('All upcoming events'); // Navigate to 'Blog' tab and check blog elements. - $i->click('Blog', '.uw-tab'); + $i->scrollTo('.uw-tab button[aria-controls="Blog"]'); + $i->waitForElementClickable('.uw-tab button[aria-controls="Blog"]', 10); + $i->executeJS("document.querySelector('.uw-tab button[aria-controls=\"Blog\"]').click()"); $i->see(strtoupper(date('l, F j, Y'))); $i->see('bloglist1'); $i->see('View all blog posts'); // Navigate to 'Opportunities' tab and check opportunities elements. - $i->click('Opportunities', '.uw-tab'); + $i->scrollTo('.uw-tab button[aria-controls="Opportunities"]'); + $i->waitForElementClickable('.uw-tab button[aria-controls="Opportunities"]', 10); + $i->executeJS("document.querySelector('.uw-tab button[aria-controls=\"Opportunities\"]').click()"); $i->see('opportunitylist1'); $i->see('View all opportunities'); } @@ -179,6 +193,9 @@ class WcmsTestsBlocksListingsCest { $i->click('Automatic list'); $i->waitForText('Configure block'); + // Switch the block form iframe. + $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]'); + // Step through each content type and test that it is in // the select list. foreach (array_keys($content_types) as $machine_name) { @@ -222,6 +239,9 @@ class WcmsTestsBlocksListingsCest { $i->click('Manual list'); $i->waitForText('Configure block'); + // Switch the block form iframe. + $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]'); + // Step through each content type and test that it is in // the select list. foreach (array_keys($content_types) as $machine_name) { @@ -377,6 +397,9 @@ class WcmsTestsBlocksListingsCest { $i->click('Waterloo Events'); $i->waitForText('Configure block'); + // Switch the block form iframe. + $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]'); + // Step through and add all Waterloo Events urls. foreach ($events as $index => $eventUrls) { @@ -389,8 +412,11 @@ class WcmsTestsBlocksListingsCest { } // Add the block. - $i->click('Add block'); - $i->waitForElement(Locator::contains('div[class="uw-admin-label"]', 'Waterloo Events')); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + + $i->switchtoIFrame(); + $i->waitForText('Waterloo Events'); // Navigate to link are validate that url is not repeated. $i->click('Save layout'); @@ -459,27 +485,40 @@ class WcmsTestsBlocksListingsCest { $i->waitForText('Choose a block'); $i->click('Automatic list'); $i->waitForText('Configure block'); - $i->fillField('input[name="settings[label]"]', 'title'); + + // Switch the block form iframe. + $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]'); $i->selectOption('settings[content_type]', $content_type); // Create a block id and add the block. $i->fillField('input[name="settings[layout_builder_id]"]', 'automatic' . $machine_name); - $i->click('Add block'); - $i->waitForElement('.uw-admin-label'); + + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); + $i->waitForElement('.block-uw-cbl-automatic-list'); + $i->seeElement('.block-uw-cbl-automatic-list'); // Add an manual list block. $i->waitForText('Add block'); + $i->waitForElement('.layout-builder__add-block'); $i->click('Add block'); $i->waitForText('Choose a block'); $i->click('Manual list'); $i->waitForText('Configure block'); - $i->fillField('input[name="settings[label]"]', 'title'); + + // Switch the block form iframe. + $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]'); + $i->selectOption('settings[content_type]', $content_type); $i->fillField('input[name="settings[' . $machine_name . '][items_fieldset][' . $machine_name . '_ids][0][id]"]', 'test' . $machine_name); // Create a block id and add the block. $i->fillField('input[name="settings[layout_builder_id]"]', 'manual' . $machine_name); - $i->click('Add block'); + + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Edit layout for testpage'); // Save the layout. @@ -774,7 +813,9 @@ class WcmsTestsBlocksListingsCest { case 'blog': $i->selectOption('settings[blog][limit]', '6'); - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Automatic list'); $i->waitForElement('.card__teaser--blog'); $i->seeNumberOfElements('.card__teaser--blog', 4); @@ -799,20 +840,27 @@ class WcmsTestsBlocksListingsCest { $i->fillField('input[name="settings[blog][tags]"]', 'bt1'); $i->pressKey('input[name="settings[blog][tags]"]', WebDriverKeys::ARROW_DOWN); $i->pressKey('input[name="settings[blog][tags]"]', WebDriverKeys::ENTER); - $i->click('Add block'); + + // Siwtch to iframe. + $i->switchToIFrame(); + $i->waitForElement('.card__teaser--blog'); $i->seeNumberOfElements('.card__teaser--blog', 2); break; case 'catalog': - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Automatic list'); $i->waitForElement('.views-field-nid'); $i->seeNumberOfElements('.views-field-nid', 3); break; case 'catalog_item': - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Automatic list'); $i->waitForElement('.views-field-title'); $i->seeNumberOfElements('.views-field-title', 3); @@ -825,13 +873,17 @@ class WcmsTestsBlocksListingsCest { 10 ); $i->fillField('input[name="settings[catalog_item][catalog]"]', 'c1'); - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForElement('.views-field-title'); $i->seeNumberOfElements('.views-field-title', 2); break; case 'contact': - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Automatic list'); $i->waitForElement('.uw-contact'); $i->seeNumberOfElements('.uw-contact', 3); @@ -844,13 +896,17 @@ class WcmsTestsBlocksListingsCest { 10 ); $i->fillField('input[name="settings[contact][groups]"]', 'cg1'); - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForElement('.uw-contact'); $i->seeNumberOfElements('.uw-contact', 2); break; case 'event': - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Automatic list'); $i->waitForElement('.card__teaser--event'); $i->seeNumberOfElements('.card__teaser--event', 3); @@ -863,13 +919,17 @@ class WcmsTestsBlocksListingsCest { 10 ); $i->fillField('input[name="settings[event][tags]"]', 'et1'); - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForElement('.card__teaser--event'); $i->seeNumberOfElements('.card__teaser--event', 2); break; case 'news_item': - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Automatic list'); $i->waitForElement('.card__teaser--news-item'); $i->seeNumberOfElements('.card__teaser--news-item', 3); @@ -882,13 +942,17 @@ class WcmsTestsBlocksListingsCest { 10 ); $i->fillField('input[name="settings[news_item][tags]"]', 'nt1'); - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForElement('.card__teaser--news-item'); $i->seeNumberOfElements('.card__teaser--news-item', 2); break; case 'opportunity': - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Automatic list'); $i->waitForElement('.card__teaser--opportunity'); $i->seeNumberOfElements('.card__teaser--opportunity', 3); @@ -903,13 +967,17 @@ class WcmsTestsBlocksListingsCest { $i->selectOption('select[name="settings[opportunity][type]"]', 35); $i->selectOption('select[name="settings[opportunity][employment]"]', 38); $i->selectOption('select[name="settings[opportunity][rate_of_pay]"]', 41); - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForElement('.card__teaser--opportunity'); $i->seeNumberOfElements('.card__teaser--opportunity', 2); break; case 'profile': - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Automatic list'); $i->waitForElement('.card__teaser--profile'); $i->seeNumberOfElements('.card__teaser--profile', 3); @@ -922,13 +990,17 @@ class WcmsTestsBlocksListingsCest { 10 ); $i->fillField('input[name="settings[profile][types]"]', 'ptype1'); - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForElement('.card__teaser--profile'); $i->seeNumberOfElements('.card__teaser--profile', 2); break; case 'project': - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Automatic list'); $i->waitForElement('.card__teaser--project'); $i->seeNumberOfElements('.card__teaser--project', 3); @@ -942,7 +1014,9 @@ class WcmsTestsBlocksListingsCest { ); $i->selectOption('select[name="settings[project][status]"]', 44); $i->selectOption('select[name="settings[project][topic]"]', 'pt1'); - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForElement('.card__teaser--project'); $i->seeNumberOfElements('.card__teaser--project', 2); break; @@ -952,7 +1026,9 @@ class WcmsTestsBlocksListingsCest { break; case 'service': - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForText('Automatic list'); $i->waitForElement('.views-field-field-uw-service-summary'); $this->removeAddFirstSection($i); @@ -961,10 +1037,15 @@ class WcmsTestsBlocksListingsCest { $i->waitForText('Choose a block'); $i->click('Automatic list'); $i->waitForText('Automatic list'); - $i->waitForElement('.js-form-item-settings-content-type'); + $i->see('Automatic list'); + $i->waitForElement('.lbim-dialog-iframe'); + $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]'); + $i->waitForElement('#edit-settings-content-type'); $i->selectOption('settings[content_type]', 'service'); $i->fillField('input[name="settings[service][categories]"]', 'sc1'); - $i->click('Add block'); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); $i->waitForElement('.views-field-field-uw-service-summary'); break; @@ -992,7 +1073,9 @@ class WcmsTestsBlocksListingsCest { $i->fillField('input[name="settings[event][items_fieldset][event_ids][0][id]"]', 'Events1'); $i->selectOption('settings[event][style]', 'agenda'); $i->click('Add block'); - $i->waitForText('Manual list'); + $i->switchToIFrame(); + $i->waitForText('Events1'); + $i->see('Events1'); $i->waitForElement('.uw-agenda'); $this->removeAddFirstSection($i); $this->addListingBlockWithContentType( @@ -1004,6 +1087,7 @@ class WcmsTestsBlocksListingsCest { $i->fillField('input[name="settings[event][items_fieldset][event_ids][0][id]"]', 'Events1'); $i->selectOption('settings[event][style]', 'default'); $i->click('Add block'); + $i->switchtoIFrame(); $i->waitForText('Manual list'); $i->dontSeeElement('.uw-agenda'); break; @@ -1051,8 +1135,14 @@ class WcmsTestsBlocksListingsCest { $i->click('Add block'); $i->waitForText('Choose a block'); $i->click('Automatic list'); + $i->waitForText('Configure block'); + + // Switch the block form iframe. + $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]'); + $i->waitForText('Automatic list'); - $i->waitForElement('.js-form-item-settings-content-type'); + $i->see('Automatic list'); + $i->waitForElement('#edit-settings-content-type'); $i->selectOption('settings[content_type]', 'catalog'); $i->see('Catalog list settings'); $i->see('Heading selector'); @@ -1147,7 +1237,10 @@ class WcmsTestsBlocksListingsCest { $i->waitForText('Choose a block'); $i->click('Automatic list'); $i->waitForText('Automatic list'); - $i->waitForElement('.js-form-item-settings-content-type'); + $i->see('Automatic list'); + $i->waitForElement('.lbim-dialog-iframe'); + $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]'); + $i->waitForElement('#edit-settings-content-type'); $i->selectOption('settings[content_type]', 'service'); $i->see('Service list settings'); $i->see('Categories'); @@ -1241,17 +1334,25 @@ class WcmsTestsBlocksListingsCest { $i->click('Add block'); $i->waitForText('Choose a block'); $i->click($block_type); + $i->waitForText('Configure block'); + + // Switch the block form iframe. + $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]'); + $i->waitForText($block_type); - $i->waitForElement('.js-form-item-settings-content-type'); + $i->see($block_type); + $i->waitForElement('#edit-settings-content-type'); $i->selectOption('settings[content_type]', $content_type); + if ($block_type == 'Automatic list' && $content_type != 'services' && $block_type != 'catalogs') { $i->selectOption('settings[' . $content_type . '][limit]', $limit); } if ($save_block) { - $i->click('Add block'); - $i->waitForText($block_type); + $i->waitForElementClickable('input[id*="edit-actions-submit"]'); + $i->click('input[id*="edit-actions-submit"]'); + $i->switchToIFrame(); } } -- GitLab