Skip to content

Commit dff01bc

Browse files
Merge branch 'main' into DS-1774
2 parents f7e78dc + 89447a6 commit dff01bc

47 files changed

Lines changed: 80 additions & 104 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"eslint-plugin-import",
77
"eslint-plugin-jsdoc",
88
"eslint-plugin-deprecation",
9-
"eslint-plugin-unused-imports",
9+
"unused-imports",
1010
"eslint-plugin-lodash"
1111
],
1212
"overrides": [
@@ -205,7 +205,7 @@
205205
"import/order": "off",
206206
"import/no-deprecated": "warn",
207207
"import/no-namespace": "error",
208-
208+
"unused-imports/no-unused-imports": "error",
209209
"lodash/import-scope": [
210210
"error",
211211
"method"

cypress/integration/my-dspace.spec.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { testA11y } from 'cypress/support/utils';
44

55
describe('My DSpace page', () => {
66
it('should display recent submissions and pass accessibility tests', () => {
7-
cy.login(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
8-
97
cy.visit('/mydspace');
108

9+
// This page is restricted, so we will be shown the login form. Fill it out & submit.
10+
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
11+
1112
cy.get('ds-my-dspace-page').should('exist');
1213

1314
// At least one recent submission should be displayed
@@ -36,10 +37,11 @@ describe('My DSpace page', () => {
3637
});
3738

3839
it('should have a working detailed view that passes accessibility tests', () => {
39-
cy.login(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
40-
4140
cy.visit('/mydspace');
4241

42+
// This page is restricted, so we will be shown the login form. Fill it out & submit.
43+
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
44+
4345
cy.get('ds-my-dspace-page').should('exist');
4446

4547
// Click button in sidebar to display detailed view
@@ -61,9 +63,11 @@ describe('My DSpace page', () => {
6163

6264
// NOTE: Deleting existing submissions is exercised by submission.spec.ts
6365
it('should let you start a new submission & edit in-progress submissions', () => {
64-
cy.login(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
6566
cy.visit('/mydspace');
6667

68+
// This page is restricted, so we will be shown the login form. Fill it out & submit.
69+
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
70+
6771
// Open the New Submission dropdown
6872
cy.get('button[data-test="submission-dropdown"]').click();
6973
// Click on the "Item" type in that dropdown
@@ -131,9 +135,11 @@ describe('My DSpace page', () => {
131135
});
132136

133137
it('should let you import from external sources', () => {
134-
cy.login(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
135138
cy.visit('/mydspace');
136139

140+
// This page is restricted, so we will be shown the login form. Fill it out & submit.
141+
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
142+
137143
// Open the New Import dropdown
138144
cy.get('button[data-test="import-dropdown"]').click();
139145
// Click on the "Item" type in that dropdown

cypress/integration/submission.spec.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ describe('New Submission page', () => {
66
// NOTE: We already test that new submissions can be started from MyDSpace in my-dspace.spec.ts
77

88
it('should create a new submission when using /submit path & pass accessibility', () => {
9-
cy.login(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
10-
119
// Test that calling /submit with collection & entityType will create a new submission
1210
cy.visit('/submit?collection=' + TEST_SUBMIT_COLLECTION_UUID + '&entityType=none');
1311

12+
// This page is restricted, so we will be shown the login form. Fill it out & submit.
13+
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
14+
1415
// Should redirect to /workspaceitems, as we've started a new submission
1516
cy.url().should('include', '/workspaceitems');
1617

@@ -33,11 +34,12 @@ describe('New Submission page', () => {
3334
});
3435

3536
it('should block submission & show errors if required fields are missing', () => {
36-
cy.login(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
37-
3837
// Create a new submission
3938
cy.visit('/submit?collection=' + TEST_SUBMIT_COLLECTION_UUID + '&entityType=none');
4039

40+
// This page is restricted, so we will be shown the login form. Fill it out & submit.
41+
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
42+
4143
// Attempt an immediate deposit without filling out any fields
4244
cy.get('button#deposit').click();
4345

@@ -92,11 +94,12 @@ describe('New Submission page', () => {
9294
});
9395

9496
it('should allow for deposit if all required fields completed & file uploaded', () => {
95-
cy.login(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
96-
9797
// Create a new submission
9898
cy.visit('/submit?collection=' + TEST_SUBMIT_COLLECTION_UUID + '&entityType=none');
9999

100+
// This page is restricted, so we will be shown the login form. Fill it out & submit.
101+
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
102+
100103
// Fill out all required fields (Title, Date)
101104
cy.get('input#dc_title').type('DSpace logo uploaded via e2e tests');
102105
cy.get('input#dc_date_issued_year').type('2022');

cypress/support/commands.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,23 @@ declare global {
1919
* @param password password to login as
2020
*/
2121
login(email: string, password: string): typeof login;
22+
23+
/**
24+
* Login via form before accessing the next page. Useful to fill out login
25+
* form when a cy.visit() call is to an a page which requires authentication.
26+
* @param email email to login as
27+
* @param password password to login as
28+
*/
29+
loginViaForm(email: string, password: string): typeof loginViaForm;
2230
}
2331
}
2432
}
2533

2634
/**
2735
* Login user via REST API directly, and pass authentication token to UI via
2836
* the UI's dsAuthInfo cookie.
37+
* WARNING: WHILE THIS METHOD WORKS, OCCASIONALLY RANDOM AUTHENTICATION ERRORS OCCUR.
38+
* At this time "loginViaForm()" seems more consistent/stable.
2939
* @param email email to login as
3040
* @param password password to login as
3141
*/
@@ -81,3 +91,20 @@ function login(email: string, password: string): void {
8191
}
8292
// Add as a Cypress command (i.e. assign to 'cy.login')
8393
Cypress.Commands.add('login', login);
94+
95+
96+
/**
97+
* Login user via displayed login form
98+
* @param email email to login as
99+
* @param password password to login as
100+
*/
101+
function loginViaForm(email: string, password: string): void {
102+
// Enter email
103+
cy.get('ds-log-in [data-test="email"]').type(email);
104+
// Enter password
105+
cy.get('ds-log-in [data-test="password"]').type(password);
106+
// Click login button
107+
cy.get('ds-log-in [data-test="login-button"]').click();
108+
}
109+
// Add as a Cypress command (i.e. assign to 'cy.loginViaForm')
110+
Cypress.Commands.add('loginViaForm', loginViaForm);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@
162162
"@types/sanitize-html": "^2.6.2",
163163
"@typescript-eslint/eslint-plugin": "5.11.0",
164164
"@typescript-eslint/parser": "5.11.0",
165-
"axe-core": "^4.3.3",
165+
"axe-core": "^4.4.3",
166166
"compression-webpack-plugin": "^9.2.0",
167167
"copy-webpack-plugin": "^6.4.1",
168168
"cross-env": "^7.0.3",
169169
"css-loader": "^6.2.0",
170170
"css-minimizer-webpack-plugin": "^3.4.1",
171171
"cssnano": "^5.0.6",
172-
"cypress": "9.5.1",
172+
"cypress": "9.7.0",
173173
"cypress-axe": "^0.14.0",
174174
"debug-loader": "^0.0.1",
175175
"deep-freeze": "0.0.1",

src/app/admin/admin-import-metadata-page/metadata-import-page.component.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { Location } from '@angular/common';
2-
import { Component, OnInit } from '@angular/core';
2+
import { Component } from '@angular/core';
33
import { Router } from '@angular/router';
44
import { TranslateService } from '@ngx-translate/core';
5-
import { Observable } from 'rxjs';
6-
import { map, switchMap } from 'rxjs/operators';
7-
import { AuthService } from '../../core/auth/auth.service';
85
import { METADATA_IMPORT_SCRIPT_NAME, ScriptDataService } from '../../core/data/processes/script-data.service';
9-
import { EPerson } from '../../core/eperson/models/eperson.model';
106
import { ProcessParameter } from '../../process-page/processes/process-parameter.model';
117
import { isNotEmpty } from '../../shared/empty.util';
128
import { NotificationsService } from '../../shared/notifications/notifications.service';

src/app/admin/admin-registries/bitstream-formats/bitstream-formats.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { Component, OnDestroy, OnInit } from '@angular/core';
2-
import {combineLatest, combineLatest as observableCombineLatest, Observable, of as observableOf, zip} from 'rxjs';
2+
import { combineLatest as observableCombineLatest, Observable} from 'rxjs';
33
import { RemoteData } from '../../../core/data/remote-data';
44
import { PaginatedList } from '../../../core/data/paginated-list.model';
55
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
66
import { BitstreamFormat } from '../../../core/shared/bitstream-format.model';
77
import { BitstreamFormatDataService } from '../../../core/data/bitstream-format-data.service';
88
import { map, mergeMap, switchMap, take, toArray } from 'rxjs/operators';
9-
import { hasValue } from '../../../shared/empty.util';
109
import { NotificationsService } from '../../../shared/notifications/notifications.service';
1110
import { Router } from '@angular/router';
1211
import { TranslateService } from '@ngx-translate/core';

src/app/admin/admin-registries/metadata-registry/metadata-registry.component.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ import { RestResponse } from '../../../core/cache/response.models';
1919
import { MetadataSchema } from '../../../core/metadata/metadata-schema.model';
2020
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
2121
import { PaginationService } from '../../../core/pagination/pagination.service';
22-
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
23-
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
2422
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
25-
import { FindListOptions } from '../../../core/data/find-list-options.model';
2623

2724
describe('MetadataRegistryComponent', () => {
2825
let comp: MetadataRegistryComponent;

src/app/admin/admin-registries/metadata-schema/metadata-schema.component.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ import { MetadataSchema } from '../../../core/metadata/metadata-schema.model';
2323
import { MetadataField } from '../../../core/metadata/metadata-field.model';
2424
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
2525
import { VarDirective } from '../../../shared/utils/var.directive';
26-
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
27-
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
2826
import { PaginationService } from '../../../core/pagination/pagination.service';
2927
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
30-
import { FindListOptions } from '../../../core/data/find-list-options.model';
3128

3229
describe('MetadataSchemaComponent', () => {
3330
let comp: MetadataSchemaComponent;

src/app/admin/admin-sidebar/admin-sidebar.component.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
1616
import { RouterTestingModule } from '@angular/router/testing';
1717
import { ActivatedRoute } from '@angular/router';
1818
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
19-
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
2019
import createSpy = jasmine.createSpy;
2120
import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
2221
import { Item } from '../../core/shared/item.model';

0 commit comments

Comments
 (0)