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