mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[DURACOM-191] Fix tests
This commit is contained in:
@@ -36,7 +36,7 @@
|
|||||||
[authorityValue]="mdValue.newValue.confidence"
|
[authorityValue]="mdValue.newValue.confidence"
|
||||||
[iconMode]="true"
|
[iconMode]="true"
|
||||||
></i>
|
></i>
|
||||||
<input class="form-control form-outline" [(ngModel)]="mdValue.newValue.authority" [disabled]="!editingAuthority"
|
<input class="form-control form-outline" data-test="authority-input" [(ngModel)]="mdValue.newValue.authority" [disabled]="!editingAuthority"
|
||||||
[attr.aria-label]="(dsoType + '.edit.metadata.edit.authority.key') | translate"
|
[attr.aria-label]="(dsoType + '.edit.metadata.edit.authority.key') | translate"
|
||||||
(change)="onChangeAuthorityKey()" />
|
(change)="onChangeAuthorityKey()" />
|
||||||
<button class="btn btn-outline-secondary btn-sm ng-star-inserted" id="metadata-confirm-btn" *ngIf="!editingAuthority"
|
<button class="btn btn-outline-secondary btn-sm ng-star-inserted" id="metadata-confirm-btn" *ngIf="!editingAuthority"
|
||||||
|
@@ -37,6 +37,8 @@ import {
|
|||||||
VIRTUAL_METADATA_PREFIX,
|
VIRTUAL_METADATA_PREFIX,
|
||||||
} from '../../../core/shared/metadata.models';
|
} from '../../../core/shared/metadata.models';
|
||||||
import { ItemMetadataRepresentation } from '../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
import { ItemMetadataRepresentation } from '../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||||
|
import { DsDynamicOneboxComponent } from '../../../shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component';
|
||||||
|
import { DsDynamicScrollableDropdownComponent } from '../../../shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component';
|
||||||
import { ThemedTypeBadgeComponent } from '../../../shared/object-collection/shared/badges/type-badge/themed-type-badge.component';
|
import { ThemedTypeBadgeComponent } from '../../../shared/object-collection/shared/badges/type-badge/themed-type-badge.component';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||||
import { VarDirective } from '../../../shared/utils/var.directive';
|
import { VarDirective } from '../../../shared/utils/var.directive';
|
||||||
@@ -202,7 +204,7 @@ describe('DsoEditMetadataValueComponent', () => {
|
|||||||
})
|
})
|
||||||
.overrideComponent(DsoEditMetadataValueComponent, {
|
.overrideComponent(DsoEditMetadataValueComponent, {
|
||||||
remove: {
|
remove: {
|
||||||
imports: [ThemedTypeBadgeComponent],
|
imports: [DsDynamicOneboxComponent, DsDynamicScrollableDropdownComponent, ThemedTypeBadgeComponent],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
@@ -464,22 +466,30 @@ describe('DsoEditMetadataValueComponent', () => {
|
|||||||
expect(component.onChangeEditingAuthorityStatus).toHaveBeenCalledWith(true);
|
expect(component.onChangeEditingAuthorityStatus).toHaveBeenCalledWith(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should disable the input when editingAuthority is false', () => {
|
it('should disable the input when editingAuthority is false', (done) => {
|
||||||
component.editingAuthority = false;
|
component.editingAuthority = false;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const inputElement = fixture.nativeElement.querySelector('input');
|
fixture.detectChanges();
|
||||||
expect(inputElement.disabled).toBe(true);
|
fixture.whenStable().then(() => {
|
||||||
|
const inputElement = fixture.nativeElement.querySelector('input[data-test="authority-input"]');
|
||||||
|
expect(inputElement.disabled).toBeTruthy();
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should enable the input when editingAuthority is true', () => {
|
it('should enable the input when editingAuthority is true', (done) => {
|
||||||
component.editingAuthority = true;
|
component.editingAuthority = true;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
const inputElement = fixture.nativeElement.querySelector('input[data-test="authority-input"]');
|
||||||
|
expect(inputElement.disabled).toBeFalsy();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
const inputElement = fixture.nativeElement.querySelector('input');
|
|
||||||
expect(inputElement.disabled).toBe(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update mdValue.newValue properties when authority is present', () => {
|
it('should update mdValue.newValue properties when authority is present', () => {
|
||||||
|
@@ -3,6 +3,7 @@ import {
|
|||||||
fakeAsync,
|
fakeAsync,
|
||||||
TestBed,
|
TestBed,
|
||||||
tick,
|
tick,
|
||||||
|
waitForAsync,
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { NotifyRequestsStatusDataService } from 'src/app/core/data/notify-services-status-data.service';
|
import { NotifyRequestsStatusDataService } from 'src/app/core/data/notify-services-status-data.service';
|
||||||
@@ -10,6 +11,7 @@ import { NotifyRequestsStatusDataService } from 'src/app/core/data/notify-servic
|
|||||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils';
|
||||||
import { NotifyRequestsStatus } from '../notify-requests-status.model';
|
import { NotifyRequestsStatus } from '../notify-requests-status.model';
|
||||||
import { RequestStatusEnum } from '../notify-status.enum';
|
import { RequestStatusEnum } from '../notify-status.enum';
|
||||||
|
import { RequestStatusAlertBoxComponent } from '../request-status-alert-box/request-status-alert-box.component';
|
||||||
import { NotifyRequestsStatusComponent } from './notify-requests-status.component';
|
import { NotifyRequestsStatusComponent } from './notify-requests-status.component';
|
||||||
|
|
||||||
describe('NotifyRequestsStatusComponent', () => {
|
describe('NotifyRequestsStatusComponent', () => {
|
||||||
@@ -22,7 +24,7 @@ describe('NotifyRequestsStatusComponent', () => {
|
|||||||
itemuuid: 'testUuid',
|
itemuuid: 'testUuid',
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
notifyInfoServiceSpy = {
|
notifyInfoServiceSpy = {
|
||||||
getNotifyRequestsStatus:() => createSuccessfulRemoteDataObject$(mock),
|
getNotifyRequestsStatus:() => createSuccessfulRemoteDataObject$(mock),
|
||||||
};
|
};
|
||||||
@@ -31,8 +33,12 @@ describe('NotifyRequestsStatusComponent', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: NotifyRequestsStatusDataService, useValue: notifyInfoServiceSpy },
|
{ provide: NotifyRequestsStatusDataService, useValue: notifyInfoServiceSpy },
|
||||||
],
|
],
|
||||||
|
}).overrideComponent(NotifyRequestsStatusComponent, {
|
||||||
|
remove: {
|
||||||
|
imports: [RequestStatusAlertBoxComponent],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(NotifyRequestsStatusComponent);
|
fixture = TestBed.createComponent(NotifyRequestsStatusComponent);
|
||||||
|
@@ -1,10 +1,6 @@
|
|||||||
<ng-container *ngIf="data?.length > 0 && displayOptions">
|
<ng-container *ngIf="data?.length > 0 && displayOptions">
|
||||||
<div
|
<div [ngClass]="{'align-items-center': data.length === 1}"
|
||||||
[ngClass]="{'align-items-center': data.length === 1}"
|
class="alert d-flex flex-row sections-gap {{displayOptions.alertType}}">
|
||||||
class="alert d-flex flex-row sections-gap {{
|
|
||||||
displayOptions.alertType
|
|
||||||
}}"
|
|
||||||
>
|
|
||||||
<img
|
<img
|
||||||
class="source-logo"
|
class="source-logo"
|
||||||
src="assets/images/qa-coar-notify-logo.png"
|
src="assets/images/qa-coar-notify-logo.png"
|
||||||
@@ -14,17 +10,11 @@
|
|||||||
<ds-truncatable-part [id]="status" [minLines]="1">
|
<ds-truncatable-part [id]="status" [minLines]="1">
|
||||||
<div class="w-100 d-flex flex-column">
|
<div class="w-100 d-flex flex-column">
|
||||||
<ng-container *ngFor="let request of data">
|
<ng-container *ngFor="let request of data">
|
||||||
<div
|
<div [innerHTML]="displayOptions.text | translate: {
|
||||||
[innerHTML]="
|
|
||||||
displayOptions.text
|
|
||||||
| translate
|
|
||||||
: {
|
|
||||||
serviceName: request.serviceName,
|
serviceName: request.serviceName,
|
||||||
serviceUrl: request.serviceUrl,
|
serviceUrl: request.serviceUrl,
|
||||||
offerType: request.offerType
|
offerType: request.offerType
|
||||||
}
|
}"></div>
|
||||||
"
|
|
||||||
></div>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
|
@@ -2,9 +2,12 @@ import {
|
|||||||
ComponentFixture,
|
ComponentFixture,
|
||||||
fakeAsync,
|
fakeAsync,
|
||||||
TestBed,
|
TestBed,
|
||||||
|
waitForAsync,
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
|
import { TruncatableComponent } from '../../../../shared/truncatable/truncatable.component';
|
||||||
|
import { TruncatablePartComponent } from '../../../../shared/truncatable/truncatable-part/truncatable-part.component';
|
||||||
import { RequestStatusEnum } from '../notify-status.enum';
|
import { RequestStatusEnum } from '../notify-status.enum';
|
||||||
import { RequestStatusAlertBoxComponent } from './request-status-alert-box.component';
|
import { RequestStatusAlertBoxComponent } from './request-status-alert-box.component';
|
||||||
|
|
||||||
@@ -28,11 +31,15 @@ describe('RequestStatusAlertBoxComponent', () => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(waitForAsync(() => {
|
||||||
await TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), RequestStatusAlertBoxComponent],
|
imports: [TranslateModule.forRoot(), RequestStatusAlertBoxComponent],
|
||||||
|
}).overrideComponent(RequestStatusAlertBoxComponent, {
|
||||||
|
remove: {
|
||||||
|
imports: [TruncatablePartComponent, TruncatableComponent],
|
||||||
|
},
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(RequestStatusAlertBoxComponent);
|
fixture = TestBed.createComponent(RequestStatusAlertBoxComponent);
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
NgClass,
|
NgClass,
|
||||||
NgForOf,
|
NgForOf,
|
||||||
|
NgIf,
|
||||||
} from '@angular/common';
|
} from '@angular/common';
|
||||||
import {
|
import {
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
@@ -22,6 +23,7 @@ import { RequestStatusEnum } from '../notify-status.enum';
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
|
NgIf,
|
||||||
TruncatablePartComponent,
|
TruncatablePartComponent,
|
||||||
TruncatableComponent,
|
TruncatableComponent,
|
||||||
NgForOf,
|
NgForOf,
|
||||||
|
@@ -14,6 +14,7 @@ import { SearchConfigurationService } from '../core/shared/search/search-configu
|
|||||||
import { configureSearchComponentTestingModule } from '../shared/search/search.component.spec';
|
import { configureSearchComponentTestingModule } from '../shared/search/search.component.spec';
|
||||||
import { ConfigurationSearchPageComponent } from './configuration-search-page.component';
|
import { ConfigurationSearchPageComponent } from './configuration-search-page.component';
|
||||||
import createSpy = jasmine.createSpy;
|
import createSpy = jasmine.createSpy;
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
const CONFIGURATION = 'test-configuration';
|
const CONFIGURATION = 'test-configuration';
|
||||||
const QUERY = 'test query';
|
const QUERY = 'test query';
|
||||||
@@ -52,6 +53,7 @@ describe('ConfigurationSearchPageComponent', () => {
|
|||||||
|
|
||||||
routeService = TestBed.inject(RouteService);
|
routeService = TestBed.inject(RouteService);
|
||||||
routeService.setParameter = createSpy('setParameter');
|
routeService.setParameter = createSpy('setParameter');
|
||||||
|
routeService.getRouteParameterValue = createSpy('getRouteParameterValue').and.returnValue(of(CONFIGURATION));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
@@ -1,21 +1,13 @@
|
|||||||
|
import { AdminNotifySearchResultComponent } from '../../../../admin/admin-notify-dashboard/admin-notify-search-result/admin-notify-search-result.component';
|
||||||
|
import { AdminNotifySearchResult } from '../../../../admin/admin-notify-dashboard/models/admin-notify-message-search-result.model';
|
||||||
import { Context } from '../../../../core/shared/context.model';
|
import { Context } from '../../../../core/shared/context.model';
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||||
import { getTabulatableObjectsComponent } from './tabulatable-objects.decorator';
|
import { getTabulatableObjectsComponent } from './tabulatable-objects.decorator';
|
||||||
|
|
||||||
const type = 'TestType';
|
|
||||||
|
|
||||||
class TestTable {
|
|
||||||
}
|
|
||||||
describe('TabulatableObject decorator function', () => {
|
describe('TabulatableObject decorator function', () => {
|
||||||
|
|
||||||
it('should have a decorator for table', () => {
|
|
||||||
const tableDecorator = getTabulatableObjectsComponent(['Item'], ViewMode.Table);
|
|
||||||
expect(tableDecorator.length).not.toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should return the matching class', () => {
|
it('should return the matching class', () => {
|
||||||
const component = getTabulatableObjectsComponent([type], ViewMode.Table, Context.Search);
|
const component = getTabulatableObjectsComponent([AdminNotifySearchResult], ViewMode.Table, Context.CoarNotify);
|
||||||
expect(component).toEqual(TestTable);
|
expect(component).toEqual(AdminNotifySearchResultComponent);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user