Skip to content
Snippets Groups Projects
Commit dfcc4591 authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-6000 reset send observable' (#685) from...

Merge pull request 'OZG-6000 reset send observable' (#685) from OZG-6000-fix-statushandling into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/alfa/pulls/685


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents 7c3a1baf 8cfa9800
No related branches found
No related tags found
No related merge requests found
import { BescheidLinkRel, BescheidResource, BescheidService } from '@alfa-client/bescheid-shared';
import { CommandOrder, CommandResource } from '@alfa-client/command-shared';
import {
StateResource,
createEmptyStateResource,
createStateResource,
StateResource,
} from '@alfa-client/tech-shared';
import {
Mock,
dispatchEventFromFixture,
existsAsHtmlElement,
getElementFromFixture,
Mock,
mock,
notExistsAsHtmlElement,
} from '@alfa-client/test-utils';
......@@ -59,6 +59,7 @@ describe('VorgangDetailBescheidenResultComponent', () => {
new BehaviorSubject({ beschiedenAm: new Date(), bewilligt: false }),
);
formService.getActiveStep.mockReturnValue(EMPTY);
formService.isSendByManual.mockReturnValue(EMPTY);
await TestBed.configureTestingModule({
declarations: [
......@@ -219,10 +220,12 @@ describe('VorgangDetailBescheidenResultComponent', () => {
expect(formService.getBescheidChanges).toHaveBeenCalled();
});
it('should call formservice to get sendByManual', () => {
it('should get is send by manual', () => {
component.getIsSendManually = jest.fn();
component.ngOnInit();
expect(formService.isSendByManual).toHaveBeenCalled();
expect(component.getIsSendManually).toHaveBeenCalled();
});
it('should call service to get upload bescheid document in progress', () => {
......@@ -668,4 +671,27 @@ describe('VorgangDetailBescheidenResultComponent', () => {
expect(component.sendWithNachricht$.value).toEqual(createEmptyStateResource());
});
});
describe('getIsSendManually', () => {
beforeEach(() => {
component.resetSend = jest.fn();
});
it('should get is send by manual from from service', () => {
component.getIsSendManually();
expect(formService.isSendByManual).toHaveBeenCalled();
});
it.each([true, false])(
'should reset send if send by manual is %s',
(isSendByManual: boolean) => {
formService.isSendByManual.mockReturnValue(of(isSendByManual));
component.getIsSendManually().subscribe();
expect(component.resetSend).toHaveBeenCalled();
},
);
});
});
......@@ -13,10 +13,10 @@ import {
switchMapCommandSuccessfullyDone,
tapOnCommandSuccessfullyDone,
} from '@alfa-client/command-shared';
import { StateResource, createEmptyStateResource, isLoaded } from '@alfa-client/tech-shared';
import { createEmptyStateResource, isLoaded, StateResource } from '@alfa-client/tech-shared';
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Resource, hasLink } from '@ngxp/rest';
import { BehaviorSubject, Observable, OperatorFunction, filter, map, of, tap } from 'rxjs';
import { hasLink, Resource } from '@ngxp/rest';
import { BehaviorSubject, filter, map, Observable, of, OperatorFunction, tap } from 'rxjs';
import { BescheidenFormService } from '../bescheiden.formservice';
type sendBescheid = (
......@@ -84,7 +84,7 @@ export class VorgangDetailBescheidenResultComponent implements OnInit {
this.activeStep$ = this.getActiveStep();
this.bescheid$ = this.formService.getBescheidChanges();
this.sendByManual$ = this.formService.isSendByManual();
this.sendByManual$ = this.getIsSendManually();
this.canSave$ = this.bescheidDraftStateResource$.pipe(
filter(isLoaded),
......@@ -107,6 +107,10 @@ export class VorgangDetailBescheidenResultComponent implements OnInit {
.pipe(tap((step: number) => this.resetStateOnStepChange(step)));
}
getIsSendManually(): Observable<boolean> {
return this.formService.isSendByManual().pipe(tap(() => this.resetSend()));
}
private resetStateOnStepChange(step: number): void {
if (this.isNotLast(step)) this.resetSend();
if (this.shouldClearAttachmentInProgress(step)) this.bescheidService.clearAttachmentUpload();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment