Skip to content

Commit

Permalink
Merge branch 'main' into DURACOM-195
Browse files Browse the repository at this point in the history
# Conflicts:
#	cypress/e2e/collection-statistics.cy.ts
#	cypress/e2e/community-statistics.cy.ts
#	cypress/e2e/item-statistics.cy.ts
  • Loading branch information
davide-negretti committed Jan 17, 2024
2 parents 6dee989 + 1c782b2 commit 6dec34c
Show file tree
Hide file tree
Showing 36 changed files with 728 additions and 236 deletions.
11 changes: 7 additions & 4 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export default defineConfig({
openMode: 0,
},
env: {
// Global constants used in DSpace e2e tests (see also ./cypress/support/e2e.ts)
// May be overridden in our cypress.json config file using specified environment variables.
// Global DSpace environment variables used in all our Cypress e2e tests
// May be modified in this config, or overridden in a variety of ways.
// See Cypress environment variable docs: https://docs.cypress.io/guides/guides/environment-variables
// Default values listed here are all valid for the Demo Entities Data set available at
// https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
// (This is the data set used in our CI environment)
Expand All @@ -21,12 +22,14 @@ export default defineConfig({
// Community/collection/publication used for view/edit tests
DSPACE_TEST_COMMUNITY: '0958c910-2037-42a9-81c7-dca80e3892b4',
DSPACE_TEST_COLLECTION: '282164f5-d325-4740-8dd1-fa4d6d3e7200',
DSPACE_TEST_ENTITY_PUBLICATION: 'e98b0f27-5c19-49a0-960d-eb6ad5287067',
DSPACE_TEST_ENTITY_PUBLICATION: '6160810f-1e53-40db-81ef-f6621a727398',
// Search term (should return results) used in search tests
DSPACE_TEST_SEARCH_TERM: 'test',
// Collection used for submission tests
// Main Collection used for submission tests. Should be able to accept normal Item objects
DSPACE_TEST_SUBMIT_COLLECTION_NAME: 'Sample Collection',
DSPACE_TEST_SUBMIT_COLLECTION_UUID: '9d8334e9-25d3-4a67-9cea-3dffdef80144',
// Collection used for Person entity submission tests. MUST be configured with EntityType=Person.
DSPACE_TEST_SUBMIT_PERSON_COLLECTION_NAME: 'People',
// Account used to test basic submission process
DSPACE_TEST_SUBMIT_USER: '[email protected]',
DSPACE_TEST_SUBMIT_USER_PASSWORD: 'dspace',
Expand Down
28 changes: 28 additions & 0 deletions cypress/e2e/admin-sidebar.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Options } from 'cypress-axe';
import { testA11y } from 'cypress/support/utils';

describe('Admin Sidebar', () => {
beforeEach(() => {
// Must login as an Admin for sidebar to appear
cy.visit('/login');
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
});

it('should be pinnable and pass accessibility tests', () => {
// Pin the sidebar open
cy.get('#sidebar-collapse-toggle').click();

// Click on every expandable section to open all menus
cy.get('ds-expandable-admin-sidebar-section').click({multiple: true});

// Analyze <ds-admin-sidebar> for accessibility
testA11y('ds-admin-sidebar',
{
rules: {
// Currently all expandable sections have nested interactive elements
// See https://github.com/DSpace/dspace-angular/issues/2178
'nested-interactive': { enabled: false },
}
} as Options);
});
});
3 changes: 1 addition & 2 deletions cypress/e2e/breadcrumbs.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
import { testA11y } from 'cypress/support/utils';

describe('Breadcrumbs', () => {
it('should pass accessibility tests', () => {
// Visit an Item, as those have more breadcrumbs
cy.visit('/entities/publication/'.concat(TEST_ENTITY_PUBLICATION));
cy.visit('/entities/publication/'.concat(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION')));

// Wait for breadcrumbs to be visible
cy.get('ds-breadcrumbs').should('be.visible');
Expand Down
128 changes: 128 additions & 0 deletions cypress/e2e/collection-edit.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { testA11y } from 'cypress/support/utils';

const COLLECTION_EDIT_PAGE = '/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')).concat('/edit');

beforeEach(() => {
// All tests start with visiting the Edit Collection Page
cy.visit(COLLECTION_EDIT_PAGE);

// This page is restricted, so we will be shown the login form. Fill it out & submit.
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
});

describe('Edit Collection > Edit Metadata tab', () => {
it('should pass accessibility tests', () => {
// <ds-edit-collection> tag must be loaded
cy.get('ds-edit-collection').should('be.visible');

// Analyze <ds-edit-collection> for accessibility issues
testA11y('ds-edit-collection');
});
});

describe('Edit Collection > Assign Roles tab', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="roles"]').click();

// <ds-collection-roles> tag must be loaded
cy.get('ds-collection-roles').should('be.visible');

// Analyze for accessibility issues
testA11y('ds-collection-roles');
});
});

describe('Edit Collection > Content Source tab', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="source"]').click();

// <ds-collection-source> tag must be loaded
cy.get('ds-collection-source').should('be.visible');

// Check the external source checkbox (to display all fields on the page)
cy.get('#externalSourceCheck').check();

// Wait for the source controls to appear
cy.get('ds-collection-source-controls').should('be.visible');

// Analyze entire page for accessibility issues
testA11y('ds-collection-source');
});
});

describe('Edit Collection > Curate tab', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="curate"]').click();

// <ds-collection-curate> tag must be loaded
cy.get('ds-collection-curate').should('be.visible');

// Analyze for accessibility issues
testA11y('ds-collection-curate');
});
});

describe('Edit Collection > Access Control tab', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="access-control"]').click();

// <ds-collection-access-control> tag must be loaded
cy.get('ds-collection-access-control').should('be.visible');

// Analyze for accessibility issues
testA11y('ds-collection-access-control');
});
});

describe('Edit Collection > Authorizations tab', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="authorizations"]').click();

// <ds-collection-authorizations> tag must be loaded
cy.get('ds-collection-authorizations').should('be.visible');

// Analyze for accessibility issues
testA11y('ds-collection-authorizations');
});
});

describe('Edit Collection > Item Mapper tab', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="mapper"]').click();

// <ds-collection-item-mapper> tag must be loaded
cy.get('ds-collection-item-mapper').should('be.visible');

// Analyze entire page for accessibility issues
testA11y('ds-collection-item-mapper');

// Click on the "Map new Items" tab
cy.get('li[data-test="mapTab"] a').click();

// Make sure search form is now visible
cy.get('ds-search-form').should('be.visible');

// Analyze entire page (again) for accessibility issues
testA11y('ds-collection-item-mapper');
});
});


describe('Edit Collection > Delete page', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="delete-button"]').click();

// <ds-delete-collection> tag must be loaded
cy.get('ds-delete-collection').should('be.visible');

// Analyze for accessibility issues
testA11y('ds-delete-collection');
});
});
3 changes: 1 addition & 2 deletions cypress/e2e/collection-page.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { TEST_COLLECTION } from 'cypress/support/e2e';
import { testA11y } from 'cypress/support/utils';

describe('Collection Page', () => {

it('should pass accessibility tests', () => {
cy.visit('/collections/'.concat(TEST_COLLECTION));
cy.visit('/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')));

// <ds-collection-page> tag must be loaded
cy.get('ds-collection-page').should('be.visible');
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/collection-statistics.cy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_COLLECTION } from 'cypress/support/e2e';
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
import { testA11y } from 'cypress/support/utils';

describe('Collection Statistics Page', () => {
const COLLECTIONSTATISTICSPAGE = '/statistics/collections/'.concat(TEST_COLLECTION);
const COLLECTIONSTATISTICSPAGE = '/statistics/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION'));

it('should load if you click on "Statistics" from a Collection page', () => {
cy.visit('/collections/'.concat(TEST_COLLECTION));
cy.visit('/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')));
cy.get('ds-navbar ds-link-menu-item a[data-test="link-menu-item.menu.section.statistics"]').click();
cy.location('pathname').should('eq', COLLECTIONSTATISTICSPAGE);
});
Expand All @@ -18,7 +18,7 @@ describe('Collection Statistics Page', () => {
it('should contain a "Total visits per month" section', () => {
cy.visit(COLLECTIONSTATISTICSPAGE);
// 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');
cy.get('.'.concat(Cypress.env('DSPACE_TEST_COLLECTION')).concat('_TotalVisitsPerMonth')).should('exist');
});

it('should pass accessibility tests', () => {
Expand Down
86 changes: 86 additions & 0 deletions cypress/e2e/community-edit.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { testA11y } from 'cypress/support/utils';

const COMMUNITY_EDIT_PAGE = '/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')).concat('/edit');

beforeEach(() => {
// All tests start with visiting the Edit Community Page
cy.visit(COMMUNITY_EDIT_PAGE);

// This page is restricted, so we will be shown the login form. Fill it out & submit.
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
});

describe('Edit Community > Edit Metadata tab', () => {
it('should pass accessibility tests', () => {
// <ds-edit-community> tag must be loaded
cy.get('ds-edit-community').should('be.visible');

// Analyze <ds-edit-community> for accessibility issues
testA11y('ds-edit-community');
});
});

describe('Edit Community > Assign Roles tab', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="roles"]').click();

// <ds-community-roles> tag must be loaded
cy.get('ds-community-roles').should('be.visible');

// Analyze for accessibility issues
testA11y('ds-community-roles');
});
});

