Skip to content

Commit c151cf3

Browse files
Merge branch 'main' into CST-6171
2 parents f109e97 + 89447a6 commit c151cf3

195 files changed

Lines changed: 1805 additions & 1922 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: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"eslint-plugin-import",
77
"eslint-plugin-jsdoc",
88
"eslint-plugin-deprecation",
9-
"eslint-plugin-unused-imports"
9+
"unused-imports",
10+
"eslint-plugin-lodash"
1011
],
1112
"overrides": [
1213
{
@@ -202,7 +203,13 @@
202203
"deprecation/deprecation": "warn",
203204

204205
"import/order": "off",
205-
"import/no-deprecated": "warn"
206+
"import/no-deprecated": "warn",
207+
"import/no-namespace": "error",
208+
"unused-imports/no-unused-imports": "error",
209+
"lodash/import-scope": [
210+
"error",
211+
"method"
212+
]
206213
}
207214
},
208215
{

.github/workflows/build.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ name: Build
66
# Run this Build for all pushes / PRs to current branch
77
on: [push, pull_request]
88

9+
permissions:
10+
contents: read # to fetch code (actions/checkout)
11+
912
jobs:
1013
tests:
1114
runs-on: ubuntu-latest
@@ -29,11 +32,11 @@ jobs:
2932
steps:
3033
# https://github.com/actions/checkout
3134
- name: Checkout codebase
32-
uses: actions/checkout@v2
35+
uses: actions/checkout@v3
3336

3437
# https://github.com/actions/setup-node
3538
- name: Install Node.js ${{ matrix.node-version }}
36-
uses: actions/setup-node@v2
39+
uses: actions/setup-node@v3
3740
with:
3841
node-version: ${{ matrix.node-version }}
3942

@@ -58,7 +61,7 @@ jobs:
5861
id: yarn-cache-dir-path
5962
run: echo "::set-output name=dir::$(yarn cache dir)"
6063
- name: Cache Yarn dependencies
61-
uses: actions/cache@v2
64+
uses: actions/cache@v3
6265
with:
6366
# Cache entire Yarn cache directory (see previous step)
6467
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -85,7 +88,7 @@ jobs:
8588
# Upload coverage reports to Codecov (for one version of Node only)
8689
# https://github.com/codecov/codecov-action
8790
- name: Upload coverage to Codecov.io
88-
uses: codecov/codecov-action@v2
91+
uses: codecov/codecov-action@v3
8992
if: matrix.node-version == '16.x'
9093

9194
# Using docker-compose start backend using CI configuration
@@ -100,7 +103,7 @@ jobs:
100103
# https://github.com/cypress-io/github-action
101104
# (NOTE: to run these e2e tests locally, just use 'ng e2e')
102105
- name: Run e2e tests (integration tests)
103-
uses: cypress-io/github-action@v2
106+
uses: cypress-io/github-action@v4
104107
with:
105108
# Run tests in Chrome, headless mode
106109
browser: chrome
@@ -116,7 +119,7 @@ jobs:
116119
# Cypress always creates a video of all e2e tests (whether they succeeded or failed)
117120
# Save those in an Artifact
118121
- name: Upload e2e test videos to Artifacts
119-
uses: actions/upload-artifact@v2
122+
uses: actions/upload-artifact@v3
120123
if: always()
121124
with:
122125
name: e2e-test-videos
@@ -125,7 +128,7 @@ jobs:
125128
# If e2e tests fail, Cypress creates a screenshot of what happened
126129
# Save those in an Artifact
127130
- name: Upload e2e test failure screenshots to Artifacts
128-
uses: actions/upload-artifact@v2
131+
uses: actions/upload-artifact@v3
129132
if: failure()
130133
with:
131134
name: e2e-test-screenshots

.github/workflows/docker.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
- 'dspace-**'
1313
pull_request:
1414

15+
permissions:
16+
contents: read # to fetch code (actions/checkout)
17+
1518
jobs:
1619
docker:
1720
# Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
@@ -39,11 +42,11 @@ jobs:
3942
steps:
4043
# https://github.com/actions/checkout
4144
- name: Checkout codebase
42-
uses: actions/checkout@v2
45+
uses: actions/checkout@v3
4346

4447
# https://github.com/docker/setup-buildx-action
4548
- name: Setup Docker Buildx
46-
uses: docker/setup-buildx-action@v1
49+
uses: docker/setup-buildx-action@v2
4750

4851
# https://github.com/docker/setup-qemu-action
4952
- name: Set up QEMU emulation to build for multiple architectures
@@ -53,7 +56,7 @@ jobs:
5356
- name: Login to DockerHub
5457
# Only login if not a PR, as PRs only trigger a Docker build and not a push
5558
if: github.event_name != 'pull_request'
56-
uses: docker/login-action@v1
59+
uses: docker/login-action@v2
5760
with:
5861
username: ${{ secrets.DOCKER_USERNAME }}
5962
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
@@ -65,7 +68,7 @@ jobs:
6568
# Get Metadata for docker_build step below
6669
- name: Sync metadata (tags, labels) from GitHub to Docker for 'dspace-angular' image
6770
id: meta_build
68-
uses: docker/metadata-action@v3
71+
uses: docker/metadata-action@v4
6972
with:
7073
images: dspace/dspace-angular
7174
tags: ${{ env.IMAGE_TAGS }}
@@ -74,7 +77,7 @@ jobs:
7477
# https://github.com/docker/build-push-action
7578
- name: Build and push 'dspace-angular' image
7679
id: docker_build
77-
uses: docker/build-push-action@v2
80+
uses: docker/build-push-action@v3
7881
with:
7982
context: .
8083
file: ./Dockerfile

.github/workflows/issue_opened.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,22 @@ on:
55
issues:
66
types: [opened]
77

8+
permissions: {}
89
jobs:
910
automation:
1011
runs-on: ubuntu-latest
1112
steps:
1213
# Add the new issue to a project board, if it needs triage
13-
# See https://github.com/marketplace/actions/create-project-card-action
14-
- name: Add issue to project board
14+
# See https://github.com/actions/add-to-project
15+
- name: Add issue to triage board
1516
# Only add to project board if issue is flagged as "needs triage" or has no labels
1617
# NOTE: By default we flag new issues as "needs triage" in our issue template
1718
if: (contains(github.event.issue.labels.*.name, 'needs triage') || join(github.event.issue.labels.*.name) == '')
18-
uses: technote-space/create-project-card-action@v1
19+
uses: actions/add-to-project@v0.3.0
1920
# Note, the authentication token below is an ORG level Secret.
20-
# It must be created/recreated manually via a personal access token with "public_repo" and "admin:org" permissions
21+
# It must be created/recreated manually via a personal access token with admin:org, project, public_repo permissions
2122
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token
2223
# This is necessary because the "DSpace Backlog" project is an org level project (i.e. not repo specific)
2324
with:
24-
GITHUB_TOKEN: ${{ secrets.ORG_PROJECT_TOKEN }}
25-
PROJECT: DSpace Backlog
26-
COLUMN: Triage
27-
CHECK_ORG_PROJECT: true
28-
# Ignore errors
29-
continue-on-error: true
25+
github-token: ${{ secrets.TRIAGE_PROJECT_TOKEN }}
26+
project-url: https://github.com/orgs/DSpace/projects/24

.github/workflows/label_merge_conflicts.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,32 @@ name: Check for merge conflicts
55
# NOTE: This means merge conflicts are only checked for when a PR is merged to main.
66
on:
77
push:
8-
branches:
9-
- main
8+
branches: [ main ]
9+
# So that the `conflict_label_name` is removed if conflicts are resolved,
10+
# we allow this to run for `pull_request_target` so that github secrets are available.
11+
pull_request_target:
12+
types: [ synchronize ]
13+
14+
permissions: {}
1015

1116
jobs:
1217
triage:
18+
# Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
19+
if: github.repository == 'dspace/dspace-angular'
1320
runs-on: ubuntu-latest
21+
permissions:
22+
pull-requests: write
1423
steps:
15-
# See: https://github.com/mschilde/auto-label-merge-conflicts/
24+
# See: https://github.com/prince-chrismc/label-merge-conflicts-action
1625
- name: Auto-label PRs with merge conflicts
17-
uses: mschilde/auto-label-merge-conflicts@v2.0
26+
uses: prince-chrismc/label-merge-conflicts-action@v2
1827
# Add "merge conflict" label if a merge conflict is detected. Remove it when resolved.
1928
# Note, the authentication token is created automatically
2029
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
2130
with:
22-
CONFLICT_LABEL_NAME: 'merge conflict'
23-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24-
# Ignore errors
25-
continue-on-error: true
31+
conflict_label_name: 'merge conflict'
32+
github_token: ${{ secrets.GITHUB_TOKEN }}
33+
conflict_comment: |
34+
Hi @${author},
35+
Conflicts have been detected against the base branch.
36+
Please [resolve these conflicts](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/about-merge-conflicts) as soon as you can. Thanks!

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);

0 commit comments

Comments
 (0)