diff --git a/goofy-client/apps/goofy-e2e/src/components/vorgang/vorgang.formular-daten.historie.e2e.component.ts b/goofy-client/apps/goofy-e2e/src/components/vorgang/vorgang.formular-daten.historie.e2e.component.ts index 4b4969801908f10f848a41e64438477932724045..aacf32c6360b98f94a23adb2ca3abe7d38b4f96d 100644 --- a/goofy-client/apps/goofy-e2e/src/components/vorgang/vorgang.formular-daten.historie.e2e.component.ts +++ b/goofy-client/apps/goofy-e2e/src/components/vorgang/vorgang.formular-daten.historie.e2e.component.ts @@ -149,6 +149,7 @@ export class KommentarHistorieItemE2EComponent { private readonly locatorRoot: string; private readonly locatorText: string = 'kommentar-text'; + private readonly locatorAttachment: string = 'historie-item-attachment'; constructor(rootLocator: string) { this.locatorRoot = rootLocator; @@ -161,4 +162,8 @@ export class KommentarHistorieItemE2EComponent { public getText() { return this.getRoot().findTestElementWithClass(this.locatorText); } + + public getAttachment() { + return this.getRoot().findTestElementWithClass(this.locatorAttachment); + } } \ No newline at end of file diff --git a/goofy-client/apps/goofy-e2e/src/integration/main-tests/historie/historie.e2e-spec.ts b/goofy-client/apps/goofy-e2e/src/integration/main-tests/historie/historie.e2e-spec.ts index 7b4607fc4dc2589c4bed33c7a38d07dc62743388..aa28e7a8285edc5677ebb80d737d3ea6b85293ce 100644 --- a/goofy-client/apps/goofy-e2e/src/integration/main-tests/historie/historie.e2e-spec.ts +++ b/goofy-client/apps/goofy-e2e/src/integration/main-tests/historie/historie.e2e-spec.ts @@ -63,15 +63,16 @@ describe('Historie', () => { 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 = { ...buildCommand(CommandOrderE2E.CREATE_ATTACHED_ITEM, vorgang._id.$oid, vorgang._id.$oid), - bodyObject: kommentarCommandBody, + bodyObject: createKommentarCommandBody, createdAt: { $date: '2020-01-01T10:01:00.000Z' } }; + const editKommentarCommandBody = { itemName: 'Kommentar', item: {...createKommentar(), attachments: ['DummyAttachment', 'DummyAttachment2']} }; const editKommentarCommand: CommandE2E = { ...buildCommand(CommandOrderE2E.UPDATE_ATTACHED_ITEM, vorgang._id.$oid, vorgang._id.$oid), - bodyObject: kommentarCommandBody, + bodyObject: editKommentarCommandBody, createdAt: { $date: '2020-01-01T10:02:00.000Z' } }; @@ -225,7 +226,9 @@ describe('Historie', () => { historieItem.getExpandButton().click(); 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', () => { @@ -238,7 +241,8 @@ describe('Historie', () => { historieItem.getExpandButton().click(); 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')); }) }) diff --git a/goofy-client/libs/historie/src/lib/historie-container/historie-list/historie-item-kommentar/historie-item-kommentar.component.html b/goofy-client/libs/historie/src/lib/historie-container/historie-list/historie-item-kommentar/historie-item-kommentar.component.html index d6d837f368c8c182e4465e0e28492de9ec68c7e3..a5acd907c96a54a5cac1481dd046c0ade43924b0 100644 --- a/goofy-client/libs/historie/src/lib/historie-container/historie-list/historie-item-kommentar/historie-item-kommentar.component.html +++ b/goofy-client/libs/historie/src/lib/historie-container/historie-list/historie-item-kommentar/historie-item-kommentar.component.html @@ -25,4 +25,5 @@ --> <goofy-client-expansion-panel-with-user [headline]="headline" [resource]="command"> <p data-test-class="kommentar-text">{{ kommentar.text }}</p> -</goofy-client-expansion-panel-with-user> \ No newline at end of file + <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> diff --git a/goofy-client/libs/historie/src/lib/historie-container/historie-list/historie-item-kommentar/historie-item-kommentar.component.spec.ts b/goofy-client/libs/historie/src/lib/historie-container/historie-list/historie-item-kommentar/historie-item-kommentar.component.spec.ts index 73167fb8e5675351332b22848798f94fb92783b4..c1c046ee9865b0394487f10df9e13bf5582a8819 100644 --- a/goofy-client/libs/historie/src/lib/historie-container/historie-list/historie-item-kommentar/historie-item-kommentar.component.spec.ts +++ b/goofy-client/libs/historie/src/lib/historie-container/historie-list/historie-item-kommentar/historie-item-kommentar.component.spec.ts @@ -23,9 +23,14 @@ */ import { ComponentFixture, TestBed } from '@angular/core/testing'; 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 { getDataTestClassOf } from 'libs/tech-shared/test/data-test'; 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 { HistorieItemAttachmentComponent } from '../historie-item-attachment/historie-item-attachment.component'; import { HistorieItemKommentarComponent } from './historie-item-kommentar.component'; describe('HistorieItemKommentarComponent', () => { @@ -38,11 +43,14 @@ describe('HistorieItemKommentarComponent', () => { body: { item: { text: 'Beispiel text fuer einen Kommentar' } } }; + const attachment: string = getDataTestClassOf('historie-item-kommentar-attachment'); + beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [ HistorieItemKommentarComponent, - MockComponent(ExpansionPanelWithUserComponent) + MockComponent(ExpansionPanelWithUserComponent), + MockComponent(HistorieItemAttachmentComponent) ], }).compileComponents(); }); @@ -58,7 +66,7 @@ describe('HistorieItemKommentarComponent', () => { expect(component).toBeTruthy(); }); - describe('ngOnIniit', () => { + describe('ngOnInit', () => { it('should set headline for order ' + CommandOrder.CREATE_KOMMENTAR, () => { component.command = { ...kommentarCommand, order: CommandOrder.CREATE_KOMMENTAR }; @@ -76,4 +84,35 @@ describe('HistorieItemKommentarComponent', () => { 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 } }; + } + }) }); diff --git a/goofy-client/libs/historie/src/test-setup.ts b/goofy-client/libs/historie/src/test-setup.ts index 50e09a1cc5ecb5498c9613292b662da4c66011f0..a34d602adcc3acf9aca31a86021eff1f069e918d 100644 --- a/goofy-client/libs/historie/src/test-setup.ts +++ b/goofy-client/libs/historie/src/test-setup.ts @@ -21,4 +21,19 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +import '@testing-library/jest-dom'; 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 diff --git a/goofy-client/libs/kommentar/src/lib/kommentar-list-in-vorgang-container/kommentar-form/kommentar-form.component.spec.ts b/goofy-client/libs/kommentar/src/lib/kommentar-list-in-vorgang-container/kommentar-form/kommentar-form.component.spec.ts index c84a65172217bf034d97a38148cbfd18c70f02ce..110928737df9c6f08d1e7f8aaa3698df988fcbff 100644 --- a/goofy-client/libs/kommentar/src/lib/kommentar-list-in-vorgang-container/kommentar-form/kommentar-form.component.spec.ts +++ b/goofy-client/libs/kommentar/src/lib/kommentar-list-in-vorgang-container/kommentar-form/kommentar-form.component.spec.ts @@ -24,17 +24,17 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ReactiveFormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; +import { BinaryFileAttachmentContainerComponent } from '@goofy-client/binary-file'; import { KommentarLinkRel, KommentarService } from '@goofy-client/kommentar-shared'; +import { createStateResource } from '@goofy-client/tech-shared'; import { mock } from '@goofy-client/test-utils'; import { ButtonWithSpinnerComponent, TextAreaEditorComponent } from '@goofy-client/ui'; 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 { 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', () => { let component: KommentarFormComponent; diff --git a/goofy-client/libs/navigation/src/test-setup.ts b/goofy-client/libs/navigation/src/test-setup.ts index 5870fdabb6470fd0f6f3f63be3d4f6b8041b4dd2..dc74cf29206a7ce287ef667322818782b2ba86b4 100644 --- a/goofy-client/libs/navigation/src/test-setup.ts +++ b/goofy-client/libs/navigation/src/test-setup.ts @@ -25,10 +25,7 @@ import '@testing-library/jest-dom'; import 'jest-preset-angular/setup-jest'; import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; getTestBed().resetTestEnvironment(); getTestBed().initTestEnvironment( diff --git a/goofy-server/src/main/resources/application-e2e.yml b/goofy-server/src/main/resources/application-e2e.yml index 3ab8ea8cc5d1edecd02cc3d4709b109b9471aafa..536b1d81e83e8f1bf6b0fb0938a43d93db258dfa 100644 --- a/goofy-server/src/main/resources/application-e2e.yml +++ b/goofy-server/src/main/resources/application-e2e.yml @@ -1,6 +1,6 @@ keycloak: - realm: sh-e2e-dev - resource: sh-e2e-dev-goofy + realm: by-e2e-local-dev + resource: by-e2e-local-dev-goofy kop: forwarding: