diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.html b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.html index 0c9088cebcff3a2af6cfb04ffe3273ebed6e39f6..948be283b510f3091ef8044b9509fd6ea936b517 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.html +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.html @@ -23,7 +23,7 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<a routerLink="postfach"> +<a [routerLink]="onPage ? null : 'postfach'" data-test-class="incoming-mail-routing"> <div class="mail-head"> <div class="subject" data-test-id="mail-subject"> <mat-icon data-test-id="reply-icon">reply</mat-icon> diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.scss b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.scss index e0ac6f3a748f13674dc88e800b453dcf1316e82e..a7c44b0f07853d161e9e205a2a189f5ffabd67bb 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.scss +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.scss @@ -29,10 +29,6 @@ a { text-decoration: none; color: inherit; - - :host-context(.postfach-links-disabled) { - pointer-events: none; - } } .subject { diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.spec.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.spec.ts index e2a9572af4c3a17adcf142028db596f7c960f674..7ef16d31fb1312bf41e337a1c124ad35fdd96fea 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.spec.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/incomming-mail/incomming-mail.component.spec.ts @@ -23,11 +23,13 @@ */ import { ON_PAGE, PostfachMailLinkRel } from '@alfa-client/postfach-shared'; import { FormatDateWithTimePipe, HasLinkPipe } from '@alfa-client/tech-shared'; -import { getElementFromFixture } from '@alfa-client/test-utils'; +import { getDebugElementFromFixtureByCss, getElementFromFixture } from '@alfa-client/test-utils'; import { registerLocaleData } from '@angular/common'; import localeDe from '@angular/common/locales/de'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MatIcon } from '@angular/material/icon'; +import { provideRouter, RouterLinkWithHref, RouterModule } from '@angular/router'; +import { getDataTestClassOf, getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent } from 'ng-mocks'; import { createPostfachMailResource } from '../../../../../../../postfach-shared/test/postfach'; import { PostfachMailDateComponent } from '../postfach-mail-date/postfach-mail-date.component'; @@ -39,7 +41,8 @@ describe('IncommingMailComponent', () => { let component: IncommingMailComponent; let fixture: ComponentFixture<IncommingMailComponent>; - const attachmentIcon: string = '[data-test-id="postfach-nachricht-attachment-icon"]'; + const attachmentIcon: string = getDataTestIdOf('postfach-nachricht-attachment-icon'); + const routing: string = getDataTestClassOf('incoming-mail-routing'); beforeEach(async () => { await TestBed.configureTestingModule({ @@ -51,7 +54,9 @@ describe('IncommingMailComponent', () => { HasLinkPipe, MatIcon, ], + imports: [RouterModule], providers: [ + provideRouter([]), { provide: ON_PAGE, useValue: undefined, @@ -82,4 +87,26 @@ describe('IncommingMailComponent', () => { expect(element).toBeInstanceOf(HTMLElement); }); }); + + describe('routing should be', () => { + it('null on page site', () => { + component.onPage = false; + + fixture.detectChanges(); + + const routerElement = getDebugElementFromFixtureByCss(fixture, routing); + const routerLinkInstance: RouterLinkWithHref = (<any>routerElement).injector.get(RouterLinkWithHref); + expect((<any>routerLinkInstance).routerLinkInput[0]).toEqual('postfach'); + }); + + it('"postfach" on detail site', () => { + component.onPage = true; + + fixture.detectChanges(); + + const routerElement = getDebugElementFromFixtureByCss(fixture, routing); + const routerLinkInstance: RouterLinkWithHref = (<any>routerElement).injector.get(RouterLinkWithHref); + expect((<any>routerLinkInstance).routerLinkInput).toBeNull(); + }); + }); }); diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.html b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.html index c1fcab4f48bdba4b090c1ca3b5e9394efdb1296e..a3d8233fccdc8cd9d12bf0a8bc3537284981e667 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.html +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.html @@ -25,7 +25,8 @@ --> <a [ngClass]="{ error: postfachMail | hasLink: postfachNachrichtLinkRel.RESEND_POSTFACH_MAIL }" - routerLink="postfach" + [routerLink]="onPage ? null : 'postfach'" + data-test-class="outgoing-mail-routing" > <div class="mail-head"> <alfa-user-profile-in-postfach-mail-container @@ -53,9 +54,7 @@ > </a> -<alfa-outgoing-mail-error-container - [postfachMailResource]="postfachMail" -></alfa-outgoing-mail-error-container> +<alfa-outgoing-mail-error-container [postfachMailResource]="postfachMail"></alfa-outgoing-mail-error-container> <alfa-postfach-nachricht-edit-button-container *ngIf="(postfachMail | hasLink: postfachNachrichtLinkRel.EDIT) && !onPage" data-test-id="postfach-nachricht-edit-button-container" diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.scss b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.scss index f5ec610968b1d94cd8c7ed35d865c13eba8f88ad..3a27d85601ca856b02e95a6b99715706c2f674e0 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.scss +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.scss @@ -25,10 +25,6 @@ a { text-decoration: none; color: inherit; - :host-context(.postfach-links-disabled) { - pointer-events: none; - } - .message { margin-bottom: 0.25rem; } diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.spec.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.spec.ts index bda7d7fa45697697fadf51fc146533788a1c3210..1c5549014cf02065fcac328e8e38dbd3505f9f98 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.spec.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component.spec.ts @@ -21,19 +21,21 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MatIcon } from '@angular/material/icon'; import { ON_PAGE, PostfachMailLinkRel, PostfachMailResource } from '@alfa-client/postfach-shared'; -import { HasLinkPipe, StateResource, createStateResource } from '@alfa-client/tech-shared'; +import { createStateResource, HasLinkPipe, StateResource } from '@alfa-client/tech-shared'; import { existsAsHtmlElement, + getDebugElementFromFixtureByCss, getElementFromFixture, getMockComponent, notExistsAsHtmlElement, } from '@alfa-client/test-utils'; import { UserProfileInPostfachMailContainerComponent } from '@alfa-client/user-profile'; import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; -import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { MatIcon } from '@angular/material/icon'; +import { provideRouter, RouterLinkWithHref, RouterModule } from '@angular/router'; +import { getDataTestClassOf, getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; import { MockComponent } from 'ng-mocks'; import { createPostfachMailResource } from '../../../../../../../postfach-shared/test/postfach'; @@ -50,6 +52,8 @@ describe('OutgoingMailComponent', () => { const postfachEditButton: string = getDataTestIdOf('postfach-nachricht-edit-button-container'); const postfachOutgoingNachrichtDate: string = getDataTestIdOf('postfach-outgoing-nachricht-date'); + const routing: string = getDataTestClassOf('outgoing-mail-routing'); + beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [ @@ -62,7 +66,9 @@ describe('OutgoingMailComponent', () => { MockComponent(PostfachMailDateComponent), MockComponent(PostfachNachrichtEditButtonContainerComponent), ], + imports: [RouterModule], providers: [ + provideRouter([]), { provide: ON_PAGE, useValue: undefined, @@ -95,9 +101,7 @@ describe('OutgoingMailComponent', () => { }); describe('edit button container component', () => { - const postfachNachricht: PostfachMailResource = createPostfachMailResource([ - PostfachMailLinkRel.EDIT, - ]); + const postfachNachricht: PostfachMailResource = createPostfachMailResource([PostfachMailLinkRel.EDIT]); describe('on existing edit link', () => { beforeEach(() => { @@ -151,9 +155,7 @@ describe('OutgoingMailComponent', () => { }); describe('in detail context', () => { - const postfachNachricht: PostfachMailResource = createPostfachMailResource([ - PostfachMailLinkRel.EDIT, - ]); + const postfachNachricht: PostfachMailResource = createPostfachMailResource([PostfachMailLinkRel.EDIT]); beforeEach(() => { component.onPage = true; @@ -185,4 +187,26 @@ describe('OutgoingMailComponent', () => { notExistsAsHtmlElement(fixture, postfachOutgoingNachrichtDate); }); }); + + describe('routing should be', () => { + it('null on page site', () => { + component.onPage = false; + + fixture.detectChanges(); + + const routerElement = getDebugElementFromFixtureByCss(fixture, routing); + const routerLinkInstance: RouterLinkWithHref = routerElement.injector.get(RouterLinkWithHref); + expect((<any>routerLinkInstance).routerLinkInput[0]).toEqual('postfach'); + }); + + it('"postfach" on detail site', () => { + component.onPage = true; + + fixture.detectChanges(); + + const routerElement = getDebugElementFromFixtureByCss(fixture, routing); + const routerLinkInstance: RouterLinkWithHref = routerElement.injector.get(RouterLinkWithHref); + expect((<any>routerLinkInstance).routerLinkInput).toBeNull(); + }); + }); }); diff --git a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page-mail-list/postfach-page-mail-list.component.html b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page-mail-list/postfach-page-mail-list.component.html index 0d0efa20640f413bdc4ab0d7ef083e321f1b0beb..9d74f0c569922238813f128c9def3394b701e647 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page-mail-list/postfach-page-mail-list.component.html +++ b/alfa-client/libs/postfach/src/lib/postfach-page-container/postfach-page/postfach-page-mail-list/postfach-page-mail-list.component.html @@ -26,11 +26,10 @@ <ozgcloud-spinner *ngIf="postfachMailListStateResource"> <alfa-postfach-mail *ngFor=" - let postfachMail of postfachMailListStateResource.resource - | toEmbeddedResources: postfachMailListLinkRel.POSTFACH_MAIL_LIST + let postfachMail of postfachMailListStateResource.resource | toEmbeddedResources: postfachMailListLinkRel.POSTFACH_MAIL_LIST " [attr.data-test-id]="(postfachMail.subject | convertForDataTest) + '-item'" - class="postfach postfach-links-disabled w-full lg:w-1/2" + class="postfach w-full lg:w-1/2" [postfachMail]="postfachMail" > </alfa-postfach-mail>