mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Make statistics tests more stable by waiting on page to fully load
This commit is contained in:
@@ -1,23 +1,24 @@
|
|||||||
import { TEST_COLLECTION } from 'cypress/support/e2e';
|
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_COLLECTION } from 'cypress/support/e2e';
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Collection Statistics Page', () => {
|
describe('Collection Statistics Page', () => {
|
||||||
const COLLECTIONSTATISTICSPAGE = '/statistics/collections/' + TEST_COLLECTION;
|
const COLLECTIONSTATISTICSPAGE = '/statistics/collections/'.concat(TEST_COLLECTION);
|
||||||
|
|
||||||
it('should load if you click on "Statistics" from a Collection page', () => {
|
it('should load if you click on "Statistics" from a Collection page', () => {
|
||||||
cy.visit('/collections/' + TEST_COLLECTION);
|
cy.visit('/collections/'.concat(TEST_COLLECTION));
|
||||||
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
|
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
|
||||||
cy.location('pathname').should('eq', COLLECTIONSTATISTICSPAGE);
|
cy.location('pathname').should('eq', COLLECTIONSTATISTICSPAGE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain a "Total visits" section', () => {
|
it('should contain a "Total visits" section', () => {
|
||||||
cy.visit(COLLECTIONSTATISTICSPAGE);
|
cy.visit(COLLECTIONSTATISTICSPAGE);
|
||||||
cy.get('.' + TEST_COLLECTION + '_TotalVisits').should('be.visible');
|
cy.get('table[data-test="TotalVisits"]').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain a "Total visits per month" section', () => {
|
it('should contain a "Total visits per month" section', () => {
|
||||||
cy.visit(COLLECTIONSTATISTICSPAGE);
|
cy.visit(COLLECTIONSTATISTICSPAGE);
|
||||||
cy.get('.' + TEST_COLLECTION + '_TotalVisitsPerMonth').should('exist');
|
// Check just for existence because this table is empty in CI environment as it's historical data
|
||||||
|
cy.get('.'.concat(TEST_COLLECTION).concat('_TotalVisitsPerMonth')).should('exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
@@ -26,6 +27,10 @@ describe('Collection Statistics Page', () => {
|
|||||||
// <ds-collection-statistics-page> tag must be loaded
|
// <ds-collection-statistics-page> tag must be loaded
|
||||||
cy.get('ds-collection-statistics-page').should('be.visible');
|
cy.get('ds-collection-statistics-page').should('be.visible');
|
||||||
|
|
||||||
|
// Verify / wait until "Total Visits" table's label is non-empty
|
||||||
|
// (This table loads these labels asynchronously, so we want to wait for them before analyzing page)
|
||||||
|
cy.get('table[data-test="TotalVisits"] th[data-test="statistics-label"]').contains(REGEX_MATCH_NON_EMPTY_TEXT);
|
||||||
|
|
||||||
// Analyze <ds-collection-statistics-page> for accessibility issues
|
// Analyze <ds-collection-statistics-page> for accessibility issues
|
||||||
testA11y('ds-collection-statistics-page');
|
testA11y('ds-collection-statistics-page');
|
||||||
});
|
});
|
||||||
|
@@ -1,23 +1,24 @@
|
|||||||
import { TEST_COMMUNITY } from 'cypress/support/e2e';
|
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_COMMUNITY } from 'cypress/support/e2e';
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Community Statistics Page', () => {
|
describe('Community Statistics Page', () => {
|
||||||
const COMMUNITYSTATISTICSPAGE = '/statistics/communities/' + TEST_COMMUNITY;
|
const COMMUNITYSTATISTICSPAGE = '/statistics/communities/'.concat(TEST_COMMUNITY);
|
||||||
|
|
||||||
it('should load if you click on "Statistics" from a Community page', () => {
|
it('should load if you click on "Statistics" from a Community page', () => {
|
||||||
cy.visit('/communities/' + TEST_COMMUNITY);
|
cy.visit('/communities/'.concat(TEST_COMMUNITY));
|
||||||
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
|
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
|
||||||
cy.location('pathname').should('eq', COMMUNITYSTATISTICSPAGE);
|
cy.location('pathname').should('eq', COMMUNITYSTATISTICSPAGE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain a "Total visits" section', () => {
|
it('should contain a "Total visits" section', () => {
|
||||||
cy.visit(COMMUNITYSTATISTICSPAGE);
|
cy.visit(COMMUNITYSTATISTICSPAGE);
|
||||||
cy.get('.' + TEST_COMMUNITY + '_TotalVisits').should('be.visible');
|
cy.get('table[data-test="TotalVisits"]').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain a "Total visits per month" section', () => {
|
it('should contain a "Total visits per month" section', () => {
|
||||||
cy.visit(COMMUNITYSTATISTICSPAGE);
|
cy.visit(COMMUNITYSTATISTICSPAGE);
|
||||||
cy.get('.' + TEST_COMMUNITY + '_TotalVisitsPerMonth').should('exist');
|
// Check just for existence because this table is empty in CI environment as it's historical data
|
||||||
|
cy.get('.'.concat(TEST_COMMUNITY).concat('_TotalVisitsPerMonth')).should('exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
@@ -26,6 +27,10 @@ describe('Community Statistics Page', () => {
|
|||||||
// <ds-community-statistics-page> tag must be loaded
|
// <ds-community-statistics-page> tag must be loaded
|
||||||
cy.get('ds-community-statistics-page').should('be.visible');
|
cy.get('ds-community-statistics-page').should('be.visible');
|
||||||
|
|
||||||
|
// Verify / wait until "Total Visits" table's label is non-empty
|
||||||
|
// (This table loads these labels asynchronously, so we want to wait for them before analyzing page)
|
||||||
|
cy.get('table[data-test="TotalVisits"] th[data-test="statistics-label"]').contains(REGEX_MATCH_NON_EMPTY_TEXT);
|
||||||
|
|
||||||
// Analyze <ds-community-statistics-page> for accessibility issues
|
// Analyze <ds-community-statistics-page> for accessibility issues
|
||||||
testA11y('ds-community-statistics-page');
|
testA11y('ds-community-statistics-page');
|
||||||
});
|
});
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Site Statistics Page', () => {
|
describe('Site Statistics Page', () => {
|
||||||
@@ -10,8 +11,14 @@ describe('Site Statistics Page', () => {
|
|||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
cy.visit('/statistics');
|
cy.visit('/statistics');
|
||||||
|
|
||||||
// <ds-site-statistics-page> tag must be loaded
|
// <ds-site-statistics-page> tag must be visable
|
||||||
cy.get('ds-site-statistics-page').should('exist');
|
cy.get('ds-site-statistics-page').should('be.visible');
|
||||||
|
|
||||||
|
// Verify / wait until "Total Visits" table's *last* label is non-empty
|
||||||
|
// (This table loads these labels asynchronously, so we want to wait for them before analyzing page)
|
||||||
|
cy.get('table[data-test="TotalVisits"] th[data-test="statistics-label"]').last().contains(REGEX_MATCH_NON_EMPTY_TEXT);
|
||||||
|
// Wait an extra 500ms, just so all entries in Total Visits have loaded.
|
||||||
|
cy.wait(500);
|
||||||
|
|
||||||
// Analyze <ds-site-statistics-page> for accessibility issues
|
// Analyze <ds-site-statistics-page> for accessibility issues
|
||||||
testA11y('ds-site-statistics-page');
|
testA11y('ds-site-statistics-page');
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
|
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Item Statistics Page', () => {
|
describe('Item Statistics Page', () => {
|
||||||
const ITEMSTATISTICSPAGE = '/statistics/items/' + TEST_ENTITY_PUBLICATION;
|
const ITEMSTATISTICSPAGE = '/statistics/items/'.concat(TEST_ENTITY_PUBLICATION);
|
||||||
|
|
||||||
it('should load if you click on "Statistics" from an Item/Entity page', () => {
|
it('should load if you click on "Statistics" from an Item/Entity page', () => {
|
||||||
cy.visit('/entities/publication/' + TEST_ENTITY_PUBLICATION);
|
cy.visit('/entities/publication/'.concat(TEST_ENTITY_PUBLICATION));
|
||||||
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
|
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
|
||||||
cy.location('pathname').should('eq', ITEMSTATISTICSPAGE);
|
cy.location('pathname').should('eq', ITEMSTATISTICSPAGE);
|
||||||
});
|
});
|
||||||
@@ -18,12 +18,13 @@ describe('Item Statistics Page', () => {
|
|||||||
|
|
||||||
it('should contain a "Total visits" section', () => {
|
it('should contain a "Total visits" section', () => {
|
||||||
cy.visit(ITEMSTATISTICSPAGE);
|
cy.visit(ITEMSTATISTICSPAGE);
|
||||||
cy.get('.' + TEST_ENTITY_PUBLICATION + '_TotalVisits').should('be.visible');
|
cy.get('table[data-test="TotalVisits"]').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain a "Total visits per month" section', () => {
|
it('should contain a "Total visits per month" section', () => {
|
||||||
cy.visit(ITEMSTATISTICSPAGE);
|
cy.visit(ITEMSTATISTICSPAGE);
|
||||||
cy.get('.' + TEST_ENTITY_PUBLICATION + '_TotalVisitsPerMonth').should('exist');
|
// Check just for existence because this table is empty in CI environment as it's historical data
|
||||||
|
cy.get('.'.concat(TEST_ENTITY_PUBLICATION).concat('_TotalVisitsPerMonth')).should('exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
@@ -32,6 +33,10 @@ describe('Item Statistics Page', () => {
|
|||||||
// <ds-item-statistics-page> tag must be loaded
|
// <ds-item-statistics-page> tag must be loaded
|
||||||
cy.get('ds-item-statistics-page').should('be.visible');
|
cy.get('ds-item-statistics-page').should('be.visible');
|
||||||
|
|
||||||
|
// Verify / wait until "Total Visits" table's label is non-empty
|
||||||
|
// (This table loads these labels asynchronously, so we want to wait for them before analyzing page)
|
||||||
|
cy.get('table[data-test="TotalVisits"] th[data-test="statistics-label"]').contains(REGEX_MATCH_NON_EMPTY_TEXT);
|
||||||
|
|
||||||
// Analyze <ds-item-statistics-page> for accessibility issues
|
// Analyze <ds-item-statistics-page> for accessibility issues
|
||||||
testA11y('ds-item-statistics-page');
|
testA11y('ds-item-statistics-page');
|
||||||
});
|
});
|
||||||
|
@@ -57,3 +57,10 @@ export const TEST_SUBMIT_COLLECTION_NAME = Cypress.env('DSPACE_TEST_SUBMIT_COLLE
|
|||||||
export const TEST_SUBMIT_COLLECTION_UUID = Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_UUID') || '9d8334e9-25d3-4a67-9cea-3dffdef80144';
|
export const TEST_SUBMIT_COLLECTION_UUID = Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_UUID') || '9d8334e9-25d3-4a67-9cea-3dffdef80144';
|
||||||
export const TEST_SUBMIT_USER = Cypress.env('DSPACE_TEST_SUBMIT_USER') || 'dspacedemo+submit@gmail.com';
|
export const TEST_SUBMIT_USER = Cypress.env('DSPACE_TEST_SUBMIT_USER') || 'dspacedemo+submit@gmail.com';
|
||||||
export const TEST_SUBMIT_USER_PASSWORD = Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD') || 'dspace';
|
export const TEST_SUBMIT_USER_PASSWORD = Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD') || 'dspace';
|
||||||
|
|
||||||
|
|
||||||
|
// USEFUL REGEX for testing
|
||||||
|
|
||||||
|
// Match any string that contains at least one non-space character
|
||||||
|
// Can be used with "contains()" to determine if an element has a non-empty text value
|
||||||
|
export const REGEX_MATCH_NON_EMPTY_TEXT = /^(?!\s*$).+/;
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
{{ 'statistics.table.title.' + report.reportType | translate }}
|
{{ 'statistics.table.title.' + report.reportType | translate }}
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped" [attr.data-test]="report.reportType">
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<tr *ngFor="let point of report.points"
|
<tr *ngFor="let point of report.points"
|
||||||
class="{{point.id}}-data">
|
class="{{point.id}}-data">
|
||||||
<th scope="row">
|
<th scope="row" data-test="statistics-label">
|
||||||
{{ getLabel(point) | async }}
|
{{ getLabel(point) | async }}
|
||||||
</th>
|
</th>
|
||||||
<td *ngFor="let header of headers"
|
<td *ngFor="let header of headers"
|
||||||
|
Reference in New Issue
Block a user