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

OZG-3030 OZG-3102 translate order RESEND_POSTFACH_MAIL; add E2E Tests

parent 084b7670
No related branches found
No related tags found
No related merge requests found
Showing
with 85 additions and 14 deletions
......@@ -128,6 +128,8 @@ describe('Historie', () => {
createdAt: { $date: '2020-01-01T10:08:00.000Z' }
};
const resendPostfachNachricht: CommandE2E = buildCommand(CommandOrderE2E.RESEND_POSTFACH_NACHRICHT, vorgang._id.$oid, vorgang._id.$oid);
const createWiedervorlageCommandBody = { ...createWiedervorlageItem('Create Wiedervorlage Betreff'), attachments: 'DummyAttachment' };
const createWiedervorlageCommand: CommandE2E = {
...buildCommand(CommandOrderE2E.CREATE_ATTACHED_ITEM, vorgang._id.$oid, vorgang._id.$oid),
......@@ -157,7 +159,7 @@ describe('Historie', () => {
assignUserCommand,
createKommentarCommand, editKommentarCommand,
forwardVorgangCommand, forwardSuccessfulCommand, forwardFailedCommand,
sendPostfachMailCommand, sendPostfachNachrichtCommand, receivePostfachNachrichtCommand,
sendPostfachMailCommand, sendPostfachNachrichtCommand, receivePostfachNachrichtCommand, resendPostfachNachricht,
createWiedervorlageCommand, editWiedervorlageCommand, wiedervorlageErledigenCommand, wiedervorlageWiedereroeffnenCommand
]);
initUsermanagerUsers([getUserManagerUserSabine(), getUserManagerUserPeter(), getUserManagerUserEmil()]);
......@@ -315,12 +317,20 @@ describe('Historie', () => {
contains(postfachNachtichtItem.getPostfachNachrichtSubject(), receivePostfachNachrichtCommand.bodyObject.item.subject);
contains(postfachNachtichtItem.getPostfachNachrichtMailBody(), receivePostfachNachrichtCommand.bodyObject.item.mailBody);
})
it('resend postfach nachricht', () => {
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieContainer().getListItemByIndex(9);
exist(historieItem.getRoot());
contains(historieItem.getHeadline(), HistorieHeadlineE2E.RESEND_POSTFACH_NACHRICHT);
contains(historieItem.getUser(), userName);
})
})
describe('wiedervorlage order', () => {
it('create wiedervorlage', () => {
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieContainer().getListItemByIndex(9);
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieContainer().getListItemByIndex(10);
exist(historieItem.getRoot());
contains(historieItem.getHeadline(), HistorieHeadlineE2E.CREATE_WIEDERVORLAGE);
......@@ -336,7 +346,7 @@ describe('Historie', () => {
})
it('edit wiedervorlage', () => {
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieContainer().getListItemByIndex(10);
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieContainer().getListItemByIndex(11);
exist(historieItem.getRoot());
contains(historieItem.getHeadline(), HistorieHeadlineE2E.EDIT_WIEDERVORLAGE);
......@@ -352,7 +362,7 @@ describe('Historie', () => {
})
it('wiedervorlage erledigen', () => {
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieContainer().getListItemByIndex(11);
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieContainer().getListItemByIndex(12);
exist(historieItem.getRoot());
contains(historieItem.getHeadline(), HistorieHeadlineE2E.WIEDERVORLAGE_ERLEDIGEN);
......@@ -361,7 +371,7 @@ describe('Historie', () => {
})
it('wiedervorlage wiedereroeffnen', () => {
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieContainer().getListItemByIndex(12);
const historieItem: VorgangFormularDatenHistorieItemE2EComponent = vorgangDatenFormular.getHistorieContainer().getListItemByIndex(13);
exist(historieItem.getRoot());
contains(historieItem.getHeadline(), HistorieHeadlineE2E.WIEDERVORLAGE_WIEDEREROEFFNEN);
......
......@@ -31,9 +31,10 @@ export enum CommandOrderE2E {
FORWARD_SUCCESSFUL = 'FORWARD_SUCCESSFULL', //TODO Rename Order
FORWARD_FAILED = 'FORWARD_FAILED',
PATCH_ATTACHED_ITEM = 'PATCH_ATTACHED_ITEM',
RECEIVE_POSTFACH_NACHRICHT = 'RECEIVE_POSTFACH_NACHRICHT',
RESEND_POSTFACH_NACHRICHT = 'RESEND_POSTFACH_MAIL',
SEND_POSTFACH_MAIL = 'SEND_POSTFACH_MAIL',
SEND_POSTFACH_NACHRICHT = 'SEND_POSTFACH_NACHRICHT',
RECEIVE_POSTFACH_NACHRICHT = 'RECEIVE_POSTFACH_NACHRICHT',
UPDATE_ATTACHED_ITEM = 'UPDATE_ATTACHED_ITEM'
}
export class CommandE2E {
......
......@@ -35,6 +35,7 @@ export enum HistorieHeadlineE2E {
FORWARD_FAILED = 'die Weiterleitung widerrufen.',
SEND_POSTFACH_NACHRICHT = 'eine Nachricht geschrieben',
RECEIVE_POSTFACH_NACHRICHT = 'eine Nachricht des Antragstellers empfangen.',
RESEND_POSTFACH_NACHRICHT = 'eine Nachricht erneut versendet.',
WIEDERVORLAGE_ERLEDIGEN = 'eine Wiedervorlage als erledigt markiert.',
WIEDERVORLAGE_WIEDEREROEFFNEN = 'eine Wiedervorlage als offen markiert.',
}
......
......@@ -64,6 +64,7 @@ export enum CommandOrder {
FORWARD_SUCCESSFULL = 'FORWARD_SUCCESSFULL',
SEND_POSTFACH_NACHRICHT = 'SEND_POSTFACH_NACHRICHT',
RECEIVE_POSTFACH_NACHRICHT = 'RECEIVE_POSTFACH_NACHRICHT',
RESEND_POSTFACH_NACHRICHT = 'RESEND_POSTFACH_MAIL',
WIEDERVORLAGE_ERLEDIGEN = 'WIEDERVORLAGE_ERLEDIGEN',
WIEDERVORLAGE_WIEDEREROEFFNEN = 'WIEDERVORLAGE_WIEDEREROEFFNEN',
VORGANG_ANNEHMEN = 'VORGANG_ANNEHMEN',
......@@ -96,6 +97,7 @@ export const ORDER_TYPE_BY_COMMAND_ORDER = {
[CommandOrder.FORWARD_SUCCESSFULL]: CommandOrderType.FORWARDING,
[CommandOrder.SEND_POSTFACH_NACHRICHT]: CommandOrderType.POSTFACH_NACHRICHT,
[CommandOrder.RECEIVE_POSTFACH_NACHRICHT]: CommandOrderType.POSTFACH_NACHRICHT,
[CommandOrder.RESEND_POSTFACH_NACHRICHT]: CommandOrderType.POSTFACH_NACHRICHT,
[CommandOrder.WIEDERVORLAGE_ERLEDIGEN]: CommandOrderType.WIEDERVORLAGE,
[CommandOrder.WIEDERVORLAGE_WIEDEREROEFFNEN]: CommandOrderType.WIEDERVORLAGE,
[CommandOrder.VORGANG_ANNEHMEN]: CommandOrderType.VORGANG,
......
......@@ -23,8 +23,13 @@
unter der Lizenz sind dem Lizenztext zu entnehmen.
-->
<goofy-client-expansion-panel-with-user [headline]="headline" [resource]="command" data-test-id="historie-item-wiedervorlage-user-expansion-panel">
<goofy-client-expansion-panel-with-user *ngIf="postfachNachricht; else withoutBody" [headline]="headline" [resource]="command" data-test-class="historie-item-postfach-nachricht-user-expansion-panel-with-body">
<p data-test-class="postfach-nachricht-subject" class="subject">{{postfachNachricht.subject}}</p>
<p data-test-class="postfach-nachricht-mail-body">{{postfachNachricht.mailBody}}</p>
<goofy-client-historie-item-attachment *ngIf="postfachNachricht.attachments" [attachments]="postfachNachricht.attachments" data-test-id="historie-item-postfach-nachricht-attachment"></goofy-client-historie-item-attachment>
<goofy-client-historie-item-attachment *ngIf="postfachNachricht.attachments" [attachments]="postfachNachricht.attachments" data-test-class="historie-item-postfach-nachricht-attachment"></goofy-client-historie-item-attachment>
</goofy-client-expansion-panel-with-user>
<ng-template #withoutBody>
<goofy-client-expansion-panel-with-user [headline]="headline" [resource]="command" data-test-class="historie-item-postfach-nachricht-user-expansion-panel">
</goofy-client-expansion-panel-with-user>
</ng-template>
\ No newline at end of file
......@@ -27,8 +27,8 @@ import { CommandOrder, CommandResource } from '@goofy-client/command-shared';
import { PostfachMail } from '@goofy-client/postfach-shared';
import { getElementFromFixture } from '@goofy-client/test-utils';
import { createCommandResource } from 'libs/command-shared/test/command';
import { createPostfachMail } from 'libs/postfach-shared/test/postfach';
import { getDataTestIdOf } from 'libs/tech-shared/test/data-test';
import { createPostfachMail, createPostfachMailResource } from 'libs/postfach-shared/test/postfach';
import { getDataTestClassOf } from 'libs/tech-shared/test/data-test';
import { MockComponent } from 'ng-mocks';
import { ExpansionPanelWithUserComponent } from '../expansion-panel-with-user/expansion-panel-with-user.component';
import { HistorieItemAttachmentComponent } from '../historie-item-attachment/historie-item-attachment.component';
......@@ -41,7 +41,9 @@ describe('HistorieItemPostfachNachrichtComponent', () => {
const item: PostfachMail = createPostfachMail();
const postfachNachrichtCommand: CommandResource = { ...createCommandResource(), body: { item: item } };
const attachment: string = getDataTestIdOf('historie-item-postfach-nachricht-attachment');
const attachment: string = getDataTestClassOf('historie-item-postfach-nachricht-attachment');
const expansionPanel: string = getDataTestClassOf('historie-item-postfach-nachricht-user-expansion-panel');
const mailBody: string = getDataTestClassOf('postfach-nachricht-mail-body');
beforeEach(async () => {
await TestBed.configureTestingModule({
......@@ -136,4 +138,45 @@ describe('HistorieItemPostfachNachrichtComponent', () => {
expect(attachmentElement).toBeInstanceOf(HTMLElement);
})
})
describe('postfach nachricht body exists', () => {
beforeEach(() => {
component.postfachNachricht = createPostfachMailResource();
fixture.detectChanges();
})
it('should show postfach nachricht with body', () => {
const element = getElementFromFixture(fixture, mailBody);
expect(element).toBeInstanceOf(HTMLElement);
})
it('should hide postfach nachricht', () => {
const element = getElementFromFixture(fixture, expansionPanel);
expect(element).not.toBeInstanceOf(HTMLElement);
})
})
describe('postfach nachricht body not exists', () => {
beforeEach(() => {
component.postfachNachricht = undefined;
fixture.detectChanges();
})
it('should show postfach nachricht', () => {
const element = getElementFromFixture(fixture, expansionPanel);
expect(element).toBeInstanceOf(HTMLElement);
})
it('should hide postfach nachricht with body', () => {
const element = getElementFromFixture(fixture, mailBody);
expect(element).not.toBeInstanceOf(HTMLElement);
})
})
});
......@@ -54,4 +54,5 @@ export class HistorieItemPostfachNachrichtComponent {
const HISTORIE_TEXT_BY_POSTFACH_NACHRICHT_ORDER: { [order: string]: string } = {
[CommandOrder.SEND_POSTFACH_NACHRICHT]: 'eine Nachricht geschrieben.',
[CommandOrder.RECEIVE_POSTFACH_NACHRICHT]: 'eine Nachricht des Antragstellers empfangen.',
[CommandOrder.RESEND_POSTFACH_NACHRICHT]: 'eine Nachricht erneut versendet.'
}
\ No newline at end of file
......@@ -109,13 +109,21 @@ describe('PostfachUtil', () => {
expect(count).toBe(PostfachNachrichtenCount.NONE);
})
it('should return NONE on non existing resources', () => {
it('should return NONE on empty resource list', () => {
var listResource: PostfachMailListResource = createListResource([]);
var count: PostfachNachrichtenCount = getPostfachNachrichtenCount(listResource);
expect(count).toBe(PostfachNachrichtenCount.NONE);
})
it('should return NONE on non existing resources', () => {
var listResource: PostfachMailListResource = toResource({}, [], {});
var count: PostfachNachrichtenCount = getPostfachNachrichtenCount(listResource);
expect(count).toBe(PostfachNachrichtenCount.NONE);
})
})
it('should return SINGLE on one existing resources', () => {
......
......@@ -49,7 +49,7 @@ export function getPostfachNachrichtenCount(postfachMailListResource: PostfachMa
}
const resources: PostfachMailResource[] = getEmbeddedResource<PostfachMailResource[]>(postfachMailListResource, PostfachMailListLinkRel.POSTFACH_MAIL_LIST);
if (resources.length == 0) {
if (isNil(resources) || resources.length == 0) {
return PostfachNachrichtenCount.NONE;
}
if (resources.length == 1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment