Commit 6651ddc0 authored by Tim Plunkett's avatar Tim Plunkett Committed by Ben Mullins
Browse files

Issue #3252678 by tim.plunkett, Rajab Natshah, fjgarlin: The pager is not...

Issue #3252678 by tim.plunkett, Rajab Natshah, fjgarlin: The pager is not following with the limit of items
parent 5a6f0673
Loading
Loading
Loading
Loading
+0 −0

File changed.

Preview suppressed by a .gitattributes entry or the file's encoding is unsupported.

+0 −0

File changed.

Preview suppressed by a .gitattributes entry or the file's encoding is unsupported.

+1 −1
Changes for sveltejs/src/Pagination.svelte: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
    previous: Drupal.t('Previous'),
  };

  $: pageCount = Math.floor(count / pageSize);
  $: pageCount = Math.ceil(count / pageSize) - 1;
</script>

<!-- svelte-ignore a11y-no-redundant-roles -->
+7 −1
Changes for tests/fixtures/projects_fixture.json: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -827,7 +827,13 @@
        "7.x-1.x": 90,
        "8.x-2.x": 800
      },
      "taxonomy_vocabulary_3": [],
      "taxonomy_vocabulary_3": [
        {
          "uri": "https://www.drupal.org/api-d7/taxonomy_term/67",
          "id": "67",
          "resource": "taxonomy_term"
        }
      ],
      "taxonomy_vocabulary_44": {
        "uri": "https://www.drupal.org/api-d7/taxonomy_term/13028",
        "id": "13028",
+80 −15
Changes for tests/src/FunctionalJavascript/ProjectBrowserUiTest.php: 80 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -57,6 +57,23 @@ class ProjectBrowserUiTest extends WebDriverTestBase {
    $this->assertSame($project_titles, $titles);
  }

  /**
   * Asserts that a given list of pager items are present on the page.
   *
   * @param array $pager_items
   *   An array of expected pager item labels.
   */
  protected function assertPagerItems(array $pager_items): void {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $assert_session->waitForElementVisible('css', '#project-browser .project');
    $items = array_map(function ($element) {
      return $element->getText();
    }, $page->findAll('css', '#project-browser .pager__item'));
    $this->assertSame($pager_items, $items);
  }

  /**
   * Tests the grid view.
   */
@@ -141,16 +158,16 @@ class ProjectBrowserUiTest extends WebDriverTestBase {
      'Tooth Fairy',
      'Vitamin&C;$?',
      'Cream cheese on a bagel',
      'Pinky and the Brain',
      'No Scrubs',
      'Soup',
      'Mad About You',
      'Dancing Queen',
      'Kangaroo',
      '9 Starts With a Higher Number',
      'Quiznos',
    ]);
    $assert_session->waitForElementVisible('css', '#project-browser .project');
    $assert_session->pageTextContains('22 Results');
    $assert_session->pageTextContains('23 Results');
  }

  /**
@@ -161,28 +178,76 @@ class ProjectBrowserUiTest extends WebDriverTestBase {
    $assert_session = $this->assertSession();

    $this->drupalGet('admin/modules/browse');
    $assert_session->waitForElementVisible('css', '#project-browser .project');
    $this->assertProjectsVisible([
      'Cream cheese on a bagel',
      'Pinky and the Brain',
      'Dancing Queen',
      'Kangaroo',
      '9 Starts With a Higher Number',
      'Octopus',
      'Helvetica',
      'Unwritten&:/',
      'Astronaut Simulator',
    ]);
    $this->assertPagerItems(['1']);
    $assert_session->pageTextContains('9 Results');
    $assert_session->elementsCount('css', '.pager__item--number', 1);

    $page->pressButton('Clear filters');
    $assert_session->waitForElementVisible('css', '#project-browser .project');
    $this->assertProjectsVisible([
      'Jazz',
      'Eggman',
      'Tooth Fairy',
      'Vitamin&C;$?',
      'Cream cheese on a bagel',
      'Pinky and the Brain',
      'Ice Ice',
      'No Scrubs',
      'Soup',
      'Mad About You',
      'Dancing Queen',
      'Kangaroo',
    ]);
    $this->assertPagerItems(['1', '2', '3', 'Next', 'Last']);
    $assert_session->pageTextContains('25 Results');
    $assert_session->elementsCount('css', '.pager__item--number', 3);

    $assert_session->elementTextContains('css', '#project-browser .project', 'Jazz');
    $assert_session->elementsCount('css', '#project-browser .project', 12);
    $assert_session->elementExists('css', '.pager__item--active > .is-active[aria-label="Page 1"]');

    $page->find('css', '[aria-label="Next page"]')->click();
    $assert_session->waitForElementVisible('css', '#project-browser .project');
    $assert_session->elementTextContains('css', '#project-browser .project', '9 Starts With a Higher Number');
    $assert_session->elementsCount('css', '#project-browser .project', 12);
    $this->assertProjectsVisible([
      '9 Starts With a Higher Number',
      'Quiznos',
      'Octopus',
      'Helvetica',
      '1 Starts With a Number',
      'Ruh roh',
      'Fire',
      'Looper',
      'Grapefruit',
      'Become a Banana',
      'Unwritten&:/',
      'Doomer',
    ]);
    $this->assertPagerItems(['First', 'Previous', '1', '2', '3', 'Next', 'Last']);

    $page->find('css', '[aria-label="Next page"]')->click();
    $assert_session->waitForElementVisible('css', '#project-browser .project');
    $assert_session->elementTextContains('css', '#project-browser .project', 'Astronaut Simulator');
    $assert_session->elementsCount('css', '#project-browser .project', 1);
    $this->assertProjectsVisible([
      'Astronaut Simulator',
    ]);
    $this->assertPagerItems(['First', 'Previous', '1', '2', '3']);

    // Ensure that when the number of projects is even divisible by the number
    // shown on a page, the pager has the correct number of items.
    $page->find('css', '[aria-label="First page"]')->click();
    // Click 'Media' checkbox.
    $page->find('css', '#67')->click();
    // Click 'Commerce/Advertising' checkbox.
    $page->find('css', '#55')->click();
    // Click 'E-commerce' checkbox.
    $page->find('css', '#104')->click();
    $this->assertPagerItems(['1', '2', 'Next', 'Last']);
    $assert_session->pageTextContains('24 Results');

    $page->find('css', '[aria-label="Next page"]')->click();
    $this->assertPagerItems(['First', 'Previous', '1', '2']);
  }

  /**