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

Merge pull request 'OZG-2508 OZG-2520 Anhänge nicht duplizieren nach...

Merge pull request 'OZG-2508 OZG-2520 Anhänge nicht duplizieren nach Statusänderung' (#64) from OZG-2508 into master

Reviewed-on: https://git.ozg-sh.de/mgm/goofy/pulls/64
parents 9423a871 2baa0a52
Branches
Tags
No related merge requests found
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
<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)">
......
......@@ -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);
......
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));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment