Skip to content

Commit 840bce4

Browse files
committed
Merged ux-plus-cris-2024_02_x into task/ux-plus-cris-2024_02_x/UXP-295
2 parents d0eeaa0 + e37d567 commit 840bce4

22 files changed

Lines changed: 319 additions & 139 deletions

bitbucket-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ definitions:
164164
- git clone https://x-token-auth:${DSPACE_VALUES_ACCESS_TOKEN}@${DSPACE_VALUES_REPO}
165165
- cd dspace-values
166166
- '[ -f "dev/${BRANCH_FILE}" ] && sed -i "/^angular:/,/^[^ ]/s/\(tag: \).*/\1${BRANCH_NAME}-${HASH_COMMIT}/" "dev/${BRANCH_FILE}"'
167-
- git config --global user.email "ci@4science.com"
168-
- git config --global user.name "CI Bot"
167+
- git config --global user.email "${BB_EMAIL}"
168+
- git config --global user.name "${BB_USER}"
169169
- git commit -am "Update TAG with ${BRANCH_NAME}-${HASH_COMMIT}"
170170
- git push
171171

cypress/e2e/admin-search-page.cy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ describe('Admin Search Page', () => {
1616
// (As we want to scan filter section for accessibility issues as well)
1717
cy.get('[data-test="filter-toggle"]').click({ multiple: true });
1818
// Analyze <ds-admin-search-page> for accessibility issues
19-
testA11y('ds-admin-search-page');
19+
testA11y({
20+
include: ['ds-admin-search-page'],
21+
exclude: ['.noUi-handle'],
22+
});
2023
});
2124
});

cypress/e2e/admin-workflow-page.cy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ describe('Admin Workflow Page', () => {
1616
// (As we want to scan filter section for accessibility issues as well)
1717
cy.get('[data-test="filter-toggle"]').click({ multiple: true });
1818
// Analyze <ds-admin-workflow-page> for accessibility issues
19-
testA11y('ds-admin-workflow-page');
19+
testA11y({
20+
include: ['ds-admin-workflow-page'],
21+
exclude: ['.noUi-handle'],
22+
});
2023
});
2124
});

cypress/e2e/bulk-access.cy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ describe('Bulk Access', () => {
1717
// (As we want to scan filter section for accessibility issues as well)
1818
cy.get('[data-test="filter-toggle"]').click({ multiple: true });
1919
// Analyze <ds-bulk-access> for accessibility issues
20-
testA11y('ds-bulk-access', {
20+
testA11y({
21+
include: ['ds-bulk-access'],
22+
exclude: ['.noUi-handle'],
23+
}, {
2124
rules: {
2225
// All panels are accordians & fail "aria-required-children" and "nested-interactive".
2326
// Seem to require updating ng-bootstrap and https://github.com/DSpace/dspace-angular/issues/2216

cypress/e2e/end-user-agreement.cy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ describe('End User Agreement', () => {
88
cy.get('ds-end-user-agreement').should('be.visible');
99

1010
// Analyze <ds-end-user-agreement> for accessibility
11-
testA11y('ds-end-user-agreement');
11+
testA11y({
12+
include: ['ds-end-user-agreement'],
13+
exclude: ['ds-markdown-viewer'],
14+
});
1215
});
1316
});

cypress/e2e/my-dspace.cy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ describe('My DSpace page', () => {
1717
cy.get('.filter-toggle').click({ multiple: true });
1818

1919
// Analyze <ds-my-dspace-page> for accessibility issues
20-
testA11y('ds-my-dspace-page');
20+
testA11y({
21+
include: ['ds-my-dspace-page'],
22+
exclude: ['.noUi-handle'],
23+
});
2124
});
2225

2326
it('should have a working detailed view that passes accessibility tests', () => {

cypress/e2e/submission.cy.ts

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ describe('New Submission page', () => {
2828

2929
// Test entire page for accessibility
3030
testA11y('ds-submission-edit',
31-
{
32-
rules: {
33-
// Author & Subject fields have invalid "aria-multiline" attrs.
34-
// See https://github.com/DSpace/dspace-angular/issues/1272
35-
'aria-allowed-attr': { enabled: false },
36-
// All panels are accordians & fail "aria-required-children" and "nested-interactive".
37-
// Seem to require updating ng-bootstrap and https://github.com/DSpace/dspace-angular/issues/2216
38-
'aria-required-children': { enabled: false },
39-
'nested-interactive': { enabled: false },
40-
// All select boxes fail to have a name / aria-label.
41-
// This is a bug in ng-dynamic-forms and may require https://github.com/DSpace/dspace-angular/issues/2216
42-
'select-name': { enabled: false },
43-
},
44-
45-
} as Options,
31+
{
32+
rules: {
33+
// Author & Subject fields have invalid "aria-multiline" attrs.
34+
// See https://github.com/DSpace/dspace-angular/issues/1272
35+
'aria-allowed-attr': { enabled: false },
36+
// All panels are accordians & fail "aria-required-children" and "nested-interactive".
37+
// Seem to require updating ng-bootstrap and https://github.com/DSpace/dspace-angular/issues/2216
38+
'aria-required-children': { enabled: false },
39+
'nested-interactive': { enabled: false },
40+
// All select boxes fail to have a name / aria-label.
41+
// This is a bug in ng-dynamic-forms and may require https://github.com/DSpace/dspace-angular/issues/2216
42+
'select-name': { enabled: false },
43+
},
44+
45+
} as Options,
4646
);
4747

4848
// Discard button should work
@@ -123,7 +123,7 @@ describe('New Submission page', () => {
123123

124124
// Confirm the required license by checking checkbox
125125
// (NOTE: requires "force:true" cause Cypress claims this checkbox is covered by its own <span>)
126-
cy.get('input#granted').check( { force: true } );
126+
cy.get('input#granted').check({ force: true });
127127

128128
// Before using Cypress drag & drop, we have to manually trigger the "dragover" event.
129129
// This ensures our UI displays the dropzone that covers the entire submission page.
@@ -187,20 +187,23 @@ describe('New Submission page', () => {
187187
cy.get('div#section_license').should('be.visible');
188188

189189
// Test entire page for accessibility
190-
testA11y('ds-submission-edit',
191-
{
192-
rules: {
193-
// Author & Subject fields have invalid "aria-multiline" attrs.
194-
// See https://github.com/DSpace/dspace-angular/issues/1272
195-
'aria-allowed-attr': { enabled: false },
196-
197-
// All panels are accordians & fail "aria-required-children" and "nested-interactive".
198-
// Seem to require updating ng-bootstrap and https://github.com/DSpace/dspace-angular/issues/2216
199-
'aria-required-children': { enabled: false },
200-
'nested-interactive': { enabled: false },
201-
},
202-
203-
} as Options,
190+
testA11y({
191+
include: ['ds-submission-edit'],
192+
exclude: ['.noUi-handle'],
193+
},
194+
{
195+
rules: {
196+
// Author & Subject fields have invalid "aria-multiline" attrs.
197+
// See https://github.com/DSpace/dspace-angular/issues/1272
198+
'aria-allowed-attr': { enabled: false },
199+
200+
// All panels are accordians & fail "aria-required-children" and "nested-interactive".
201+
// Seem to require updating ng-bootstrap and https://github.com/DSpace/dspace-angular/issues/2216
202+
'aria-required-children': { enabled: false },
203+
'nested-interactive': { enabled: false },
204+
},
205+
206+
} as Options,
204207
);
205208

206209
// Back on the form, click the discard button to remove new submission

src/app/app-routes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { COMMUNITY_MODULE_PATH } from './community-page/community-page-routing-p
3131
import { authBlockingGuard } from './core/auth/auth-blocking.guard';
3232
import { authenticatedGuard } from './core/auth/authenticated.guard';
3333
import { groupAdministratorGuard } from './core/data/feature-authorization/feature-authorization-guard/group-administrator.guard';
34-
import { siteAdministratorGuard } from './core/data/feature-authorization/feature-authorization-guard/site-administrator.guard';
3534
import { siteRegisterGuard } from './core/data/feature-authorization/feature-authorization-guard/site-register.guard';
3635
import { endUserAgreementCurrentUserGuard } from './core/end-user-agreement/end-user-agreement-current-user.guard';
3736
import { reloadGuard } from './core/reload/reload.guard';
@@ -173,7 +172,7 @@ export const APP_ROUTES: Route[] = [
173172
path: ADMIN_MODULE_PATH,
174173
loadChildren: () => import('./admin/admin-routes')
175174
.then((m) => m.ROUTES),
176-
canActivate: [siteAdministratorGuard, endUserAgreementCurrentUserGuard],
175+
canActivate: [authenticatedGuard, endUserAgreementCurrentUserGuard],
177176
},
178177
{
179178
path: NOTIFICATIONS_MODULE_PATH,

src/app/collection-page/delete-collection-page/delete-collection-page.component.spec.ts

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,49 @@ import { of as observableOf } from 'rxjs';
1212

1313
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
1414
import { CollectionDataService } from '../../core/data/collection-data.service';
15-
import { RequestService } from '../../core/data/request.service';
15+
import {
16+
DSPACE_OBJECT_DELETION_SCRIPT_NAME,
17+
ScriptDataService,
18+
} from '../../core/data/processes/script-data.service';
19+
import { Collection } from '../../core/shared/collection.model';
20+
import { ProcessParameter } from '../../process-page/processes/process-parameter.model';
1621
import { DSONameServiceMock } from '../../shared/mocks/dso-name.service.mock';
1722
import { NotificationsService } from '../../shared/notifications/notifications.service';
23+
import {
24+
createFailedRemoteDataObject$,
25+
createSuccessfulRemoteDataObject$,
26+
} from '../../shared/remote-data.utils';
27+
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
1828
import { DeleteCollectionPageComponent } from './delete-collection-page.component';
1929

2030
describe('DeleteCollectionPageComponent', () => {
31+
32+
let scriptService;
2133
let comp: DeleteCollectionPageComponent;
34+
let notificationService: NotificationsServiceStub;
2235
let fixture: ComponentFixture<DeleteCollectionPageComponent>;
2336

37+
const mockCollection: Collection = Object.assign(new Collection(), {
38+
uuid: 'test-uuid',
39+
id: 'test-uuid',
40+
name: 'Test Collection',
41+
type: 'collection',
42+
});
43+
2444
beforeEach(waitForAsync(() => {
45+
notificationService = new NotificationsServiceStub();
46+
scriptService = jasmine.createSpyObj('scriptService', {
47+
invoke: createSuccessfulRemoteDataObject$({ processId: '123' }),
48+
});
49+
2550
TestBed.configureTestingModule({
2651
imports: [TranslateModule.forRoot(), CommonModule, RouterTestingModule, DeleteCollectionPageComponent],
2752
providers: [
2853
{ provide: DSONameService, useValue: new DSONameServiceMock() },
2954
{ provide: CollectionDataService, useValue: {} },
3055
{ provide: ActivatedRoute, useValue: { data: observableOf({ dso: { payload: {} } }) } },
31-
{ provide: NotificationsService, useValue: {} },
32-
{ provide: RequestService, useValue: {} },
56+
{ provide: NotificationsService, useValue: notificationService },
57+
{ provide: ScriptDataService, useValue: scriptService },
3358
],
3459
schemas: [NO_ERRORS_SCHEMA],
3560
}).compileComponents();
@@ -41,9 +66,37 @@ describe('DeleteCollectionPageComponent', () => {
4166
fixture.detectChanges();
4267
});
4368

44-
describe('frontendURL', () => {
45-
it('should have the right frontendURL set', () => {
46-
expect((comp as any).frontendURL).toEqual('/collections/');
69+
it('should create', () => {
70+
expect(comp).toBeTruthy();
71+
});
72+
73+
it('should have the right frontendURL set', () => {
74+
expect((comp as any).frontendURL).toEqual('/collections/');
75+
});
76+
77+
describe('onConfirm', () => {
78+
it('should invoke the deletion script with correct params, show success notification and redirect on success', (done) => {
79+
const parameterValues: ProcessParameter[] = [
80+
Object.assign(new ProcessParameter(), { name: '-i', value: mockCollection.uuid }),
81+
];
82+
(scriptService.invoke as jasmine.Spy).and.returnValue(createSuccessfulRemoteDataObject$({ processId: '123' }));
83+
comp.onConfirm(mockCollection);
84+
setTimeout(() => {
85+
expect(scriptService.invoke).toHaveBeenCalledWith(DSPACE_OBJECT_DELETION_SCRIPT_NAME, parameterValues, []);
86+
expect(notificationService.success).toHaveBeenCalledWith('collection.delete.notification.success');
87+
expect(notificationService.process).toHaveBeenCalledWith('123', 5000, jasmine.any(Object));
88+
done();
89+
}, 0);
90+
});
91+
92+
it('error notification is shown', (done) => {
93+
(scriptService.invoke as jasmine.Spy).and.returnValue(createFailedRemoteDataObject$('Error', 500));
94+
comp.onConfirm(mockCollection);
95+
setTimeout(() => {
96+
expect(notificationService.error).toHaveBeenCalledWith('collection.delete.notification.fail');
97+
done();
98+
}, 0);
4799
});
48100
});
101+
49102
});

src/app/collection-page/delete-collection-page/delete-collection-page.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414

1515
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
1616
import { CollectionDataService } from '../../core/data/collection-data.service';
17+
import { ScriptDataService } from '../../core/data/processes/script-data.service';
1718
import { Collection } from '../../core/shared/collection.model';
1819
import { BtnDisabledDirective } from '../../shared/btn-disabled.directive';
1920
import { DeleteComColPageComponent } from '../../shared/comcol/comcol-forms/delete-comcol-page/delete-comcol-page.component';
@@ -46,7 +47,8 @@ export class DeleteCollectionPageComponent extends DeleteComColPageComponent<Col
4647
protected route: ActivatedRoute,
4748
protected notifications: NotificationsService,
4849
protected translate: TranslateService,
50+
protected scriptDataService: ScriptDataService,
4951
) {
50-
super(dsoDataService, dsoNameService, router, route, notifications, translate);
52+
super(dsoDataService, dsoNameService, router, route, notifications, translate, scriptDataService);
5153
}
5254
}

0 commit comments

Comments
 (0)