fix(editor): Prevent pagination setting from being overwritten in URL (#13266)

This commit is contained in:
Milorad FIlipović
2025-02-17 11:38:35 +01:00
committed by GitHub
parent 8e15ebf833
commit d1e65a1cd5
4 changed files with 92 additions and 17 deletions

View File

@@ -97,4 +97,45 @@ describe('Workflows', () => {
WorkflowsPage.getters.workflowCards().should('have.length', 1);
});
it('should preserve filters and pagination in URL', () => {
// Add a search query
WorkflowsPage.getters.searchBar().type('My');
// Add a tag filter
WorkflowsPage.getters.workflowFilterButton().click();
WorkflowsPage.getters.workflowTagsDropdown().click();
WorkflowsPage.getters.workflowTagItem('other-tag-1').click();
WorkflowsPage.getters.workflowsListContainer().click();
// Update sort order
WorkflowsPage.getters.workflowSortDropdown().click();
WorkflowsPage.getters.workflowSortItem('Sort by last created').click({ force: true });
// Update page size
WorkflowsPage.getters.workflowListPageSizeDropdown().click();
WorkflowsPage.getters.workflowListPageSizeItem('25').click();
// URL should contain all applied filters and pagination
cy.url().should('include', 'search=My');
// Cannot really know tag id, so just check if it contains 'tags='
cy.url().should('include', 'tags=');
cy.url().should('include', 'sort=lastCreated');
cy.url().should('include', 'pageSize=25');
// Reload the page
cy.reload();
// Check if filters and pagination are preserved
WorkflowsPage.getters.searchBar().should('have.value', 'My');
WorkflowsPage.getters.workflowFilterButton().click();
WorkflowsPage.getters.workflowTagsDropdown().should('contain.text', 'other-tag-1');
WorkflowsPage.getters
.workflowSortItem('Sort by last created')
.should('have.attr', 'aria-selected', 'true');
WorkflowsPage.getters
.workflowListPageSizeItem('25', false)
.should('have.attr', 'aria-selected', 'true');
// Aso, check if the URL is preserved
cy.url().should('include', 'search=My');
cy.url().should('include', 'tags=');
cy.url().should('include', 'sort=lastCreated');
cy.url().should('include', 'pageSize=25');
});
});

View File

@@ -47,6 +47,18 @@ export class WorkflowsPage extends BasePage {
workflowOwnershipDropdown: () => cy.getByTestId('user-select-trigger'),
workflowOwner: (email: string) => cy.getByTestId('user-email').contains(email),
workflowResetFilters: () => cy.getByTestId('workflows-filter-reset'),
workflowSortDropdown: () => cy.getByTestId('resources-list-sort'),
workflowSortItem: (sort: string) =>
cy.getByTestId('resources-list-sort-item').contains(sort).parent(),
workflowPagination: () => cy.getByTestId('resources-list-pagination'),
workflowListPageSizeDropdown: () => this.getters.workflowPagination().find('.select-trigger'),
workflowListPageSizeItem: (pageSize: string, visible: boolean = true) => {
if (visible) {
return cy.get('[role=option]').filter(':visible').contains(`${pageSize}/page`);
}
return cy.get('[role=option]').contains(`${pageSize}/page`).parent();
},
workflowsListContainer: () => cy.getByTestId('resources-list-wrapper'),
// Not yet implemented
// myWorkflows: () => cy.getByTestId('my-workflows'),
// allWorkflows: () => cy.getByTestId('all-workflows'),