mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 20:43:08 +00:00
Merged coar-notify-7 into CST-12498
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// ... test imports
|
// ... test imports
|
||||||
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, inject, TestBed,waitForAsync } from '@angular/core/testing';
|
||||||
|
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@ import { By } from '@angular/platform-browser';
|
|||||||
|
|
||||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
import { StoreModule } from '@ngrx/store';
|
import { StoreModule } from '@ngrx/store';
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
// Load the implementations that should be tested
|
// Load the implementations that should be tested
|
||||||
import { FooterComponent } from './footer.component';
|
import { FooterComponent } from './footer.component';
|
||||||
@@ -18,22 +19,21 @@ import { storeModuleConfig } from '../app.reducer';
|
|||||||
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
|
||||||
import { AuthorizationDataServiceStub } from '../shared/testing/authorization-service.stub';
|
import { AuthorizationDataServiceStub } from '../shared/testing/authorization-service.stub';
|
||||||
import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service';
|
import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service';
|
||||||
import { of } from 'rxjs';
|
import { environment } from 'src/environments/environment';
|
||||||
|
|
||||||
|
|
||||||
let comp: FooterComponent;
|
let comp: FooterComponent;
|
||||||
|
let compAny: any;
|
||||||
let fixture: ComponentFixture<FooterComponent>;
|
let fixture: ComponentFixture<FooterComponent>;
|
||||||
let de: DebugElement;
|
let de: DebugElement;
|
||||||
let el: HTMLElement;
|
let el: HTMLElement;
|
||||||
|
|
||||||
let notifyInfoServiceStub: any;
|
let notifyInfoService = {
|
||||||
|
|
||||||
describe('Footer component', () => {
|
|
||||||
|
|
||||||
// waitForAsync beforeEach
|
|
||||||
beforeEach(waitForAsync(() => {
|
|
||||||
notifyInfoServiceStub = {
|
|
||||||
isCoarConfigEnabled: () => of(true)
|
isCoarConfigEnabled: () => of(true)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
describe('Footer component', () => {
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
return TestBed.configureTestingModule({
|
return TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot({
|
imports: [CommonModule, StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot({
|
||||||
loader: {
|
loader: {
|
||||||
@@ -45,7 +45,7 @@ describe('Footer component', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
FooterComponent,
|
FooterComponent,
|
||||||
{ provide: AuthorizationDataService, useClass: AuthorizationDataServiceStub },
|
{ provide: AuthorizationDataService, useClass: AuthorizationDataServiceStub },
|
||||||
{ provide: NotifyInfoService, useValue: notifyInfoServiceStub },
|
{ provide: NotifyInfoService, useValue: notifyInfoService }
|
||||||
],
|
],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
});
|
});
|
||||||
@@ -54,9 +54,8 @@ describe('Footer component', () => {
|
|||||||
// synchronous beforeEach
|
// synchronous beforeEach
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(FooterComponent);
|
fixture = TestBed.createComponent(FooterComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
comp = fixture.componentInstance; // component test instance
|
compAny = comp as any;
|
||||||
|
|
||||||
// query for the title <p> by CSS element selector
|
// query for the title <p> by CSS element selector
|
||||||
de = fixture.debugElement.query(By.css('p'));
|
de = fixture.debugElement.query(By.css('p'));
|
||||||
el = de.nativeElement;
|
el = de.nativeElement;
|
||||||
@@ -67,4 +66,56 @@ describe('Footer component', () => {
|
|||||||
expect(app).toBeTruthy();
|
expect(app).toBeTruthy();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should set showPrivacyPolicy to the value of environment.info.enablePrivacyStatement', () => {
|
||||||
|
expect(comp.showPrivacyPolicy).toBe(environment.info.enablePrivacyStatement);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set showEndUserAgreement to the value of environment.info.enableEndUserAgreement', () => {
|
||||||
|
expect(comp.showEndUserAgreement).toBe(environment.info.enableEndUserAgreement);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('showCookieSettings', () => {
|
||||||
|
it('should call cookies.showSettings() if cookies is defined', () => {
|
||||||
|
const cookies = jasmine.createSpyObj('cookies', ['showSettings']);
|
||||||
|
compAny.cookies = cookies;
|
||||||
|
comp.showCookieSettings();
|
||||||
|
expect(cookies.showSettings).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not call cookies.showSettings() if cookies is undefined', () => {
|
||||||
|
compAny.cookies = undefined;
|
||||||
|
expect(() => comp.showCookieSettings()).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false', () => {
|
||||||
|
expect(comp.showCookieSettings()).toBeFalse();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when coarLdnEnabled is true', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(notifyInfoService, 'isCoarConfigEnabled').and.returnValue(of(true));
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set coarLdnEnabled based on notifyInfoService', () => {
|
||||||
|
expect(comp.coarLdnEnabled).toBeTruthy();
|
||||||
|
// Check if COAR Notify section is rendered
|
||||||
|
const notifySection = fixture.debugElement.query(By.css('.notify-enabled'));
|
||||||
|
expect(notifySection).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should redirect to info/coar-notify-support', () => {
|
||||||
|
// Check if the link to the COAR Notify support page is present
|
||||||
|
const routerLink = fixture.debugElement.query(By.css('a[routerLink="info/coar-notify-support"].coar-notify-support-route'));
|
||||||
|
expect(routerLink).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have an img tag with the class "n-coar" when coarLdnEnabled is true', fakeAsync(() => {
|
||||||
|
// Check if the img tag with the class "n-coar" is present
|
||||||
|
const imgTag = fixture.debugElement.query(By.css('.notify-enabled img.n-coar'));
|
||||||
|
expect(imgTag).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -60,6 +60,16 @@
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
[routerLink]="['/items', eventElement?.target?.id]">{{eventElement.title}}</a>
|
[routerLink]="['/items', eventElement?.target?.id]">{{eventElement.title}}</a>
|
||||||
<span *ngIf="!eventElement?.target">{{eventElement.title}}</span>
|
<span *ngIf="!eventElement?.target">{{eventElement.title}}</span>
|
||||||
|
<div *ngIf="eventElement?.event?.message?.serviceName">
|
||||||
|
<span class="small pr-1">{{'quality-assurance.event.table.event.message.serviceName' | translate}}</span>
|
||||||
|
<span class="badge badge-info">{{eventElement.event.message.serviceName}}</span>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="eventElement?.event?.message?.href" class="d-flex align-items-center">
|
||||||
|
<span class="small pr-1">{{'quality-assurance.event.table.event.message.link' | translate}}</span>
|
||||||
|
<span [title]="eventElement.event.message.href" class="text-truncate d-inline-block w-75">
|
||||||
|
<a [href]="eventElement.event.message.href" target="_blank">{{eventElement.event.message.href}}</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td *ngIf="showTopic.indexOf('/PID') !== -1">
|
<td *ngIf="showTopic.indexOf('/PID') !== -1">
|
||||||
<p><span class="small">{{'quality-assurance.event.table.pidtype' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.type}}</span></p>
|
<p><span class="small">{{'quality-assurance.event.table.pidtype' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.type}}</span></p>
|
||||||
|
@@ -3375,6 +3375,10 @@
|
|||||||
|
|
||||||
"quality-assurance.event.table.more": "Show more",
|
"quality-assurance.event.table.more": "Show more",
|
||||||
|
|
||||||
|
"quality-assurance.event.table.event.message.serviceName": "Service Name:",
|
||||||
|
|
||||||
|
"quality-assurance.event.table.event.message.link": "Link:",
|
||||||
|
|
||||||
"quality-assurance.event.project.found": "Bound to the local record:",
|
"quality-assurance.event.project.found": "Bound to the local record:",
|
||||||
|
|
||||||
"quality-assurance.event.project.notFound": "No local record found",
|
"quality-assurance.event.project.notFound": "No local record found",
|
||||||
|
Reference in New Issue
Block a user