mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
Merge remote-tracking branch 'origin/main' into w2p-92282_Fix-missing-auth-tokens-when-retrieving-Bitstreams
This commit is contained in:
@@ -34,6 +34,9 @@ export class AuthRequestServiceStub {
|
||||
},
|
||||
eperson: {
|
||||
href: this.mockUser._links.self.href
|
||||
},
|
||||
specialGroups: {
|
||||
href: this.mockUser._links.self.href
|
||||
}
|
||||
};
|
||||
} else {
|
||||
@@ -62,6 +65,9 @@ export class AuthRequestServiceStub {
|
||||
},
|
||||
eperson: {
|
||||
href: this.mockUser._links.self.href
|
||||
},
|
||||
specialGroups: {
|
||||
href: this.mockUser._links.self.href
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
@@ -33,7 +33,7 @@ export class AuthServiceStub {
|
||||
return observableOf(authStatus);
|
||||
} else {
|
||||
console.log('error');
|
||||
throw(new Error('Message Error test'));
|
||||
throw (new Error('Message Error test'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export class AuthServiceStub {
|
||||
if (token.accessToken === 'token_test') {
|
||||
return observableOf(EPersonMock._links.self.href);
|
||||
} else {
|
||||
throw(new Error('Message Error test'));
|
||||
throw (new Error('Message Error test'));
|
||||
}
|
||||
}
|
||||
|
||||
|
13
src/app/shared/testing/browser-only-mock.pipe.ts
Normal file
13
src/app/shared/testing/browser-only-mock.pipe.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
/**
|
||||
* Support dsBrowserOnly in unit tests.
|
||||
*/
|
||||
@Pipe({
|
||||
name: 'dsBrowserOnly'
|
||||
})
|
||||
export class BrowserOnlyMockPipe implements PipeTransform {
|
||||
transform(value: string): string | undefined {
|
||||
return value;
|
||||
}
|
||||
}
|
@@ -1,9 +1,13 @@
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { hasValue } from '../empty.util';
|
||||
|
||||
export class HALEndpointServiceStub {
|
||||
|
||||
constructor(private url: string) {}
|
||||
getEndpoint(path: string) {
|
||||
getEndpoint(path: string, startHref?: string) {
|
||||
if (hasValue(startHref)) {
|
||||
return observableOf(startHref + '/' + path);
|
||||
}
|
||||
return observableOf(this.url + '/' + path);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { MenuID } from '../menu/initial-menus-state';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { MenuSection } from '../menu/menu.reducer';
|
||||
import { MenuSection } from '../menu/menu-section.model';
|
||||
import { MenuState } from '../menu/menu-state.model';
|
||||
import { MenuID } from '../menu/menu-id.model';
|
||||
|
||||
export class MenuServiceStub {
|
||||
visibleSection1 = {
|
||||
@@ -77,6 +78,10 @@ export class MenuServiceStub {
|
||||
return observableOf(true);
|
||||
}
|
||||
|
||||
getMenu(id: MenuID): Observable<MenuState> { // todo: resolve import
|
||||
return observableOf({} as MenuState);
|
||||
}
|
||||
|
||||
getMenuTopSections(id: MenuID): Observable<MenuSection[]> {
|
||||
return observableOf([this.visibleSection1, this.visibleSection2]);
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { Directive, Input } from '@angular/core';
|
||||
|
||||
/* tslint:disable:directive-class-suffix */
|
||||
/* eslint-disable @angular-eslint/directive-class-suffix */
|
||||
@Directive({
|
||||
// tslint:disable-next-line:directive-selector
|
||||
// eslint-disable-next-line @angular-eslint/directive-selector
|
||||
selector: '[ngComponentOutlet]',
|
||||
})
|
||||
export class NgComponentOutletDirectiveStub {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../core/data/request.models';
|
||||
import { FindListOptions } from '../../core/data/find-list-options.model';
|
||||
|
||||
export class PaginationServiceStub {
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { Directive, Input } from '@angular/core';
|
||||
|
||||
/* tslint:disable:directive-class-suffix */
|
||||
/* eslint-disable @angular-eslint/directive-class-suffix */
|
||||
@Directive({
|
||||
// tslint:disable-next-line:directive-selector
|
||||
// eslint-disable-next-line @angular-eslint/directive-selector
|
||||
selector: '[queryParams]',
|
||||
})
|
||||
export class QueryParamsDirectiveStub {
|
||||
|
@@ -1,14 +1,18 @@
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { EMPTY, of as observableOf } from 'rxjs';
|
||||
|
||||
export const routeServiceStub: any = {
|
||||
/* tslint:disable:no-empty */
|
||||
/* eslint-disable no-empty,@typescript-eslint/no-empty-function */
|
||||
hasQueryParamWithValue: (param: string, value: string) => {
|
||||
return EMPTY;
|
||||
},
|
||||
hasQueryParam: (param: string) => {
|
||||
return EMPTY;
|
||||
},
|
||||
removeQueryParameterValue: (param: string, value: string) => {
|
||||
return EMPTY;
|
||||
},
|
||||
addQueryParameterValue: (param: string, value: string) => {
|
||||
return EMPTY;
|
||||
},
|
||||
getQueryParameterValues: (param: string) => {
|
||||
return observableOf({});
|
||||
@@ -34,5 +38,5 @@ export const routeServiceStub: any = {
|
||||
getPreviousUrl: () => {
|
||||
return observableOf('/home');
|
||||
}
|
||||
/* tslint:enable:no-empty */
|
||||
/* eslint-enable no-empty, @typescript-eslint/no-empty-function */
|
||||
};
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { Directive, Input } from '@angular/core';
|
||||
|
||||
/* tslint:disable:directive-class-suffix */
|
||||
/* eslint-disable @angular-eslint/directive-class-suffix */
|
||||
@Directive({
|
||||
// tslint:disable-next-line:directive-selector
|
||||
// eslint-disable-next-line @angular-eslint/directive-selector
|
||||
selector: '[routerLink]',
|
||||
})
|
||||
export class RouterLinkDirectiveStub {
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import { BehaviorSubject, of as observableOf } from 'rxjs';
|
||||
import { SearchConfig } from '../../core/shared/search/search-filters/search-config.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
|
||||
export class SearchConfigurationServiceStub {
|
||||
|
||||
@@ -15,7 +17,31 @@ export class SearchConfigurationServiceStub {
|
||||
return observableOf('test-id');
|
||||
}
|
||||
|
||||
getCurrentQuery(a) {
|
||||
return observableOf(a);
|
||||
}
|
||||
|
||||
getCurrentConfiguration(a) {
|
||||
return observableOf(a);
|
||||
}
|
||||
|
||||
getConfig () {
|
||||
return observableOf({ hasSucceeded: true, payload: [] });
|
||||
}
|
||||
|
||||
getAvailableConfigurationOptions() {
|
||||
return observableOf([{value: 'test', label: 'test'}]);
|
||||
}
|
||||
|
||||
getConfigurationSearchConfigObservable() {
|
||||
return observableOf(new SearchConfig());
|
||||
}
|
||||
|
||||
getConfigurationSortOptionsObservable() {
|
||||
return observableOf([new SortOptions('score', SortDirection.ASC), new SortOptions('score', SortDirection.DESC)]);
|
||||
}
|
||||
|
||||
initializeSortOptionsFromConfiguration() {
|
||||
/* empty */
|
||||
}
|
||||
}
|
||||
|
@@ -20,4 +20,5 @@ export class SectionsServiceStub {
|
||||
computeSectionConfiguredMetadata = jasmine.createSpy('computeSectionConfiguredMetadata');
|
||||
getShownSectionErrors = jasmine.createSpy('getShownSectionErrors');
|
||||
getSectionServerErrors = jasmine.createSpy('getSectionServerErrors');
|
||||
getIsInformational = jasmine.createSpy('getIsInformational');
|
||||
}
|
||||
|
56
src/app/shared/testing/special-group.mock.ts
Normal file
56
src/app/shared/testing/special-group.mock.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { EPersonMock } from './eperson.mock';
|
||||
import { PageInfo } from '../../core/shared/page-info.model';
|
||||
import { buildPaginatedList, PaginatedList } from '../../core/data/paginated-list.model';
|
||||
import { Group } from '../../core/eperson/models/group.model';
|
||||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../remote-data.utils';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
|
||||
export const SpecialGroupMock2: Group = Object.assign(new Group(), {
|
||||
handle: null,
|
||||
subgroups: [],
|
||||
epersons: [],
|
||||
permanent: true,
|
||||
selfRegistered: false,
|
||||
_links: {
|
||||
self: {
|
||||
href: 'https://rest.api/server/api/eperson/specialGroups/testgroupid2',
|
||||
},
|
||||
subgroups: { href: 'https://rest.api/server/api/eperson/specialGroups/testgroupid2/subgroups' },
|
||||
object: { href: 'https://rest.api/server/api/eperson/specialGroups/testgroupid2/object' },
|
||||
epersons: { href: 'https://rest.api/server/api/eperson/specialGroups/testgroupid2/epersons' }
|
||||
},
|
||||
_name: 'testgroupname2',
|
||||
id: 'testgroupid2',
|
||||
uuid: 'testgroupid2',
|
||||
type: 'specialGroups',
|
||||
// object: createSuccessfulRemoteDataObject$({ name: 'testspecialGroupsid2objectName'})
|
||||
});
|
||||
|
||||
export const SpecialGroupMock: Group = Object.assign(new Group(), {
|
||||
handle: null,
|
||||
subgroups: [SpecialGroupMock2],
|
||||
epersons: [EPersonMock],
|
||||
selfRegistered: false,
|
||||
permanent: false,
|
||||
_links: {
|
||||
self: {
|
||||
href: 'https://rest.api/server/api/eperson/specialGroups/testgroupid',
|
||||
},
|
||||
subgroups: { href: 'https://rest.api/server/api/eperson/specialGroups/testgroupid/subgroups' },
|
||||
object: { href: 'https://rest.api/server/api/eperson/specialGroups/testgroupid2/object' },
|
||||
epersons: { href: 'https://rest.api/server/api/eperson/specialGroups/testgroupid/epersons' }
|
||||
},
|
||||
_name: 'testgroupname',
|
||||
id: 'testgroupid',
|
||||
uuid: 'testgroupid',
|
||||
type: 'specialGroups',
|
||||
});
|
||||
|
||||
export const SpecialGroupDataMock: RemoteData<PaginatedList<Group>> = createSuccessfulRemoteDataObject(buildPaginatedList(new PageInfo(), [SpecialGroupMock2,SpecialGroupMock]));
|
||||
export const SpecialGroupDataMock$: Observable<RemoteData<PaginatedList<Group>>> = createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [SpecialGroupMock2,SpecialGroupMock]));
|
||||
export const EmptySpecialGroupDataMock$: Observable<RemoteData<PaginatedList<Group>>> = createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), []));
|
||||
|
||||
|
||||
|
@@ -2,8 +2,8 @@ import { of as observableOf } from 'rxjs';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { RequestService } from '../../core/data/request.service';
|
||||
import { CoreState } from '../../core/core.reducers';
|
||||
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
|
||||
import { CoreState } from '../../core/core-state.model';
|
||||
|
||||
export class SubmissionRestServiceStub {
|
||||
protected linkPath = 'workspaceitems';
|
||||
|
@@ -5,6 +5,7 @@ import { SharedModule } from '../shared.module';
|
||||
import { NgComponentOutletDirectiveStub } from './ng-component-outlet-directive.stub';
|
||||
import { QueryParamsDirectiveStub } from './query-params-directive.stub';
|
||||
import { RouterLinkDirectiveStub } from './router-link-directive.stub';
|
||||
import { BrowserOnlyMockPipe } from './browser-only-mock.pipe';
|
||||
|
||||
/**
|
||||
* This module isn't used. It serves to prevent the AoT compiler
|
||||
@@ -21,7 +22,8 @@ import { RouterLinkDirectiveStub } from './router-link-directive.stub';
|
||||
QueryParamsDirectiveStub,
|
||||
MySimpleItemActionComponent,
|
||||
RouterLinkDirectiveStub,
|
||||
NgComponentOutletDirectiveStub
|
||||
NgComponentOutletDirectiveStub,
|
||||
BrowserOnlyMockPipe,
|
||||
],
|
||||
exports: [
|
||||
QueryParamsDirectiveStub
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { buildPaginatedList, PaginatedList } from '../../core/data/paginated-list.model';
|
||||
import { PageInfo } from '../../core/shared/page-info.model';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { RequestEntry, RequestEntryState } from '../../core/data/request.reducer';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { UnCacheableObject } from '../../core/shared/uncacheable-object.model';
|
||||
import { RequestEntryState } from '../../core/data/request-entry-state.model';
|
||||
import { RequestEntry } from '../../core/data/request-entry.model';
|
||||
|
||||
/**
|
||||
* Returns true if a Native Element has a specified css class.
|
||||
|
Reference in New Issue
Block a user