@@ -2,12 +2,12 @@ import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
22import { testA11y } from 'cypress/support/utils' ;
33
44describe ( '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} ) ;
0 commit comments