Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset pagination when a filter is selected #704

Merged
merged 1 commit into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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