Skip to content

Commit 12b1974

Browse files
Fix two cy files - 4195
1 parent 9db5d0d commit 12b1974

2 files changed

Lines changed: 35 additions & 13 deletions

File tree

cypress/e2e/collection-statistics.cy.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
22
import { testA11y } from 'cypress/support/utils';
33

44
describe('Collection Statistics Page', () => {
5-
const COLLECTIONSTATISTICSPAGE = `/statistics/collections/${Cypress.env('DSPACE_TEST_COLLECTION')}`;
5+
const id = Cypress.env('DSPACE_TEST_COLLECTION');
6+
const COLLECTIONSTATISTICSPAGE = `/statistics/collections/${id}`;
67

78
it('should load if you click on "Statistics" from a Collection page', () => {
8-
cy.visit(`/collections/${Cypress.env('DSPACE_TEST_COLLECTION')}`);
9-
cy.contains('a', 'Statistics', { timeout: 10000 }).should('be.visible').click();
9+
cy.visit(`/collections/${id}`);
10+
cy.get('ds-link-menu-item[data-test="link-menu-item.menu.section.statistics"]', { timeout: 10000 })
11+
.should('be.visible')
12+
.click();
13+
1014
cy.location('pathname').should('eq', COLLECTIONSTATISTICSPAGE);
1115
});
1216

@@ -17,14 +21,21 @@ describe('Collection Statistics Page', () => {
1721

1822
it('should contain a "Total visits per month" section', () => {
1923
cy.visit(COLLECTIONSTATISTICSPAGE);
20-
cy.get(`.${Cypress.env('DSPACE_TEST_COLLECTION')}_TotalVisitsPerMonth`).should('exist');
24+
// Check just for existence because this table is empty in CI environment as it's historical data
25+
cy.get('.'.concat(Cypress.env('DSPACE_TEST_COLLECTION')).concat('_TotalVisitsPerMonth')).should('exist');
2126
});
2227

2328
it('should pass accessibility tests', () => {
2429
cy.visit(COLLECTIONSTATISTICSPAGE);
30+
31+
// <ds-collection-statistics-page> tag must be loaded
2532
cy.get('ds-collection-statistics-page').should('be.visible');
26-
cy.get('table[data-test="TotalVisits"] th[data-test="statistics-label"]')
27-
.contains(REGEX_MATCH_NON_EMPTY_TEXT);
33+
34+
// Verify / wait until "Total Visits" table's label is non-empty
35+
// (This table loads these labels asynchronously, so we want to wait for them before analyzing page)
36+
cy.get('table[data-test="TotalVisits"] th[data-test="statistics-label"]').contains(REGEX_MATCH_NON_EMPTY_TEXT);
37+
38+
// Analyze <ds-collection-statistics-page> for accessibility issues
2839
testA11y('ds-collection-statistics-page');
2940
});
3041
});

cypress/e2e/community-statistics.cy.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,41 @@ import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
22
import { testA11y } from 'cypress/support/utils';
33

44
describe('Community Statistics Page', () => {
5-
const COMMUNITYSTATISTICSPAGE = `/statistics/communities/${Cypress.env('DSPACE_TEST_COMMUNITY')}`;
5+
const id = Cypress.env('DSPACE_TEST_COMMUNITY');
6+
const COMMUNITYSTATISTICSPAGE = `/statistics/communities/${id}`;
67

7-
//solve error
88
it('should load if you click on "Statistics" from a Community page', () => {
9-
cy.visit(`/communities/${Cypress.env('DSPACE_TEST_COMMUNITY')}`);
10-
cy.contains('a', 'Statistics', { timeout: 10000 }).should('be.visible').click();
9+
cy.visit(`/communities/${id}`);
10+
cy.get('ds-link-menu-item[data-test="link-menu-item.menu.section.statistics"]', { timeout: 10000 })
11+
.should('be.visible')
12+
.click();
13+
1114
cy.location('pathname').should('eq', COMMUNITYSTATISTICSPAGE);
1215
});
1316

17+
1418
it('should contain a "Total visits" section', () => {
1519
cy.visit(COMMUNITYSTATISTICSPAGE);
1620
cy.get('table[data-test="TotalVisits"]').should('be.visible');
1721
});
1822

1923
it('should contain a "Total visits per month" section', () => {
2024
cy.visit(COMMUNITYSTATISTICSPAGE);
21-
cy.get(`.${Cypress.env('DSPACE_TEST_COMMUNITY')}_TotalVisitsPerMonth`).should('exist');
25+
// Check just for existence because this table is empty in CI environment as it's historical data
26+
cy.get('.'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')).concat('_TotalVisitsPerMonth')).should('exist');
2227
});
2328

2429
it('should pass accessibility tests', () => {
2530
cy.visit(COMMUNITYSTATISTICSPAGE);
31+
32+
// <ds-community-statistics-page> tag must be loaded
2633
cy.get('ds-community-statistics-page').should('be.visible');
27-
cy.get('table[data-test="TotalVisits"] th[data-test="statistics-label"]')
28-
.contains(REGEX_MATCH_NON_EMPTY_TEXT);
34+
35+
// Verify / wait until "Total Visits" table's label is non-empty
36+
// (This table loads these labels asynchronously, so we want to wait for them before analyzing page)
37+
cy.get('table[data-test="TotalVisits"] th[data-test="statistics-label"]').contains(REGEX_MATCH_NON_EMPTY_TEXT);
38+
39+
// Analyze <ds-community-statistics-page> for accessibility issues
2940
testA11y('ds-community-statistics-page');
3041
});
3142
});

0 commit comments

Comments
 (0)