Skip to content

Commit

Permalink
EWPP-1350: Update banner paragraph rendering test.
Browse files Browse the repository at this point in the history
  • Loading branch information
22Alexandra committed Jul 28, 2021
1 parent 010acc4 commit f7f4621
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions tests/Kernel/Paragraphs/MediaParagraphsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(0, $crawler->filter('div.ecl-page-banner--full-width'));
$this->assertCount(0, $crawler->filter('.ecl-hero-banner--full-width'));

// Render paragraph in Bulgarian.
$html = $this->renderParagraph($paragraph, 'bg');
Expand Down Expand Up @@ -414,7 +414,7 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(0, $crawler->filter('div.ecl-page-banner--full-width'));
$this->assertCount(0, $crawler->filter('.ecl-hero-banner--full-width'));

// Variant - image / Modifier - page_center / Full width - No.
$paragraph->get('field_oe_banner_type')->setValue('page_center');
Expand All @@ -433,7 +433,7 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(0, $crawler->filter('div.ecl-page-banner--full-width'));
$this->assertCount(0, $crawler->filter('.ecl-page-banner--full-width'));

// Variant - image / Modifier - page_left / Full width - Yes.
$paragraph->get('field_oe_banner_type')->setValue('page_left');
Expand All @@ -443,7 +443,7 @@ public function testBanner(): void {
$crawler = new Crawler($html);

$this->assertCount(0, $crawler->filter('section.ecl-page-banner.ecl-page-banner--image.ecl-page-banner--centered'));
$this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--image'));
$this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--image.ecl-page-banner--full-width'));
$image_element = $crawler->filter('section.ecl-page-banner.ecl-page-banner--image div.ecl-page-banner__image');
$this->assertCount(1, $image_element);
$this->assertContains(
Expand All @@ -454,7 +454,6 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner--full-width'));

// Variant - image-shade / Modifier - hero_center / Full width - Yes.
$paragraph->get('oe_paragraphs_variant')->setValue('oe_banner_image_shade');
Expand All @@ -463,7 +462,7 @@ public function testBanner(): void {
$html = $this->renderParagraph($paragraph);
$crawler = new Crawler($html);

$this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade.ecl-hero-banner--centered'));
$this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade.ecl-hero-banner--centered.ecl-hero-banner--full-width'));
$image_element = $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade.ecl-hero-banner--centered div.ecl-hero-banner__image');
$this->assertCount(1, $image_element);
$this->assertContains(
Expand All @@ -474,7 +473,6 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner--full-width'));

// Variant - image-shade / Modifier - hero_left / Full width - Yes.
$paragraph->get('field_oe_banner_type')->setValue('hero_left');
Expand All @@ -483,7 +481,7 @@ public function testBanner(): void {
$crawler = new Crawler($html);

$this->assertCount(0, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade.ecl-hero-banner--centered'));
$this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade'));
$this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade.ecl-hero-banner--full-width'));
$image_element = $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade div.ecl-hero-banner__image');
$this->assertCount(1, $image_element);
$this->assertContains(
Expand All @@ -494,7 +492,6 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner--full-width'));

// Variant - image-shade / Modifier - page_center / Full width - No.
$paragraph->get('field_oe_banner_type')->setValue('page_center');
Expand All @@ -514,7 +511,7 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(0, $crawler->filter('div.ecl-page-banner--full-width'));
$this->assertCount(0, $crawler->filter('.ecl-page-banner--full-width'));

// Variant - image-shade / Modifier - page_left / Full width - No.
$paragraph->get('field_oe_banner_type')->setValue('page_left');
Expand All @@ -534,7 +531,7 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(0, $crawler->filter('div.ecl-page-banner--full-width'));
$this->assertCount(0, $crawler->filter('.ecl-page-banner--full-width'));

// Variant - default / Modifier - hero_center / Full width - No.
$paragraph->get('oe_paragraphs_variant')->setValue('default');
Expand All @@ -555,7 +552,7 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(0, $crawler->filter('div.ecl-page-banner--full-width'));
$this->assertCount(0, $crawler->filter('.ecl-hero-banner--full-width'));

// Variant - default / Modifier - hero_left / Full width - Yes.
$paragraph->get('field_oe_banner_type')->setValue('hero_left');
Expand All @@ -565,7 +562,7 @@ public function testBanner(): void {
$crawler = new Crawler($html);

$this->assertCount(0, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--default.ecl-hero-banner--centered'));
$this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--default'));
$this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--default.ecl-hero-banner--full-width'));

// No image should be displayed on 'default' variant.
$this->assertCount(0, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image div.ecl-hero-banner__image'));
Expand All @@ -577,15 +574,14 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner--full-width'));

// Variant - default / Modifier - page_center / Full width - Yes.
$paragraph->get('field_oe_banner_type')->setValue('page_center');
$paragraph->save();
$html = $this->renderParagraph($paragraph);
$crawler = new Crawler($html);

$this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--default.ecl-page-banner--centered'));
$this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--default.ecl-page-banner--centered.ecl-page-banner--full-width'));

// No image should be displayed on 'default' variant.
$this->assertCount(0, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image div.ecl-hero-banner__image'));
Expand All @@ -597,7 +593,6 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner--full-width'));

// Variant - default / Modifier - page_left / Full width - Yes.
$paragraph->get('field_oe_banner_type')->setValue('page_left');
Expand All @@ -606,7 +601,7 @@ public function testBanner(): void {
$crawler = new Crawler($html);

$this->assertCount(0, $crawler->filter('section.ecl-page-banner.ecl-page-banner--default.ecl-page-banner--centered'));
$this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--default'));
$this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--default.ecl-page-banner--full-width'));

// No image should be displayed on 'default' variant.
$this->assertCount(0, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image div.ecl-hero-banner__image'));
Expand All @@ -618,7 +613,6 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner--full-width'));

// Variant - primary / Modifier - hero_center / Full width - Yes.
$paragraph->get('oe_paragraphs_variant')->setValue('oe_banner_primary');
Expand All @@ -627,7 +621,7 @@ public function testBanner(): void {
$html = $this->renderParagraph($paragraph);
$crawler = new Crawler($html);

$this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--primary.ecl-hero-banner--centered'));
$this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--primary.ecl-hero-banner--centered.ecl-hero-banner--full-width'));

// No image should be displayed on 'primary' variant.
$this->assertCount(0, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image.ecl-hero-banner--centered div.ecl-hero-banner__image'));
Expand All @@ -639,7 +633,6 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner--full-width'));

// Variant - primary / Modifier - hero_left / Full width - Yes.
$paragraph->get('field_oe_banner_type')->setValue('hero_left');
Expand All @@ -648,7 +641,7 @@ public function testBanner(): void {
$crawler = new Crawler($html);

$this->assertCount(0, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--primary.ecl-hero-banner--centered'));
$this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--primary'));
$this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--primary.ecl-hero-banner--full-width'));

// No image should be displayed on 'primary' variant.
$this->assertCount(0, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image div.ecl-hero-banner__image'));
Expand All @@ -660,15 +653,14 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner--full-width'));

// Variant - primary / Modifier - page_center / Full width - Yes.
$paragraph->get('field_oe_banner_type')->setValue('page_center');
$paragraph->save();
$html = $this->renderParagraph($paragraph);
$crawler = new Crawler($html);

$this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--primary.ecl-page-banner--centered'));
$this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--primary.ecl-page-banner--centered.ecl-page-banner--full-width'));

// No image should be displayed on 'primary' variant.
$this->assertCount(0, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image.ecl-hero-banner--centered div.ecl-hero-banner__image'));
Expand All @@ -680,7 +672,6 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner--full-width'));

// Variant - primary / Modifier - page_left / Full width - No.
$paragraph->get('field_oe_banner_type')->setValue('page_left');
Expand All @@ -702,7 +693,7 @@ public function testBanner(): void {
$this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text()));
$this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after'));
$this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text()));
$this->assertCount(0, $crawler->filter('div.ecl-page-banner--full-width'));
$this->assertCount(0, $crawler->filter('.ecl-page-banner--full-width'));

// Create a media using AV Portal image and add it to the paragraph.
$media = $media_storage->create([
Expand Down

0 comments on commit f7f4621

Please sign in to comment.