diff --git a/tests/src/FunctionalJavascript/WidgetJSTest.php b/tests/src/FunctionalJavascript/WidgetJSTest.php index 3559e66..3604197 100644 --- a/tests/src/FunctionalJavascript/WidgetJSTest.php +++ b/tests/src/FunctionalJavascript/WidgetJSTest.php @@ -50,8 +50,9 @@ class WidgetJSTest extends JavascriptTestBase { */ public function testCheckboxWidget() { $facet_storage = \Drupal::entityTypeManager()->getStorage('facets_facet'); - $id = 'llama'; + + // Create and save a facet with a checkbox widget on the 'type' field. $facet = $facet_storage->create([ 'id' => $id, 'name' => strtoupper($id), @@ -64,15 +65,25 @@ class WidgetJSTest extends JavascriptTestBase { $facet->save(); $this->createBlock($id); + // Go to the views page. $this->drupalGet('search-api-test-fulltext'); + // Make sure the block is shown on the page. $page = $this->getSession()->getPage(); $page_content = $page->getContent(); - $this->assertTrue(strpos($page_content, 'Llama block') > 0); + $this->assertTrue(strpos($page_content, 'Llama block') > 0, 'Block found on page.'); + + // Narrow the context to the block that shows the facet and get objects that + // contain the
  • -html elements. + $list_items = $page->findById('block-llama-block')->findAll('css', 'li'); - $links = $page->findById('block-llama-block')->findAll('css', 'a'); + $this->assertCount(2, $list_items); - $this->assertNotNull($links); + /** @var \Behat\Mink\Element\NodeElement $list_item */ + foreach ($list_items as $list_item) { + $this->assertEquals('li', $list_item->getTagName()); + $this->assertTrue(strpos($list_item->getHtml(), 'assertEquals(5, $indexed_items, '5 items indexed.'); } + /** + * Create and place a facet block in the first sidebar. + * + * @param string $id + * Create a block for a facet. + */ protected function createBlock($id) { $config = \Drupal::configFactory(); $settings = [