diff --git a/cypress/e2e/collection-page.cy.ts b/cypress/e2e/collection-page.cy.ts index be7ef8d182..630fa0a18b 100644 --- a/cypress/e2e/collection-page.cy.ts +++ b/cypress/e2e/collection-page.cy.ts @@ -7,7 +7,7 @@ describe('Collection Page', () => { cy.visit('/collections/' + TEST_COLLECTION); // tag must be loaded - cy.get('ds-collection-page').should('exist'); + cy.get('ds-collection-page').should('be.visible'); // Analyze for accessibility issues testA11y('ds-collection-page'); diff --git a/cypress/e2e/collection-statistics.cy.ts b/cypress/e2e/collection-statistics.cy.ts index 58601f1c4e..f3e36e7bc5 100644 --- a/cypress/e2e/collection-statistics.cy.ts +++ b/cypress/e2e/collection-statistics.cy.ts @@ -12,7 +12,7 @@ describe('Collection Statistics Page', () => { it('should contain a "Total visits" section', () => { cy.visit(COLLECTIONSTATISTICSPAGE); - cy.get('.' + TEST_COLLECTION + '_TotalVisits').should('exist'); + cy.get('.' + TEST_COLLECTION + '_TotalVisits').should('be.visible'); }); it('should contain a "Total visits per month" section', () => { @@ -24,7 +24,7 @@ describe('Collection Statistics Page', () => { cy.visit(COLLECTIONSTATISTICSPAGE); // tag must be loaded - cy.get('ds-collection-statistics-page').should('exist'); + cy.get('ds-collection-statistics-page').should('be.visible'); // Analyze for accessibility issues testA11y('ds-collection-statistics-page'); diff --git a/cypress/e2e/community-list.cy.ts b/cypress/e2e/community-list.cy.ts index a7ba72b74a..7b60b59dbc 100644 --- a/cypress/e2e/community-list.cy.ts +++ b/cypress/e2e/community-list.cy.ts @@ -7,10 +7,10 @@ describe('Community List Page', () => { cy.visit('/community-list'); // tag must be loaded - cy.get('ds-community-list-page').should('exist'); + cy.get('ds-community-list-page').should('be.visible'); - // Open first Community (to show Collections)...that way we scan sub-elements as well - cy.get('ds-community-list :nth-child(1) > .btn-group > .btn').click(); + // Open every expand button on page, so that we can scan sub-elements as well + cy.get('[data-test="expand-button"]').click({ multiple: true }); // Analyze for accessibility issues // Disable heading-order checks until it is fixed diff --git a/cypress/e2e/community-page.cy.ts b/cypress/e2e/community-page.cy.ts index 080dccf820..34f03e829a 100644 --- a/cypress/e2e/community-page.cy.ts +++ b/cypress/e2e/community-page.cy.ts @@ -7,7 +7,7 @@ describe('Community Page', () => { cy.visit('/communities/' + TEST_COMMUNITY); // tag must be loaded - cy.get('ds-community-page').should('exist'); + cy.get('ds-community-page').should('be.visible'); // Analyze for accessibility issues testA11y('ds-community-page',); diff --git a/cypress/e2e/community-statistics.cy.ts b/cypress/e2e/community-statistics.cy.ts index 4eb1d7935d..994b73dad9 100644 --- a/cypress/e2e/community-statistics.cy.ts +++ b/cypress/e2e/community-statistics.cy.ts @@ -12,7 +12,7 @@ describe('Community Statistics Page', () => { it('should contain a "Total visits" section', () => { cy.visit(COMMUNITYSTATISTICSPAGE); - cy.get('.' + TEST_COMMUNITY + '_TotalVisits').should('exist'); + cy.get('.' + TEST_COMMUNITY + '_TotalVisits').should('be.visible'); }); it('should contain a "Total visits per month" section', () => { @@ -24,7 +24,7 @@ describe('Community Statistics Page', () => { cy.visit(COMMUNITYSTATISTICSPAGE); // tag must be loaded - cy.get('ds-community-statistics-page').should('exist'); + cy.get('ds-community-statistics-page').should('be.visible'); // Analyze for accessibility issues testA11y('ds-community-statistics-page'); diff --git a/cypress/e2e/item-page.cy.ts b/cypress/e2e/item-page.cy.ts index f55cfc4b4d..7f6282a36f 100644 --- a/cypress/e2e/item-page.cy.ts +++ b/cypress/e2e/item-page.cy.ts @@ -16,7 +16,7 @@ describe('Item Page', () => { cy.visit(ENTITYPAGE); // tag must be loaded - cy.get('ds-item-page').should('exist'); + cy.get('ds-item-page').should('be.visible'); // Analyze for accessibility issues // Disable heading-order checks until it is fixed diff --git a/cypress/e2e/item-statistics.cy.ts b/cypress/e2e/item-statistics.cy.ts index 4fa90d4ef8..50e8f193da 100644 --- a/cypress/e2e/item-statistics.cy.ts +++ b/cypress/e2e/item-statistics.cy.ts @@ -12,13 +12,13 @@ describe('Item Statistics Page', () => { it('should contain element ds-item-statistics-page when navigating to an item statistics page', () => { cy.visit(ITEMSTATISTICSPAGE); - cy.get('ds-item-statistics-page').should('exist'); + cy.get('ds-item-statistics-page').should('be.visible'); cy.get('ds-item-page').should('not.exist'); }); it('should contain a "Total visits" section', () => { cy.visit(ITEMSTATISTICSPAGE); - cy.get('.' + TEST_ENTITY_PUBLICATION + '_TotalVisits').should('exist'); + cy.get('.' + TEST_ENTITY_PUBLICATION + '_TotalVisits').should('be.visible'); }); it('should contain a "Total visits per month" section', () => { @@ -30,7 +30,7 @@ describe('Item Statistics Page', () => { cy.visit(ITEMSTATISTICSPAGE); // tag must be loaded - cy.get('ds-item-statistics-page').should('exist'); + cy.get('ds-item-statistics-page').should('be.visible'); // Analyze for accessibility issues testA11y('ds-item-statistics-page'); diff --git a/cypress/e2e/my-dspace.cy.ts b/cypress/e2e/my-dspace.cy.ts index d6fa707f82..cf717d936d 100644 --- a/cypress/e2e/my-dspace.cy.ts +++ b/cypress/e2e/my-dspace.cy.ts @@ -9,7 +9,7 @@ describe('My DSpace page', () => { // This page is restricted, so we will be shown the login form. Fill it out & submit. cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD); - cy.get('ds-my-dspace-page').should('exist'); + cy.get('ds-my-dspace-page').should('be.visible'); // At least one recent submission should be displayed cy.get('[data-test="list-object"]').should('be.visible'); @@ -42,12 +42,12 @@ describe('My DSpace page', () => { // This page is restricted, so we will be shown the login form. Fill it out & submit. cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD); - cy.get('ds-my-dspace-page').should('exist'); + cy.get('ds-my-dspace-page').should('be.visible'); // Click button in sidebar to display detailed view cy.get('ds-search-sidebar [data-test="detail-view"]').click(); - cy.get('ds-object-detail').should('exist'); + cy.get('ds-object-detail').should('be.visible'); // Analyze for accessibility issues testA11y('ds-my-dspace-page', diff --git a/cypress/e2e/pagenotfound.cy.ts b/cypress/e2e/pagenotfound.cy.ts index 48520bcaa3..43e3c3af24 100644 --- a/cypress/e2e/pagenotfound.cy.ts +++ b/cypress/e2e/pagenotfound.cy.ts @@ -2,7 +2,7 @@ describe('PageNotFound', () => { it('should contain element ds-pagenotfound when navigating to page that doesnt exist', () => { // request an invalid page (UUIDs at root path aren't valid) cy.visit('/e9019a69-d4f1-4773-b6a3-bd362caa46f2', { failOnStatusCode: false }); - cy.get('ds-pagenotfound').should('exist'); + cy.get('ds-pagenotfound').should('be.visible'); }); it('should not contain element ds-pagenotfound when navigating to existing page', () => { diff --git a/cypress/e2e/search-page.cy.ts b/cypress/e2e/search-page.cy.ts index 8078c4a969..5c1d068b74 100644 --- a/cypress/e2e/search-page.cy.ts +++ b/cypress/e2e/search-page.cy.ts @@ -17,7 +17,7 @@ describe('Search Page', () => { cy.get('[data-test="search-box"]').should('have.value', TEST_SEARCH_TERM); // tag must be loaded - cy.get('ds-search-page').should('exist'); + cy.get('ds-search-page').should('be.visible'); // At least one search result should be displayed cy.get('[data-test="list-object"]').should('be.visible'); @@ -51,7 +51,7 @@ describe('Search Page', () => { cy.get('ds-search-sidebar [data-test="grid-view"]').click(); // tag must be loaded - cy.get('ds-search-page').should('exist'); + cy.get('ds-search-page').should('be.visible'); // At least one grid object (card) should be displayed cy.get('[data-test="grid-object"]').should('be.visible'); diff --git a/cypress/support/utils.ts b/cypress/support/utils.ts index 96575969e8..fc0820d25c 100644 --- a/cypress/support/utils.ts +++ b/cypress/support/utils.ts @@ -40,5 +40,13 @@ export const testA11y = (context?: any, options?: Options) => { { id: 'color-contrast', enabled: false }, ] }); + // Default retries to 2, meaning this accessibility test will retry up to 2 times. + const a11yRetries = 2; + if (options) { + options.retries = a11yRetries; + } else { + options = { retries: a11yRetries } as Options; + } + cy.checkA11y(context, options, terminalLog); }; diff --git a/src/app/community-list-page/community-list/community-list.component.html b/src/app/community-list-page/community-list/community-list.component.html index 821cb58473..ea772bb891 100644 --- a/src/app/community-list-page/community-list/community-list.component.html +++ b/src/app/community-list-page/community-list/community-list.component.html @@ -28,7 +28,8 @@ [title]="'toggle ' + node.name" [attr.aria-label]="'toggle ' + node.name" (click)="toggleExpanded(node)" - [ngClass]="(hasChild(null, node)| async) ? 'visible' : 'invisible'"> + [ngClass]="(hasChild(null, node)| async) ? 'visible' : 'invisible'" + [attr.data-test]="(hasChild(null, node)| async) ? 'expand-button' : ''">