Skip to content

Commit 68ebd7c

Browse files
Fix Cys File - 4195
1 parent d1a876a commit 68ebd7c

2 files changed

Lines changed: 13 additions & 27 deletions

File tree

cypress/e2e/collection-statistics.cy.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ 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/'.concat(Cypress.env('DSPACE_TEST_COLLECTION'));
5+
const COLLECTIONSTATISTICSPAGE = `/statistics/collections/${Cypress.env('DSPACE_TEST_COLLECTION')}`;
66

77
it('should load if you click on "Statistics" from a Collection page', () => {
8-
cy.visit('/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')));
9-
cy.get('ds-navbar', { timeout: 10000 }).should('be.visible');
10-
cy.get('a[data-test="link-menu-item.menu.section.statistics"]', { timeout: 10000 }).should('be.visible').click();
8+
cy.visit(`/collections/${Cypress.env('DSPACE_TEST_COLLECTION')}`);
9+
// Busca el enlace por su texto visible
10+
cy.contains('a', 'Statistics', { timeout: 10000 }).should('be.visible').click();
1111
cy.location('pathname').should('eq', COLLECTIONSTATISTICSPAGE);
1212
});
1313

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

1919
it('should contain a "Total visits per month" section', () => {
2020
cy.visit(COLLECTIONSTATISTICSPAGE);
21-
// Check just for existence because this table is empty in CI environment as it's historical data
22-
cy.get('.'.concat(Cypress.env('DSPACE_TEST_COLLECTION')).concat('_TotalVisitsPerMonth')).should('exist');
21+
cy.get(`.${Cypress.env('DSPACE_TEST_COLLECTION')}_TotalVisitsPerMonth`).should('exist');
2322
});
2423

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

cypress/e2e/community-statistics.cy.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ 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/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY'));
5+
const COMMUNITYSTATISTICSPAGE = `/statistics/communities/${Cypress.env('DSPACE_TEST_COMMUNITY')}`;
66

77
it('should load if you click on "Statistics" from a Community page', () => {
8-
cy.visit('/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')));
9-
cy.get('a[data-test="link-menu-item.menu.section.statistics"]', { timeout: 10000 }).should('be.visible').click();
8+
cy.visit(`/communities/${Cypress.env('DSPACE_TEST_COMMUNITY')}`);
9+
cy.contains('a', 'Statistics', { timeout: 10000 }).should('be.visible').click();
1010
cy.location('pathname').should('eq', COMMUNITYSTATISTICSPAGE);
1111
});
1212

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

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

2423
it('should pass accessibility tests', () => {
2524
cy.visit(COMMUNITYSTATISTICSPAGE);
26-
27-
// <ds-community-statistics-page> tag must be loaded
2825
cy.get('ds-community-statistics-page').should('be.visible');
29-
30-
// Verify / wait until "Total Visits" table's label is non-empty
31-
// (This table loads these labels asynchronously, so we want to wait for them before analyzing page)
32-
cy.get('table[data-test="TotalVisits"] th[data-test="statistics-label"]').contains(REGEX_MATCH_NON_EMPTY_TEXT);
33-
34-
// Analyze <ds-community-statistics-page> for accessibility issues
26+
cy.get('table[data-test="TotalVisits"] th[data-test="statistics-label"]')
27+
.contains(REGEX_MATCH_NON_EMPTY_TEXT);
3528
testA11y('ds-community-statistics-page');
3629
});
3730
});

0 commit comments

Comments
 (0)