Skip to content
Snippets Groups Projects
Commit 1415fc53 authored by Sebastian Bergandy's avatar Sebastian Bergandy :keyboard:
Browse files

Merge branch 'OZG-6185-bescheid-refactoring-bescheid-versenden' into 'main'

Bescheid refactoring Schritte 2 und 3

See merge request !43
parents 3d816f64 a899bfe8
No related branches found
No related tags found
1 merge request!43Bescheid refactoring Schritte 2 und 3
Showing
with 1749 additions and 442 deletions
......@@ -24,6 +24,7 @@
import { contains, enterWith } from '../../support/cypress.util';
import { uploadFile } from '../../support/file-upload';
import { getAdjustedDateGerman } from '../../support/tech.util';
import Chainable = Cypress.Chainable;
export class VorgangBescheidWizardE2EComponent {
private readonly bewilligtButton: string = 'button-bewilligt';
......@@ -43,10 +44,8 @@ export class VorgangBescheidWizardE2EComponent {
private readonly closeButton: string = 'close-bescheid';
private readonly closeDialog: string = 'bescheid-close-dialog';
private readonly bescheidResultBox: string = 'bescheiden-result';
private readonly bescheidVerwerfenButton: string =
'bescheiderstellung-abbrechen-entwurf-verwerfen';
private readonly bescheidSpeichernButton: string =
'bescheiderstellung-abbrechen-entwurf-speichern';
private readonly bescheidVerwerfenButton: string = 'bescheiderstellung-abbrechen-entwurf-verwerfen';
private readonly bescheidSpeichernButton: string = 'bescheiderstellung-abbrechen-entwurf-speichern';
private readonly uploadBescheidFileButton: string = '-single-file-upload-button';
private readonly uploadAttachmentButton: string = 'Anhang_hochladen-file-upload-button';
private readonly uploadAutomaticBescheid: string = 'create-bescheid-document-button';
......@@ -60,18 +59,15 @@ export class VorgangBescheidWizardE2EComponent {
private readonly fileBescheidValid: string = 'Bescheid_validpdf-file-item';
private readonly fileAnhangValid: string = 'Anhang_validpdf-file-item';
private readonly fileAutomaticBescheid: string =
'KFAS_LIVE_KI_10_Haltverbot_befristetpdf-file-item';
private readonly fileAutomaticBescheid: string = 'KFAS_LIVE_KI_10_Haltverbot_befristetpdf-file-item';
private readonly bescheidDocument: string = 'bescheid-document';
private readonly attachmentDocument: string = 'bescheid-attachments';
private readonly bescheidUploadSpinner: string =
'[data-test-id="bescheid-document"] ods-spinner-icon';
private readonly attachmentUploadSpinner: string =
'[data-test-id="bescheid-attachments"] ods-spinner-icon';
private readonly bescheidSaveSpinner: string =
'[data-test-id="confirm-and-save-button"] ods-spinner-icon';
private readonly bescheidUploadSpinner: string = '[data-test-id="bescheid-document"] ods-spinner-icon';
private readonly attachmentUploadSpinner: string = '[data-test-id="bescheid-attachments"] ods-spinner-icon';
private readonly bescheidSaveSpinner: string = '[data-test-id="confirm-and-save-button"] ods-spinner-icon';
private readonly sendenSpinner: string = '[data-test-id="send-button"] ods-spinner-icon';
private readonly missingBescheidDocumentMessage: string = 'missing-bescheid-document-error-message';
private locatorRoot: string = 'bescheid-wizard';
......@@ -93,6 +89,7 @@ export class VorgangBescheidWizardE2EComponent {
public getUeberspringenButton(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.getTestElement(this.ueberspringenButton);
}
public getStatusText(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.getTestElement(this.statusText);
}
......@@ -112,6 +109,7 @@ export class VorgangBescheidWizardE2EComponent {
public getDateInput(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.getTestElement(this.dateInput);
}
public getDateError(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.getTestElement(this.dateError);
}
......@@ -292,4 +290,8 @@ export class VorgangBescheidWizardE2EComponent {
public closeDialogIsShown(): void {
this.getCloseDialog().should('exist');
}
public getMissingBescheidDocumentMessage(): Chainable<Element> {
return cy.getTestElement(this.missingBescheidDocumentMessage);
}
}
......@@ -26,11 +26,7 @@ import localeDe from '@angular/common/locales/de';
import localeDeExtra from '@angular/common/locales/extra/de';
import { VorgangBescheidWizardE2EComponent } from 'apps/alfa-e2e/src/components/vorgang/vorgang-bescheid-wizard.e2e.component';
import { VorgangFormularButtonsE2EComponent } from 'apps/alfa-e2e/src/components/vorgang/vorgang-formular-buttons.e2e.components';
import {
VorgangE2E,
VorgangStatusE2E,
vorgangStatusLabelE2E,
} from 'apps/alfa-e2e/src/model/vorgang';
import { VorgangE2E, VorgangStatusE2E, vorgangStatusLabelE2E } from 'apps/alfa-e2e/src/model/vorgang';
import { uploadFile } from 'apps/alfa-e2e/src/support/file-upload';
import { getAdjustedDateGerman } from 'apps/alfa-e2e/src/support/tech.util';
import 'cypress-real-events/support';
......@@ -39,10 +35,7 @@ import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.
import { VorgangPage } from '../../../page-objects/vorgang.po';
import { dropCollections } from '../../../support/cypress-helper';
import { contains, exist, haveText, notExist } from '../../../support/cypress.util';
import {
TEST_FILE_BESCHEID_ANHANG_VALID,
TEST_FILE_BESCHEID_VALID,
} from '../../../support/data.util';
import { TEST_FILE_BESCHEID_ANHANG_VALID, TEST_FILE_BESCHEID_VALID } from '../../../support/data.util';
import { initUsermanagerUsers, loginAsSabine } from '../../../support/user-util';
import { buildVorgang, initVorgaenge, objectIds } from '../../../support/vorgang-util';
......@@ -64,8 +57,7 @@ describe('Vorgang - Bescheid abbrechen', () => {
status: VorgangStatusE2E.IN_BEARBEITUNG,
};
const vorgangFormularButtons: VorgangFormularButtonsE2EComponent =
vorgangPage.getFormularButtons();
const vorgangFormularButtons: VorgangFormularButtonsE2EComponent = vorgangPage.getFormularButtons();
before(() => {
initVorgaenge([bescheidVorgang]);
......@@ -81,7 +73,7 @@ describe('Vorgang - Bescheid abbrechen', () => {
dropCollections();
});
describe.skip('Sollte gefixt sein nach OZG-6185 - Discard changes after click on Verwerfen', () => {
describe('Discard changes after click on Verwerfen', () => {
it('should click abgelehnt, enter date, and continue to step 2', () => {
vorgangList.getListItem(bescheidVorgang.name).getRoot().click();
waitForSpinnerToDisappear();
......@@ -118,14 +110,18 @@ describe('Vorgang - Bescheid abbrechen', () => {
});
it('should show status In Bearbeitung', () => {
haveText(
vorgangPage.getVorgangDetailHeader().getStatus(),
vorgangStatusLabelE2E[VorgangStatusE2E.IN_BEARBEITUNG],
);
haveText(vorgangPage.getVorgangDetailHeader().getStatus(), vorgangStatusLabelE2E[VorgangStatusE2E.IN_BEARBEITUNG]);
});
});
describe('Keep changes after click on Entwurf speichern', () => {
it('should navigate to vorgang list page', () => {
vorgangPage.getSubnavigation().getBackButton().click();
waitForSpinnerToDisappear();
exist(vorgangList.getRoot());
});
it('click Vorgang', () => {
vorgangList.getListItem(bescheidVorgang.name).getRoot().click();
waitForSpinnerToDisappear();
......@@ -160,10 +156,7 @@ describe('Vorgang - Bescheid abbrechen', () => {
});
it('should show status In Bearbeitung', () => {
haveText(
vorgangPage.getVorgangDetailHeader().getStatus(),
vorgangStatusLabelE2E[VorgangStatusE2E.IN_BEARBEITUNG],
);
haveText(vorgangPage.getVorgangDetailHeader().getStatus(), vorgangStatusLabelE2E[VorgangStatusE2E.IN_BEARBEITUNG]);
});
it('should keep date and status from current Bescheid in progress', () => {
......
......@@ -33,16 +33,8 @@ import { VorgangListE2EComponent } from '../../../components/vorgang/vorgang-lis
import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.po';
import { VorgangPage } from '../../../page-objects/vorgang.po';
import { dropCollections, getTestElement } from '../../../support/cypress-helper';
import { contains, exist, haveValue, notContains, notExist } from '../../../support/cypress.util';
import {
TEST_FILE_BESCHEID_ANHANG_BIG,
TEST_FILE_BESCHEID_ANHANG_VALID,
TEST_FILE_BESCHEID_VALID,
TEST_FILE_JPEG,
TEST_FILE_JPG,
TEST_FILE_PNG,
TEST_FILE_WITH_CONTENT,
} from '../../../support/data.util';
import { contains, exist, haveText, haveValue, notContains, notExist } from '../../../support/cypress.util';
import { TEST_FILE_BESCHEID_ANHANG_BIG, TEST_FILE_BESCHEID_ANHANG_VALID, TEST_FILE_BESCHEID_VALID, TEST_FILE_JPEG, TEST_FILE_JPG, TEST_FILE_PNG, TEST_FILE_WITH_CONTENT, } from '../../../support/data.util';
import { initUsermanagerUsers, loginAsSabine } from '../../../support/user-util';
import { buildVorgang, initVorgaenge, objectIds } from '../../../support/vorgang-util';
......@@ -60,12 +52,11 @@ describe('Bescheid Dokumente hochladen', () => {
status: VorgangStatusE2E.IN_BEARBEITUNG,
};
const vorgangFormularButtons: VorgangFormularButtonsE2EComponent =
vorgangPage.getFormularButtons();
const vorgangFormularButtons: VorgangFormularButtonsE2EComponent = vorgangPage.getFormularButtons();
const documentError: string = 'Erlaubte Dateiendungen';
const sizeError: string = 'Anhänge größer';
const missingBescheidError: string = 'Bitte fügen Sie';
const missingBescheidError: string = 'Bitte fügen Sie ein Bescheiddokument hinzu.';
const nachrichtHeader: string = 'Neue Nachricht';
const antragstellerName: string = 'An: Max Testermann';
const betreffText: string = 'Ihr Bescheid zum Antrag';
......@@ -127,17 +118,11 @@ describe('Bescheid Dokumente hochladen', () => {
});
it('should delete files on clicking X button', () => {
bescheidWizard
.getDeleteButtonOfElement(
bescheidWizard.getElementFromFileName(TEST_FILE_BESCHEID_ANHANG_VALID),
)
.click();
bescheidWizard.getDeleteButtonOfElement(bescheidWizard.getElementFromFileName(TEST_FILE_BESCHEID_ANHANG_VALID)).click();
notExist(bescheidWizard.getFileAnhangValidInWizard());
exist(bescheidWizard.getFileBescheidValidInWizard());
bescheidWizard
.getDeleteButtonOfElement(bescheidWizard.getElementFromFileName(TEST_FILE_BESCHEID_VALID))
.click();
bescheidWizard.getDeleteButtonOfElement(bescheidWizard.getElementFromFileName(TEST_FILE_BESCHEID_VALID)).click();
notExist(bescheidWizard.getFileBescheidValidInWizard());
});
......@@ -169,7 +154,8 @@ describe('Bescheid Dokumente hochladen', () => {
describe('do not continue without attached Bescheid', () => {
it('should show error if no Bescheid is attached and step 3 is clicked', () => {
bescheidWizard.getWeiterButton().click();
contains(bescheidWizard.getBescheidDocument(), missingBescheidError);
exist(bescheidWizard.getMissingBescheidDocumentMessage());
haveText(bescheidWizard.getMissingBescheidDocumentMessage(), missingBescheidError);
});
});
......
......@@ -29,16 +29,10 @@ import { VorgangBescheideE2EComponent } from 'apps/alfa-e2e/src/components/vorga
import { VorgangFormularButtonsE2EComponent } from 'apps/alfa-e2e/src/components/vorgang/vorgang-formular-buttons.e2e.components';
import { VorgangFormularDatenE2EComponent } from 'apps/alfa-e2e/src/components/vorgang/vorgang-formular.e2e.component';
import { VorgangSubnavigationE2EComponent } from 'apps/alfa-e2e/src/components/vorgang/vorgang-subnavigation';
import {
BescheidHistorieItemE2EComponent,
VorgangFormularDatenHistorieItemE2EComponent,
} from 'apps/alfa-e2e/src/components/vorgang/vorgang.formular-daten.historie.e2e.component';
import { BescheidHistorieItemE2EComponent, VorgangFormularDatenHistorieItemE2EComponent, } from 'apps/alfa-e2e/src/components/vorgang/vorgang.formular-daten.historie.e2e.component';
import { HistorieHeadlineE2E } from 'apps/alfa-e2e/src/model/historie';
import { VorgangE2E, VorgangStatusE2E } from 'apps/alfa-e2e/src/model/vorgang';
import {
TEST_FILE_BESCHEID_ANHANG_VALID,
TEST_FILE_BESCHEID_VALID,
} from 'apps/alfa-e2e/src/support/data.util';
import { TEST_FILE_BESCHEID_ANHANG_VALID, TEST_FILE_BESCHEID_VALID } from 'apps/alfa-e2e/src/support/data.util';
import { uploadFile } from 'apps/alfa-e2e/src/support/file-upload';
import { getAdjustedDateGerman } from 'apps/alfa-e2e/src/support/tech.util';
import 'cypress-real-events/support';
......@@ -79,14 +73,11 @@ describe('Bescheid History', () => {
status: VorgangStatusE2E.IN_BEARBEITUNG,
};
const vorgangDatenFormular: VorgangFormularDatenE2EComponent =
vorgangPage.getFormularDatenContainer();
const vorgangDatenFormular: VorgangFormularDatenE2EComponent = vorgangPage.getFormularDatenContainer();
const vorgangFormularButtons: VorgangFormularButtonsE2EComponent =
vorgangPage.getFormularButtons();
const vorgangFormularButtons: VorgangFormularButtonsE2EComponent = vorgangPage.getFormularButtons();
const vorgangSubnavigationButtons: VorgangSubnavigationE2EComponent =
vorgangPage.getSubnavigation();
const vorgangSubnavigationButtons: VorgangSubnavigationE2EComponent = vorgangPage.getSubnavigation();
const bescheide: VorgangBescheideE2EComponent = vorgangPage.getBescheide();
......@@ -125,16 +116,14 @@ describe('Bescheid History', () => {
waitForSpinnerToDisappear();
vorgangDatenFormular.getHistorieTab().click();
const historieItem: VorgangFormularDatenHistorieItemE2EComponent =
vorgangDatenFormular.getHistorieItemByIndex(0);
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieItemByIndex(0);
contains(historieItem.getHeadline(), HistorieHeadlineE2E.BESCHEID_ERSTELLT);
contains(historieItem.getUser(), userName);
});
it('should show detailed info after click on arrow', () => {
const historieItem: VorgangFormularDatenHistorieItemE2EComponent =
vorgangDatenFormular.getHistorieItemByIndex(0);
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieItemByIndex(0);
const bescheidItem: BescheidHistorieItemE2EComponent = historieItem.getBescheid();
historieItem.getExpandButton().click();
......@@ -160,8 +149,7 @@ describe('Bescheid History', () => {
waitForSpinnerToDisappear();
vorgangDatenFormular.getHistorieTab().click();
const historieItem: VorgangFormularDatenHistorieItemE2EComponent =
vorgangDatenFormular.getHistorieItemByIndex(0);
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieItemByIndex(0);
const bescheidItem: BescheidHistorieItemE2EComponent = historieItem.getBescheid();
historieItem.getExpandButton().click();
......@@ -172,7 +160,7 @@ describe('Bescheid History', () => {
});
});
describe.skip('Show history entry after sending Bescheid', () => {
describe('Show history entry after sending Bescheid', () => {
it('should show Bescheid entry on history tab after sending message', () => {
vorgangSubnavigationButtons.getBackButton().click();
vorgangList.getListItem(bescheidSendenVorgang.name).getRoot().click();
......@@ -194,8 +182,7 @@ describe('Bescheid History', () => {
notExist(bescheidWizard.getSendenSpinner());
vorgangDatenFormular.getHistorieTab().click();
const historieItemExpand: VorgangFormularDatenHistorieItemE2EComponent =
vorgangDatenFormular.getHistorieItemByIndex(0);
const historieItemExpand: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieItemByIndex(0);
const bescheidItem: BescheidHistorieItemE2EComponent = historieItemExpand.getBescheid();
historieItemExpand.getExpandButton().click();
......@@ -206,13 +193,11 @@ describe('Bescheid History', () => {
});
it('should show history entries for sent Bescheid and message', () => {
const historieItemSent: VorgangFormularDatenHistorieItemE2EComponent =
vorgangDatenFormular.getHistorieItemByIndex(1);
const historieItemSent: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieItemByIndex(1);
contains(historieItemSent.getHeadline(), HistorieHeadlineE2E.BESCHEID_VERSCHICKT);
contains(historieItemSent.getUser(), userName);
const historieItemMessage: VorgangFormularDatenHistorieItemE2EComponent =
vorgangDatenFormular.getHistorieItemByIndex(3);
const historieItemMessage: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieItemByIndex(3);
contains(historieItemMessage.getHeadline(), HistorieHeadlineE2E.SEND_POSTFACH_NACHRICHT);
contains(historieItemMessage.getUser(), userName);
});
......
......@@ -26,11 +26,7 @@ import localeDe from '@angular/common/locales/de';
import localeDeExtra from '@angular/common/locales/extra/de';
import { VorgangBescheidWizardE2EComponent } from 'apps/alfa-e2e/src/components/vorgang/vorgang-bescheid-wizard.e2e.component';
import { VorgangFormularButtonsE2EComponent } from 'apps/alfa-e2e/src/components/vorgang/vorgang-formular-buttons.e2e.components';
import {
VorgangE2E,
VorgangStatusE2E,
vorgangStatusLabelE2E,
} from 'apps/alfa-e2e/src/model/vorgang';
import { VorgangE2E, VorgangStatusE2E, vorgangStatusLabelE2E } from 'apps/alfa-e2e/src/model/vorgang';
import { uploadFile } from 'apps/alfa-e2e/src/support/file-upload';
import { getAdjustedDateGerman } from 'apps/alfa-e2e/src/support/tech.util';
import 'cypress-real-events/support';
......@@ -39,10 +35,7 @@ import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.
import { VorgangPage } from '../../../page-objects/vorgang.po';
import { dropCollections } from '../../../support/cypress-helper';
import { contains, enterWith, exist, haveText, notExist } from '../../../support/cypress.util';
import {
TEST_FILE_BESCHEID_ANHANG_VALID,
TEST_FILE_BESCHEID_VALID,
} from '../../../support/data.util';
import { TEST_FILE_BESCHEID_ANHANG_VALID, TEST_FILE_BESCHEID_VALID } from '../../../support/data.util';
import { initUsermanagerUsers, loginAsSabine } from '../../../support/user-util';
import { buildVorgang, initVorgaenge, objectIds } from '../../../support/vorgang-util';
......@@ -53,7 +46,7 @@ describe('Bescheid speichern', () => {
const vorgangList: VorgangListE2EComponent = mainPage.getVorgangList();
const abgelehntText: string = 'Abgelehnt am';
const manuellText: string = 'Bescheid muss manuell';
const manuellText: string = 'Der Bescheid muss manuell versendet werden.';
const vorgangPage: VorgangPage = new VorgangPage();
const bescheidWizard: VorgangBescheidWizardE2EComponent = vorgangPage.getBescheidWizard();
......@@ -63,8 +56,7 @@ describe('Bescheid speichern', () => {
status: VorgangStatusE2E.IN_BEARBEITUNG,
};
const vorgangFormularButtons: VorgangFormularButtonsE2EComponent =
vorgangPage.getFormularButtons();
const vorgangFormularButtons: VorgangFormularButtonsE2EComponent = vorgangPage.getFormularButtons();
before(() => {
initVorgaenge([bescheidVorgang]);
......@@ -108,10 +100,7 @@ describe('Bescheid speichern', () => {
notExist(bescheidWizard.getRoot());
waitForSpinnerToDisappear();
haveText(
vorgangPage.getVorgangDetailHeader().getStatus(),
vorgangStatusLabelE2E[VorgangStatusE2E.BESCHIEDEN],
);
haveText(vorgangPage.getVorgangDetailHeader().getStatus(), vorgangStatusLabelE2E[VorgangStatusE2E.BESCHIEDEN]);
});
});
});
......@@ -22,10 +22,10 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { CommandOrder, CommandResource } from '@alfa-client/command-shared';
import { ApiError } from '@alfa-client/tech-shared';
import { ApiError, createEmptyStateResource } from '@alfa-client/tech-shared';
import { VorgangWithEingangLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { Action } from '@ngrx/store';
import { createCommandResource } from 'libs/command-shared/test/command';
import { createCommandResource, createSuccessfullyDoneCommandStateResource } from 'libs/command-shared/test/command';
import { createApiError } from 'libs/tech-shared/test/error';
import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang';
import { BescheidState, initialState, reducer } from './bescheid.reducer';
......@@ -55,7 +55,21 @@ describe('Bescheid Reducer', () => {
const state: BescheidState = reducer(initialState, action);
expect(state.bescheidCommand.loading).toBeTruthy();
expect(state.bescheidCommand).toEqual(createEmptyStateResource(true));
});
it('should replace state resource with loading', () => {
const initialState: BescheidState = { bescheidCommand: createSuccessfullyDoneCommandStateResource() };
const resource: VorgangWithEingangResource = createVorgangWithEingangResource();
const action: Action = CommandActions.createCommand({
resource,
linkRel: VorgangWithEingangLinkRel.CREATE_BESCHEID_DRAFT,
command: { ...createCommandResource(), order: CommandOrder.CREATE_BESCHEID },
});
const state: BescheidState = reducer(initialState, action);
expect(state.bescheidCommand).toEqual(createEmptyStateResource(true));
});
});
......
......@@ -21,19 +21,8 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import {
CommandProps,
CommandResource,
CreateCommandFailureProps,
CreateCommandProps,
} from '@alfa-client/command-shared';
import {
ApiError,
StateResource,
createEmptyStateResource,
createErrorStateResource,
createStateResource,
} from '@alfa-client/tech-shared';
import { CommandProps, CommandResource, CreateCommandFailureProps, CreateCommandProps } from '@alfa-client/command-shared';
import { ApiError, createEmptyStateResource, createErrorStateResource, createStateResource, StateResource, } from '@alfa-client/tech-shared';
import { HttpErrorResponse } from '@angular/common/http';
import { Action, ActionReducer, createReducer, on } from '@ngrx/store';
import { isCreateBescheidCommand } from '../bescheid.util';
......@@ -56,35 +45,22 @@ export const initialState: BescheidState = {
const bescheidReducer: ActionReducer<BescheidState, Action> = createReducer(
initialState,
on(
CommandActions.createCommand,
(state: BescheidState, props: CreateCommandProps): BescheidState => {
return isCreateBescheidCommand(props.command.order) ?
{ ...state, bescheidCommand: { ...state.bescheidCommand, loading: true } }
: state;
},
),
on(
CommandActions.createCommandSuccess,
(state: BescheidState, props: CommandProps): BescheidState => {
on(CommandActions.createCommand, (state: BescheidState, props: CreateCommandProps): BescheidState => {
return isCreateBescheidCommand(props.command.order) ? { ...state, bescheidCommand: createEmptyStateResource(true) } : state;
}),
on(CommandActions.createCommandSuccess, (state: BescheidState, props: CommandProps): BescheidState => {
return isCreateBescheidCommand(props.command.order) ?
{ ...state, bescheidCommand: createStateResource(props.command) }
: state;
},
),
on(
CommandActions.createCommandFailure,
(state: BescheidState, props: CreateCommandFailureProps): BescheidState => {
}),
on(CommandActions.createCommandFailure, (state: BescheidState, props: CreateCommandFailureProps): BescheidState => {
return isCreateBescheidCommand(props.command.order) ?
{
...state,
bescheidCommand: createErrorStateResource(
<ApiError>(<HttpErrorResponse>props.error).error,
),
bescheidCommand: createErrorStateResource(<ApiError>(<HttpErrorResponse>props.error).error),
}
: state;
},
),
}),
);
export function reducer(state: BescheidState, action: Action): BescheidState {
......
import { CommandOrder, CommandResourceService, CommandService } from '@alfa-client/command-shared';
import { ResourceRepository, ResourceServiceConfig } from '@alfa-client/tech-shared';
import { VorgangService, VorgangWithEingangLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { BescheidLinkRel } from './bescheid.linkrel';
import { BescheidResource } from './bescheid.model';
export class BescheidResourceService extends CommandResourceService<VorgangWithEingangResource, BescheidResource> {}
export function createBescheidResourceService(
repository: ResourceRepository,
commandService: CommandService,
vorgangService: VorgangService,
): CommandResourceService<VorgangWithEingangResource, BescheidResource> {
console.info('Create Bescheid Resource Service');
return new CommandResourceService(buildConfig(vorgangService), repository, commandService);
}
function buildConfig(vorgangService: VorgangService): ResourceServiceConfig<VorgangWithEingangResource> {
return {
resource: vorgangService.getVorgangWithEingang(),
getLinkRel: VorgangWithEingangLinkRel.BESCHEID_DRAFT,
delete: { linkRel: BescheidLinkRel.DELETE, order: CommandOrder.DELETE_BESCHEID },
edit: { linkRel: BescheidLinkRel.UPDATE, order: CommandOrder.UPDATE_BESCHEID },
};
}
......@@ -21,8 +21,10 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { HttpError, ListResource } from '@alfa-client/tech-shared';
import { Resource } from '@ngxp/rest';
import { BinaryFileResource } from '@alfa-client/binary-file-shared';
import { CommandResource } from '@alfa-client/command-shared';
import { createEmptyStateResource, HttpError, ListResource, StateResource } from '@alfa-client/tech-shared';
import { Resource, ResourceUri } from '@ngxp/rest';
export enum BescheidStatus {
DRAFT = 'DRAFT',
......@@ -64,3 +66,55 @@ export enum BescheidWizardStep {
export interface BescheidWizardDialogResult {
reloadVorgang: boolean;
}
export interface BescheidDocument {
upload: UploadFileInProgress;
create: StateResource<CommandResource>;
documentUri?: ResourceUri;
resource?: BinaryFileResource;
}
export function createEmptyBescheidDocument(): BescheidDocument {
return {
upload: createEmptyUploadInProgress(),
create: createEmptyStateResource(),
};
}
export interface BescheidAttachments {
upload: UploadFileInProgress;
uploadStateResource: StateResource<BinaryFileResource>;
items: BinaryFileResource[];
}
export function createEmptyBescheidAttachments(): BescheidAttachments {
return {
upload: createEmptyUploadInProgress(),
uploadStateResource: createEmptyStateResource(),
items: [],
};
}
export function createEmptyUploadInProgress(): UploadFileInProgress {
return {
loading: false,
fileName: null,
};
}
export interface Wizard {
activeStep: BescheidWizardStep;
sendBy: BescheidSendBy;
canBeSend: boolean;
bescheidCreated: boolean;
empfaenger?: string;
}
export function createInitialWizard(): Wizard {
return {
activeStep: BescheidWizardStep.AntragBescheiden,
sendBy: BescheidSendBy.NACHRICHT,
canBeSend: true,
bescheidCreated: false,
};
}
This diff is collapsed.
import {
Bescheid,
BescheidAttachments,
BescheidDocument,
BescheidLinkRel,
BescheidResource,
BescheidSendBy,
BescheidWizardStep,
buildCreateBescheidCommand,
buildCreateBescheidDocumentCommandProps,
buildCreateBescheidDocumentFromFileProps,
buildSendBescheidCommandProps,
buildUpdateBescheidCommandProps,
createEmptyBescheidAttachments,
createEmptyBescheidDocument,
createEmptyUploadInProgress,
createInitialWizard,
DocumentResource,
Wizard,
} from '@alfa-client/bescheid-shared';
import {
BinaryFileListLinkRel,
BinaryFileListResource,
BinaryFileResource,
BinaryFileService,
} from '@alfa-client/binary-file-shared';
import {
CommandOrder,
CommandResource,
CommandService,
getEffectedResourceUrl,
notHasCommandError,
tapOnCommandSuccessfullyDone,
} from '@alfa-client/command-shared';
import { PostfachService } from '@alfa-client/postfach-shared';
import {
createEmptyStateResource,
createLoadingStateResource,
filterIsLoadedOrHasError,
getEmbeddedResources,
hasStateResourceError,
isLoaded,
ResourceRepository,
StateResource,
} from '@alfa-client/tech-shared';
import { VorgangCommandService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { inject, Injectable } from '@angular/core';
import { getUrl, hasLink, LinkRel, Resource, ResourceUri } from '@ngxp/rest';
import { isNil } from 'lodash-es';
import { BehaviorSubject, filter, first, map, Observable, switchMap } from 'rxjs';
import { BescheidFacade } from './+state/bescheid.facade';
import { BescheidResourceService } from './bescheid-resource-service';
import { DocumentLinkRel } from './document.linkrel';
@Injectable()
export class BescheidService2 {
private readonly bescheidFacade = inject(BescheidFacade);
private readonly commandService = inject(CommandService);
private readonly vorgangCommandService = inject(VorgangCommandService);
private readonly binaryFileService = inject(BinaryFileService);
private readonly resourceRepository = inject(ResourceRepository);
private readonly postfachService = inject(PostfachService);
private readonly bescheidResourceService = inject(BescheidResourceService);
readonly _bescheidDocument$: BehaviorSubject<BescheidDocument> = new BehaviorSubject(createEmptyBescheidDocument());
readonly _attachments$: BehaviorSubject<BescheidAttachments> = new BehaviorSubject(createEmptyBescheidAttachments());
readonly _wizard$: BehaviorSubject<Wizard> = new BehaviorSubject(createInitialWizard());
public init(): void {
this._wizard$.next(createInitialWizard());
this._bescheidDocument$.next(createEmptyBescheidDocument());
this._attachments$.next(createEmptyBescheidAttachments());
}
public exit(): void {
this.postfachService.setPostfachMailOnReload();
}
public skipBescheidCreation(
vorgangWithEingangResource: VorgangWithEingangResource,
bescheidResource: BescheidResource,
): Observable<StateResource<CommandResource>> {
if (isNil(bescheidResource)) {
return this.vorgangCommandService.abschliessen(vorgangWithEingangResource);
}
return this.deleteBescheidAndCompleteVorgang(vorgangWithEingangResource);
}
deleteBescheidAndCompleteVorgang(
vorgangWithEingangResource: VorgangWithEingangResource,
): Observable<StateResource<CommandResource>> {
return this.vorgangCommandService
.abschliessen(vorgangWithEingangResource)
.pipe(tapOnCommandSuccessfullyDone(() => this.deleteBescheid()));
}
public deleteBescheid(): Observable<StateResource<CommandResource>> {
return this.bescheidResourceService.delete();
}
public loadFiles(bescheidResource: BescheidResource): void {
this.loadBescheidDocument(bescheidResource);
this.loadAttachments(bescheidResource);
}
public createBescheidDocument(bescheidResource: BescheidResource): void {
this._bescheidDocument$.next({ ...createEmptyBescheidDocument(), create: createEmptyStateResource(true) });
this.doCreateBescheidDocument(bescheidResource)
.pipe(filterIsLoadedOrHasError(), first())
.subscribe((commandStateResource: StateResource<CommandResource>) =>
this.handleCreateBescheidDocumentResponse(commandStateResource),
);
}
doCreateBescheidDocument(bescheidResource: BescheidResource): Observable<StateResource<CommandResource>> {
return this.commandService.createCommandByProps(buildCreateBescheidDocumentCommandProps(bescheidResource));
}
handleCreateBescheidDocumentResponse(commandStateResource: StateResource<CommandResource>): void {
if (notHasCommandError(commandStateResource.resource)) {
const documentUri: ResourceUri = getEffectedResourceUrl(commandStateResource.resource);
this._bescheidDocument$.next({ ...this._bescheidDocument$.value, documentUri });
this.loadBescheidDocumentByUri(documentUri);
} else {
this._bescheidDocument$.next({ ...this._bescheidDocument$.value, create: commandStateResource });
}
}
emitBescheidDocumentError(stateResource: StateResource<Resource>): void {
const value: BescheidDocument = this._bescheidDocument$.value;
this._bescheidDocument$.next({
...value,
upload: { ...value.upload, loading: false, error: stateResource.error },
});
}
loadBescheidDocument(bescheidResource: BescheidResource): void {
if (hasLink(bescheidResource, BescheidLinkRel.BESCHEID_DOCUMENT)) {
this.loadBescheidDocumentByUri(getUrl(bescheidResource, BescheidLinkRel.BESCHEID_DOCUMENT));
}
}
public loadBescheidDocumentByUri(resourceUri: ResourceUri): void {
this.resourceRepository
.getResource(resourceUri)
.pipe(first())
.subscribe((document: DocumentResource) => this.loadBescheidDocumentFile(document));
}
loadBescheidDocumentFile(document: DocumentResource): void {
this.binaryFileService
.getFile(getUrl(document, DocumentLinkRel.FILE))
.pipe(filterIsLoadedOrHasError(), first())
.subscribe((binaryFile: StateResource<BinaryFileResource>) => {
this._bescheidDocument$.next({
...this._bescheidDocument$.value,
upload: createEmptyUploadInProgress(),
create: createEmptyStateResource(),
resource: binaryFile.resource,
documentUri: getUrl(document, LinkRel.Self),
});
});
}
loadAttachments(bescheidResource: BescheidResource): void {
if (hasLink(bescheidResource, BescheidLinkRel.ATTACHMENTS)) {
this.binaryFileService
.getFiles(bescheidResource, BescheidLinkRel.ATTACHMENTS)
.pipe(
filterIsLoadedOrHasError(),
first(),
map((stateResource: StateResource<BinaryFileListResource>) =>
getEmbeddedResources<BinaryFileResource>(stateResource, BinaryFileListLinkRel.FILE_LIST),
),
)
.subscribe((files: BinaryFileResource[]) => this._attachments$.next({ ...this._attachments$.value, items: files }));
}
}
public uploadAttachment(attachment: File, bescheidResource: BescheidResource): void {
this._attachments$.next({
...this._attachments$.value,
upload: { fileName: attachment.name, loading: true },
uploadStateResource: createLoadingStateResource(),
});
this.binaryFileService
.uploadFile(bescheidResource, BescheidLinkRel.UPLOAD_ATTACHMENT, attachment, false)
.pipe(filterIsLoadedOrHasError(), first())
.subscribe((binaryFileStateResource: StateResource<BinaryFileResource>) =>
this.handleAttachmentUpload(binaryFileStateResource),
);
}
handleAttachmentUpload(binaryFileStateResource: StateResource<BinaryFileResource>) {
const value: BescheidAttachments = this._attachments$.value;
if (hasStateResourceError(binaryFileStateResource)) {
this._attachments$.next({
...value,
uploadStateResource: binaryFileStateResource,
upload: { ...value.upload, error: binaryFileStateResource.error, loading: binaryFileStateResource.loading },
});
} else {
this._attachments$.next({
...value,
uploadStateResource: binaryFileStateResource,
items: [...value.items, binaryFileStateResource.resource],
upload: { ...value.upload, error: binaryFileStateResource.error, loading: binaryFileStateResource.loading },
});
}
}
public deleteAttachment(attachment: BinaryFileResource): void {
const value: BescheidAttachments = this._attachments$.value;
this._attachments$.next({
...value,
items: value.items.filter((each: BinaryFileResource) => getUrl(each) !== getUrl(attachment)),
});
}
public uploadBescheidDocument(document: File, bescheid: BescheidResource): void {
this._bescheidDocument$.next({ ...this._bescheidDocument$.value, upload: { fileName: document.name, loading: true } });
this.binaryFileService
.uploadFile(bescheid, BescheidLinkRel.UPLOAD_BESCHEID_FILE, document, false)
.pipe(filterIsLoadedOrHasError(), first())
.subscribe((binaryFileStateResource: StateResource<BinaryFileResource>) =>
this.handleUploadBescheidDocumentResponse(bescheid, binaryFileStateResource),
);
}
handleUploadBescheidDocumentResponse(
bescheid: BescheidResource,
binaryFileStateResource: StateResource<BinaryFileResource>,
): void {
if (hasStateResourceError(binaryFileStateResource)) {
this.emitBescheidDocumentError(binaryFileStateResource);
} else {
this.createBescheidDocumentFromFile(bescheid, binaryFileStateResource.resource);
}
}
createBescheidDocumentFromFile(bescheid: BescheidResource, binaryFile: BinaryFileResource): void {
this.commandService
.createCommandByProps(buildCreateBescheidDocumentFromFileProps(bescheid, binaryFile))
.pipe(filterIsLoadedOrHasError(), first())
.subscribe((commandStateResource: StateResource<CommandResource>) =>
this.handleCreateBescheidDocumentFromFileResponse(commandStateResource, binaryFile),
);
}
handleCreateBescheidDocumentFromFileResponse(
commandStateResource: StateResource<CommandResource>,
binaryFile: BinaryFileResource,
): void {
if (hasStateResourceError(commandStateResource)) {
this.emitBescheidDocumentError(commandStateResource);
} else {
this._bescheidDocument$.next({
...this._bescheidDocument$.value,
documentUri: getEffectedResourceUrl(commandStateResource.resource),
upload: createEmptyUploadInProgress(),
resource: binaryFile,
});
}
}
public createBescheid(
vorgangWithEingang: VorgangWithEingangResource,
bescheid?: Bescheid,
): Observable<StateResource<CommandResource>> {
this.bescheidFacade.createBescheidDraft(vorgangWithEingang, buildCreateBescheidCommand(bescheid));
return this.bescheidFacade
.getBescheidCommand()
.pipe(
tapOnCommandSuccessfullyDone((commandStateResource: StateResource<CommandResource>) =>
this.updateBescheidDraft(commandStateResource.resource),
),
);
}
updateBescheidDraft(command: CommandResource): void {
this.bescheidResourceService.loadByResourceUri(getEffectedResourceUrl(command));
if (command.order === CommandOrder.CREATE_BESCHEID) {
this._wizard$.next({ ...this._wizard$.value, bescheidCreated: true });
}
}
public updateBescheid(
bescheidResource: BescheidResource,
updatedBescheid: Bescheid,
): Observable<StateResource<CommandResource>> {
return this.doUpdateBescheid(bescheidResource, updatedBescheid).pipe(
tapOnCommandSuccessfullyDone((commandStateResource: StateResource<CommandResource>) => {
this.updateBescheidDraft(commandStateResource.resource);
}),
);
}
doUpdateBescheid(bescheidResource: BescheidResource, bescheid: Bescheid): Observable<StateResource<CommandResource>> {
return this.commandService.createCommandByProps(buildUpdateBescheidCommandProps(bescheidResource, bescheid));
}
public sendBescheidManually(): Observable<StateResource<CommandResource>> {
return this.sendBescheid(BescheidLinkRel.BESCHEIDEN);
}
public sendBescheidMessage(): Observable<StateResource<CommandResource>> {
return this.sendBescheid(BescheidLinkRel.BESCHEIDEN_UND_SENDEN);
}
sendBescheid(linkRel: BescheidLinkRel): Observable<StateResource<CommandResource>> {
return this.getBescheidDraft().pipe(
filter(isLoaded),
map((stateResource: StateResource<BescheidResource>) => stateResource.resource),
switchMap((bescheidResource: BescheidResource) =>
this.commandService.createCommandByProps(buildSendBescheidCommandProps(bescheidResource, linkRel)),
),
);
}
public getBescheidDraft(): Observable<StateResource<BescheidResource>> {
return this.bescheidResourceService.get();
}
public getAttachments(): Observable<BescheidAttachments> {
return this._attachments$.asObservable();
}
public getBescheidDocument(): Observable<BescheidDocument> {
return this._bescheidDocument$.asObservable();
}
public deleteBescheidDocument(): void {
this._bescheidDocument$.next(createEmptyBescheidDocument());
}
public getActiveStep(): Observable<BescheidWizardStep> {
return this._wizard$.asObservable().pipe(map((wizard: Wizard) => wizard.activeStep));
}
public setActiveStep(step: BescheidWizardStep): void {
this._wizard$.next({ ...this._wizard$.value, activeStep: step });
}
public getBescheidCreated(): Observable<boolean> {
return this._wizard$.asObservable().pipe(map((wizard: Wizard) => wizard.bescheidCreated));
}
public selectBescheidResource(): Observable<StateResource<BescheidResource>> {
return this.bescheidResourceService.selectResource();
}
public getWizard(): Observable<Wizard> {
return this._wizard$.asObservable();
}
public setSendBy(sendBy: BescheidSendBy): void {
this._wizard$.next({ ...this._wizard$.value, sendBy: sendBy });
}
public setNachrichtEmpfaenger(empfaenger: string): void {
this._wizard$.next({ ...this._wizard$.value, empfaenger: empfaenger });
}
public lockBescheidSending(): void {
this._wizard$.next({ ...this._wizard$.value, canBeSend: false });
}
public unlockBescheidSending(): void {
this._wizard$.next({ ...this._wizard$.value, canBeSend: true });
}
public finishAddingAttachments(): void {
this._attachments$.next({
...this._attachments$.value,
upload: createEmptyUploadInProgress(),
uploadStateResource: createEmptyStateResource(),
});
}
public finishAddingBescheidDocument(): void {
this._bescheidDocument$.next({
...this._bescheidDocument$.value,
upload: createEmptyUploadInProgress(),
create: createEmptyStateResource(),
});
}
}
......@@ -25,16 +25,11 @@ import { createStateResource, StateResource } from '@alfa-client/tech-shared';
import { faker } from '@faker-js/faker';
import { toResource } from 'libs/tech-shared/test/resource';
import { times } from 'lodash-es';
import { createApiError } from '../../../tech-shared/test/error';
import { createBinaryFileResource } from '../../../binary-file-shared/test/binary-file';
import { createSuccessfullyDoneCommandStateResource } from '../../../command-shared/test/command';
import { createProblemDetail } from '../../../tech-shared/test/error';
import { BescheidListLinkRel } from '../lib/bescheid.linkrel';
import {
Bescheid,
BescheidListResource,
BescheidResource,
BescheidSendBy,
BescheidStatus,
UploadFileInProgress,
} from '../lib/bescheid.model';
import { Bescheid, BescheidAttachments, BescheidDocument, BescheidListResource, BescheidResource, BescheidSendBy, BescheidStatus, BescheidWizardStep, UploadFileInProgress, Wizard, } from '../lib/bescheid.model';
export function createBescheid(): Bescheid {
return {
......@@ -53,14 +48,12 @@ export function createBescheidResource(linkRel: string[] = []): BescheidResource
return toResource(createBescheid(), linkRel);
}
export function createBescheidStateResource(
linkRel: string[] = [],
): StateResource<BescheidResource> {
export function createBescheidStateResource(linkRel: string[] = []): StateResource<BescheidResource> {
return createStateResource(createBescheidResource(linkRel));
}
export function createUploadFileInProgress(): UploadFileInProgress {
return { loading: true, fileName: faker.person.firstName(), error: createApiError() };
return { loading: true, fileName: faker.person.firstName(), error: createProblemDetail() };
}
export function createBescheidResources(linkRelations: string[] = []): BescheidResource[] {
......@@ -75,3 +68,54 @@ export function createBescheidListResource(
[BescheidListLinkRel.BESCHEID_LIST]: bescheide,
});
}
export function createBescheidAttachments(): BescheidAttachments {
return {
upload: createUploadFileInProgress(),
items: [createBinaryFileResource()],
uploadStateResource: createStateResource(createBinaryFileResource()),
};
}
export function createBescheidDocument(): BescheidDocument {
return {
upload: createUploadFileInProgress(),
create: createSuccessfullyDoneCommandStateResource(),
documentUri: faker.internet.url(),
resource: createBinaryFileResource(),
};
}
export function createSuccessfulUpload(): UploadFileInProgress {
return {
loading: false,
error: null,
fileName: faker.system.fileName(),
};
}
export function createPendingUpload(): UploadFileInProgress {
return {
loading: true,
fileName: faker.system.fileName(),
error: null,
};
}
export function createErrorUpload(): UploadFileInProgress {
return {
loading: false,
error: createProblemDetail(),
fileName: faker.system.fileName(),
};
}
export function createWizard(): Wizard {
return {
empfaenger: faker.person.fullName(),
sendBy: BescheidSendBy.MANUAL,
bescheidCreated: false,
canBeSend: true,
activeStep: BescheidWizardStep.BescheidVersenden,
};
}
......@@ -27,28 +27,25 @@
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
<div class="flex h-full items-center justify-center p-8">
<div
class="relative h-full w-full max-w-7xl transform overflow-hidden rounded-lg bg-background-200 px-6 py-10 text-left shadow-xl transition-all"
class="relative h-full w-full max-w-7xl transform overflow-hidden rounded-lg bg-background-200 py-9 pl-6 pr-9 text-left shadow-xl transition-all"
>
<ng-container *ngIf="bescheidDraftStateResource$ | async as bescheidStateResource">
@let bescheidStateResource = bescheidDraftStateResource$ | async;
<ods-button
variant="ghost"
size="fit"
class="absolute right-0 top-0 text-text"
(clickEmitter)="cancelWizard(bescheidStateResource.resource)"
data-test-id="close-bescheid"
dataTestId="close-bescheid"
>
<ods-close-icon icon />
</ods-button>
<alfa-bescheid-wizard
[vorgangWithEingangResource]="vorgangWithEingangResource"
[activeStep]="bescheidService.getActiveStep() | async"
[activeStep]="activeStep$ | async"
[bescheidStateResource]="bescheidStateResource"
[submitStateResource]="submitStateResource$ | async"
(weiterClickEmitter)="onWeiter($event)"
(vorgangAbgeschlossen)="onVorgangAbgeschlossen()"
data-test-id="bescheid-wizard"
></alfa-bescheid-wizard>
</ng-container>
</div>
</div>
</div>
......
......@@ -21,21 +21,15 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { BescheidResource, BescheidService, BescheidWizardDialogResult, BescheidWizardStep } from '@alfa-client/bescheid-shared';
import { BescheidResource, BescheidWizardDialogResult, BescheidWizardStep } from '@alfa-client/bescheid-shared';
import { CommandOrder, CommandResource } from '@alfa-client/command-shared';
import { createEmptyStateResource, createStateResource, ESCAPE_KEY, StateResource } from '@alfa-client/tech-shared';
import {
ESCAPE_KEY,
StateResource,
createEmptyStateResource,
createErrorStateResource,
createStateResource,
} from '@alfa-client/tech-shared';
import {
DialogRefMock,
Mock,
createDialogRefMock,
DialogRefMock,
existsAsHtmlElement,
getElementFromFixtureByType,
Mock,
mock,
triggerEvent,
useFromMock,
......@@ -47,15 +41,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ButtonComponent, CloseIconComponent } from '@ods/system';
import { MockComponent } from 'ng-mocks';
import { EMPTY, of } from 'rxjs';
import { BescheidService2 } from '../../../../bescheid-shared/src/lib/bescheid2.service';
import { createBescheidResource, createBescheidStateResource } from '../../../../bescheid-shared/src/test/bescheid';
import {
createCommandErrorResource,
createCommandResource,
createSuccessfullyDoneCommandResource,
createSuccessfullyDoneCommandStateResource,
} from '../../../../command-shared/test/command';
import { getDataTestIdOf } from '../../../../tech-shared/test/data-test';
import { createApiError } from '../../../../tech-shared/test/error';
import { createCommandErrorResource, createSuccessfullyDoneCommandResource } from '../../../../command-shared/test/command';
import { getDataTestIdAttributeOf, getDataTestIdOf } from '../../../../tech-shared/test/data-test';
import { singleColdCompleted } from '../../../../tech-shared/test/marbles';
import { createKeydownKeyboardEvent } from '../../../../test-utils/src/lib/keyboard';
import { createVorgangWithEingangResource } from '../../../../vorgang-shared/test/vorgang';
......@@ -73,9 +62,9 @@ describe('BescheidWizardContainerComponent', () => {
let fixture: ComponentFixture<BescheidWizardContainerComponent>;
const bescheidWizard: string = getDataTestIdOf('bescheid-wizard');
const closeButton: string = getDataTestIdOf('close-bescheid');
const closeButton: string = getDataTestIdAttributeOf('close-bescheid');
let bescheidService: Mock<BescheidService>;
let bescheidService: Mock<BescheidService2>;
let ozgcloudDialogService: Mock<OzgcloudDialogService>;
let formService: Mock<BescheidFormService>;
let wizardDialogRef: DialogRefMock<BescheidWizardDialogResult>;
......@@ -83,7 +72,8 @@ describe('BescheidWizardContainerComponent', () => {
const vorgangWithEingangResource: VorgangWithEingangResource = createVorgangWithEingangResource();
beforeEach(() => {
bescheidService = mock(BescheidService);
bescheidService = mock(BescheidService2);
bescheidService.getBescheidCreated.mockReturnValue(EMPTY);
ozgcloudDialogService = mock(OzgcloudDialogService);
formService = mock(BescheidFormService);
wizardDialogRef = createDialogRefMock();
......@@ -115,7 +105,7 @@ describe('BescheidWizardContainerComponent', () => {
useValue: { vorgangWithEingangResource },
},
{
provide: BescheidService,
provide: BescheidService2,
useValue: bescheidService,
},
{
......@@ -160,6 +150,14 @@ describe('BescheidWizardContainerComponent', () => {
expect(formService.setVorgangWithEingangResource).toHaveBeenCalledWith(vorgangWithEingangResource);
});
it('should set active step', () => {
bescheidService.getActiveStep.mockReturnValue(of(BescheidWizardStep.BescheidVersenden));
component.ngOnInit();
expect(component.activeStep$).toBeObservable(singleColdCompleted(BescheidWizardStep.BescheidVersenden));
});
it('should subscribe to bescheid resource', () => {
component.subscribeToBescheidResourceIfExists = jest.fn();
......@@ -231,74 +229,6 @@ describe('BescheidWizardContainerComponent', () => {
});
});
describe('onWeiter', () => {
beforeEach(() => {
formService.submit = jest.fn().mockReturnValue(of(createSuccessfullyDoneCommandStateResource()));
component.isBescheidSuccessfullyCreated = jest.fn().mockReturnValue(true);
bescheidService.getBescheidDraft.mockReturnValue(of(createBescheidStateResource()));
});
it('should submit form', () => {
component.onWeiter(BescheidWizardStep.DokumenteHochladen);
expect(formService.submit).toHaveBeenCalled();
});
it('should increment step on created bescheid', () => {
component.onWeiter(BescheidWizardStep.DokumenteHochladen);
component.submitStateResource$.subscribe();
expect(bescheidService.setActiveStep).toHaveBeenCalledWith(BescheidWizardStep.DokumenteHochladen);
});
it('should increment step on updated bescheid', () => {
component.isBescheidSuccessfullyCreated = jest.fn().mockReturnValue(false);
component.onWeiter(BescheidWizardStep.DokumenteHochladen);
component.submitStateResource$.subscribe();
expect(bescheidService.setActiveStep).toHaveBeenCalledWith(BescheidWizardStep.DokumenteHochladen);
});
it('should not increment step on command resource error', () => {
component.isBescheidSuccessfullyCreated = jest.fn().mockReturnValue(false);
formService.submit = jest.fn().mockReturnValue(of(createErrorStateResource(createApiError())));
component.onWeiter(BescheidWizardStep.DokumenteHochladen);
component.submitStateResource$.subscribe();
expect(bescheidService.setActiveStep).not.toHaveBeenCalled();
});
it('should not increment step on command resource loading', () => {
component.isBescheidSuccessfullyCreated = jest.fn().mockReturnValue(false);
formService.submit = jest.fn().mockReturnValue(of(createStateResource(createCommandResource(), true)));
component.onWeiter(BescheidWizardStep.DokumenteHochladen);
component.submitStateResource$.subscribe();
expect(bescheidService.setActiveStep).not.toHaveBeenCalled();
});
it('should not increment step on bescheid resource error', () => {
bescheidService.getBescheidDraft.mockReturnValue(of(createErrorStateResource(createApiError())));
component.onWeiter(BescheidWizardStep.DokumenteHochladen);
component.submitStateResource$.subscribe();
expect(bescheidService.setActiveStep).not.toHaveBeenCalled();
});
it('should not increment step on bescheid loading', () => {
bescheidService.getBescheidDraft.mockReturnValue(of(createStateResource(null, true)));
component.onWeiter(BescheidWizardStep.DokumenteHochladen);
component.submitStateResource$.subscribe();
expect(bescheidService.setActiveStep).not.toHaveBeenCalled();
});
});
describe('isBescheidSuccessfullyCreated', () => {
it('should return true', () => {
const createBescheidCommandResource: CommandResource = {
......@@ -498,51 +428,27 @@ describe('BescheidWizardContainerComponent', () => {
});
describe('template', () => {
describe('alfa-bescheid-wizard', () => {
describe('wizard', () => {
function getElementComponent(): BescheidWizardComponent {
return getElementFromFixtureByType(fixture, BescheidWizardComponent);
}
describe('input', () => {
it('should set vorgangWithEingangResource', () => {
it('should have been called with inputs', () => {
component.vorgangWithEingangResource = createVorgangWithEingangResource();
fixture.detectChanges();
expect(getElementComponent().vorgangWithEingangResource).toBe(component.vorgangWithEingangResource);
});
it('should set activeStep', () => {
bescheidService.getActiveStep.mockReturnValue(of(2));
fixture.detectChanges();
expect(getElementComponent().activeStep).toBe(2);
});
it('should set bescheidStateResource', () => {
bescheidService.getActiveStep.mockReturnValue(of(BescheidWizardStep.DokumenteHochladen));
const bescheidStateResource: StateResource<BescheidResource> = createBescheidStateResource();
component.bescheidDraftStateResource$ = of(bescheidStateResource);
component.ngOnInit();
fixture.detectChanges();
expect(getElementComponent().bescheidStateResource).toBe(bescheidStateResource);
});
expect(getElementComponent().vorgangWithEingangResource).toEqual(component.vorgangWithEingangResource);
expect(getElementComponent().activeStep).toEqual(2);
expect(getElementComponent().bescheidStateResource).toEqual(bescheidStateResource);
});
describe('output', () => {
it('should call onWeiter', () => {
component.onWeiter = jest.fn();
triggerEvent({
fixture,
name: 'weiterClickEmitter',
elementSelector: bescheidWizard,
});
expect(component.onWeiter).toHaveBeenCalled();
});
describe('vorgangAbgeschlossen', () => {
it('should call onVorgangAbgeschlossen', () => {
component.onVorgangAbgeschlossen = jest.fn();
......@@ -556,13 +462,15 @@ describe('BescheidWizardContainerComponent', () => {
});
});
});
});
describe('ods-button close', () => {
it('should show', () => {
describe('close button', () => {
it('should exists', () => {
existsAsHtmlElement(fixture, closeButton);
});
describe('output', () => {
describe('clickEmitter', () => {
it('should call cancelWizard', () => {
component.cancelWizard = jest.fn();
......@@ -578,3 +486,4 @@ describe('BescheidWizardContainerComponent', () => {
});
});
});
});
......@@ -21,28 +21,19 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { BescheidResource, BescheidService, BescheidWizardDialogResult, BescheidWizardStep } from '@alfa-client/bescheid-shared';
import { CommandOrder, CommandResource, isSuccessfulDone } from '@alfa-client/command-shared';
import {
StateResource,
createEmptyStateResource,
hasStateResourceError,
isEscapeKey,
isLoaded,
isNotLoading,
isNotNil,
} from '@alfa-client/tech-shared';
import { BescheidResource, BescheidWizardDialogResult, BescheidWizardStep } from '@alfa-client/bescheid-shared';
import { CommandOrder, CommandResource, CommandService, isSuccessfulDone } from '@alfa-client/command-shared';
import { createEmptyStateResource, isEscapeKey, isNotLoading, isNotNil, ResourceRepository, StateResource, } from '@alfa-client/tech-shared';
import { OzgcloudDialogService } from '@alfa-client/ui';
import { VorgangWithEingangLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { VorgangService, VorgangWithEingangLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { getEmpfaenger } from '@alfa-client/vorgang-shared-ui';
import { DIALOG_DATA, DialogRef } from '@angular/cdk/dialog';
import { Component, Inject, OnDestroy, OnInit, ViewContainerRef } from '@angular/core';
import { Resource, hasLink } from '@ngxp/rest';
import { Observable, Subscription, filter, first, of, switchMap, tap } from 'rxjs';
import {
BescheidWizardCancelDialogContainerComponent,
CancelWizardDialogData,
CancelWizardDialogResult,
} from './bescheid-wizard/cancel-dialog-container/bescheid-wizard-cancel-dialog-container.component';
import { Component, inject, OnDestroy, OnInit, ViewContainerRef } from '@angular/core';
import { hasLink } from '@ngxp/rest';
import { BescheidResourceService, createBescheidResourceService } from 'libs/bescheid-shared/src/lib/bescheid-resource-service';
import { filter, first, Observable, of, Subscription, switchMap } from 'rxjs';
import { BescheidService2 } from '../../../../bescheid-shared/src/lib/bescheid2.service';
import { BescheidWizardCancelDialogContainerComponent, CancelWizardDialogData, CancelWizardDialogResult, } from './bescheid-wizard/cancel-dialog-container/bescheid-wizard-cancel-dialog-container.component';
import { BescheidFormService } from './bescheid.formservice';
export interface BescheidWizardDialogData {
......@@ -52,42 +43,63 @@ export interface BescheidWizardDialogData {
@Component({
selector: 'alfa-bescheid-wizard-container',
templateUrl: './bescheid-wizard-container.component.html',
providers: [BescheidFormService],
providers: [
BescheidFormService,
BescheidService2,
{
provide: BescheidResourceService,
useFactory: createBescheidResourceService,
deps: [ResourceRepository, CommandService, VorgangService],
},
],
})
export class BescheidWizardContainerComponent implements OnInit, OnDestroy {
private readonly bescheidService = inject(BescheidService2);
private readonly ozgcloudDialogService = inject(OzgcloudDialogService);
private readonly dialogData: BescheidWizardDialogData = inject(DIALOG_DATA);
private readonly dialogRef = inject(DialogRef<BescheidWizardDialogResult>);
private readonly formService = inject(BescheidFormService);
readonly viewContainerRef = inject(ViewContainerRef);
public bescheidDraftStateResource$: Observable<StateResource<BescheidResource>> =
of(createEmptyStateResource<BescheidResource>());
public submitStateResource$: Observable<StateResource<Resource>> = of(createEmptyStateResource<Resource>());
public activeStep$: Observable<BescheidWizardStep>;
cancelDialogRef: DialogRef<CancelWizardDialogResult>;
vorgangWithEingangResource: VorgangWithEingangResource;
keydownEventsSubscription: Subscription;
constructor(
@Inject(DIALOG_DATA) private readonly dialogData: BescheidWizardDialogData,
private readonly dialogRef: DialogRef<BescheidWizardDialogResult>,
readonly viewContainerRef: ViewContainerRef,
public readonly formService: BescheidFormService,
readonly bescheidService: BescheidService,
private readonly ozgcloudDialogService: OzgcloudDialogService,
) {
this.vorgangWithEingangResource = dialogData.vorgangWithEingangResource;
constructor() {
this.vorgangWithEingangResource = this.dialogData.vorgangWithEingangResource;
}
ngOnInit(): void {
this.bescheidService.init();
this.bescheidService.setNachrichtEmpfaenger(getEmpfaenger(this.vorgangWithEingangResource));
this.formService.setVorgangWithEingangResource(this.vorgangWithEingangResource);
this.activeStep$ = this.bescheidService.getActiveStep();
this.subscribeToBescheidResourceIfExists();
this.handleEscapeKey();
}
ngOnDestroy(): void {
this.keydownEventsSubscription.unsubscribe();
this.bescheidService.exit();
}
subscribeToBescheidResourceIfExists(): void {
if (hasLink(this.vorgangWithEingangResource, VorgangWithEingangLinkRel.BESCHEID_DRAFT)) {
this.bescheidDraftStateResource$ = this.bescheidService.getBescheidDraft();
} else {
this.bescheidService
.getBescheidCreated()
.pipe(
filter((created: boolean) => created),
first(),
)
.subscribe(() => {
this.bescheidDraftStateResource$ = this.bescheidService.selectBescheidResource();
});
}
}
......@@ -103,23 +115,6 @@ export class BescheidWizardContainerComponent implements OnInit, OnDestroy {
});
}
public onWeiter(nextStep: BescheidWizardStep): void {
this.submitStateResource$ = this.formService.submit().pipe(
switchMap((commandStateResource: StateResource<CommandResource>) => {
if (this.isBescheidSuccessfullyCreated(commandStateResource.resource)) {
this.bescheidDraftStateResource$ = this.bescheidService.getBescheidDraft();
return this.bescheidDraftStateResource$;
}
return of(commandStateResource);
}),
tap((stateResource: StateResource<Resource>) => {
if (isLoaded(stateResource) && !hasStateResourceError(stateResource)) {
this.bescheidService.setActiveStep(nextStep);
}
}),
);
}
isBescheidSuccessfullyCreated(commandResource: CommandResource): boolean {
return isSuccessfulDone(commandResource) && commandResource.order === CommandOrder.CREATE_BESCHEID;
}
......
......@@ -21,31 +21,18 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import {
createDialogRefMock,
DialogRefMock,
existsAsHtmlElement,
mock,
Mock,
triggerEvent,
useFromMock,
} from '@alfa-client/test-utils';
import { OzgcloudDialogService } from '@alfa-client/ui';
import { BescheidResource } from '@alfa-client/bescheid-shared';
import { createDialogRefMock, DialogRefMock, existsAsHtmlElement, mock, Mock, triggerEvent, useFromMock, } from '@alfa-client/test-utils';
import { createDialogResult, OzgcloudDialogCommandResult, OzgcloudDialogService } from '@alfa-client/ui';
import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { EventEmitter } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { of } from 'rxjs';
import { createSuccessfullyDoneCommandStateResource } from '../../../../../../command-shared/test/command';
import { getDataTestIdOf } from '../../../../../../tech-shared/test/data-test';
import {
createDialogResult,
OzgcloudDialogCommandResult,
} from '../../../../../../ui/src/lib/ui/ozgcloud-dialog/ozgcloud-dialog.result';
import { createVorgangWithEingangResource } from '../../../../../../vorgang-shared/test/vorgang';
import {
AbschliessenDialogData,
BescheidWizardAbschliessenDialogContainerComponent,
} from '../abschliessen-dialog-container/bescheid-wizard-abschliessen-dialog-container.component';
import { createBescheidResource } from '../../../../../../../bescheid-shared/src/test/bescheid';
import { createSuccessfullyDoneCommandStateResource } from '../../../../../../../command-shared/test/command';
import { getDataTestIdOf } from '../../../../../../../tech-shared/test/data-test';
import { createVorgangWithEingangResource } from '../../../../../../../vorgang-shared/test/vorgang';
import { AbschliessenDialogData, BescheidWizardAbschliessenDialogContainerComponent, } from '../abschliessen-dialog-container/bescheid-wizard-abschliessen-dialog-container.component';
import { BescheidWizardAbschliessenButtonComponent } from './bescheid-wizard-abschliessen-button.component';
describe('BescheidWizardAbschliessenButtonComponent', () => {
......@@ -89,14 +76,16 @@ describe('BescheidWizardAbschliessenButtonComponent', () => {
it('should open dialog', () => {
const vorgangWithEingangResource: VorgangWithEingangResource = createVorgangWithEingangResource();
const bescheidResource: BescheidResource = createBescheidResource();
component.vorgangWithEingangResource = vorgangWithEingangResource;
component.bescheidResource = bescheidResource;
component.onClick();
expect(ozgcloudDialogService.openInCallingComponentContext).toHaveBeenCalledWith(
BescheidWizardAbschliessenDialogContainerComponent,
component.viewContainerRef,
{ vorgangWithEingangResource } as AbschliessenDialogData,
{ vorgangWithEingangResource, bescheidResource } as AbschliessenDialogData,
);
});
......
......@@ -21,15 +21,16 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { BescheidResource } from '@alfa-client/bescheid-shared';
import { OzgcloudDialogService } from '@alfa-client/ui';
import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { DialogRef } from '@angular/cdk/dialog';
import { Component, EventEmitter, Input, Output, ViewContainerRef } from '@angular/core';
import { Component, EventEmitter, inject, Input, Output, ViewContainerRef } from '@angular/core';
import { filter } from 'rxjs';
import {
OzgcloudDialogCommandResult,
isDialogSuccessfullyCompleted,
} from '../../../../../../ui/src/lib/ui/ozgcloud-dialog/ozgcloud-dialog.result';
OzgcloudDialogCommandResult,
} from '../../../../../../../ui/src/lib/ui/ozgcloud-dialog/ozgcloud-dialog.result';
import {
AbschliessenDialogData,
BescheidWizardAbschliessenDialogContainerComponent,
......@@ -38,24 +39,24 @@ import {
@Component({
selector: 'alfa-bescheid-wizard-abschliessen-button',
templateUrl: './bescheid-wizard-abschliessen-button.component.html',
styles: [':host {@apply flex-1 flex items-end}'],
})
export class BescheidWizardAbschliessenButtonComponent {
@Input() vorgangWithEingangResource: VorgangWithEingangResource;
@Input() bescheidResource: BescheidResource;
@Output() vorgangAbgeschlossen: EventEmitter<void> = new EventEmitter<void>();
constructor(
private readonly ozgclouDialogService: OzgcloudDialogService,
readonly viewContainerRef: ViewContainerRef,
) {}
private readonly ozgcloudDialogService = inject(OzgcloudDialogService);
readonly viewContainerRef = inject(ViewContainerRef);
public onClick(): void {
const dialogData: AbschliessenDialogData = {
vorgangWithEingangResource: this.vorgangWithEingangResource,
bescheidResource: this.bescheidResource,
};
const dialogRef: DialogRef<OzgcloudDialogCommandResult> =
this.ozgclouDialogService.openInCallingComponentContext(
const dialogRef: DialogRef<OzgcloudDialogCommandResult> = this.ozgcloudDialogService.openInCallingComponentContext(
BescheidWizardAbschliessenDialogContainerComponent,
this.viewContainerRef,
dialogData,
......@@ -65,8 +66,6 @@ export class BescheidWizardAbschliessenButtonComponent {
}
handleDialogClosed(dialogRef: DialogRef<OzgcloudDialogCommandResult>): void {
dialogRef.closed
.pipe(filter(isDialogSuccessfullyCompleted))
.subscribe(() => this.vorgangAbgeschlossen.emit());
dialogRef.closed.pipe(filter(isDialogSuccessfullyCompleted)).subscribe(() => this.vorgangAbgeschlossen.emit());
}
}
......@@ -21,33 +21,24 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { BescheidService } from '@alfa-client/bescheid-shared';
import { BescheidResource } from '@alfa-client/bescheid-shared';
import { CommandResource } from '@alfa-client/command-shared';
import { StateResource } from '@alfa-client/tech-shared';
import {
createDialogRefMock,
DialogRefMock,
getElementComponentFromFixtureByCss,
mock,
Mock,
triggerEvent,
} from '@alfa-client/test-utils';
import { OzgcloudStrokedButtonWithSpinnerComponent } from '@alfa-client/ui';
import { createDialogRefMock, DialogRefMock, getElementComponentFromFixtureByCss, mock, Mock, triggerEvent, } from '@alfa-client/test-utils';
import { createDialogResult, OzgcloudStrokedButtonWithSpinnerComponent } from '@alfa-client/ui';
import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { DIALOG_DATA, DialogRef } from '@angular/cdk/dialog';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatIcon } from '@angular/material/icon';
import { MockComponent } from 'ng-mocks';
import { of } from 'rxjs';
import { createSuccessfullyDoneCommandStateResource } from '../../../../../../command-shared/test/command';
import { getDataTestIdOf } from '../../../../../../tech-shared/test/data-test';
import { singleColdCompleted } from '../../../../../../tech-shared/test/marbles';
import { createDialogResult } from '../../../../../../ui/src/lib/ui/ozgcloud-dialog/ozgcloud-dialog.result';
import { createVorgangWithEingangResource } from '../../../../../../vorgang-shared/test/vorgang';
import {
AbschliessenDialogData,
BescheidWizardAbschliessenDialogContainerComponent,
} from './bescheid-wizard-abschliessen-dialog-container.component';
import { BescheidService2 } from '../../../../../../../bescheid-shared/src/lib/bescheid2.service';
import { createBescheidResource } from '../../../../../../../bescheid-shared/src/test/bescheid';
import { createSuccessfullyDoneCommandStateResource } from '../../../../../../../command-shared/test/command';
import { getDataTestIdOf } from '../../../../../../../tech-shared/test/data-test';
import { singleColdCompleted } from '../../../../../../../tech-shared/test/marbles';
import { createVorgangWithEingangResource } from '../../../../../../../vorgang-shared/test/vorgang';
import { AbschliessenDialogData, BescheidWizardAbschliessenDialogContainerComponent, } from './bescheid-wizard-abschliessen-dialog-container.component';
describe('BescheidWizardAbschliessenDialogContainerComponent', () => {
let component: BescheidWizardAbschliessenDialogContainerComponent;
......@@ -57,13 +48,14 @@ describe('BescheidWizardAbschliessenDialogContainerComponent', () => {
const confirmButtonDataTestId: string = getDataTestIdOf('ueberspringen-abschliessen-button');
const cancelButtonDataTestId: string = getDataTestIdOf('ueberspringen-abbrechen-button');
const vorgangWithEingangResource: VorgangWithEingangResource = createVorgangWithEingangResource();
const dialogData: AbschliessenDialogData = { vorgangWithEingangResource };
const bescheidResource: BescheidResource = createBescheidResource();
const dialogData: AbschliessenDialogData = { vorgangWithEingangResource, bescheidResource };
let dialogRef: DialogRefMock;
let bescheidService: Mock<BescheidService>;
let bescheidService: Mock<BescheidService2>;
beforeEach(() => {
bescheidService = mock(BescheidService);
bescheidService = mock(BescheidService2);
dialogRef = createDialogRefMock();
});
......@@ -84,7 +76,7 @@ describe('BescheidWizardAbschliessenDialogContainerComponent', () => {
useValue: dialogRef,
},
{
provide: BescheidService,
provide: BescheidService2,
useValue: bescheidService,
},
],
......@@ -111,16 +103,16 @@ describe('BescheidWizardAbschliessenDialogContainerComponent', () => {
describe('onConfirm', () => {
it('should call bescheid service', () => {
const commandStateResource: StateResource<CommandResource> = createSuccessfullyDoneCommandStateResource();
bescheidService.bescheidErstellungUeberspringen.mockReturnValue(of(commandStateResource));
bescheidService.skipBescheidCreation.mockReturnValue(of(commandStateResource));
component.onConfirm();
expect(bescheidService.bescheidErstellungUeberspringen).toHaveBeenCalledWith(vorgangWithEingangResource);
expect(bescheidService.skipBescheidCreation).toHaveBeenCalledWith(vorgangWithEingangResource, bescheidResource);
});
it('should set abschliessen$', () => {
const commandStateResource: StateResource<CommandResource> = createSuccessfullyDoneCommandStateResource();
bescheidService.bescheidErstellungUeberspringen.mockReturnValue(of(commandStateResource));
bescheidService.skipBescheidCreation.mockReturnValue(of(commandStateResource));
component.onConfirm();
......@@ -129,7 +121,7 @@ describe('BescheidWizardAbschliessenDialogContainerComponent', () => {
it('should close dialog', () => {
const commandStateResource: StateResource<CommandResource> = createSuccessfullyDoneCommandStateResource();
bescheidService.bescheidErstellungUeberspringen.mockReturnValue(of(commandStateResource));
bescheidService.skipBescheidCreation.mockReturnValue(of(commandStateResource));
component.onConfirm();
component.abschliessen$.subscribe();
......@@ -140,7 +132,7 @@ describe('BescheidWizardAbschliessenDialogContainerComponent', () => {
});
describe('template', () => {
describe('button close', () => {
describe('close button', () => {
describe('output', () => {
it('should call onClose', () => {
component.onClose = jest.fn();
......@@ -152,7 +144,7 @@ describe('BescheidWizardAbschliessenDialogContainerComponent', () => {
});
});
describe('ozgcloud-stroked-button-with-spinner Überspringen und abschließen', () => {
describe('überspringen und abschließen button', () => {
function getElementComponent(): OzgcloudStrokedButtonWithSpinnerComponent {
return getElementComponentFromFixtureByCss(fixture, confirmButtonDataTestId);
}
......@@ -172,18 +164,14 @@ describe('BescheidWizardAbschliessenDialogContainerComponent', () => {
it('should call onConfirm', () => {
component.onConfirm = jest.fn();
triggerEvent({
fixture,
name: 'click',
elementSelector: confirmButtonDataTestId,
});
triggerEvent({ fixture, name: 'click', elementSelector: confirmButtonDataTestId });
expect(component.onConfirm).toHaveBeenCalled();
});
});
});
describe('ozgcloud-stroked-button-with-spinner Abbrechen', () => {
describe('abbrechen button', () => {
it('should call onClose', () => {
component.onClose = jest.fn();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment