diff --git a/tests/src/Kernel/CallForProposalsRenderTest.php b/tests/src/Kernel/CallForProposalsRenderTest.php index 17c5beb18..80b932d36 100644 --- a/tests/src/Kernel/CallForProposalsRenderTest.php +++ b/tests/src/Kernel/CallForProposalsRenderTest.php @@ -9,7 +9,10 @@ use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; use Drupal\Tests\oe_theme\PatternAssertions\ListItemAssert; +use Drupal\Tests\oe_theme\PatternAssertions\FieldListAssert; +use Drupal\Tests\oe_theme\PatternAssertions\PatternAssertState; use Drupal\Tests\user\Traits\UserCreationTrait; +use Symfony\Component\DomCrawler\Crawler; /** * Tests call for proposals rendering. @@ -110,10 +113,35 @@ public function testTeaser(): void { ], ], 'image' => NULL, - // @todo Replace additional_information assertion with lists in EWPP-2508. + 'lists' => [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Reference', + 'body' => 'Call for proposals reference', + ], [ + 'label' => 'Opening date', + 'body' => '14 February 2020', + ], [ + 'label' => 'Deadline model', + 'body' => 'Single-stage', + ], [ + 'label' => 'Deadline date', + 'body' => '21 February 2020', + ], [ + 'label' => 'Funding programme', + 'body' => 'Arab Common Market', + ], + ], + ]), + ], ]; $assert->assertPattern($expected_values, $html); + $crawler = new Crawler($html); + $actual = $crawler->filter('span.ecl-label.ecl-label--high'); + $this->assertCount(1, $actual); + // Test short title fallback. $node->set('oe_content_short_title', 'CFP short title')->save(); $build = $this->nodeViewBuilder->view($node, 'teaser'); @@ -131,7 +159,28 @@ public function testTeaser(): void { $node->set('oe_call_proposals_model', 'two_stage')->save(); $build = $this->nodeViewBuilder->view($node, 'teaser'); $html = $this->renderRoot($build); - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Reference', + 'body' => 'Call for proposals reference', + ], [ + 'label' => 'Opening date', + 'body' => '14 February 2020', + ], [ + 'label' => 'Deadline model', + 'body' => 'Two-stage', + ], [ + 'label' => 'Deadline dates', + 'body' => "21 February 2020\n | 22 February 2020", + ], [ + 'label' => 'Funding programme', + 'body' => 'Arab Common Market', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $html); // Check status Closed and highlighted labels and background. @@ -153,9 +202,34 @@ public function testTeaser(): void { 'variant' => 'highlight', ], ]; - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Reference', + 'body' => 'Call for proposals reference', + ], [ + 'label' => 'Opening date', + 'body' => '14 February 2020', + ], [ + 'label' => 'Deadline model', + 'body' => 'Multiple cut-off', + ], [ + 'label' => 'Deadline date', + 'body' => '17 February 2020', + ], [ + 'label' => 'Funding programme', + 'body' => 'Arab Common Market', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $html); + $crawler = new Crawler($html); + $actual = $crawler->filter('span.ecl-label.ecl-label--low'); + $this->assertCount(1, $actual); + // Check status Upcoming label and background. $opening_date->modify('+ 10 days'); $deadline_date->modify('+ 4 days'); @@ -170,9 +244,34 @@ public function testTeaser(): void { 'label' => 'Call status: Upcoming', 'variant' => 'medium', ]; - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Reference', + 'body' => 'Call for proposals reference', + ], [ + 'label' => 'Opening date', + 'body' => '24 February 2020', + ], [ + 'label' => 'Deadline model', + 'body' => 'Single-stage', + ], [ + 'label' => 'Deadline date', + 'body' => '21 February 2020', + ], [ + 'label' => 'Funding programme', + 'body' => 'Arab Common Market', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $html); + $crawler = new Crawler($html); + $actual = $crawler->filter('span.ecl-label.ecl-label--medium'); + $this->assertCount(1, $actual); + // Check status N/A. $publication_date->modify('+ 5 days'); $deadline_date->modify('+ 5 days'); @@ -184,7 +283,22 @@ public function testTeaser(): void { $build = $this->nodeViewBuilder->view($node, 'teaser'); $html = $this->renderRoot($build); $expected_values['badges'][0] = []; - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Reference', + 'body' => 'Call for proposals reference', + ], [ + 'label' => 'Deadline model', + 'body' => 'Permanent', + ], [ + 'label' => 'Funding programme', + 'body' => 'Arab Common Market', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $html); } diff --git a/tests/src/Kernel/CallForTendersRenderTest.php b/tests/src/Kernel/CallForTendersRenderTest.php index a7d97182b..ac9e5a286 100644 --- a/tests/src/Kernel/CallForTendersRenderTest.php +++ b/tests/src/Kernel/CallForTendersRenderTest.php @@ -9,8 +9,11 @@ use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; use Drupal\Tests\oe_theme\PatternAssertions\ListItemAssert; +use Drupal\Tests\oe_theme\PatternAssertions\FieldListAssert; +use Drupal\Tests\oe_theme\PatternAssertions\PatternAssertState; use Drupal\Tests\user\Traits\UserCreationTrait; use Drupal\user\Entity\User; +use Symfony\Component\DomCrawler\Crawler; /** * Tests call for tenders rendering. @@ -115,10 +118,32 @@ public function testTeaser(): void { ], ], 'image' => NULL, - // @todo Replace additional_information assertion with lists in EWPP-2508. + 'lists' => [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Reference', + 'body' => 'Call for tenders reference', + ], [ + 'label' => 'Opening date', + 'body' => $opening_date->format('d F Y'), + ], [ + 'label' => 'Deadline date', + 'body' => $deadline_date->format('d F Y, H:i (T)'), + ], [ + 'label' => 'Departments', + 'body' => 'Audit Board of the European Communities, Arab Common Market', + ], + ], + ]), + ], ]; $assert->assertPattern($expected_values, $html); + $crawler = new Crawler($html); + $actual = $crawler->filter('span.ecl-label.ecl-label--high'); + $this->assertCount(1, $actual); + // Test short title fallback. $node->set('oe_content_short_title', 'CFT short title'); $node->set('sticky', NodeInterface::STICKY)->save(); @@ -131,7 +156,25 @@ public function testTeaser(): void { $node->set('oe_departments', 'http://publications.europa.eu/resource/authority/corporate-body/ABEC')->save(); $build = $this->nodeViewBuilder->view($node, 'teaser'); $html = $this->renderRoot($build); - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Reference', + 'body' => 'Call for tenders reference', + ], [ + 'label' => 'Opening date', + 'body' => $opening_date->format('d F Y'), + ], [ + 'label' => 'Deadline date', + 'body' => $deadline_date->format('d F Y, H:i (T)'), + ], [ + 'label' => 'Department', + 'body' => 'Audit Board of the European Communities', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $html); // Check status Closed and highlighted labels and background. @@ -150,10 +193,35 @@ public function testTeaser(): void { ], ]; $deadline_date->setTimeZone(new \DateTimeZone('Australia/Sydney')); - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Reference', + 'body' => 'Call for tenders reference', + ], [ + 'label' => 'Opening date', + 'body' => $opening_date->format('d F Y'), + ], [ + 'label' => 'Deadline date', + 'body' => $deadline_date->format('d F Y, H:i (T)'), + ], [ + 'label' => 'Department', + 'body' => 'Audit Board of the European Communities', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $html); - // @todo Restore Deadline date assert in EWPP-2508. + $crawler = new Crawler($html); + $actual = $crawler->filter('span.ecl-label.ecl-label--low'); + $this->assertCount(1, $actual); + + // Check Deadline date is striked when Call for tenders is closed. + $actual = $crawler->filter('dd.ecl-description-list__definition > .ecl-u-type-strike'); + $this->assertCount(1, $actual); + // Check status Upcoming label and background. $opening_date = (clone $static_time)->modify('+ 10 days'); $deadline_date = (clone $static_time)->modify('+ 5 days'); @@ -166,9 +234,31 @@ public function testTeaser(): void { 'label' => 'Call status: Upcoming', 'variant' => 'medium', ]; - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Reference', + 'body' => 'Call for tenders reference', + ], [ + 'label' => 'Opening date', + 'body' => $opening_date->format('d F Y'), + ], [ + 'label' => 'Deadline date', + 'body' => $deadline_date->format('d F Y, H:i (T)'), + ], [ + 'label' => 'Department', + 'body' => 'Audit Board of the European Communities', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $html); + $crawler = new Crawler($html); + $actual = $crawler->filter('span.ecl-label.ecl-label--medium'); + $this->assertCount(1, $actual); + // Check status N/A. $publication_date = (clone $static_time)->modify('+ 5 days'); $deadline_date = (clone $static_time)->modify('+ 5 days'); @@ -181,7 +271,22 @@ public function testTeaser(): void { $deadline_date->setTimeZone(new \DateTimeZone('Australia/Sydney')); $expected_values['badges'][0] = []; - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Reference', + 'body' => 'Call for tenders reference', + ], [ + 'label' => 'Deadline date', + 'body' => $deadline_date->format('d F Y, H:i (T)'), + ], [ + 'label' => 'Department', + 'body' => 'Audit Board of the European Communities', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $html); } diff --git a/tests/src/Kernel/ConsultationRenderTest.php b/tests/src/Kernel/ConsultationRenderTest.php index dfc21d288..48ab40616 100644 --- a/tests/src/Kernel/ConsultationRenderTest.php +++ b/tests/src/Kernel/ConsultationRenderTest.php @@ -9,7 +9,10 @@ use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; use Drupal\Tests\oe_theme\PatternAssertions\ListItemAssert; +use Drupal\Tests\oe_theme\PatternAssertions\FieldListAssert; +use Drupal\Tests\oe_theme\PatternAssertions\PatternAssertState; use Drupal\Tests\user\Traits\UserCreationTrait; +use Symfony\Component\DomCrawler\Crawler; /** * Tests consultation rendering. @@ -103,10 +106,27 @@ public function testTeaser(): void { ], ], 'image' => NULL, - // @todo Replace additional_information assertion with lists in EWPP-2508. + 'lists' => [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Opening date', + 'body' => '14 February 2020', + ], + [ + 'label' => 'Deadline', + 'body' => '21 February 2020, 01:00 (AEDT)', + ], + ], + ]), + ], ]; $assert->assertPattern($expected_values, $html); + $crawler = new Crawler($html); + $actual = $crawler->filter('span.ecl-label.ecl-label--high'); + $this->assertCount(1, $actual); + // Test short title fallback. $node->set('oe_content_short_title', 'Consultation short title'); $node->set('sticky', NodeInterface::STICKY)->save(); @@ -132,7 +152,19 @@ public function testTeaser(): void { 'variant' => 'highlight', ], ]; - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Opening date', + 'body' => '14 February 2020', + ], [ + 'label' => 'Deadline', + 'body' => '17 February 2020, 12:00 (AEDT)', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $html); // Check status Upcoming label and background. @@ -148,8 +180,24 @@ public function testTeaser(): void { 'label' => 'Status: Upcoming', 'variant' => 'medium', ]; - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Opening date', + 'body' => '24 February 2020', + ], [ + 'label' => 'Deadline', + 'body' => '21 February 2020, 12:00 (AEDT)', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $html); + + $crawler = new Crawler($html); + $actual = $crawler->filter('span.ecl-label.ecl-label--medium'); + $this->assertCount(1, $actual); } } diff --git a/tests/src/Kernel/OrganisationRenderTest.php b/tests/src/Kernel/OrganisationRenderTest.php index 0fca0c3e5..a12b51e18 100644 --- a/tests/src/Kernel/OrganisationRenderTest.php +++ b/tests/src/Kernel/OrganisationRenderTest.php @@ -7,9 +7,12 @@ use Drupal\media\Entity\Media; use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; +use Drupal\Tests\oe_theme\PatternAssertions\FieldListAssert; use Drupal\Tests\oe_theme\PatternAssertions\ListItemAssert; +use Drupal\Tests\oe_theme\PatternAssertions\PatternAssertState; use Drupal\Tests\user\Traits\UserCreationTrait; use Drupal\user\Entity\User; +use Symfony\Component\DomCrawler\Crawler; /** * Tests the organisation rendering. @@ -115,7 +118,28 @@ public function testOrganisationTeaser(): void { 'alt' => '', ], 'date' => NULL, - // @todo Replace additional_information assertion with lists in EWPP-2508. + 'lists' => [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Website', + 'body' => 'http://www.example.com/website_first_contact', + ], + [ + 'label' => 'Email', + 'body' => 'first_contact@example.com', + ], + [ + 'label' => 'Phone number', + 'body' => 'Phone number first_contact', + ], + [ + 'label' => 'Address', + 'body' => 'Address first_contact, 1001 Brussels, Belgium', + ], + ], + ]), + ], ]; $assert->assertPattern($expected_values, $html); $assert->assertVariant('thumbnail_secondary', $html); @@ -140,7 +164,34 @@ public function testOrganisationTeaser(): void { $node->save(); $build = $this->nodeViewBuilder->view($node, 'teaser'); - // @todo Replace additional_information assertion with lists in EWPP-2508. + $html = $this->renderRoot($build); + $crawler = new Crawler($html); + $contacts_render = $crawler->filter('article .ecl-content-block.ecl-content-item__content-block .ecl-description-list.ecl-description-list--horizontal.ecl-content-block__list'); + $this->assertCount(2, $contacts_render); + + $field_assert = new FieldListAssert(); + $second_contact_expected_values = [ + 'items' => [ + [ + 'label' => 'Website', + 'body' => 'http://www.example.com/website_second_contact', + ], + [ + 'label' => 'Email', + 'body' => 'second_contact@example.com', + ], + [ + 'label' => 'Phone number', + 'body' => 'Phone number second_contact', + ], + [ + 'label' => 'Address', + 'body' => 'Address second_contact, 1001 Brussels, Belgium', + ], + ], + ]; + $second_contact_render = $crawler->filter('article .ecl-content-block.ecl-content-item__content-block .ecl-content-block__list-container dl:nth-child(2)'); + $field_assert->assertPattern($second_contact_expected_values, $second_contact_render->outerHtml()); // Change organisation type to non eu. $node->set('oe_organisation_contact', NULL); $node->set('oe_organisation_org_type', 'non_eu'); diff --git a/tests/src/Kernel/PersonRenderTest.php b/tests/src/Kernel/PersonRenderTest.php index 60e24d7b6..1761535dd 100644 --- a/tests/src/Kernel/PersonRenderTest.php +++ b/tests/src/Kernel/PersonRenderTest.php @@ -12,10 +12,13 @@ use Drupal\oe_content_person\Entity\PersonJob; use Drupal\oe_content_person\Entity\PersonJobInterface; use Drupal\Tests\oe_theme\PatternAssertions\ListItemAssert; +use Drupal\Tests\oe_theme\PatternAssertions\FieldListAssert; +use Drupal\Tests\oe_theme\PatternAssertions\PatternAssertState; use Drupal\Tests\user\Traits\UserCreationTrait; +use Symfony\Component\DomCrawler\Crawler; /** - * Tests consultation rendering. + * Tests person rendering. * * @group batch2 */ @@ -127,7 +130,16 @@ public function testTeaser(): void { // Assert Departments field. $node->set('oe_departments', 'http://publications.europa.eu/resource/authority/corporate-body/ABEC')->save(); - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Department', + 'body' => 'Audit Board of the European Communities', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $this->getRenderedNode($node)); // Assert multiple values in Departments field. @@ -135,7 +147,16 @@ public function testTeaser(): void { 'http://publications.europa.eu/resource/authority/corporate-body/ABEC', 'http://publications.europa.eu/resource/authority/corporate-body/ACM', ])->save(); - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'] = [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Departments', + 'body' => 'Audit Board of the European Communities, Arab Common Market', + ], + ], + ]), + ]; $assert->assertPattern($expected_values, $this->getRenderedNode($node)); // Assert Contact field with Organisation reference Contact entity with @@ -152,7 +173,32 @@ public function testTeaser(): void { $organisation_reference_empty_contact, $general_contact, ])->save(); - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'][] = new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Email', + 'body' => 'direct_contact@example.com', + ], [ + 'label' => 'Phone number', + 'body' => 'Phone number direct_contact', + ], [ + 'label' => 'Mobile number', + 'body' => 'Mobile number direct_contact', + ], [ + 'label' => 'Fax number', + 'body' => 'Fax number direct_contact', + ], [ + 'label' => 'Address', + 'body' => 'Address direct_contact, 1001 Brussels, Belgium', + ], [ + 'label' => 'Office', + 'body' => 'Office direct_contact', + ], [ + 'label' => 'Social media links', + 'body' => 'Social media direct_contact', + ], + ], + ]); $assert->assertPattern($expected_values, $this->getRenderedNode($node)); // Assert Contacts field with an organisation as contact. @@ -163,7 +209,40 @@ public function testTeaser(): void { $organisation_reference_contact, ])->save(); - // @todo Replace additional_information assertion with lists in EWPP-2508. + $html = $this->getRenderedNode($node); + $crawler = new Crawler($html); + $contacts_render = $crawler->filter('article .ecl-content-block.ecl-content-item__content-block .ecl-description-list.ecl-description-list--horizontal.ecl-content-block__list'); + $this->assertCount(3, $contacts_render); + + $field_assert = new FieldListAssert(); + $second_contact_expected_values = [ + 'items' => [ + [ + 'label' => 'Email', + 'body' => 'organisation_reference_contact@example.com', + ], [ + 'label' => 'Phone number', + 'body' => 'Phone number organisation_reference_contact', + ], [ + 'label' => 'Mobile number', + 'body' => 'Mobile number organisation_reference_contact', + ], [ + 'label' => 'Fax number', + 'body' => 'Fax number organisation_reference_contact', + ], [ + 'label' => 'Address', + 'body' => 'Address organisation_reference_contact, 1001 Brussels, Belgium', + ], [ + 'label' => 'Office', + 'body' => 'Office organisation_reference_contact', + ], [ + 'label' => 'Social media links', + 'body' => 'Social media organisation_reference_contact', + ], + ], + ]; + $second_contact_render = $crawler->filter('article .ecl-content-block.ecl-content-item__content-block .ecl-content-block__list-container dl:nth-child(3)'); + $field_assert->assertPattern($second_contact_expected_values, $second_contact_render->outerHtml()); // Assert Jobs field and highlighted label. $job_1 = $this->createPersonJobEntity('job_1', [ 'oe_acting' => TRUE, @@ -181,7 +260,14 @@ public function testTeaser(): void { $expected_values['meta'] = [ '(Acting) Adviser', ]; - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'][1] = new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Responsibilities', + 'body' => '(Acting) AdviserDescription job_1', + ], + ], + ]); $assert->assertPattern($expected_values, $this->getRenderedNode($node)); $job_2 = $this->createPersonJobEntity('job_2', ['oe_role_reference' => 'http://publications.europa.eu/resource/authority/role-qualifier/ADVIS_CHIEF']); @@ -189,7 +275,14 @@ public function testTeaser(): void { $expected_values['meta'] = [ '(Acting) Adviser, Chief Adviser', ]; - // @todo Replace additional_information assertion with lists in EWPP-2508. + $expected_values['lists'][1] = new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Responsibilities', + 'body' => '(Acting) AdviserDescription job_1Chief AdviserDescription job_2', + ], + ], + ]); $assert->assertPattern($expected_values, $this->getRenderedNode($node)); // Assert non-eu person. @@ -216,11 +309,56 @@ public function testTeaser(): void { 'src' => 'person_portrait.png', 'alt' => '', ], - // @todo Replace additional_information assertion with lists in EWPP-2508. + 'lists' => [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Organisation', + 'body' => 'Organisation node non_eu', + ], + ], + ]), + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Email', + 'body' => 'direct_contact@example.com', + ], [ + 'label' => 'Phone number', + 'body' => 'Phone number direct_contact', + ], [ + 'label' => 'Mobile number', + 'body' => 'Mobile number direct_contact', + ], [ + 'label' => 'Fax number', + 'body' => 'Fax number direct_contact', + ], [ + 'label' => 'Address', + 'body' => 'Address direct_contact, 1001 Brussels, Belgium', + ], [ + 'label' => 'Office', + 'body' => 'Office direct_contact', + ], [ + 'label' => 'Social media links', + 'body' => 'Social media direct_contact', + ], + ], + ]), + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Responsibilities', + 'body' => 'SingerDescription job_1DancerDescription job_2', + ], + ], + ]), + ], ]; $html = $this->getRenderedNode($node); $assert->assertPattern($expected_values, $html); - // @todo Replace additional_information assertion with lists in EWPP-2508. + $crawler = new Crawler($html); + $jobs_render = $crawler->filter('article .ecl-content-block.ecl-content-item__content-block .ecl-content-block__list-container dl:nth-child(3)'); + $this->assertCount(1, $jobs_render); } /** diff --git a/tests/src/Kernel/ProjectRenderTest.php b/tests/src/Kernel/ProjectRenderTest.php index 59360e314..7844dab97 100644 --- a/tests/src/Kernel/ProjectRenderTest.php +++ b/tests/src/Kernel/ProjectRenderTest.php @@ -8,7 +8,9 @@ use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; use Drupal\oe_content_entity_organisation\Entity\Organisation; +use Drupal\Tests\oe_theme\PatternAssertions\FieldListAssert; use Drupal\Tests\oe_theme\PatternAssertions\ListItemAssert; +use Drupal\Tests\oe_theme\PatternAssertions\PatternAssertState; use Drupal\Tests\user\Traits\UserCreationTrait; use Drupal\user\Entity\User; @@ -165,7 +167,16 @@ public function testProjectTeaser(): void { 'alt' => '', ], 'date' => NULL, - // @todo Replace additional_information assertion with lists in EWPP-2508. + 'lists' => [ + new PatternAssertState(new FieldListAssert(), [ + 'items' => [ + [ + 'label' => 'Project locations', + 'body' => 'Belgium', + ], + ], + ]), + ], ]; $assert->assertPattern($expected_values, $html); $assert->assertVariant('thumbnail_secondary', $html); diff --git a/tests/src/PatternAssertions/ListItemAssert.php b/tests/src/PatternAssertions/ListItemAssert.php index 51c77ce39..b7c83f550 100644 --- a/tests/src/PatternAssertions/ListItemAssert.php +++ b/tests/src/PatternAssertions/ListItemAssert.php @@ -244,7 +244,7 @@ protected function assertLists($expected, Crawler $crawler): void { } $list_terms = $crawler->filter($list_container_selector . ' dt.ecl-description-list__term'); $list_definitions = $crawler->filter($list_container_selector . ' dd.ecl-description-list__definition'); - self::assertCount(count($expected), $list_terms); + self::assertCount(count($expected), $crawler->filter($list_container_selector)); foreach ($expected as $index => $expected_list) { foreach ($expected_list as $term => $definitions) { self::assertEquals($term, trim($list_terms->eq($index)->text()), \sprintf('The expected text of the term number %s does not correspond to the found term text.', $index));