describe('Edit Community > Curate tab', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="curate"]').click();

// <ds-community-curate> tag must be loaded
cy.get('ds-community-curate').should('be.visible');

// Analyze for accessibility issues
testA11y('ds-community-curate');
});
});

describe('Edit Community > Access Control tab', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="access-control"]').click();

// <ds-community-access-control> tag must be loaded
cy.get('ds-community-access-control').should('be.visible');

// Analyze for accessibility issues
testA11y('ds-community-access-control');
});
});

describe('Edit Community > Authorizations tab', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="authorizations"]').click();

// <ds-community-authorizations> tag must be loaded
cy.get('ds-community-authorizations').should('be.visible');

// Analyze for accessibility issues
testA11y('ds-community-authorizations');
});
});

describe('Edit Community > Delete page', () => {

it('should pass accessibility tests', () => {
cy.get('a[data-test="delete-button"]').click();

// <ds-delete-community> tag must be loaded
cy.get('ds-delete-community').should('be.visible');

// Analyze for accessibility issues
testA11y('ds-delete-community');
});
});
5 changes: 2 additions & 3 deletions cypress/e2e/community-page.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { TEST_COMMUNITY } from 'cypress/support/e2e';
import { testA11y } from 'cypress/support/utils';

describe('Community Page', () => {

it('should pass accessibility tests', () => {
cy.visit('/communities/'.concat(TEST_COMMUNITY));
cy.visit('/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')));

// <ds-community-page> tag must be loaded
cy.get('ds-community-page').should('be.visible');

// Analyze <ds-community-page> for accessibility issues
testA11y('ds-community-page',);
testA11y('ds-community-page');
});
});
8 changes: 4 additions & 4 deletions cypress/e2e/community-statistics.cy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_COMMUNITY } from 'cypress/support/e2e';
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
import { testA11y } from 'cypress/support/utils';

describe('Community Statistics Page', () => {
const COMMUNITYSTATISTICSPAGE = '/statistics/communities/'.concat(TEST_COMMUNITY);
const COMMUNITYSTATISTICSPAGE = '/statistics/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY'));

it('should load if you click on "Statistics" from a Community page', () => {
cy.visit('/communities/'.concat(TEST_COMMUNITY));
cy.visit('/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')));
cy.get('ds-navbar ds-link-menu-item a[data-test="link-menu-item.menu.section.statistics"]').click();
cy.location('pathname').should('eq', COMMUNITYSTATISTICSPAGE);
});
Expand All @@ -18,7 +18,7 @@ describe('Community Statistics Page', () => {
it('should contain a "Total visits per month" section', () => {
cy.visit(COMMUNITYSTATISTICSPAGE);
// 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');
cy.get('.'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')).concat('_TotalVisitsPerMonth')).should('exist');
});

it('should pass accessibility tests', () => {
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/homepage-statistics.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
import { testA11y } from 'cypress/support/utils';
import '../support/commands';

Expand All @@ -11,8 +11,8 @@ describe('Site Statistics Page', () => {

it('should pass accessibility tests', () => {
// generate 2 view events on an Item's page
cy.generateViewEvent(TEST_ENTITY_PUBLICATION, 'item');
cy.generateViewEvent(TEST_ENTITY_PUBLICATION, 'item');
cy.generateViewEvent(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION'), 'item');
cy.generateViewEvent(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION'), 'item');

cy.visit('/statistics');

Expand Down
Loading

0 comments on commit 6dec34c

Please sign in to comment.