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

OZG-7593 add condition for routerLink

parent db38a189
No related branches found
No related tags found
1 merge request!65Ozg 7593 button erneut vesuchen bug
......@@ -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>
......
......@@ -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();
});
});
});
......@@ -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"
......
......@@ -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();
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment