diff --git a/goofy-client/apps/goofy-e2e/src/integration/main-tests/wiedervorlage-attachment/wiedervorlage-attachment.e2e-spec.ts b/goofy-client/apps/goofy-e2e/src/integration/main-tests/wiedervorlage-attachment/wiedervorlage-attachment.e2e-spec.ts index 40b75498cb7bc6bf7324993a2b52a123f5dbcffa..ba33064224e38a6e59e2c85881154acd8d54170f 100644 --- a/goofy-client/apps/goofy-e2e/src/integration/main-tests/wiedervorlage-attachment/wiedervorlage-attachment.e2e-spec.ts +++ b/goofy-client/apps/goofy-e2e/src/integration/main-tests/wiedervorlage-attachment/wiedervorlage-attachment.e2e-spec.ts @@ -1,4 +1,5 @@ import { AttachmentContainerE2EComponent, AttachmentListE2EComponent } from 'apps/goofy-e2e/src/components/attachment/attachment.e2e.component'; +import { WiedervorlageSubnavigationE2EComponent } from 'apps/goofy-e2e/src/components/wiedervorlage/wiedervorlage-subnavigation'; import { BinaryFileSnackbarMessageE2E } from 'apps/goofy-e2e/src/model/binary-file'; import { WiedervorlageE2E } from 'apps/goofy-e2e/src/model/wiedervorlage'; import { dropCollections, readFileFromDownloads } from 'apps/goofy-e2e/src/support/cypress-helper'; @@ -11,7 +12,7 @@ import { VorgangE2E } from '../../../model/vorgang'; import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.po'; import { VorgangPage } from '../../../page-objects/vorgang.po'; import { WiedervorlagePage } from '../../../page-objects/wiedervorlage.po'; -import { contains, exist, notExist } from '../../../support/cypress.util'; +import { containClass, contains, exist, haveLength, notContainClass, notExist } from '../../../support/cypress.util'; import { TEST_FILE_WITHOUT_CONTENT, TEST_FILE_WITH_CONTENT, TEST_FILE_WITH_CONTENT_46MB } from '../../../support/data.util'; import { uploadEmptyFile, uploadFile } from '../../../support/file-upload'; import { loginAsSabine } from '../../../support/user-util'; @@ -29,6 +30,7 @@ describe('Wiedervorlage attachments', () => { const wiedervorlageContainer: WiedervorlageE2EComponent = wiedervorlagePage.getWiedervorlageContainer(); const attachmentContainer: AttachmentContainerE2EComponent = wiedervorlageContainer.getAttachmentContainer(); const attachmentList: AttachmentListE2EComponent = attachmentContainer.getList(); + const subnavigation: WiedervorlageSubnavigationE2EComponent = wiedervorlagePage.getSubnavigation(); const snackbar: SnackBarE2EComponent = mainPage.getSnackBar(); @@ -141,7 +143,7 @@ describe('Wiedervorlage attachments', () => { const wiedervorlageComp: WiedervorlageInVorgangE2EComponent = wiedervorlageContainerInVorgang.getWiedervorlage(WIEDERVORLAGE_WITH_ATTACHMENTS_BETREFF); - it('open wiedervorlage page', () => { + it('should open wiedervorlage page', () => { wiedervorlageComp.getLink().click(); exist(attachmentList.getItem(TEST_FILE_WITHOUT_CONTENT).getRoot()); @@ -188,4 +190,33 @@ describe('Wiedervorlage attachments', () => { wiedervorlagePage.getSubnavigation().navigateBack(); }) }) + + describe('Same number of attachments after status change', () => { + const wiedervorlageComp: WiedervorlageInVorgangE2EComponent = wiedervorlageContainerInVorgang.getWiedervorlage(WIEDERVORLAGE_WITH_ATTACHMENTS_BETREFF); + + it('should open wiedervorlage page', () => { + wiedervorlageComp.getLink().click(); + + exist(attachmentList.getItem(TEST_FILE_WITH_CONTENT).getRoot()); + }) + + it('should mark as erledigt', () => { + subnavigation.erledigen(); + + containClass(wiedervorlageContainer.getStatusDot(), 'erledigt'); + }) + + it('should mark as open', () => { + subnavigation.wiedereroeffnen(); + + notContainClass(wiedervorlageContainer.getStatusDot(), 'erledigt'); + }) + + it('should still have 1 attachment only', () => { + const attachmentList: AttachmentListE2EComponent = wiedervorlageContainerInVorgang.getWiedervorlage(wiedervorlage.betreff).getAttachmentContainer().getList(); + + haveLength(attachmentList.getRoot(), 1); + }) + }) + }) \ No newline at end of file diff --git a/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.html b/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.html index 0e705c9498f60c7f8437733ee14452e9ca01ce55..9fc8545c7c6fbfd08307be7b66c06d4f174aa595 100644 --- a/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.html +++ b/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.html @@ -1,4 +1,4 @@ -<div class="binary-file-list"> +<div class="binary-file-list" data-test-id="file-list"> <goofy-client-binary-file-container *ngFor="let file of fileList" [file]="file" [deletable]="true" (startDelete)="deleteAttachment($event)"> diff --git a/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.spec.ts b/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.spec.ts index bf85371b793952bfd65dceaf570513051e4d0e4f..2118870ab17bef4bdc4ecdbd83ccf76aef9be950 100644 --- a/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.spec.ts +++ b/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.spec.ts @@ -46,6 +46,19 @@ describe('BinaryFileAttachmentContainerComponent', () => { expect(component).toBeTruthy(); }) + describe('existing files', () => { + it('should show existing files', () => { + const binaryFile2: BinaryFileResource = createBinaryFileResource(); + + component.existFiles = [binaryFile2, binaryFile]; + fixture.detectChanges(); + + expect(component.fileList.length).toBe(2); + expect(component.fileList[0]).toBe(binaryFile2); + expect(component.fileList[1]).toBe(binaryFile); + }) + }) + describe('upload file', () => { const file: File = <any>{ name: 'TestDatei' }; const responseStateResource: StateResource<BinaryFileResource> = createStateResource(binaryFile); diff --git a/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.ts b/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.ts index c578ce8b096737ed7bc6d51e9afc49bc3ed47345..2b2c2a35fe0d0cb35c6a5f03af83f4cea7047016 100644 --- a/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.ts +++ b/goofy-client/libs/binary-file/src/lib/binary-file-attachment-container/binary-file-attachment-container.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { BinaryFileResource, BinaryFileService } from '@goofy-client/binary-file-shared'; import { createEmptyStateResource, doOnValidStateResource, isNotNil, StateResource } from '@goofy-client/tech-shared'; import { getUrl, Resource, ResourceUri } from '@ngxp/rest'; @@ -10,24 +10,20 @@ import { tap } from 'rxjs/operators'; templateUrl: './binary-file-attachment-container.component.html', styleUrls: ['./binary-file-attachment-container.component.scss'], }) -export class BinaryFileAttachmentContainerComponent implements OnChanges { +export class BinaryFileAttachmentContainerComponent { - @Input() existFiles: BinaryFileResource[]; @Input() formArrayName: string; @Input() uploadStateResource: StateResource<Resource>; @Input() linkRelUploadAttachment: string; + @Input() set existFiles(value: BinaryFileResource[]) { + this.fileList = isNotNil(value) ? value : []; + } uploadInProgress$: Observable<StateResource<any>> = of(createEmptyStateResource()); fileList: BinaryFileResource[] = []; constructor(private binaryFileService: BinaryFileService) { } - ngOnChanges(changes: SimpleChanges): void { - if (changes.existFiles) { - if (isNotNil(this.existFiles)) this.fileList = this.fileList.concat(this.existFiles); - } - } - getFileUriList(): string[] { return this.fileList.map(file => getUrl(file)); }