Skip to content
Snippets Groups Projects
Verified Commit 435dc201 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3248295 by danflanagan8, xjm, dww, mglaman: Taxonomy tests should not rely on Classy

parent 4fa09fb8
Branches
Tags
38 merge requests!12227Issue #3181946 by jonmcl, mglaman,!7471uncessary 5 files are moved from media-library folder to misc folder,!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!54479.5.x SF update,!5014Issue #3071143: Table Render Array Example Is Incorrect,!4868Issue #1428520: Improve menu parent link selection,!4289Issue #1344552 by marcingy, Niklas Fiekas, Ravi.J, aleevas, Eduardo Morales...,!4114Issue #2707291: Disable body-level scrolling when a dialog is open as a modal,!3630Issue #2815301 by Chi, DanielVeza, kostyashupenko, smustgrave: Allow to create...,!3291Issue #3336463: Rewrite rules for gzipped CSS and JavaScript aggregates never match,!3143Issue #3313342: [PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 LayoutBuilderUiCacheContext.php on line 28,!3102Issue #3164428 by DonAtt, longwave, sahil.goyal, Anchal_gupta, alexpott: Use...,!2853#3274419 Makes BaseFieldOverride inherit the internal property from the base field.,!2719Issue #3110137: Remove Classy from core.,!2437Issue #3238257 by hooroomoo, Wim Leers: Fragment link pointing to <textarea>...,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2074Issue #2707689: NodeForm::actions() checks for delete access on new entities,!2062Issue #3246454: Add weekly granularity to views date sort,!1591Issue #3199697: Add JSON:API Translation experimental module,!1484Exposed filters get values from URL when Ajax is on,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1254Issue #3238915: Refactor (if feasible) uses of the jQuery ready function to use VanillaJS,!1162Issue #3100350: Unable to save '/' root path alias,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!957Added throwing of InvalidPluginDefinitionException from getDefinition().,!925Issue #2339235: Remove taxonomy hard dependency on node module,!877Issue #2708101: Default value for link text is not saved,!873Issue #2875228: Site install not using batch API service,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links,!844Resolve #3036010 "Updaters",!712Issue #2909128: Autocomplete intermittent on Chrome Android,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!485Sets the autocomplete attribute for username/password input field on login form.,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
......@@ -6,6 +6,7 @@
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\taxonomy\Entity\Term;
use Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait;
/**
* Tests load, save and delete for taxonomy terms.
......@@ -14,6 +15,8 @@
*/
class TermTest extends TaxonomyTestBase {
use AssertBreadcrumbTrait;
/**
* Vocabulary for testing.
*
......@@ -38,7 +41,7 @@ class TermTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
......@@ -384,12 +387,12 @@ public function testTermInterface() {
$this->assertSession()->pageTextContains($edit['description[0][value]']);
// Did this page request display a 'term-listing-heading'?
$this->assertSession()->elementExists('xpath', '//div[contains(@class, "field--name-description")]');
$this->assertSession()->elementExists('xpath', '//div[@class="views-element-container"]/div/header/div/div/p');
// Check that it does NOT show a description when description is blank.
$term->setDescription(NULL);
$term->save();
$this->drupalGet('taxonomy/term/' . $term->id());
$this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "field--entity-taxonomy-term--description")]');
$this->assertSession()->elementNotExists('xpath', '//div[@class="views-element-container"]/div/header/div/div/p');
// Check that the description value is processed.
$value = $this->randomMachineName();
......@@ -580,20 +583,20 @@ public function testTermBreadcrumbs() {
$this->assertNotNull($term, 'Term found in database.');
// Check the breadcrumb on the term edit page.
$this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
$breadcrumbs = $this->getSession()->getPage()->findAll('css', 'nav.breadcrumb ol li a');
$this->assertCount(2, $breadcrumbs, 'The breadcrumbs are present on the page.');
$this->assertSame('Home', $breadcrumbs[0]->getText(), 'First breadcrumb text is Home');
$this->assertSame($term->label(), $breadcrumbs[1]->getText(), 'Second breadcrumb text is term name on term edit page.');
$this->assertSession()->assertEscaped($breadcrumbs[1]->getText());
$trail = [
'' => 'Home',
'taxonomy/term/' . $term->id() => $term->label(),
];
$this->assertBreadcrumb('taxonomy/term/' . $term->id() . '/edit', $trail);
$this->assertSession()->assertEscaped($term->label());
// Check the breadcrumb on the term delete page.
$this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
$breadcrumbs = $this->getSession()->getPage()->findAll('css', 'nav.breadcrumb ol li a');
$this->assertCount(2, $breadcrumbs, 'The breadcrumbs are present on the page.');
$this->assertSame('Home', $breadcrumbs[0]->getText(), 'First breadcrumb text is Home');
$this->assertSame($term->label(), $breadcrumbs[1]->getText(), 'Second breadcrumb text is term name on term delete page.');
$this->assertSession()->assertEscaped($breadcrumbs[1]->getText());
$trail = [
'' => 'Home',
'taxonomy/term/' . $term->id() => $term->label(),
];
$this->assertBreadcrumb('taxonomy/term/' . $term->id() . '/delete', $trail);
$this->assertSession()->assertEscaped($term->label());
}
}
......@@ -41,7 +41,7 @@ class TermTranslationTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
......
......@@ -33,7 +33,7 @@ class TaxonomyIndexTidUiTest extends UITestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'stark';
/**
* Modules to enable.
......@@ -169,9 +169,20 @@ public function testExposedFilter() {
// Only the nodes with the selected term should be shown.
$this->drupalGet('test-filter-taxonomy-index-tid');
$this->assertSession()->elementsCount('xpath', '//div[@class="view-content"]//a', 2);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node2->toUrl()->toString()}']", 1);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node3->toUrl()->toString()}']", 1);
$this->assertSession()->pageTextNotContains($node1->getTitle());
$this->assertSession()->linkByHrefNotExists($node1->toUrl()->toString());
$xpath_node2_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node2->toUrl()->toString(),
':label' => $node2->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node2_link, 1);
$xpath_node3_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node3->toUrl()->toString(),
':label' => $node3->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node3_link, 1);
$this->assertSession()->pageTextNotContains($node4->getTitle());
$this->assertSession()->linkByHrefNotExists($node4->toUrl()->toString());
// Expose the filter.
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid');
......@@ -187,8 +198,17 @@ public function testExposedFilter() {
// After switching to 'empty' operator, the node without a term should be
// shown.
$this->drupalGet('test-filter-taxonomy-index-tid');
$this->assertSession()->elementsCount('xpath', '//div[@class="view-content"]//a', 1);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node1->toUrl()->toString()}']", 1);
$xpath_node1_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node1->toUrl()->toString(),
':label' => $node1->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node1_link, 1);
$this->assertSession()->pageTextNotContains($node2->getTitle());
$this->assertSession()->linkByHrefNotExists($node2->toUrl()->toString());
$this->assertSession()->pageTextNotContains($node3->getTitle());
$this->assertSession()->linkByHrefNotExists($node3->toUrl()->toString());
$this->assertSession()->pageTextNotContains($node4->getTitle());
$this->assertSession()->linkByHrefNotExists($node4->toUrl()->toString());
// Set the operator to 'not empty'.
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid');
......@@ -199,10 +219,23 @@ public function testExposedFilter() {
// After switching to 'not empty' operator, all nodes with terms should be
// shown.
$this->drupalGet('test-filter-taxonomy-index-tid');
$this->assertSession()->elementsCount('xpath', '//div[@class="view-content"]//a', 3);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node2->toUrl()->toString()}']", 1);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node3->toUrl()->toString()}']", 1);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node4->toUrl()->toString()}']", 1);
$this->assertSession()->pageTextNotContains($node1->getTitle());
$this->assertSession()->linkByHrefNotExists($node1->toUrl()->toString());
$xpath_node2_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node2->toUrl()->toString(),
':label' => $node2->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node2_link, 1);
$xpath_node3_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node3->toUrl()->toString(),
':label' => $node3->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node3_link, 1);
$xpath_node4_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node4->toUrl()->toString(),
':label' => $node4->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node4_link, 1);
// Select 'Term ID' as the field to be displayed.
$edit = ['name[taxonomy_term_field_data.tid]' => TRUE];
......@@ -231,7 +264,15 @@ public function testExposedFilter() {
$this->drupalGet('admin/structure/views/view/test_taxonomy_term_name/edit/default');
$this->submitForm([], 'Save');
$this->submitForm([], 'Update preview');
$this->assertSession()->elementNotExists('xpath', "//div[@class='view-content']");
$this->assertSession()->pageTextNotContains($node1->getTitle());
$this->assertSession()->linkByHrefNotExists($node1->toUrl()->toString());
$this->assertSession()->pageTextNotContains($node2->getTitle());
$this->assertSession()->linkByHrefNotExists($node2->toUrl()->toString());
$this->assertSession()->pageTextNotContains($node3->getTitle());
$this->assertSession()->linkByHrefNotExists($node3->toUrl()->toString());
$this->assertSession()->pageTextNotContains($node4->getTitle());
$this->assertSession()->linkByHrefNotExists($node4->toUrl()->toString());
$this->assertSession()->elementNotExists('xpath', "//div[@class='views-row']");
}
/**
......
......@@ -12,7 +12,7 @@ class TermDisplayConfigurableTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'stark';
/**
* Views used by this test.
......@@ -32,9 +32,16 @@ public function testDisplayConfigurable() {
// Check the taxonomy_term with default non-configurable display.
$this->drupalGet('test_term_show_entity');
$assert->elementTextContains('css', 'h2 > a > .field--name-name', $this->term1->getName());
$assert->elementNotExists('css', '.field--name-name .field__item');
$assert->elementNotExists('css', '.field--name-name .field__label');
// Name should be linked to entity and description should be displayed.
$assert->pageTextContains($this->term1->getName());
$assert->linkByHrefExists($this->term1->toUrl()->toString());
$assert->pageTextContains($this->term1->getDescription());
$assert->pageTextContains($this->term2->getName());
$assert->linkByHrefExists($this->term2->toUrl()->toString());
$assert->pageTextContains($this->term2->getDescription());
// The field labels should not be present.
$assert->pageTextNotContains('Name');
$assert->pageTextNotContains('Description');
// Enable helper module to make base fields' displays configurable.
\Drupal::service('module_installer')->install(['taxonomy_term_display_configurable_test']);
......@@ -48,16 +55,39 @@ public function testDisplayConfigurable() {
// Recheck the taxonomy_term with configurable display.
$this->drupalGet('test_term_show_entity');
$assert->elementTextContains('css', 'div.field--name-name > div.field__item', $this->term1->getName());
$assert->elementExists('css', 'div.field--name-name > div.field__label');
// The description should be the first field in each row, with no label.
// Name field should be the second field in view row. Value should be
// displayed after the label. It should not be linked to the term.
$assert->pageTextContains('Name');
$assert->pageTextNotContains('Description');
$assert->pageTextContains($this->term1->getName());
$assert->linkByHrefNotExists($this->term1->toUrl()->toString());
$assert->pageTextContains($this->term1->getDescription());
$assert->elementTextContains('xpath', '//*[@class="views-row"][1]/div/div[1]//p', $this->term1->getDescription());
$assert->elementTextContains('xpath', '//*[@class="views-row"][1]/div/div[2]/div[1]', 'Name');
$assert->elementTextContains('xpath', '//*[@class="views-row"][1]/div/div[2]/div[2]', $this->term1->getName());
$assert->pageTextContains($this->term2->getName());
$assert->linkByHrefNotExists($this->term2->toUrl()->toString());
$assert->pageTextContains($this->term2->getDescription());
$assert->elementTextContains('xpath', '//*[@class="views-row"][2]/div/div[1]//p', $this->term2->getDescription());
$assert->elementTextContains('xpath', '//*[@class="views-row"][2]/div/div[2]/div[1]', 'Name');
$assert->elementTextContains('xpath', '//*[@class="views-row"][2]/div/div[2]/div[2]', $this->term2->getName());
// Remove 'name' field from display.
$display->removeComponent('name')->save();
// Recheck the taxonomy_term with 'name' field removed from display.
// There should just be an unlabelled description. Nothing should be
// linked to the terms.
$this->drupalGet('test_term_show_entity');
$assert->responseNotContains($this->term1->getName());
$assert->elementNotExists('css', 'div.field--name-name');
$assert->pageTextNotContains('Name');
$assert->pageTextNotContains('Description');
$assert->pageTextNotContains($this->term1->getName());
$assert->linkByHrefNotExists($this->term1->toUrl()->toString());
$assert->pageTextContains($this->term1->getDescription());
$assert->pageTextNotContains($this->term2->getName());
$assert->linkByHrefNotExists($this->term2->toUrl()->toString());
$assert->pageTextContains($this->term2->getDescription());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment