Unverified Commit ba56921e authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3346136 by acbramley: Custom classes for pager links do not work with Olivero theme

parent 09f64bf5
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ class OliveroTest extends BrowserTestBase {
   */
  protected static $modules = [
    'olivero_test',
    'pager_test',
    'dblog',
  ];

  /**
@@ -129,4 +131,33 @@ public function testIsUninstallable() {
    $this->assertSession()->pageTextContains('The Olivero theme has been uninstalled.');
  }

  /**
   * Tests pager attribute is present using pager_test.
   */
  public function testPagerAttribute(): void {
    // Insert 300 log messages.
    $logger = \Drupal::logger('pager_test');
    for ($i = 0; $i < 300; $i++) {
      $logger->debug($this->randomString());
    }

    $this->drupalLogin($this->drupalCreateUser(['access site reports']));

    $this->drupalGet('pager-test/multiple-pagers', ['query' => ['page' => 1]]);
    $this->assertSession()->statusCodeEquals(200);
    $elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
    $this->assertNotEmpty($elements, 'Pager found.');

    // Check all links for pager-test attribute.
    foreach ($elements as $element) {
      $link = $element->find('css', 'a');
      // Current page does not have a link.
      if (empty($link)) {
        continue;
      }
      $this->assertTrue($link->hasAttribute('pager-test'), 'Pager item has attribute pager-test');
      $this->assertTrue($link->hasClass('lizards'));
    }
  }

}
+5 −5
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@
      {% if items.first %}
        {% apply spaceless %}
          <li class="pager__item pager__item--control pager__item--first">
            <a href="{{ items.first.href }}" class="pager__link" title="{{ 'Go to first page'|t }}"{{ items.first.attributes|without('href', 'title', 'class') }}>
            <a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}"{{ items.first.attributes|without('href', 'title').addClass('pager__link') }}>
              <span class="visually-hidden">{{ 'First page'|t }}</span>
              {% include "@olivero/../images/pager-first.svg" %}
            </a>
@@ -50,7 +50,7 @@
      {% if items.previous %}
        {% apply spaceless %}
          <li class="pager__item pager__item--control pager__item--previous">
            <a href="{{ items.previous.href }}" class="pager__link" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel', 'class') }}>
            <a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel').addClass('pager__link') }}>
              <span class="visually-hidden">{{ 'Previous page'|t }}</span>
              {% include "@olivero/../images/pager-previous.svg" %}
            </a>
@@ -73,7 +73,7 @@
              {% set title = 'Go to page @key'|t({'@key': key}) %}
            {% endif %}
            {% if current != key %}
              <a href="{{ item.href }}" class="pager__link{{ current == key ? ' is-active' }}" title="{{ title }}"{{ item.attributes|without('href', 'title', 'class') }}>
              <a href="{{ item.href }}" title="{{ title }}"{{ item.attributes|without('href', 'title').addClass('pager__link', current == key ? ' is-active') }}>
            {% endif %}
            <span class="visually-hidden">
              {{ current == key ? 'Current page'|t : 'Page'|t }}
@@ -95,7 +95,7 @@
      {% if items.next %}
        {% apply spaceless %}
          <li class="pager__item pager__item--control pager__item--next">
            <a href="{{ items.next.href }}" class="pager__link" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel', 'class') }}>
            <a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel').addClass('pager__link') }}>
              <span class="visually-hidden">{{ 'Next page'|t }}</span>
              {% include "@olivero/../images/pager-previous.svg" %}
            </a>
@@ -107,7 +107,7 @@
      {% if items.last %}
        {% apply spaceless %}
          <li class="pager__item pager__item--control pager__item--last">
            <a href="{{ items.last.href }}" class="pager__link" title="{{ 'Go to last page'|t }}"{{ items.last.attributes|without('href', 'title', 'class') }}>
            <a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}"{{ items.last.attributes|without('href', 'title').addClass('pager__link') }}>
              <span class="visually-hidden">{{ 'Last page'|t }}</span>
              {% include "@olivero/../images/pager-first.svg" %}
            </a>