From 77261839394c1befe61b80835e5cf57a53412376 Mon Sep 17 00:00:00 2001 From: Alisa Ismailati Date: Fri, 17 Nov 2023 15:20:00 +0100 Subject: [PATCH 1/2] [CST-12147] display serive name & link for notify-coar events --- .../qa/events/quality-assurance-events.component.html | 10 ++++++++++ src/assets/i18n/en.json5 | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.html b/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.html index d5e8a5c709e..5b4757ce8bc 100644 --- a/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.html +++ b/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.html @@ -60,6 +60,16 @@

target="_blank" [routerLink]="['/items', eventElement?.target?.id]">{{eventElement.title}} {{eventElement.title}} +
+ {{'quality-assurance.event.table.event.message.serviceName' | translate}} + {{eventElement.event.message.serviceName}} +
+
+ {{'quality-assurance.event.table.event.message.link' | translate}} + + {{eventElement.event.message.href}} + +

{{'quality-assurance.event.table.pidtype' | translate}} {{eventElement.event.message.type}}

diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index fecd9113d64..e01964a4fb8 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3375,6 +3375,10 @@ "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.notFound": "No local record found", From 53ba509ff9f052d3291a171d8de8099fd82b5504 Mon Sep 17 00:00:00 2001 From: Alisa Ismailati Date: Fri, 17 Nov 2023 17:18:16 +0100 Subject: [PATCH 2/2] [CST-11523] footer component unit tests --- src/app/footer/footer.component.spec.ts | 75 +++++++++++++++++++++---- 1 file changed, 63 insertions(+), 12 deletions(-) diff --git a/src/app/footer/footer.component.spec.ts b/src/app/footer/footer.component.spec.ts index 0d6069ece8e..010d4e22c2f 100644 --- a/src/app/footer/footer.component.spec.ts +++ b/src/app/footer/footer.component.spec.ts @@ -1,5 +1,5 @@ // ... 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'; @@ -9,6 +9,7 @@ import { By } from '@angular/platform-browser'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { StoreModule } from '@ngrx/store'; +import { of } from 'rxjs'; // Load the implementations that should be tested 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 { AuthorizationDataServiceStub } from '../shared/testing/authorization-service.stub'; 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 compAny: any; let fixture: ComponentFixture; let de: DebugElement; let el: HTMLElement; -let notifyInfoServiceStub: any; +let notifyInfoService = { + isCoarConfigEnabled: () => of(true) +}; describe('Footer component', () => { - - // waitForAsync beforeEach beforeEach(waitForAsync(() => { - notifyInfoServiceStub = { - isCoarConfigEnabled: () => of(true) - }; return TestBed.configureTestingModule({ imports: [CommonModule, StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot({ loader: { @@ -45,7 +45,7 @@ describe('Footer component', () => { providers: [ FooterComponent, { provide: AuthorizationDataService, useClass: AuthorizationDataServiceStub }, - { provide: NotifyInfoService, useValue: notifyInfoServiceStub }, + { provide: NotifyInfoService, useValue: notifyInfoService } ], schemas: [CUSTOM_ELEMENTS_SCHEMA] }); @@ -54,9 +54,8 @@ describe('Footer component', () => { // synchronous beforeEach beforeEach(() => { fixture = TestBed.createComponent(FooterComponent); - - comp = fixture.componentInstance; // component test instance - + comp = fixture.componentInstance; + compAny = comp as any; // query for the title

by CSS element selector de = fixture.debugElement.query(By.css('p')); el = de.nativeElement; @@ -67,4 +66,56 @@ describe('Footer component', () => { 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(); + })); + }); });