From 8c865b758eba2847056154a3bb20fb38a5bb2523 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Wed, 9 Feb 2022 15:07:08 -0600 Subject: [PATCH] Fix bugs / stability issues with search e2e tests --- cypress/integration/search-navbar.spec.ts | 6 +++--- cypress/integration/search-page.spec.ts | 18 +++++++----------- .../object-grid/object-grid.component.html | 2 +- .../object-list/object-list.component.html | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/cypress/integration/search-navbar.spec.ts b/cypress/integration/search-navbar.spec.ts index 3aa8e7248d..211b4836b1 100644 --- a/cypress/integration/search-navbar.spec.ts +++ b/cypress/integration/search-navbar.spec.ts @@ -31,7 +31,7 @@ describe('Search from Navigation Bar', () => { // Wait for search results to come back from the above GET command cy.wait('@search-results'); // At least one search result should be displayed - cy.get('ds-item-search-result-list-element').should('be.visible'); + cy.get('[data-e2e="list-object"]').should('be.visible'); }); it('should go to search page with correct query if submitted (from search)', () => { @@ -46,7 +46,7 @@ describe('Search from Navigation Bar', () => { // Wait for search results to come back from the above GET command cy.wait('@search-results'); // At least one search result should be displayed - cy.get('ds-item-search-result-list-element').should('be.visible'); + cy.get('[data-e2e="list-object"]').should('be.visible'); }); it('should allow user to also submit query by clicking icon', () => { @@ -61,6 +61,6 @@ describe('Search from Navigation Bar', () => { // Wait for search results to come back from the above GET command cy.wait('@search-results'); // At least one search result should be displayed - cy.get('ds-item-search-result-list-element').should('be.visible'); + cy.get('[data-e2e="list-object"]').should('be.visible'); }); }); diff --git a/cypress/integration/search-page.spec.ts b/cypress/integration/search-page.spec.ts index cbd518b97c..981c9365aa 100644 --- a/cypress/integration/search-page.spec.ts +++ b/cypress/integration/search-page.spec.ts @@ -1,13 +1,8 @@ import { Options } from 'cypress-axe'; +import { TEST_SEARCH_TERM } from 'cypress/support'; import { testA11y } from 'cypress/support/utils'; describe('Search Page', () => { - it('should contain query value when navigating to page with query parameter', () => { - const queryString = 'test query'; - cy.visit('/search?query=' + queryString); - cy.get('[data-e2e="search-box"]').should('have.value', queryString); - }); - it('should redirect to the correct url when query was set and submit button was triggered', () => { const queryString = 'Another interesting query string'; cy.visit('/search'); @@ -18,13 +13,14 @@ describe('Search Page', () => { }); it('should load results and pass accessibility tests', () => { - cy.visit('/search'); + cy.visit('/search?query=' + TEST_SEARCH_TERM); + cy.get('[data-e2e="search-box"]').should('have.value', TEST_SEARCH_TERM); // tag must be loaded cy.get('ds-search-page').should('exist'); // At least one search result should be displayed - cy.get('ds-item-search-result-list-element').should('be.visible'); + cy.get('[data-e2e="list-object"]').should('be.visible'); // Click each filter toggle to open *every* filter // (As we want to scan filter section for accessibility issues as well) @@ -49,7 +45,7 @@ describe('Search Page', () => { }); it('should have a working grid view that passes accessibility tests', () => { - cy.visit('/search'); + cy.visit('/search?query=' + TEST_SEARCH_TERM); // Click button in sidebar to display grid view cy.get('ds-search-sidebar [data-e2e="grid-view"]').click(); @@ -57,8 +53,8 @@ describe('Search Page', () => { // tag must be loaded cy.get('ds-search-page').should('exist'); - // At least one grid element (card) should be displayed - cy.get('ds-item-search-result-grid-element').should('be.visible'); + // At least one grid object (card) should be displayed + cy.get('[data-e2e="grid-object"]').should('be.visible'); // Analyze for accessibility issues testA11y('ds-search-page', diff --git a/src/app/shared/object-grid/object-grid.component.html b/src/app/shared/object-grid/object-grid.component.html index 0afd623d86..296f190d2d 100644 --- a/src/app/shared/object-grid/object-grid.component.html +++ b/src/app/shared/object-grid/object-grid.component.html @@ -13,7 +13,7 @@ (paginationChange)="onPaginationChange($event)">
-
+
diff --git a/src/app/shared/object-list/object-list.component.html b/src/app/shared/object-list/object-list.component.html index 331ff1cb28..53a62ca1f5 100644 --- a/src/app/shared/object-list/object-list.component.html +++ b/src/app/shared/object-list/object-list.component.html @@ -12,7 +12,7 @@ (sortFieldChange)="onSortFieldChange($event)" (paginationChange)="onPaginationChange($event)">
    -
  • +