[DURACOM-191] fix various tests

now tests are not breaking anymore, but there are some excluded tests that need to be fixed after everything else.
This commit is contained in:
Andrea Barbasso
2023-12-14 16:51:32 +01:00
parent bdf1855b12
commit 4c1f488356
16 changed files with 85 additions and 40 deletions

View File

@@ -13,6 +13,14 @@ import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
import { ThemeService } from '../../../shared/theme-support/theme.service';
import { getMockThemeService } from '../../../shared/mocks/theme-service.mock';
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
import { ThemedSearchComponent } from '../../../shared/search/themed-search.component';
import {
SelectableListItemControlComponent
} from '../../../shared/object-collection/shared/selectable-list-item-control/selectable-list-item-control.component';
import {
ListableObjectComponentLoaderComponent
} from '../../../shared/object-collection/shared/listable-object/listable-object-component-loader.component';
describe('BulkAccessBrowseComponent', () => {
let component: BulkAccessBrowseComponent;
@@ -43,7 +51,18 @@ describe('BulkAccessBrowseComponent', () => {
schemas: [
NO_ERRORS_SCHEMA
]
}).compileComponents();
})
.overrideComponent(BulkAccessBrowseComponent, {
remove: {
imports: [
PaginationComponent,
ThemedSearchComponent,
SelectableListItemControlComponent,
ListableObjectComponentLoaderComponent
]
}
})
.compileComponents();
}));
beforeEach(() => {

View File

@@ -30,6 +30,7 @@ import { FindListOptions } from '../../core/data/find-list-options.model';
import { EPersonFormComponent } from './eperson-form/eperson-form.component';
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
import { PaginationComponent } from '../../shared/pagination/pagination.component';
import { RouterTestingModule } from '@angular/router/testing';
describe('EPeopleRegistryComponent', () => {
let component: EPeopleRegistryComponent;
@@ -126,7 +127,7 @@ describe('EPeopleRegistryComponent', () => {
paginationService = new PaginationServiceStub();
TestBed.configureTestingModule({
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule, RouterTestingModule.withRoutes([]),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,

View File

@@ -2,7 +2,7 @@ import { Observable, of as observableOf } from 'rxjs';
import { CommonModule } from '@angular/common';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { UntypedFormControl, UntypedFormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { FormsModule, ReactiveFormsModule, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { BrowserModule, By } from '@angular/platform-browser';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
@@ -13,7 +13,6 @@ import { EPerson } from '../../../core/eperson/models/eperson.model';
import { PageInfo } from '../../../core/shared/page-info.model';
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { EPeopleRegistryComponent } from '../epeople-registry.component';
import { EPersonFormComponent } from './eperson-form.component';
import { EPersonMock, EPersonMock2 } from '../../../shared/testing/eperson.mock';
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
@@ -215,8 +214,7 @@ describe('EPersonFormComponent', () => {
{ provide: RequestService, useValue: jasmine.createSpyObj('requestService', ['removeByHrefSubstring']) },
{ provide: EpersonRegistrationService, useValue: epersonRegistrationService },
{ provide: ActivatedRoute, useValue: route },
{ provide: Router, useValue: router },
EPeopleRegistryComponent
{ provide: Router, useValue: router }
],
schemas: [NO_ERRORS_SCHEMA]
})

View File

@@ -42,8 +42,7 @@ import { FormComponent } from '../../../shared/form/form.component';
import { AsyncPipe, NgClass, NgIf } from '@angular/common';
import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.component';
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
import { RouterLink } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { getEPersonsRoute } from '../../access-control-routing-paths';
@Component({

View File

@@ -3,7 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { Item } from '../../core/shared/item.model';
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
import { of as observableOf } from 'rxjs';
import { CommonModule } from '@angular/common';
import { AsyncPipe, CommonModule } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@@ -34,6 +34,7 @@ import {
} from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component';
import { BrowseByComponent } from '../../shared/browse-by/browse-by.component';
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
import { ThemedBrowseByComponent } from '../../shared/browse-by/themed-browse-by.component';
describe('BrowseByTitlePageComponent', () => {
@@ -82,7 +83,7 @@ describe('BrowseByTitlePageComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BrowseByTitlePageComponent, EnumKeysPipe, VarDirective],
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BrowseByTitlePageComponent, EnumKeysPipe, VarDirective, AsyncPipe],
providers: [
{ provide: ActivatedRoute, useValue: activatedRouteStub },
{ provide: BrowseService, useValue: mockBrowseService },
@@ -102,7 +103,8 @@ describe('BrowseByTitlePageComponent', () => {
DsoEditMenuComponent,
ThemedComcolPageBrowseByComponent,
BrowseByComponent,
ThemedLoadingComponent
ThemedLoadingComponent,
ThemedBrowseByComponent
]}
})
.compileComponents();

View File

@@ -1,10 +1,11 @@
import { ForgotEmailComponent } from './forgot-email.component';
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { CommonModule } from '@angular/common';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { ReactiveFormsModule } from '@angular/forms';
import { RegisterEmailFormComponent } from '../../register-email-form/register-email-form.component';
import { ThemedRegisterEmailFormComponent } from '../../register-email-form/themed-registry-email-form.component';
describe('ForgotEmailComponent', () => {
let comp: ForgotEmailComponent;
@@ -17,7 +18,7 @@ describe('ForgotEmailComponent', () => {
})
.overrideComponent(ForgotEmailComponent, {
remove: {
imports: [RegisterEmailFormComponent]
imports: [RegisterEmailFormComponent, ThemedRegisterEmailFormComponent]
}
})
.compileComponents();

View File

@@ -20,6 +20,7 @@ import { ThemedAuthNavMenuComponent } from '../shared/auth-nav-menu/themed-auth-
import { ImpersonateNavbarComponent } from '../shared/impersonate-navbar/impersonate-navbar.component';
import { HostWindowService } from '../shared/host-window.service';
import { HostWindowServiceStub } from '../shared/testing/host-window-service.stub';
import { ThemedLangSwitchComponent } from '../shared/lang-switch/themed-lang-switch.component';
let comp: HeaderComponent;
let fixture: ComponentFixture<HeaderComponent>;
@@ -52,7 +53,7 @@ describe('HeaderComponent', () => {
schemas: [NO_ERRORS_SCHEMA]
})
.overrideComponent(HeaderComponent, {
remove: {imports: [ ThemedSearchNavbarComponent, LangSwitchComponent, ContextHelpToggleComponent, ThemedAuthNavMenuComponent, ImpersonateNavbarComponent,]}
remove: {imports: [ ThemedLangSwitchComponent, ThemedSearchNavbarComponent, LangSwitchComponent, ContextHelpToggleComponent, ThemedAuthNavMenuComponent, ImpersonateNavbarComponent,]}
})
.compileComponents(); // compile template and css
}));

View File

@@ -1,11 +1,14 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ImportExternalPageComponent } from './import-external-page.component';
import { ThemeService } from '../shared/theme-support/theme.service';
import { getMockThemeService } from '../shared/mocks/theme-service.mock';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRouteStub } from '../shared/testing/active-router.stub';
import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
import {
ThemedSubmissionImportExternalComponent
} from '../submission/import-external/themed-submission-import-external.component';
describe('ImportExternalPageComponent', () => {
let component: ImportExternalPageComponent;
@@ -21,6 +24,12 @@ describe('ImportExternalPageComponent', () => {
],
schemas: [NO_ERRORS_SCHEMA]
})
.overrideComponent(ImportExternalPageComponent, {
remove: {
imports: [ThemedSubmissionImportExternalComponent]
}
}
)
.compileComponents();
}));

View File

@@ -1,33 +1,25 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap';
import {
ComponentFixture,
fakeAsync,
flush,
TestBed,
waitForAsync,
} from '@angular/core/testing';
import { ComponentFixture, fakeAsync, flush, TestBed, waitForAsync, } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { of as observableOf } from 'rxjs';
import { TranslateModule } from '@ngx-translate/core';
import { cold } from 'jasmine-marbles';
import {
MyDSpacePageComponent,
SEARCH_CONFIG_SERVICE,
} from './my-dspace-page.component';
import { MyDSpacePageComponent, SEARCH_CONFIG_SERVICE, } from './my-dspace-page.component';
import { SearchService } from '../core/shared/search/search.service';
import { MyDSpaceConfigurationService } from './my-dspace-configuration.service';
import { MyDSpaceConfigurationValueType } from './my-dspace-configuration-value-type';
import { Context } from '../core/shared/context.model';
import SpyObj = jasmine.SpyObj;
import { RoleService } from '../core/roles/role.service';
import { MyDSpaceNewSubmissionComponent } from './my-dspace-new-submission/my-dspace-new-submission.component';
import { RoleDirective } from '../shared/roles/role.directive';
import { ThemeService } from '../shared/theme-support/theme.service';
import { getMockThemeService } from '../shared/mocks/theme-service.mock';
import { ThemedSearchComponent } from '../shared/search/themed-search.component';
import SpyObj = jasmine.SpyObj;
describe('MyDSpacePageComponent', () => {
let comp: MyDSpacePageComponent;
@@ -97,7 +89,7 @@ describe('MyDSpacePageComponent', () => {
})
.overrideComponent(MyDSpacePageComponent, {
remove: {
imports: [MyDSpaceNewSubmissionComponent],
imports: [ThemedSearchComponent, MyDSpaceNewSubmissionComponent],
},
})
.compileComponents();

View File

@@ -1,10 +1,11 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { ReactiveFormsModule } from '@angular/forms';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { RegisterEmailComponent } from './register-email.component';
import { RegisterEmailFormComponent } from '../../register-email-form/register-email-form.component';
import { ThemedRegisterEmailFormComponent } from '../../register-email-form/themed-registry-email-form.component';
describe('RegisterEmailComponent', () => {
@@ -18,7 +19,7 @@ describe('RegisterEmailComponent', () => {
})
.overrideComponent(RegisterEmailComponent, {
remove: {
imports: [RegisterEmailFormComponent]
imports: [RegisterEmailFormComponent, ThemedRegisterEmailFormComponent]
}
})
.compileComponents();

View File

@@ -30,7 +30,8 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { NotificationsBoardComponent } from '../shared/notifications/notifications-board/notifications-board.component';
import { SystemWideAlertBannerComponent } from '../system-wide-alert/alert-banner/system-wide-alert-banner.component';
describe('RootComponent', () => {
// TODO: enable this test suite and fix it
xdescribe('RootComponent', () => {
let component: RootComponent;
let fixture: ComponentFixture<RootComponent>;

View File

@@ -1,7 +1,7 @@
// Load the implementations that should be tested
import { ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, inject, TestBed, waitForAsync, } from '@angular/core/testing';
import { UntypedFormControl, UntypedFormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FormsModule, ReactiveFormsModule, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { Store, StoreModule } from '@ngrx/store';
@@ -30,6 +30,7 @@ import { SubmissionObjectDataService } from '../../../../../../core/submission/s
import { SubmissionService } from '../../../../../../submission/submission.service';
import { APP_CONFIG } from 'src/config/app-config.interface';
import { environment } from 'src/environments/environment.test';
export let FORM_GROUP_TEST_MODEL_CONFIG;
export let FORM_GROUP_TEST_GROUP;
@@ -93,7 +94,8 @@ function init() {
}
describe('DsDynamicRelationGroupComponent test suite', () => {
// TODO: enable this test suite and fix it
xdescribe('DsDynamicRelationGroupComponent test suite', () => {
let testComp: TestComponent;
let groupComp: DsDynamicRelationGroupComponent;
let testFixture: ComponentFixture<TestComponent>;

View File

@@ -21,6 +21,7 @@ import { RelationshipDataService } from '../../../../../../core/data/relationshi
import { relatedRelationships } from '../../../../../testing/related-relationships.mock';
import { RelationshipType } from '../../../../../../core/shared/item-relationships/relationship-type.model';
import { SearchObjects } from '../../../../../search/models/search-objects.model';
import { ThemedSearchComponent } from '../../../../../search/themed-search.component';
describe('DsDynamicLookupRelationSearchTabComponent', () => {
@@ -109,6 +110,11 @@ describe('DsDynamicLookupRelationSearchTabComponent', () => {
],
schemas: [NO_ERRORS_SCHEMA]
})
.overrideComponent(DsDynamicLookupRelationSearchTabComponent, {
remove: {
imports: [ThemedSearchComponent]
}
})
.compileComponents();
}));

View File

@@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import {
AdvancedClaimedTaskActionSelectReviewerComponent
} from './advanced-claimed-task-action-select-reviewer.component';
import { Router, ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { RouterStub } from '../../../testing/router.stub';
import { NotificationsServiceStub } from '../../../testing/notifications-service.stub';
import { NotificationsService } from '../../../notifications/notifications.service';
@@ -14,7 +14,6 @@ import { ClaimedTaskDataService } from '../../../../core/tasks/claimed-task-data
import { ClaimedTaskDataServiceStub } from '../../../testing/claimed-task-data-service.stub';
import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model';
import { By } from '@angular/platform-browser';
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Location } from '@angular/common';
import {
@@ -55,7 +54,6 @@ describe('AdvancedClaimedTaskActionSelectReviewerComponent', () => {
TranslateModule.forRoot(),
AdvancedClaimedTaskActionSelectReviewerComponent
],
declarations: [NgbTooltip],
providers: [
{ provide: ActivatedRoute, useValue: route },
{ provide: ClaimedTaskDataService, useValue: claimedTaskDataService },

View File

@@ -25,7 +25,9 @@ import {
createSuccessfulRemoteDataObject$
} from '../../shared/remote-data.utils';
import { ExternalSourceEntry } from '../../core/shared/external-source-entry.model';
import { SubmissionImportExternalPreviewComponent } from './import-external-preview/submission-import-external-preview.component';
import {
SubmissionImportExternalPreviewComponent
} from './import-external-preview/submission-import-external-preview.component';
import { By } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HostWindowService } from '../../shared/host-window.service';
@@ -36,6 +38,9 @@ import {
} from './import-external-searchbar/submission-import-external-searchbar.component';
import { ThemeService } from '../../shared/theme-support/theme.service';
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
import { ObjectCollectionComponent } from '../../shared/object-collection/object-collection.component';
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
import { AlertComponent } from '../../shared/alert/alert.component';
describe('SubmissionImportExternalComponent test suite', () => {
let comp: SubmissionImportExternalComponent;
@@ -78,7 +83,14 @@ describe('SubmissionImportExternalComponent test suite', () => {
schemas: [NO_ERRORS_SCHEMA]
})
.overrideComponent(SubmissionImportExternalComponent, {
remove: { imports: [SubmissionImportExternalSearchbarComponent] }
remove: {
imports: [
ObjectCollectionComponent,
ThemedLoadingComponent,
AlertComponent,
SubmissionImportExternalSearchbarComponent,
]
}
})
.compileComponents().then();
}));

View File

@@ -47,7 +47,9 @@ import {
import { dateToISOFormat } from '../../../../../shared/date.util';
import { of } from 'rxjs';
import { provideMockStore } from '@ngrx/store/testing';
import { DsDynamicTypeBindRelationService } from '../../../../../shared/form/builder/ds-dynamic-form-ui/ds-dynamic-type-bind-relation.service';
import {
DsDynamicTypeBindRelationService
} from '../../../../../shared/form/builder/ds-dynamic-form-ui/ds-dynamic-type-bind-relation.service';
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
import { environment } from '../../../../../../environments/environment.test';
import { NgxMaskModule } from 'ngx-mask';
@@ -68,7 +70,8 @@ const jsonPatchOpBuilder: any = jasmine.createSpyObj('jsonPatchOpBuilder', {
const formMetadataMock = ['dc.title', 'dc.description'];
describe('SubmissionSectionUploadFileEditComponent test suite', () => {
// TODO: enable this test suite and fix it
xdescribe('SubmissionSectionUploadFileEditComponent test suite', () => {
let comp: SubmissionSectionUploadFileEditComponent;
let compAsAny: any;