Skip to content

Commit

Permalink
Reset pagination when a filter is selected (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed Jul 20, 2022
1 parent c43bbc5 commit 7a1c45d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions assets/js/components/Table/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const Table = ({ config, data = [] }) => {
filters={filters}
onChange={(newFilters) => {
setFilters(newFilters);
setCurrentPage(1);
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,11 @@ Scenario: Filtering the Host Overview by Tags

When I filter by tag 'env3'
Then 8 items should be shown

Scenario: Filtering when a non 1st page is selected
Given all the hosts containing 'prd' in their name are tagged with 'env1'
And the selected page is the last one

When I filter by tag 'env1'
Then 8 items should be shown
And the selected page is the 1st one
10 changes: 10 additions & 0 deletions test/e2e/cypress/integration/hosts_overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ context('Hosts Overview', () => {
cy.get('li > div > span.ml-3.block').contains(tag).click();
});
});

it('should reset the pagination and go the 1st page when a filter is selected', () => {
const tag = 'env1';

cy.get('.tn-page-item').eq(2).click();
cy.get('span').contains('Filter Tags').parent().parent().click();
cy.get('li > div > span.ml-3.block').contains(tag).click();
cy.get('.tn-hostname').its('length').should('eq', 4);
cy.get('li > div > span.ml-3.block').contains(tag).click();
});
});
});
});
Expand Down

0 comments on commit 7a1c45d

Please sign in to comment.