Skip to content
Snippets Groups Projects
Commit 7c0626f4 authored by Albert Bruns's avatar Albert Bruns
Browse files

OZG-7773 mail-unread-link button

parent 3a2f67b7
No related branches found
No related tags found
2 merge requests!122OZG-7773-Nachrichten-auf-ungelesen-setzen-e2e,!120OZG-7773-Nachrichten-auf-ungelesen-setzen
Showing
with 164 additions and 48 deletions
...@@ -61,7 +61,7 @@ export class MailboxIconComponent { ...@@ -61,7 +61,7 @@ export class MailboxIconComponent {
@Input() size: IconVariants['size'] = 'medium'; @Input() size: IconVariants['size'] = 'medium';
@Input() class: string = undefined; @Input() class: string = undefined;
@Input() showBadge: boolean = false; @Input() showBadge: boolean = false;
@Input() badgeClass: string = undefined; @Input() badgeClass: string = 'bg-primary';
readonly iconVariants = iconVariants; readonly iconVariants = iconVariants;
readonly twMerge = twMerge; readonly twMerge = twMerge;
......
@if(hasNewPostfachNachricht){ @if(hasNewPostfachNachricht){
<ods-mailbox-icon showBadge="true" badgeClass="bg-blue-500"/> <ods-mailbox-icon showBadge="true"/>
}@else{ }@else{
<ods-mailbox-icon/> <ods-mailbox-icon/>
} }
\ No newline at end of file
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
* 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 { Component, Input } from '@angular/core';
import { PostfachMailListLinkRel, PostfachMailListResource } from '@alfa-client/postfach-shared'; import { PostfachMailListLinkRel, PostfachMailListResource } from '@alfa-client/postfach-shared';
import { StateResource } from '@alfa-client/tech-shared'; import { StateResource } from '@alfa-client/tech-shared';
import { VorgangHeaderLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { Component, Input } from '@angular/core';
@Component({ @Component({
selector: 'alfa-postfach-mail-list', selector: 'alfa-postfach-mail-list',
...@@ -36,5 +36,4 @@ export class PostfachMailListComponent { ...@@ -36,5 +36,4 @@ export class PostfachMailListComponent {
@Input() vorgangStateResource: StateResource<VorgangWithEingangResource>; @Input() vorgangStateResource: StateResource<VorgangWithEingangResource>;
readonly postfachMailListLinkRel = PostfachMailListLinkRel; readonly postfachMailListLinkRel = PostfachMailListLinkRel;
readonly vorgangHeaderLinkRel = VorgangHeaderLinkRel;
} }
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
* 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 { PostfachMailListResource, PostfachService } from '@alfa-client/postfach-shared';
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { PostfachMailResource, PostfachService } from '@alfa-client/postfach-shared';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@Component({ @Component({
...@@ -31,7 +31,7 @@ import { Observable } from 'rxjs'; ...@@ -31,7 +31,7 @@ import { Observable } from 'rxjs';
styleUrls: ['./postfach-mail-pdf-button-container.component.scss'], styleUrls: ['./postfach-mail-pdf-button-container.component.scss'],
}) })
export class PostfachMailPdfButtonContainerComponent implements OnInit { export class PostfachMailPdfButtonContainerComponent implements OnInit {
@Input() postfachMailListResource: PostfachMailResource; @Input() postfachMailListResource: PostfachMailListResource;
@Input() showButtonWithLabel: boolean = false; @Input() showButtonWithLabel: boolean = false;
isDownloadPdfInProgress$: Observable<boolean>; isDownloadPdfInProgress$: Observable<boolean>;
......
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
tooltipAriaType="aria-labelledby" tooltipAriaType="aria-labelledby"
variant="ghost" variant="ghost"
size="fit" size="fit"
dataTestId="mail-unread-icon-button" dataTestId="mail-unread-icon-button-link"
data-test-id="mail-unread-icon-button-link-host"
> >
<ods-mail-unread-icon icon class="fill-text" /> <ods-mail-unread-icon icon />
</ods-button> </ods-button>
</a> </a>
} @else { } @else {
...@@ -19,9 +20,10 @@ ...@@ -19,9 +20,10 @@
[tooltip]="'Nachrichten als ungelesen markieren'" [tooltip]="'Nachrichten als ungelesen markieren'"
text="Als ungelesen markieren" text="Als ungelesen markieren"
variant="outline" variant="outline"
dataTestId="mail-unread-button" dataTestId="mail-unread-button-link"
data-test-id="mail-unread-button-link-host"
> >
<ods-mail-unread-icon icon /> <ods-mail-unread-icon icon class="fill-primary"/>
</ods-button> </ods-button>
</a> </a>
} }
......
import { PostfachMailListLinkRel, PostfachMailListResource, PostfachService } from '@alfa-client/postfach-shared';
import { createEmptyStateResource, createStateResource, HasLinkPipe, StateResource } from '@alfa-client/tech-shared';
import {
dispatchEventFromFixture,
existsAsHtmlElement,
mock,
Mock,
MockEvent,
notExistsAsHtmlElement,
} from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterModule } from '@angular/router';
import { ButtonComponent, MailUnreadIconComponent } from '@ods/system';
import { MockComponent } from 'ng-mocks';
import { createPostfachMailListResource } from '../../../../../../postfach-shared/test/postfach';
import { getDataTestIdOf } from '../../../../../../tech-shared/test/data-test';
import { MailUnreadButtonLinkContainerComponent } from './mail-unread-button-link-container.component';
describe('MailUnreadButtonLinkContainerComponent', () => {
let component: MailUnreadButtonLinkContainerComponent;
let fixture: ComponentFixture<MailUnreadButtonLinkContainerComponent>;
let postfachService: Mock<PostfachService>;
const postfachMailListStateResource: StateResource<PostfachMailListResource> = createStateResource(
createPostfachMailListResource([PostfachMailListLinkRel.SET_HAS_NEW_POSTFACH_NACHRICHT]),
);
const button: string = getDataTestIdOf('mail-unread-button-link-host');
const iconButton: string = getDataTestIdOf('mail-unread-icon-button-link-host');
beforeEach(async () => {
postfachService = mock(PostfachService);
await TestBed.configureTestingModule({
imports: [MailUnreadButtonLinkContainerComponent, HasLinkPipe, RouterModule.forRoot([])],
declarations: [MockComponent(ButtonComponent), MockComponent(MailUnreadIconComponent)],
providers: [
{
provide: PostfachService,
useValue: postfachService,
},
],
}).compileComponents();
fixture = TestBed.createComponent(MailUnreadButtonLinkContainerComponent);
component = fixture.componentInstance;
component.postfachMailListStateResource = postfachMailListStateResource;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
describe('component', () => {
describe('mark mail as unread', () => {
it('should call set hasNewPostfachNachrichten to true', () => {
component.markMailAsUnread();
expect(postfachService.setHasNewPostfachNachrichten).toHaveBeenCalledWith(true);
});
});
});
describe('template', () => {
it('no button should exist', () => {});
describe('icon button', () => {
it('should exist', () => {
component.showAsIconButton = true;
fixture.detectChanges();
existsAsHtmlElement(fixture, iconButton);
});
it('should not exist if link does not exist', () => {
component.showAsIconButton = true;
component.postfachMailListStateResource = createEmptyStateResource();
fixture.detectChanges();
notExistsAsHtmlElement(fixture, iconButton);
});
it('should not exist if not shown as icon button', () => {
component.showAsIconButton = false;
fixture.detectChanges();
notExistsAsHtmlElement(fixture, iconButton);
});
it('should call markMailAsUnread on click', () => {
component.showAsIconButton = true;
component.markMailAsUnread = jest.fn();
fixture.detectChanges();
dispatchEventFromFixture(fixture, iconButton, MockEvent.CLICK);
expect(component.markMailAsUnread).toHaveBeenCalled();
});
});
});
describe('button', () => {
it('should exist', () => {
component.showAsIconButton = false;
fixture.detectChanges();
existsAsHtmlElement(fixture, button);
});
it('should not exist if link does not exist', () => {
component.showAsIconButton = false;
component.postfachMailListStateResource = createEmptyStateResource();
fixture.detectChanges();
notExistsAsHtmlElement(fixture, button);
});
it('should not exist if shown as icon button', () => {
component.showAsIconButton = true;
fixture.detectChanges();
notExistsAsHtmlElement(fixture, button);
});
it('should call markMailAsUnread on click', () => {
component.showAsIconButton = false;
component.markMailAsUnread = jest.fn();
fixture.detectChanges();
dispatchEventFromFixture(fixture, button, MockEvent.CLICK);
expect(component.markMailAsUnread).toHaveBeenCalled();
});
});
});
import { CommandResource } from '@alfa-client/command-shared'; import { CommandResource } from '@alfa-client/command-shared';
import { PostfachMailListLinkRel, PostfachMailListResource, PostfachService } from '@alfa-client/postfach-shared'; import { PostfachMailListLinkRel, PostfachMailListResource, PostfachService } from '@alfa-client/postfach-shared';
import { createEmptyStateResource, HasLinkPipe, StateResource } from '@alfa-client/tech-shared'; import { createEmptyStateResource, HasLinkPipe, StateResource } from '@alfa-client/tech-shared';
import { AsyncPipe } from '@angular/common';
import { Component, inject, Input } from '@angular/core'; import { Component, inject, Input } from '@angular/core';
import { RouterLink } from '@angular/router'; import { RouterLink } from '@angular/router';
import { ButtonWithSpinnerComponent } from '@ods/component';
import { ButtonComponent, MailUnreadIconComponent, TooltipDirective } from '@ods/system'; import { ButtonComponent, MailUnreadIconComponent, TooltipDirective } from '@ods/system';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
@Component({ @Component({
selector: 'alfa-postfach-page-mail-unread-button', selector: 'alfa-mail-unread-button-link-container',
standalone: true, standalone: true,
imports: [ imports: [HasLinkPipe, MailUnreadIconComponent, TooltipDirective, ButtonComponent, RouterLink],
ButtonWithSpinnerComponent, templateUrl: './mail-unread-button-link-container.component.html',
HasLinkPipe,
MailUnreadIconComponent,
AsyncPipe,
TooltipDirective,
ButtonComponent,
RouterLink,
],
templateUrl: './mail-unread-button.component.html',
}) })
export class PostfachPageMailUnreadButtonComponent { export class MailUnreadButtonLinkContainerComponent {
private readonly postfachService = inject(PostfachService); private readonly postfachService = inject(PostfachService);
@Input() postfachMailListStateResource: StateResource<PostfachMailListResource>; @Input() postfachMailListStateResource: StateResource<PostfachMailListResource>;
......
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PostfachPageMailUnreadButtonComponent } from './mail-unread-button.component';
describe('MailUnreadButtonComponent', () => {
let component: PostfachPageMailUnreadButtonComponent;
let fixture: ComponentFixture<PostfachPageMailUnreadButtonComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PostfachPageMailUnreadButtonComponent],
}).compileComponents();
fixture = TestBed.createComponent(PostfachPageMailUnreadButtonComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
--> -->
<ozgcloud-subnavigation class="mat-typography mat-app-background"> <ozgcloud-subnavigation class="mat-typography mat-app-background">
<ozgcloud-back-button linkTo="../" label="zurück zur Detailseite" /> <ozgcloud-back-button linkTo="../" label="zurück zur Detailseite" />
<alfa-postfach-page-mail-unread-button <alfa-mail-unread-button-link-container
[postfachMailListStateResource]="postfachMailListStateResource" [postfachMailListStateResource]="postfachMailListStateResource"
showAsIconButton="true" showAsIconButton="true"
/> />
......
...@@ -64,6 +64,9 @@ import { PostfachPageContainerComponent } from './postfach-page-container/postfa ...@@ -64,6 +64,9 @@ import { PostfachPageContainerComponent } from './postfach-page-container/postfa
import { PostfachPageMailUnreadButtonComponent } from './postfach-page-container/postfach-page/mail-unread-button/mail-unread-button.component'; import { PostfachPageMailUnreadButtonComponent } from './postfach-page-container/postfach-page/mail-unread-button/mail-unread-button.component';
import { PostfachPageMailListComponent } from './postfach-page-container/postfach-page/postfach-page-mail-list/postfach-page-mail-list.component'; import { PostfachPageMailListComponent } from './postfach-page-container/postfach-page/postfach-page-mail-list/postfach-page-mail-list.component';
import { PostfachPageComponent } from './postfach-page-container/postfach-page/postfach-page.component'; import { PostfachPageComponent } from './postfach-page-container/postfach-page/postfach-page.component';
import {
MailUnreadButtonLinkContainerComponent
} from "./postfach-page-container/postfach-page/mail-unread-button/mail-unread-button-link-container.component";
const routes: Routes = [ const routes: Routes = [
{ {
...@@ -104,6 +107,7 @@ const routes: Routes = [ ...@@ -104,6 +107,7 @@ const routes: Routes = [
PostfachMailListMailboxIconComponent, PostfachMailListMailboxIconComponent,
PostfachPageMailUnreadButtonComponent, PostfachPageMailUnreadButtonComponent,
PostfachPageMailUnreadButtonComponent, PostfachPageMailUnreadButtonComponent,
MailUnreadButtonLinkContainerComponent,
], ],
declarations: [ declarations: [
PostfachMailListContainerComponent, PostfachMailListContainerComponent,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment