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

Merge pull request 'OZG-2801-Historie' (#160) from OZG-2801-Historie into master

parents 067457a6 232144fa
No related branches found
No related tags found
No related merge requests found
Showing with 80 additions and 19 deletions
...@@ -149,6 +149,7 @@ export class KommentarHistorieItemE2EComponent { ...@@ -149,6 +149,7 @@ export class KommentarHistorieItemE2EComponent {
private readonly locatorRoot: string; private readonly locatorRoot: string;
private readonly locatorText: string = 'kommentar-text'; private readonly locatorText: string = 'kommentar-text';
private readonly locatorAttachment: string = 'historie-item-attachment';
constructor(rootLocator: string) { constructor(rootLocator: string) {
this.locatorRoot = rootLocator; this.locatorRoot = rootLocator;
...@@ -161,4 +162,8 @@ export class KommentarHistorieItemE2EComponent { ...@@ -161,4 +162,8 @@ export class KommentarHistorieItemE2EComponent {
public getText() { public getText() {
return this.getRoot().findTestElementWithClass(this.locatorText); return this.getRoot().findTestElementWithClass(this.locatorText);
} }
public getAttachment() {
return this.getRoot().findTestElementWithClass(this.locatorAttachment);
}
} }
\ No newline at end of file
...@@ -63,15 +63,16 @@ describe('Historie', () => { ...@@ -63,15 +63,16 @@ describe('Historie', () => {
createdAt: { $date: '2020-01-01T10:00:00.000Z' } createdAt: { $date: '2020-01-01T10:00:00.000Z' }
}; };
const kommentarCommandBody = { itemName: 'Kommentar', item: createKommentar() }; const createKommentarCommandBody = { itemName: 'Kommentar', item: {...createKommentar(), attachments: 'DummyAttachment'} };
const createKommentarCommand: CommandE2E = { const createKommentarCommand: CommandE2E = {
...buildCommand(CommandOrderE2E.CREATE_ATTACHED_ITEM, vorgang._id.$oid, vorgang._id.$oid), ...buildCommand(CommandOrderE2E.CREATE_ATTACHED_ITEM, vorgang._id.$oid, vorgang._id.$oid),
bodyObject: kommentarCommandBody, bodyObject: createKommentarCommandBody,
createdAt: { $date: '2020-01-01T10:01:00.000Z' } createdAt: { $date: '2020-01-01T10:01:00.000Z' }
}; };
const editKommentarCommandBody = { itemName: 'Kommentar', item: {...createKommentar(), attachments: ['DummyAttachment', 'DummyAttachment2']} };
const editKommentarCommand: CommandE2E = { const editKommentarCommand: CommandE2E = {
...buildCommand(CommandOrderE2E.UPDATE_ATTACHED_ITEM, vorgang._id.$oid, vorgang._id.$oid), ...buildCommand(CommandOrderE2E.UPDATE_ATTACHED_ITEM, vorgang._id.$oid, vorgang._id.$oid),
bodyObject: kommentarCommandBody, bodyObject: editKommentarCommandBody,
createdAt: { $date: '2020-01-01T10:02:00.000Z' } createdAt: { $date: '2020-01-01T10:02:00.000Z' }
}; };
...@@ -225,7 +226,9 @@ describe('Historie', () => { ...@@ -225,7 +226,9 @@ describe('Historie', () => {
historieItem.getExpandButton().click(); historieItem.getExpandButton().click();
const kommentarItem: KommentarHistorieItemE2EComponent = historieItem.getKommentar(); const kommentarItem: KommentarHistorieItemE2EComponent = historieItem.getKommentar();
contains(kommentarItem.getText(), kommentarCommandBody.item.text); contains(kommentarItem.getText(), createKommentarCommandBody.item.text);
contains(kommentarItem.getAttachment(), HistorieAttachmentE2E.SINGLE_TEXT);
}) })
it('edit kommentar', () => { it('edit kommentar', () => {
...@@ -238,7 +241,8 @@ describe('Historie', () => { ...@@ -238,7 +241,8 @@ describe('Historie', () => {
historieItem.getExpandButton().click(); historieItem.getExpandButton().click();
const kommentarItem: KommentarHistorieItemE2EComponent = historieItem.getKommentar(); const kommentarItem: KommentarHistorieItemE2EComponent = historieItem.getKommentar();
contains(kommentarItem.getText(), kommentarCommandBody.item.text); contains(kommentarItem.getText(), editKommentarCommandBody.item.text);
contains(kommentarItem.getAttachment(), HistorieAttachmentE2E.MULTIPLE_TEXT.replace('{countAttachments}', '2'));
}) })
}) })
......
...@@ -25,4 +25,5 @@ ...@@ -25,4 +25,5 @@
--> -->
<goofy-client-expansion-panel-with-user [headline]="headline" [resource]="command"> <goofy-client-expansion-panel-with-user [headline]="headline" [resource]="command">
<p data-test-class="kommentar-text">{{ kommentar.text }}</p> <p data-test-class="kommentar-text">{{ kommentar.text }}</p>
<goofy-client-historie-item-attachment *ngIf="kommentar.attachments" [attachments]="kommentar.attachments" data-test-class="historie-item-kommentar-attachment"></goofy-client-historie-item-attachment>
</goofy-client-expansion-panel-with-user> </goofy-client-expansion-panel-with-user>
...@@ -23,9 +23,14 @@ ...@@ -23,9 +23,14 @@
*/ */
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CommandOrder, CommandResource } from '@goofy-client/command-shared'; import { CommandOrder, CommandResource } from '@goofy-client/command-shared';
import { KommentarResource } from '@goofy-client/kommentar-shared';
import { getElementFromFixture } from '@goofy-client/test-utils';
import { createCommandResource } from 'libs/command-shared/test/command'; import { createCommandResource } from 'libs/command-shared/test/command';
import { getDataTestClassOf } from 'libs/tech-shared/test/data-test';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { createKommentarResource } from '../../../../../../kommentar-shared/test/kommentar';
import { ExpansionPanelWithUserComponent } from '../expansion-panel-with-user/expansion-panel-with-user.component'; import { ExpansionPanelWithUserComponent } from '../expansion-panel-with-user/expansion-panel-with-user.component';
import { HistorieItemAttachmentComponent } from '../historie-item-attachment/historie-item-attachment.component';
import { HistorieItemKommentarComponent } from './historie-item-kommentar.component'; import { HistorieItemKommentarComponent } from './historie-item-kommentar.component';
describe('HistorieItemKommentarComponent', () => { describe('HistorieItemKommentarComponent', () => {
...@@ -38,11 +43,14 @@ describe('HistorieItemKommentarComponent', () => { ...@@ -38,11 +43,14 @@ describe('HistorieItemKommentarComponent', () => {
body: { item: { text: 'Beispiel text fuer einen Kommentar' } } body: { item: { text: 'Beispiel text fuer einen Kommentar' } }
}; };
const attachment: string = getDataTestClassOf('historie-item-kommentar-attachment');
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ declarations: [
HistorieItemKommentarComponent, HistorieItemKommentarComponent,
MockComponent(ExpansionPanelWithUserComponent) MockComponent(ExpansionPanelWithUserComponent),
MockComponent(HistorieItemAttachmentComponent)
], ],
}).compileComponents(); }).compileComponents();
}); });
...@@ -58,7 +66,7 @@ describe('HistorieItemKommentarComponent', () => { ...@@ -58,7 +66,7 @@ describe('HistorieItemKommentarComponent', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
describe('ngOnIniit', () => { describe('ngOnInit', () => {
it('should set headline for order ' + CommandOrder.CREATE_KOMMENTAR, () => { it('should set headline for order ' + CommandOrder.CREATE_KOMMENTAR, () => {
component.command = { ...kommentarCommand, order: CommandOrder.CREATE_KOMMENTAR }; component.command = { ...kommentarCommand, order: CommandOrder.CREATE_KOMMENTAR };
...@@ -76,4 +84,35 @@ describe('HistorieItemKommentarComponent', () => { ...@@ -76,4 +84,35 @@ describe('HistorieItemKommentarComponent', () => {
expect(component.headline).toBe(`ein Kommentar bearbeitet.`); expect(component.headline).toBe(`ein Kommentar bearbeitet.`);
}) })
}) })
describe('attachments', () => {
beforeEach(() => {
component.command = createCommand(createKommentarResource());
})
it('should hide of NOT exists', () => {
const item: KommentarResource = createKommentarResource();
delete item['attachments'];
component.command = createCommand(item);
fixture.detectChanges();
const attachmentElement = getElementFromFixture(fixture, attachment);
expect(attachmentElement).not.toBeInstanceOf(HTMLElement);
})
it('should show if exists', () => {
component.command = createCommand(createKommentarResource());
fixture.detectChanges();
const attachmentElement = getElementFromFixture(fixture, attachment);
expect(attachmentElement).toBeInstanceOf(HTMLElement);
})
function createCommand(item: KommentarResource): CommandResource{
return { ...createCommandResource(), order: CommandOrder.CREATE_KOMMENTAR, body: { item } };
}
})
}); });
...@@ -21,4 +21,19 @@ ...@@ -21,4 +21,19 @@
* 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 '@testing-library/jest-dom';
import 'jest-preset-angular/setup-jest'; import 'jest-preset-angular/setup-jest';
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
getTestBed().resetTestEnvironment();
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{
teardown: { destroyAfterEach: false },
errorOnUnknownProperties: true,
errorOnUnknownElements: true
}
);
\ No newline at end of file
...@@ -24,17 +24,17 @@ ...@@ -24,17 +24,17 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms'; import { ReactiveFormsModule } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field'; import { MatFormFieldModule } from '@angular/material/form-field';
import { BinaryFileAttachmentContainerComponent } from '@goofy-client/binary-file';
import { KommentarLinkRel, KommentarService } from '@goofy-client/kommentar-shared'; import { KommentarLinkRel, KommentarService } from '@goofy-client/kommentar-shared';
import { createStateResource } from '@goofy-client/tech-shared';
import { mock } from '@goofy-client/test-utils'; import { mock } from '@goofy-client/test-utils';
import { ButtonWithSpinnerComponent, TextAreaEditorComponent } from '@goofy-client/ui'; import { ButtonWithSpinnerComponent, TextAreaEditorComponent } from '@goofy-client/ui';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { of } from 'rxjs';
import { createBinaryFileListResource } from '../../../../../binary-file-shared/test/binary-file';
import { createKommentarResource } from '../../../../../kommentar-shared/test/kommentar';
import { KommentarFormComponent } from './kommentar-form.component'; import { KommentarFormComponent } from './kommentar-form.component';
import { KommentarFormService } from './kommentar.formservice'; import { KommentarFormService } from './kommentar.formservice';
import { createKommentarResource } from "../../../../../kommentar-shared/test/kommentar";
import { BinaryFileAttachmentContainerComponent } from "@goofy-client/binary-file";
import { createStateResource } from "@goofy-client/tech-shared";
import { of } from "rxjs";
import { createBinaryFileListResource } from "../../../../../binary-file-shared/test/binary-file";
describe('KommentarFormComponent', () => { describe('KommentarFormComponent', () => {
let component: KommentarFormComponent; let component: KommentarFormComponent;
......
...@@ -25,10 +25,7 @@ import '@testing-library/jest-dom'; ...@@ -25,10 +25,7 @@ import '@testing-library/jest-dom';
import 'jest-preset-angular/setup-jest'; import 'jest-preset-angular/setup-jest';
import { getTestBed } from '@angular/core/testing'; import { getTestBed } from '@angular/core/testing';
import { import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
getTestBed().resetTestEnvironment(); getTestBed().resetTestEnvironment();
getTestBed().initTestEnvironment( getTestBed().initTestEnvironment(
......
keycloak: keycloak:
realm: sh-e2e-dev realm: by-e2e-local-dev
resource: sh-e2e-dev-goofy resource: by-e2e-local-dev-goofy
kop: kop:
forwarding: forwarding:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment