Skip to content

Commit

Permalink
Manual fix: sync removed imports between tests and components
Browse files Browse the repository at this point in the history
The automatic migration made it so HTML always uses the `Themed*` component, and it must therefore be imported in all standalone components that use it.
Afterwards, many unit tests fail because the removed imports no longer match up (can't inject `ThemeService`).

While we could try to support this as part of the automatic migration, there are too many edge cases for this to be consistent.
  • Loading branch information
ybnd committed Mar 28, 2024
1 parent 0b9741d commit 762e461
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';

import { ConfigurationSearchPageComponent } from '../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../search-page/themed-configuration-search-page.component';
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
import { AdminSearchPageComponent } from './admin-search-page.component';

Expand All @@ -23,7 +23,7 @@ describe('AdminSearchPageComponent', () => {
schemas: [NO_ERRORS_SCHEMA],
}).overrideComponent(AdminSearchPageComponent, {
remove: {
imports: [ConfigurationSearchPageComponent],
imports: [ThemedConfigurationSearchPageComponent],
},
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
waitForAsync,
} from '@angular/core/testing';

import { ConfigurationSearchPageComponent } from '../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../search-page/themed-configuration-search-page.component';
import { AdminWorkflowPageComponent } from './admin-workflow-page.component';

describe('AdminSearchPageComponent', () => {
Expand All @@ -20,7 +20,7 @@ describe('AdminSearchPageComponent', () => {
.overrideComponent(AdminWorkflowPageComponent, {
remove: {
imports: [
ConfigurationSearchPageComponent,
ThemedConfigurationSearchPageComponent,
],
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.serv
import { PaginationService } from '../../core/pagination/pagination.service';
import { Community } from '../../core/shared/community.model';
import { Item } from '../../core/shared/item.model';
import { BrowseByComponent } from '../../shared/browse-by/browse-by.component';
import { ThemedBrowseByComponent } from '../../shared/browse-by/themed-browse-by.component';
import { ThemedComcolPageBrowseByComponent } from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component';
import { ComcolPageContentComponent } from '../../shared/comcol/comcol-page-content/comcol-page-content.component';
Expand Down Expand Up @@ -135,7 +134,6 @@ describe('BrowseByDateComponent', () => {
ThemedComcolPageHandleComponent,
ComcolPageContentComponent,
ThemedComcolPageBrowseByComponent,
BrowseByComponent,
ThemedLoadingComponent,
ThemedBrowseByComponent,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { ItemDataService } from '../../core/data/item-data.service';
import { PaginationService } from '../../core/pagination/pagination.service';
import { Community } from '../../core/shared/community.model';
import { Item } from '../../core/shared/item.model';
import { BrowseByComponent } from '../../shared/browse-by/browse-by.component';
import { ThemedBrowseByComponent } from '../../shared/browse-by/themed-browse-by.component';
import { ThemedComcolPageBrowseByComponent } from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component';
import { ComcolPageContentComponent } from '../../shared/comcol/comcol-page-content/comcol-page-content.component';
Expand Down Expand Up @@ -108,7 +107,6 @@ describe('BrowseByTitleComponent', () => {
ComcolPageContentComponent,
DsoEditMenuComponent,
ThemedComcolPageBrowseByComponent,
BrowseByComponent,
ThemedLoadingComponent,
ThemedBrowseByComponent,
] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { of as observableOf } from 'rxjs';

import { ItemTemplateDataService } from '../../core/data/item-template-data.service';
import { Collection } from '../../core/shared/collection.model';
import { DsoEditMetadataComponent } from '../../dso-shared/dso-edit-metadata/dso-edit-metadata.component';
import { ThemedDsoEditMetadataComponent } from '../../dso-shared/dso-edit-metadata/themed-dso-edit-metadata.component';
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
import { NotificationsService } from '../../shared/notifications/notifications.service';
Expand Down Expand Up @@ -51,7 +50,7 @@ describe('EditItemTemplatePageComponent', () => {
schemas: [NO_ERRORS_SCHEMA],
}).overrideComponent(EditItemTemplatePageComponent, {
remove: {
imports: [ThemedDsoEditMetadataComponent, DsoEditMetadataComponent],
imports: [ThemedDsoEditMetadataComponent],
},
}).compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Item } from '../../core/shared/item.model';
import { ITEM } from '../../core/shared/item.resource-type';
import { MetadataValue } from '../../core/shared/metadata.models';
import { AlertComponent } from '../../shared/alert/alert.component';
import { LoadingComponent } from '../../shared/loading/loading.component';
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { TestDataService } from '../../shared/testing/test-data-service.mock';
import { VarDirective } from '../../shared/utils/var.directive';
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('DsoEditMetadataComponent', () => {
DsoEditMetadataValueHeadersComponent,
DsoEditMetadataFieldValuesComponent,
AlertComponent,
LoadingComponent,
ThemedLoadingComponent,
],
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { TruncatableComponent } from '../../../../../shared/truncatable/truncata
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
import { TruncatablePartComponent } from '../../../../../shared/truncatable/truncatable-part/truncatable-part.component';
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
import { ThumbnailComponent } from '../../../../../thumbnail/thumbnail.component';
import { ThemedThumbnailComponent } from '../../../../../thumbnail/themed-thumbnail.component';
import { JournalIssueSearchResultListElementComponent } from './journal-issue-search-result-list-element.component';

let journalIssueListElementComponent: JournalIssueSearchResultListElementComponent;
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('JournalIssueSearchResultListElementComponent', () => {
}).overrideComponent(JournalIssueSearchResultListElementComponent, {
add: { changeDetection: ChangeDetectionStrategy.Default } ,
remove: {
imports: [ThumbnailComponent, ThemedBadgesComponent, TruncatableComponent, TruncatablePartComponent],
imports: [ThemedThumbnailComponent, ThemedBadgesComponent, TruncatableComponent, TruncatablePartComponent],
} },
).compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { TruncatableComponent } from '../../../../../shared/truncatable/truncata
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
import { TruncatablePartComponent } from '../../../../../shared/truncatable/truncatable-part/truncatable-part.component';
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
import { ThumbnailComponent } from '../../../../../thumbnail/thumbnail.component';
import { ThemedThumbnailComponent } from '../../../../../thumbnail/themed-thumbnail.component';
import { JournalVolumeSearchResultListElementComponent } from './journal-volume-search-result-list-element.component';

let journalVolumeListElementComponent: JournalVolumeSearchResultListElementComponent;
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('JournalVolumeSearchResultListElementComponent', () => {
add: { changeDetection: ChangeDetectionStrategy.Default },
remove: {
imports: [
ThumbnailComponent, NgClass, ThemedBadgesComponent, TruncatableComponent, TruncatablePartComponent,
ThemedThumbnailComponent, NgClass, ThemedBadgesComponent, TruncatableComponent, TruncatablePartComponent,
],
},
}).compileComponents();
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('JournalVolumeSearchResultListElementComponent', () => {
add: { changeDetection: ChangeDetectionStrategy.Default },
remove: {
imports: [
ThumbnailComponent,
ThemedThumbnailComponent,
ThemedBadgesComponent,
TruncatableComponent,
TruncatablePartComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { TruncatableComponent } from '../../../../../shared/truncatable/truncata
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
import { TruncatablePartComponent } from '../../../../../shared/truncatable/truncatable-part/truncatable-part.component';
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
import { ThumbnailComponent } from '../../../../../thumbnail/thumbnail.component';
import { ThemedThumbnailComponent } from '../../../../../thumbnail/themed-thumbnail.component';
import { JournalSearchResultListElementComponent } from './journal-search-result-list-element.component';

let journalListElementComponent: JournalSearchResultListElementComponent;
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('JournalSearchResultListElementComponent', () => {
add: { changeDetection: ChangeDetectionStrategy.Default },
remove: {
imports: [
ThumbnailComponent,
ThemedThumbnailComponent,
ThemedBadgesComponent,
TruncatableComponent,
TruncatablePartComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ThemeService } from '../../../../../shared/theme-support/theme.service'
import { TruncatableComponent } from '../../../../../shared/truncatable/truncatable.component';
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
import { ThumbnailComponent } from '../../../../../thumbnail/thumbnail.component';
import { ThemedThumbnailComponent } from '../../../../../thumbnail/themed-thumbnail.component';
import { ProjectSearchResultListElementComponent } from './project-search-result-list-element.component';

let projectListElementComponent: ProjectSearchResultListElementComponent;
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('ProjectSearchResultListElementComponent', () => {
schemas: [NO_ERRORS_SCHEMA],
}).overrideComponent(ProjectSearchResultListElementComponent, {
add: { changeDetection: ChangeDetectionStrategy.Default },
remove: { imports: [ThumbnailComponent, TruncatableComponent, ThemedBadgesComponent] },
remove: { imports: [ThemedThumbnailComponent, TruncatableComponent, ThemedBadgesComponent] },
}).compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { ReactiveFormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';

import { RegisterEmailFormComponent } from '../../register-email-form/register-email-form.component';
import { ThemedRegisterEmailFormComponent } from '../../register-email-form/themed-registry-email-form.component';
import { ForgotEmailComponent } from './forgot-email.component';

Expand All @@ -23,7 +22,7 @@ describe('ForgotEmailComponent', () => {
})
.overrideComponent(ForgotEmailComponent, {
remove: {
imports: [RegisterEmailFormComponent, ThemedRegisterEmailFormComponent],
imports: [ThemedRegisterEmailFormComponent],
},
})
.compileComponents();
Expand Down
3 changes: 1 addition & 2 deletions src/app/header/header.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { ThemedSearchNavbarComponent } from '../search-navbar/themed-search-navb
import { ThemedAuthNavMenuComponent } from '../shared/auth-nav-menu/themed-auth-nav-menu.component';
import { HostWindowService } from '../shared/host-window.service';
import { ImpersonateNavbarComponent } from '../shared/impersonate-navbar/impersonate-navbar.component';
import { LangSwitchComponent } from '../shared/lang-switch/lang-switch.component';
import { ThemedLangSwitchComponent } from '../shared/lang-switch/themed-lang-switch.component';
import { MenuService } from '../shared/menu/menu.service';
import { ActivatedRouteStub } from '../shared/testing/active-router.stub';
Expand Down Expand Up @@ -60,7 +59,7 @@ describe('HeaderComponent', () => {
schemas: [NO_ERRORS_SCHEMA],
})
.overrideComponent(HeaderComponent, {
remove: { imports: [ ThemedLangSwitchComponent, ThemedSearchNavbarComponent, LangSwitchComponent, ContextHelpToggleComponent, ThemedAuthNavMenuComponent, ImpersonateNavbarComponent] },
remove: { imports: [ ThemedLangSwitchComponent, ThemedSearchNavbarComponent, ContextHelpToggleComponent, ThemedAuthNavMenuComponent, ImpersonateNavbarComponent] },
})
.compileComponents(); // compile template and css
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateModule } from '@ngx-translate/core';

import { Item } from '../../../../core/shared/item.model';
import { ConfigurationSearchPageComponent } from '../../../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../../../search-page/themed-configuration-search-page.component';
import { RelatedEntitiesSearchComponent } from './related-entities-search.component';

describe('RelatedEntitiesSearchComponent', () => {
Expand All @@ -30,7 +30,7 @@ describe('RelatedEntitiesSearchComponent', () => {
})
.overrideComponent(RelatedEntitiesSearchComponent, {
remove: {
imports: [ConfigurationSearchPageComponent],
imports: [ThemedConfigurationSearchPageComponent],
},
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Item } from '../../../core/shared/item.model';
import { PageInfo } from '../../../core/shared/page-info.model';
import { SearchService } from '../../../core/shared/search/search.service';
import { AlertComponent } from '../../../shared/alert/alert.component';
import { LoadingComponent } from '../../../shared/loading/loading.component';
import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.component';
import {
ItemMockPid10,
NotificationsMockDspaceObject,
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('ProjectEntryImportModalComponent test suite', () => {
.overrideComponent(ProjectEntryImportModalComponent, {
remove: {
imports: [
LoadingComponent,
ThemedLoadingComponent,
ThemedSearchResultsComponent,
AlertComponent,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { of as observableOf } from 'rxjs';

import { PaginationService } from '../../../core/pagination/pagination.service';
import { AlertComponent } from '../../../shared/alert/alert.component';
import { LoadingComponent } from '../../../shared/loading/loading.component';
import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.component';
import {
getMockNotificationsStateService,
qualityAssuranceSourceObjectMoreAbstract,
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('QualityAssuranceSourceComponent test suite', () => {
remove: {
imports: [
AlertComponent,
LoadingComponent,
ThemedLoadingComponent,
PaginationComponent,
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ItemDataService } from 'src/app/core/data/item-data.service';

import { PaginationService } from '../../../core/pagination/pagination.service';
import { AlertComponent } from '../../../shared/alert/alert.component';
import { LoadingComponent } from '../../../shared/loading/loading.component';
import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.component';
import {
getMockNotificationsStateService,
qualityAssuranceTopicObjectMoreAbstract,
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('QualityAssuranceTopicsComponent test suite', () => {
remove: {
imports: [
AlertComponent,
LoadingComponent,
ThemedLoadingComponent,
PaginationComponent,
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { ReactiveFormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';

import { RegisterEmailFormComponent } from '../../register-email-form/register-email-form.component';
import { ThemedRegisterEmailFormComponent } from '../../register-email-form/themed-registry-email-form.component';
import { RegisterEmailComponent } from './register-email.component';

Expand All @@ -24,7 +23,7 @@ describe('RegisterEmailComponent', () => {
})
.overrideComponent(RegisterEmailComponent, {
remove: {
imports: [RegisterEmailFormComponent, ThemedRegisterEmailFormComponent],
imports: [ThemedRegisterEmailFormComponent],
},
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { NotificationsService } from '../../../../../../notifications/notificati
import { ItemSearchResult } from '../../../../../../object-collection/shared/item-search-result.model';
import { SelectableListService } from '../../../../../../object-list/selectable-list/selectable-list.service';
import { createSuccessfulRemoteDataObject$ } from '../../../../../../remote-data.utils';
import { SearchResultsComponent } from '../../../../../../search/search-results/search-results.component';
import { ThemedSearchResultsComponent } from '../../../../../../search/search-results/themed-search-results.component';
import { createPaginatedList } from '../../../../../../testing/utils.test';
import { RelationshipOptions } from '../../../../models/relationship-options.model';
import {
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('DsDynamicLookupRelationExternalSourceTabComponent', () => {
schemas: [NO_ERRORS_SCHEMA],
})
.overrideComponent(ExternalSourceEntryImportModalComponent, {
remove: { imports: [SearchResultsComponent] },
remove: { imports: [ThemedSearchResultsComponent] },
})
.compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { of as observableOf } from 'rxjs';

import { APP_CONFIG } from '../../../../../config/app-config.interface';
import { Item } from '../../../../core/shared/item.model';
import { ThumbnailComponent } from '../../../../thumbnail/thumbnail.component';
import { ThemedThumbnailComponent } from '../../../../thumbnail/themed-thumbnail.component';
import { TranslateLoaderMock } from '../../../mocks/translate-loader.mock';
import { ThemedBadgesComponent } from '../../../object-collection/shared/badges/themed-badges.component';
import { ItemCollectionComponent } from '../../../object-collection/shared/mydspace-item-collection/item-collection.component';
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('ItemListPreviewComponent', () => {
add: { changeDetection: ChangeDetectionStrategy.Default },
remove: {
imports: [
ThumbnailComponent, ThemedBadgesComponent,
ThemedThumbnailComponent, ThemedBadgesComponent,
TruncatableComponent, TruncatablePartComponent,
ItemSubmitterComponent, ItemCollectionComponent,
],
Expand Down Expand Up @@ -228,7 +228,7 @@ describe('ItemListPreviewComponent', () => {
add: { changeDetection: ChangeDetectionStrategy.Default },
remove: {
imports: [
ThumbnailComponent, ThemedBadgesComponent,
ThemedThumbnailComponent, ThemedBadgesComponent,
TruncatableComponent, TruncatablePartComponent,
ItemSubmitterComponent, ItemCollectionComponent,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { SectionUploadService } from '../section-upload.service';
import { POLICY_DEFAULT_WITH_LIST } from '../section-upload-constants';
import { SubmissionSectionUploadFileEditComponent } from './edit/section-upload-file-edit.component';
import { SubmissionSectionUploadFileComponent } from './section-upload-file.component';
import { ThemedSubmissionSectionUploadFileComponent } from './themed-section-upload-file.component';
import { SubmissionSectionUploadFileViewComponent } from './view/section-upload-file-view.component';

const configMetadataFormMock = {
Expand Down Expand Up @@ -284,7 +285,7 @@ describe('SubmissionSectionUploadFileComponent test suite', () => {
template: ``,
standalone: true,
imports: [
SubmissionSectionUploadFileComponent,
ThemedSubmissionSectionUploadFileComponent,
CommonModule,
AsyncPipe,
NgbModule],
Expand Down

0 comments on commit 762e461

Please sign in to comment.