Skip to content

Commit fc19eaf

Browse files
committed
Merged dspace-cris-2023_02_x into DSC-909
2 parents 1b45ef5 + a1edb01 commit fc19eaf

121 files changed

Lines changed: 1718 additions & 8504 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.

nohup.out

Lines changed: 0 additions & 7948 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dspace-angular",
3-
"version": "2023.02.02-snapshot",
3+
"version": "2023.02.03-SNAPSHOT",
44
"scripts": {
55
"ng": "ng",
66
"config:watch": "nodemon",
@@ -17,8 +17,8 @@
1717
"build:stats": "ng build --stats-json",
1818
"build:ci": "ng config cli.cache.environment ci && yarn run build:ssr",
1919
"build:prod": "cross-env NODE_ENV=production yarn run build:ssr",
20-
"build:ssr": "npm run ng-high-memory -- build --configuration production && ng run dspace-angular:server:production",
21-
"ng-high-memory": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng",
20+
"build:ssr": "npm run ng-high-memory -- build --configuration production && npm run ng-high-memory -- run dspace-angular:server:production",
21+
"ng-high-memory": "node --max-old-space-size=8192 node_modules/@angular/cli/bin/ng",
2222
"test": "npm run ng-high-memory -- test --source-map=true --watch=false --configuration test",
2323
"test:watch": "nodemon --exec \"npm run ng-high-memory -- test --source-map=true --watch=true --configuration test\"",
2424
"test:headless": "npm run ng-high-memory -- test --source-map=true --watch=false --configuration test --browsers=ChromeHeadless --code-coverage",
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
import { ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing';
2+
import { CollectionPageComponent } from './collection-page.component';
3+
import { ActivatedRoute, Router } from '@angular/router';
4+
import { of } from 'rxjs';
5+
import { CollectionDataService } from '../core/data/collection-data.service';
6+
import { AuthService } from '../core/auth/auth.service';
7+
import { PaginationService } from '../core/pagination/pagination.service';
8+
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
9+
import { DSONameService } from '../core/breadcrumbs/dso-name.service';
10+
import { APP_CONFIG } from '../../../src/config/app-config.interface';
11+
import { PLATFORM_ID } from '@angular/core';
12+
import { ActivatedRouteStub } from '../shared/testing/active-router.stub';
13+
import { RouterStub } from '../shared/testing/router.stub';
14+
import { environment } from 'src/environments/environment.test';
15+
import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
16+
import { Collection } from '../core/shared/collection.model';
17+
import { SearchService } from '../core/shared/search/search.service';
18+
import { By } from '@angular/platform-browser';
19+
import { FormsModule } from '@angular/forms';
20+
import { RouterTestingModule } from '@angular/router/testing';
21+
import { TranslateModule } from '@ngx-translate/core';
22+
import { VarDirective } from '../shared/utils/var.directive';
23+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
24+
import { Bitstream } from '../core/shared/bitstream.model';
25+
26+
describe('CollectionPageComponent', () => {
27+
let component: CollectionPageComponent;
28+
let compAsAny: any;
29+
let fixture: ComponentFixture<CollectionPageComponent>;
30+
31+
let collectionDataServiceSpy: jasmine.SpyObj<CollectionDataService>;
32+
let authServiceSpy: jasmine.SpyObj<AuthService>;
33+
let paginationServiceSpy: jasmine.SpyObj<PaginationService>;
34+
let authorizationDataServiceSpy: jasmine.SpyObj<AuthorizationDataService>;
35+
let dsoNameServiceSpy: jasmine.SpyObj<DSONameService>;
36+
let searchServiceSpy: jasmine.SpyObj<SearchService>;
37+
let aroute = new ActivatedRouteStub();
38+
let router = new RouterStub();
39+
40+
const collection = Object.assign(new Collection(), {});
41+
42+
beforeEach(async () => {
43+
authServiceSpy = jasmine.createSpyObj('AuthService', ['isAuthenticated']);
44+
paginationServiceSpy = jasmine.createSpyObj('PaginationService', ['getCurrentPagination', 'getCurrentSort', 'clearPagination']);
45+
authorizationDataServiceSpy = jasmine.createSpyObj('AuthorizationDataService', ['isAuthorized']);
46+
collectionDataServiceSpy = jasmine.createSpyObj('CollectionDataService', ['findById', 'getAuthorizedCollection']);
47+
searchServiceSpy = jasmine.createSpyObj('SearchService', ['search']);
48+
dsoNameServiceSpy = jasmine.createSpyObj('DSONameService', ['getName']);
49+
50+
await TestBed.configureTestingModule({
51+
imports: [RouterTestingModule, FormsModule, TranslateModule.forRoot(), BrowserAnimationsModule],
52+
declarations: [CollectionPageComponent, VarDirective],
53+
providers: [
54+
{ provide: ActivatedRoute, useValue: aroute },
55+
{ provide: Router, useValue: router },
56+
{ provide: CollectionDataService, useValue: collectionDataServiceSpy },
57+
{ provide: AuthService, useValue: authServiceSpy },
58+
{ provide: PaginationService, useValue: paginationServiceSpy },
59+
{ provide: AuthorizationDataService, useValue: authorizationDataServiceSpy },
60+
{ provide: DSONameService, useValue: dsoNameServiceSpy },
61+
{ provide: SearchService, useValue: searchServiceSpy },
62+
{ provide: APP_CONFIG, useValue: environment },
63+
{ provide: PLATFORM_ID, useValue: 'browser' },
64+
]
65+
})
66+
.compileComponents();
67+
});
68+
69+
beforeEach(() => {
70+
fixture = TestBed.createComponent(CollectionPageComponent);
71+
component = fixture.componentInstance;
72+
compAsAny = component as any;
73+
component.collectionRD$ = createSuccessfulRemoteDataObject$(Object.assign(new Collection(), {
74+
name: 'Test Collection',
75+
}));
76+
fixture.detectChanges();
77+
});
78+
79+
it('should create', () => {
80+
expect(component).toBeTruthy();
81+
});
82+
83+
it('should initialize the component', () => {
84+
const routeData = {
85+
dso: createSuccessfulRemoteDataObject$(collection),
86+
};
87+
Object.defineProperty(TestBed.inject(ActivatedRoute), 'data', {
88+
get: () => of(routeData),
89+
});
90+
authorizationDataServiceSpy.isAuthorized.and.returnValue(of(true));
91+
component.ngOnInit();
92+
93+
expect(component.collectionRD$).toBeDefined();
94+
expect(component.logoRD$).toBeDefined();
95+
expect(component.isCollectionAdmin$).toBeDefined();
96+
expect(compAsAny.paginationChanges$).toBeDefined();
97+
expect(component.itemRD$).toBeDefined();
98+
expect(component.collectionPageRoute$).toBeDefined();
99+
});
100+
101+
it('should display collection name', fakeAsync(() => {
102+
component.collectionRD$ = createSuccessfulRemoteDataObject$(Object.assign(new Collection(), {
103+
name: 'Test Collection',
104+
}));
105+
fixture.detectChanges();
106+
fixture.whenStable().then(() => {
107+
const collectionNameElement = fixture.debugElement.query(By.css('ds-comcol-page-header')).nativeElement;
108+
expect(collectionNameElement.textContent.trim()).toBe('Test Collection');
109+
});
110+
}));
111+
112+
it('should display collection logo if available', () => {
113+
component.collectionRD$ = createSuccessfulRemoteDataObject$(Object.assign(new Collection(), {
114+
name: 'Test Collection',
115+
}));
116+
component.logoRD$ = createSuccessfulRemoteDataObject$(Object.assign(new Bitstream(), {
117+
name: 'Test Logo',
118+
}));
119+
fixture.detectChanges();
120+
121+
fixture.whenStable().then(() => {
122+
const logoElement = fixture.debugElement.query(By.css('ds-comcol-page-logo')).nativeElement;
123+
expect(logoElement).toBeTruthy();
124+
});
125+
});
126+
127+
it('should not display collection logo if not available', () => {
128+
component.collectionRD$ = createSuccessfulRemoteDataObject$(Object.assign(new Collection(), {
129+
name: 'Test Collection',
130+
}));
131+
component.logoRD$ = of({ hasSucceeded: false, payload: null }) as any;
132+
fixture.detectChanges();
133+
134+
fixture.whenStable().then(() => {
135+
const logoElement = fixture.debugElement.query(By.css('ds-comcol-page-logo'));
136+
expect(logoElement).toBeNull();
137+
});
138+
});
139+
140+
it('should clear pagination on ngOnDestroy', () => {
141+
component.ngOnDestroy();
142+
expect(paginationServiceSpy.clearPagination).toHaveBeenCalledWith(component.paginationConfig.id);
143+
});
144+
});
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { ActivatedRoute, Router } from '@angular/router';
3+
import { CommunityPageComponent } from './community-page.component';
4+
import { AuthService } from '../core/auth/auth.service';
5+
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
6+
import { DSONameService } from '../core/breadcrumbs/dso-name.service';
7+
import { ActivatedRouteStub } from '../shared/testing/active-router.stub';
8+
import { RouterStub } from '../shared/testing/router.stub';
9+
import { RouterTestingModule } from '@angular/router/testing';
10+
import { FormsModule } from '@angular/forms';
11+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
12+
import { TranslateModule } from '@ngx-translate/core';
13+
import { VarDirective } from '../shared/utils/var.directive';
14+
import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
15+
import { Community } from '../core/shared/community.model';
16+
import { of } from 'rxjs';
17+
import { CommunityDataService } from '../core/data/community-data.service';
18+
import { MetadataService } from '../core/metadata/metadata.service';
19+
import { Bitstream } from '../core/shared/bitstream.model';
20+
import { By } from '@angular/platform-browser';
21+
22+
describe('CommunityPageComponent', () => {
23+
let component: CommunityPageComponent;
24+
let fixture: ComponentFixture<CommunityPageComponent>;
25+
26+
let authServiceSpy: jasmine.SpyObj<AuthService>;
27+
let authorizationDataServiceSpy: jasmine.SpyObj<AuthorizationDataService>;
28+
let dsoNameServiceSpy: jasmine.SpyObj<DSONameService>;
29+
let aroute = new ActivatedRouteStub();
30+
let router = new RouterStub();
31+
32+
const community = Object.assign(new Community(), {
33+
id: 'test-community',
34+
uuid: 'test-community',
35+
metadata: [
36+
{
37+
key: 'dc.title',
38+
language: 'en_US',
39+
value: 'test community'
40+
}
41+
],
42+
logo: createSuccessfulRemoteDataObject$(new Bitstream()),
43+
});
44+
45+
beforeEach(async () => {
46+
authServiceSpy = jasmine.createSpyObj('AuthService', ['isAuthenticated']);
47+
authorizationDataServiceSpy = jasmine.createSpyObj('AuthorizationDataService', ['isAuthorized']);
48+
dsoNameServiceSpy = jasmine.createSpyObj('DSONameService', ['getName']);
49+
await TestBed.configureTestingModule({
50+
imports: [RouterTestingModule, FormsModule, TranslateModule.forRoot(), BrowserAnimationsModule],
51+
declarations: [CommunityPageComponent, VarDirective],
52+
providers: [
53+
{ provide: ActivatedRoute, useValue: aroute },
54+
{ provide: Router, useValue: router },
55+
{ provide: AuthService, useValue: authServiceSpy },
56+
{ provide: AuthorizationDataService, useValue: authorizationDataServiceSpy },
57+
{ provide: DSONameService, useValue: dsoNameServiceSpy },
58+
{ provide: CommunityDataService, useValue: {} },
59+
{ provide: MetadataService, useValue: {} }
60+
]
61+
}).compileComponents();
62+
});
63+
64+
beforeEach(() => {
65+
fixture = TestBed.createComponent(CommunityPageComponent);
66+
component = fixture.componentInstance;
67+
fixture.detectChanges();
68+
});
69+
70+
it('should create', () => {
71+
expect(component).toBeTruthy();
72+
});
73+
74+
it('should initialize the component', () => {
75+
const routeData = {
76+
data: of({ dso: createSuccessfulRemoteDataObject$(community) }),
77+
};
78+
authorizationDataServiceSpy.isAuthorized.and.returnValue(of(true));
79+
80+
Object.defineProperty(TestBed.inject(ActivatedRoute), 'data', {
81+
get: () => of(routeData),
82+
});
83+
84+
component.ngOnInit();
85+
expect(component.communityRD$).toBeDefined();
86+
expect(component.logoRD$).toBeDefined();
87+
expect(component.communityPageRoute$).toBeDefined();
88+
expect(component.isCommunityAdmin$).toBeDefined();
89+
});
90+
91+
it('should display community logo if available', () => {
92+
component.communityRD$ = createSuccessfulRemoteDataObject$(community);
93+
fixture.detectChanges();
94+
95+
fixture.whenStable().then(() => {
96+
const logoElement = fixture.debugElement.query(By.css('ds-comcol-page-logo')).nativeElement;
97+
expect(logoElement).toBeTruthy();
98+
});
99+
});
100+
101+
102+
it('should not display community logo if not available', () => {
103+
component.communityRD$ = createSuccessfulRemoteDataObject$(Object.assign(new Community(), {
104+
name: 'Test',
105+
logo: createSuccessfulRemoteDataObject$(null),
106+
}));
107+
fixture.detectChanges();
108+
109+
fixture.whenStable().then(() => {
110+
const logoElement = fixture.debugElement.query(By.css('ds-comcol-page-logo'));
111+
expect(logoElement).toBeNull();
112+
});
113+
});
114+
115+
it('should display collection name', () => {
116+
component.communityRD$ = createSuccessfulRemoteDataObject$(Object.assign(community));
117+
fixture.detectChanges();
118+
fixture.whenStable().then(() => {
119+
const collectionNameElement = fixture.debugElement.query(By.css('ds-comcol-page-header')).nativeElement;
120+
expect(collectionNameElement.textContent.trim()).toBe('Test Collection');
121+
});
122+
});
123+
});

src/app/core/core.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ import {
237237
} from './metadata/schema-json-ld/schema-types/product/product-creative-work-schema-type';
238238
import { ProductDatasetSchemaType } from './metadata/schema-json-ld/schema-types/product/product-dataset-schema-type';
239239
import { PersonSchemaType } from './metadata/schema-json-ld/schema-types/Person/person-schema-type';
240+
import { InternalLinkService } from './services/internal-link.service';
240241

241242
/**
242243
* When not in production, endpoint responses can be mocked for testing purposes
@@ -270,6 +271,7 @@ const PROVIDERS = [
270271
{ provide: DspaceRestService, useFactory: restServiceFactory, deps: [MOCK_RESPONSE_MAP, HttpClient] },
271272
EPersonDataService,
272273
LinkHeadService,
274+
InternalLinkService,
273275
HALEndpointService,
274276
HostWindowService,
275277
ItemDataService,

src/app/core/data/processes/process-data.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ export class ProcessDataService extends IdentifiableDataService<Process> impleme
6868
/**
6969
* Get a process' output files
7070
* @param processId The ID of the process
71+
* @param useCacheVersionIfAvailable If value needs to be red from cache or not
7172
*/
72-
getFiles(processId: string): Observable<RemoteData<PaginatedList<Bitstream>>> {
73+
getFiles(processId: string, useCacheVersionIfAvailable = true): Observable<RemoteData<PaginatedList<Bitstream>>> {
7374
const href$ = this.getFilesEndpoint(processId);
74-
return this.bitstreamDataService.findListByHref(href$);
75+
return this.bitstreamDataService.findListByHref(href$, {}, useCacheVersionIfAvailable);
7576
}
7677

7778
/**

src/app/core/eperson/group-data.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { Operation } from 'fast-json-patch';
4141
import { RestRequestMethod } from '../data/rest-request-method';
4242
import { dataService } from '../data/base/data-service.decorator';
4343
import { getGroupEditRoute } from '../../access-control/access-control-routing-paths';
44+
import { isNotEmpty } from '../../shared/empty.util';
4445

4546
const groupRegistryStateSelector = (state: AppState) => state.groupRegistry;
4647
const editGroupSelector = createSelector(groupRegistryStateSelector, (groupRegistryState: GroupRegistryState) => groupRegistryState.editGroup);
@@ -56,7 +57,7 @@ export class GroupDataService extends IdentifiableDataService<Group> implements
5657
public subgroupsEndpoint = 'subgroups';
5758

5859
private createData: CreateData<Group>;
59-
private searchData: SearchData<Group>;
60+
private searchData: SearchDataImpl<Group>;
6061
private patchData: PatchData<Group>;
6162
private deleteData: DeleteData<Group>;
6263

@@ -91,9 +92,9 @@ export class GroupDataService extends IdentifiableDataService<Group> implements
9192
const options = new FindListOptions();
9293
options.searchParams = [new RequestParam('groupName', groupName)];
9394

94-
return this.searchBy(searchHref, options).pipe(
95+
return this.findByHref(this.searchData.getSearchByHref(searchHref, options)).pipe(
9596
getRemoteDataPayload(),
96-
map((groups: PaginatedList<Group>) => groups.totalElements > 0),
97+
map((group: Group) => isNotEmpty(group)),
9798
catchError(() => observableOf(false)),
9899
);
99100
}

0 commit comments

Comments
 (0)