From 9e79029c92c849cce78f8780e7c6773765b07f1a Mon Sep 17 00:00:00 2001 From: 22Alexandra Date: Thu, 2 Jun 2022 11:48:01 +0300 Subject: [PATCH] EWPP-2098: Adapt site header selectors in tests. --- behat.yml.dist | 10 +++---- .../language-list-selector.html.twig | 2 +- tests/src/Behat/OeThemeTestContext.php | 27 +++++++------------ tests/src/Functional/ConfigurationTest.php | 12 ++++----- tests/src/Kernel/LanguageSwitcherTest.php | 2 +- 5 files changed, 23 insertions(+), 30 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 8cea468562..bcc9d56cfc 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -26,18 +26,18 @@ default: breadcrumb: "nav.ecl-breadcrumb" dropdown content: ".ecl-unordered-list" language switcher: ".ecl-language-list" - language switcher link: ".ecl-site-header-core__language-selector, .ecl-site-header-standardised__language-selector" + language switcher link: ".ecl-site-header__language-selector" language switcher links: ".ecl-language-list--overlay" list item: ".ecl-content-item" list item image: ".ecl-content-item__image__before" - logo: "a.ecl-site-header-core__logo-link .ecl-site-header-core__logo-image, a.ecl-site-header-standardised__logo-link .ecl-site-header-standardised__logo-image" + logo: "a.ecl-site-header__logo-link .ecl-site-header__logo-image" footer logo: "a.ecl-footer-core__logo-link .ecl-footer-core__logo-image-desktop, a.ecl-footer-standardised__logo-link .ecl-footer-standardised__logo-image-desktop" media container: ".ecl-media-container" page header: ".ecl-page-header" priorities dropdown menu: ".ecl-menu__item:nth-child(3) .ecl-menu__mega" search form: ".ecl-search-form" navigation menu: ".ecl-menu" - site name: ".ecl-site-header-standardised__site-name" + site name: ".ecl-site-header__site-name" pages: content management: "/en/admin/content" ECL components overview: "/en/components" @@ -68,8 +68,8 @@ default: region_map: about dropdown menu: ".ecl-menu__item:nth-child(2) .ecl-menu__mega" footer: "footer.ecl-footer-core, footer.ecl-footer-standardised" - header: ".ecl-site-header-core, .ecl-site-header-standardised" - header with menu: ".ecl-site-header-core[data-ecl-has-menu], .ecl-site-header-standardised[data-ecl-has-menu]" + header: ".ecl-site-header" + header with menu: ".ecl-site-header[data-ecl-has-menu]" language dialog: ".ecl-dialog" language switcher: ".ecl-language-list" navigation: ".ecl-menu" diff --git a/templates/compositions/ec-component-language-list/language-list-selector.html.twig b/templates/compositions/ec-component-language-list/language-list-selector.html.twig index 1f4095b75c..af2e35602f 100644 --- a/templates/compositions/ec-component-language-list/language-list-selector.html.twig +++ b/templates/compositions/ec-component-language-list/language-list-selector.html.twig @@ -29,7 +29,7 @@ "value" (string) (default: '') }, ... - ]. + ] #} {# Internal properties #} diff --git a/tests/src/Behat/OeThemeTestContext.php b/tests/src/Behat/OeThemeTestContext.php index 57a5922969..243781845d 100644 --- a/tests/src/Behat/OeThemeTestContext.php +++ b/tests/src/Behat/OeThemeTestContext.php @@ -393,8 +393,8 @@ public function assertEuMobileLogo(string $language): void { ]; $lang_code = array_merge($lang_code, $available_non_eu_logos); $langcode = $lang_code[$language] ?? 'en'; - $this->assertSession()->elementExists('css', 'img.ecl-site-header-' . $this->getEclBranding() . '__logo-image-mobile'); - $this->assertSession()->elementAttributeContains('css', 'img.ecl-site-header-' . $this->getEclBranding() . '__logo-image-mobile', 'src', 'oe_theme/dist/eu/images/logo/condensed-version/positive/logo-eu--' . $langcode . '.svg'); + $this->assertSession()->elementExists('css', 'img.ecl-site-header__logo-image-mobile'); + $this->assertSession()->elementAttributeContains('css', 'img.ecl-site-header__logo-image-mobile', 'src', 'oe_theme/dist/eu/images/logo/condensed-version/positive/logo-eu--' . $langcode . '.svg'); } /** @@ -407,7 +407,7 @@ public function assertHeaderLogoAccessibility(string $language): void { $component_library = \Drupal::config($theme_name . '.settings')->get('component_library'); $eu_official_languages = $this->getEuLanguages(); - $link_selector = '.ecl-site-header-' . $this->getEclBranding() . '__logo-link'; + $link_selector = '.ecl-site-header__logo-link'; $link = $this->getSession()->getPage()->find('css', $link_selector); if ($component_library === 'ec') { $href = !empty($eu_official_languages[$language]) ? 'https://ec.europa.eu/info/index_' . $eu_official_languages[$language] : 'https://ec.europa.eu/info'; @@ -437,25 +437,18 @@ public function assertHeaderLogoAccessibility(string $language): void { * @Then I should see the :ecl_branding site header */ public function iShouldSeeTheSiteHeader(string $ecl_branding): void { - $brandings = [ - 'Core' => 'core', - 'Standardised' => 'standardised', - ]; - - if (empty($brandings[$ecl_branding])) { - throw new \Exception("Theme do not support '$ecl_branding' ECL branding."); + if (!in_array($ecl_branding, ['Core', 'Standardised'])) { + throw new \Exception("Theme does not support '$ecl_branding' ECL branding. The only supported brandings and 'Core' and 'Standardised'"); } - $ecl_branding_code = $brandings[$ecl_branding]; - - $this->assertSession()->elementExists('css', 'a.ecl-site-header-' . $ecl_branding_code . '__logo-link .ecl-site-header-' . $ecl_branding_code . '__logo-image'); - $this->assertSession()->elementExists('css', '.ecl-site-header-' . $ecl_branding_code . '__top .ecl-site-header-' . $ecl_branding_code . '__action .ecl-site-header-' . $ecl_branding_code . '__language-selector'); - $this->assertSession()->elementExists('css', '.ecl-site-header-' . $ecl_branding_code . '__top .ecl-site-header-' . $ecl_branding_code . '__action .ecl-site-header-' . $ecl_branding_code . '__search-container'); + $this->assertSession()->elementExists('css', 'a.ecl-site-header__logo-link .ecl-site-header__logo-image'); + $this->assertSession()->elementExists('css', '.ecl-site-header__top .ecl-site-header__action .ecl-site-header__language-selector'); + $this->assertSession()->elementExists('css', '.ecl-site-header__top .ecl-site-header__action .ecl-site-header__search-container'); $site_name_method = 'elementExists'; - if ($ecl_branding_code == 'core') { + if ($ecl_branding == 'Core') { $site_name_method = 'elementNotExists'; } - $this->assertSession()->{$site_name_method}('css', '.ecl-site-header-' . $ecl_branding_code . '__banner'); + $this->assertSession()->{$site_name_method}('css', '.ecl-site-header__banner'); } diff --git a/tests/src/Functional/ConfigurationTest.php b/tests/src/Functional/ConfigurationTest.php index 6423e0bde5..8162400c8f 100755 --- a/tests/src/Functional/ConfigurationTest.php +++ b/tests/src/Functional/ConfigurationTest.php @@ -184,12 +184,12 @@ public function testChangeEclBranding(): void { $this->drupalGet(''); // Make sure that classes for Core template is present. - $assert_session->elementExists('css', 'header.ecl-site-header-core div.ecl-site-header-core__top'); - $assert_session->elementExists('css', 'header.ecl-site-header-core div.ecl-site-header-core__top div.ecl-site-header-core__action'); + $assert_session->elementExists('css', 'header.ecl-site-header div.ecl-site-header__top'); + $assert_session->elementExists('css', 'header.ecl-site-header div.ecl-site-header__top div.ecl-site-header__action'); // Make sure that 'Site name' banner is not present in the site header // for Core template. - $assert_session->elementNotExists('css', 'header.ecl-site-header-core .ecl-site-header-standardised__banner .ecl-container'); + $assert_session->elementNotExists('css', 'header.ecl-site-header .ecl-site-header__banner .ecl-container'); // Visit theme administration page. $this->drupalGet('/admin/appearance/settings/' . $active_theme); @@ -202,11 +202,11 @@ public function testChangeEclBranding(): void { $this->drupalGet(''); // Make sure that classes for Standardised branding is present. - $assert_session->elementExists('css', 'header.ecl-site-header-standardised .ecl-site-header-standardised__header div.ecl-site-header-standardised__top'); - $assert_session->elementExists('css', 'header.ecl-site-header-standardised .ecl-site-header-standardised__header div.ecl-site-header-standardised__top div.ecl-site-header-standardised__action'); + $assert_session->elementExists('css', 'header.ecl-site-header .ecl-site-header__header div.ecl-site-header__top'); + $assert_session->elementExists('css', 'header.ecl-site-header .ecl-site-header__header div.ecl-site-header__top div.ecl-site-header__action'); // Make sure that 'Site name' banner is present in the site header // for Standardised template. - $assert_session->elementExists('css', 'header.ecl-site-header-standardised .ecl-site-header-standardised__banner .ecl-container'); + $assert_session->elementExists('css', 'header.ecl-site-header .ecl-site-header__banner .ecl-container'); } } diff --git a/tests/src/Kernel/LanguageSwitcherTest.php b/tests/src/Kernel/LanguageSwitcherTest.php index dbbfb0f0a1..106a12e8c7 100644 --- a/tests/src/Kernel/LanguageSwitcherTest.php +++ b/tests/src/Kernel/LanguageSwitcherTest.php @@ -158,7 +158,7 @@ public function testLanguageSwitcherRendering(string $langcode, string $lang_pre $actual = $crawler->filter('a[data-ecl-language-selector]')->text(); $this->assertStringContainsString($language_name, $actual); - $actual = $crawler->filter('a[data-ecl-language-selector] .ecl-site-header-core__language-code')->text(); + $actual = $crawler->filter('a[data-ecl-language-selector] .ecl-site-header__language-code')->text(); $this->assertEquals($lang_prefix, $actual); // Make sure that the actual language link is set as active.