Skip to content
Snippets Groups Projects
Commit cf118868 authored by Martin's avatar Martin
Browse files

OZG-7593 add condition for routerLink

parent db38a189
Branches
Tags
1 merge request!65Ozg 7593 button erneut vesuchen bug
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
unter der Lizenz sind dem Lizenztext zu entnehmen. 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="mail-head">
<div class="subject" data-test-id="mail-subject"> <div class="subject" data-test-id="mail-subject">
<mat-icon data-test-id="reply-icon">reply</mat-icon> <mat-icon data-test-id="reply-icon">reply</mat-icon>
......
...@@ -23,11 +23,13 @@ ...@@ -23,11 +23,13 @@
*/ */
import { ON_PAGE, PostfachMailLinkRel } from '@alfa-client/postfach-shared'; import { ON_PAGE, PostfachMailLinkRel } from '@alfa-client/postfach-shared';
import { FormatDateWithTimePipe, HasLinkPipe } from '@alfa-client/tech-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 { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de'; import localeDe from '@angular/common/locales/de';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatIcon } from '@angular/material/icon'; 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 { MockComponent } from 'ng-mocks';
import { createPostfachMailResource } from '../../../../../../../postfach-shared/test/postfach'; import { createPostfachMailResource } from '../../../../../../../postfach-shared/test/postfach';
import { PostfachMailDateComponent } from '../postfach-mail-date/postfach-mail-date.component'; import { PostfachMailDateComponent } from '../postfach-mail-date/postfach-mail-date.component';
...@@ -39,7 +41,8 @@ describe('IncommingMailComponent', () => { ...@@ -39,7 +41,8 @@ describe('IncommingMailComponent', () => {
let component: IncommingMailComponent; let component: IncommingMailComponent;
let fixture: ComponentFixture<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 () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
...@@ -51,7 +54,9 @@ describe('IncommingMailComponent', () => { ...@@ -51,7 +54,9 @@ describe('IncommingMailComponent', () => {
HasLinkPipe, HasLinkPipe,
MatIcon, MatIcon,
], ],
imports: [RouterModule],
providers: [ providers: [
provideRouter([]),
{ {
provide: ON_PAGE, provide: ON_PAGE,
useValue: undefined, useValue: undefined,
...@@ -82,4 +87,26 @@ describe('IncommingMailComponent', () => { ...@@ -82,4 +87,26 @@ describe('IncommingMailComponent', () => {
expect(element).toBeInstanceOf(HTMLElement); 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();
});
});
}); });
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
--> -->
<a <a
[ngClass]="{ error: postfachMail | hasLink: postfachNachrichtLinkRel.RESEND_POSTFACH_MAIL }" [ngClass]="{ error: postfachMail | hasLink: postfachNachrichtLinkRel.RESEND_POSTFACH_MAIL }"
routerLink="postfach" [routerLink]="onPage ? null : 'postfach'"
data-test-class="outgoing-mail-routing"
> >
<div class="mail-head"> <div class="mail-head">
<alfa-user-profile-in-postfach-mail-container <alfa-user-profile-in-postfach-mail-container
...@@ -53,9 +54,7 @@ ...@@ -53,9 +54,7 @@
> >
</a> </a>
<alfa-outgoing-mail-error-container <alfa-outgoing-mail-error-container [postfachMailResource]="postfachMail"></alfa-outgoing-mail-error-container>
[postfachMailResource]="postfachMail"
></alfa-outgoing-mail-error-container>
<alfa-postfach-nachricht-edit-button-container <alfa-postfach-nachricht-edit-button-container
*ngIf="(postfachMail | hasLink: postfachNachrichtLinkRel.EDIT) && !onPage" *ngIf="(postfachMail | hasLink: postfachNachrichtLinkRel.EDIT) && !onPage"
data-test-id="postfach-nachricht-edit-button-container" data-test-id="postfach-nachricht-edit-button-container"
......
...@@ -21,19 +21,21 @@ ...@@ -21,19 +21,21 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen * Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen. * 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 { 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 { import {
existsAsHtmlElement, existsAsHtmlElement,
getDebugElementFromFixtureByCss,
getElementFromFixture, getElementFromFixture,
getMockComponent, getMockComponent,
notExistsAsHtmlElement, notExistsAsHtmlElement,
} from '@alfa-client/test-utils'; } from '@alfa-client/test-utils';
import { UserProfileInPostfachMailContainerComponent } from '@alfa-client/user-profile'; import { UserProfileInPostfachMailContainerComponent } from '@alfa-client/user-profile';
import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; 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 { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { createPostfachMailResource } from '../../../../../../../postfach-shared/test/postfach'; import { createPostfachMailResource } from '../../../../../../../postfach-shared/test/postfach';
...@@ -50,6 +52,8 @@ describe('OutgoingMailComponent', () => { ...@@ -50,6 +52,8 @@ describe('OutgoingMailComponent', () => {
const postfachEditButton: string = getDataTestIdOf('postfach-nachricht-edit-button-container'); const postfachEditButton: string = getDataTestIdOf('postfach-nachricht-edit-button-container');
const postfachOutgoingNachrichtDate: string = getDataTestIdOf('postfach-outgoing-nachricht-date'); const postfachOutgoingNachrichtDate: string = getDataTestIdOf('postfach-outgoing-nachricht-date');
const routing: string = getDataTestClassOf('outgoing-mail-routing');
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ declarations: [
...@@ -62,7 +66,9 @@ describe('OutgoingMailComponent', () => { ...@@ -62,7 +66,9 @@ describe('OutgoingMailComponent', () => {
MockComponent(PostfachMailDateComponent), MockComponent(PostfachMailDateComponent),
MockComponent(PostfachNachrichtEditButtonContainerComponent), MockComponent(PostfachNachrichtEditButtonContainerComponent),
], ],
imports: [RouterModule],
providers: [ providers: [
provideRouter([]),
{ {
provide: ON_PAGE, provide: ON_PAGE,
useValue: undefined, useValue: undefined,
...@@ -95,9 +101,7 @@ describe('OutgoingMailComponent', () => { ...@@ -95,9 +101,7 @@ describe('OutgoingMailComponent', () => {
}); });
describe('edit button container component', () => { describe('edit button container component', () => {
const postfachNachricht: PostfachMailResource = createPostfachMailResource([ const postfachNachricht: PostfachMailResource = createPostfachMailResource([PostfachMailLinkRel.EDIT]);
PostfachMailLinkRel.EDIT,
]);
describe('on existing edit link', () => { describe('on existing edit link', () => {
beforeEach(() => { beforeEach(() => {
...@@ -151,9 +155,7 @@ describe('OutgoingMailComponent', () => { ...@@ -151,9 +155,7 @@ describe('OutgoingMailComponent', () => {
}); });
describe('in detail context', () => { describe('in detail context', () => {
const postfachNachricht: PostfachMailResource = createPostfachMailResource([ const postfachNachricht: PostfachMailResource = createPostfachMailResource([PostfachMailLinkRel.EDIT]);
PostfachMailLinkRel.EDIT,
]);
beforeEach(() => { beforeEach(() => {
component.onPage = true; component.onPage = true;
...@@ -185,4 +187,26 @@ describe('OutgoingMailComponent', () => { ...@@ -185,4 +187,26 @@ describe('OutgoingMailComponent', () => {
notExistsAsHtmlElement(fixture, postfachOutgoingNachrichtDate); 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();
});
});
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment