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

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

(cherry picked from commit 435dc201)
parent 53225084
No related branches found
No related tags found
44 merge requests!85673265330-fix-missing-hyphens: Create patch to MR and fix remaining words,!8394[warning] array_flip(): Can only flip STRING and INTEGER values, when saving a non-revisionable custom content entity,!8357Issue #2994000 by Lendude, Pasqualle, quietone, pameeela: Notice in logs when...,!7780issue 3443822: fix for 'No route found for the specified format html. Supported formats: json, xml.',!7416Simplify the HTML of field.html.twig,!7150Revert "Issue #3137119 by munish.kumar, johnwebdev, Jaypan, jungle, xjm,...,!6445Issue #3034692: Renamed the getHandler function which return the configuration of a handler instance on given display,!5013Issue #3071143: Table Render Array Example Is Incorrect,!4848Issue #1566662: Update module should send notifications on Thursdays,!4792Issue #2230689: Remove redundant "Italic" style,!4782Issue #2662898: "Links" field not displaying on custom view modes,!4488Issue #3376281: Random machine names no longer need to be wrapped in strtolower(),!4220Issue #3368223: Link field > Access to internal links is not checked on display.,!4173Issue #2123543: Add string context and location filters to the translate interface,!3884Issue #3356842,!3870Issue #3087868,!3812Draft: Issue #3339373 by alexpott, andypost, mondrake:...,!3736Issue #3294005: Refactor Claro's form--password-confirm stylesheet,!3686Issue #3219967 against 9.5.x,!3683Issue #2939397: Clearing AliasManager cache with root path raises warning,!3543Issue #3344259: Allow ajax dialog to have focus configurable,!3437Issue #3106205: Length of menu_tree.url and menu_tree.route_param_key are too short (255 characters),!3356Issue #3209129: Scrolling problems when adding a block via layout builder,!3000Issue #793660: Check for failure of hook_install,!2982Issue #3301562: Translate the default settings for this plugin (TimestampAgoFormatter),!2940Issue #3320240: Entity count query returns a string instead of int,!2921Issue #1383696: Allow a custom HTML element to be selected for a grouping field,!2920Issue #3260175: Saving media entity without an owner crashes,!2857Issue #3314541: Remove unnecessary fill from SVG icon for the "Media Library" CKEditor 5 button — enabling dark mode support in contrib,!2841Resolve #3296811 "Resourceresponsetrait needs a",!2733Issue #3293855: Update the outdated user_help text for user.admin_permissions and the description of the select box on the role settings page,!2447Issue #3293135: shouldUpdateThumbnail does not update thumbnail is source field changed,!2280Issue #3280415: Metapackage Generator Breaks Under Composer --no-dev,!2205Quote all names in the regions section.,!2050Issue #3272969: Remove UnqiueField constraint.,!1956Issue #3268872: hook_views_invalidate_cache not called when a view is deleted,!1627Issue #3082958: Add gitignore(s) to composer-ready project templates,!1459Issue #3087632: menu_name max length is too long,!1014Issue #3226806: Move filter implementations from filter.module to plugin classes,!939Issue #2971209: Allow the MediaLibraryUiBuilder service to use an alternative view display,!878Issue #3221534: throw an exception when IDs passed to loadMultiple() are badly formed,!866Issue #2845319: The highlighting of the 'Home' menu-link does not respect query strings and fragment identifiers,!204Issue #3040556: It is not possible to react to an entity being duplicated,!88Issue #3163299: Ajax exposed filters not working for multiple instances of the same Views block placed on one page
......@@ -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();
......@@ -644,20 +647,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.
Finish editing this message first!
Please register or to comment