From e6bfcaa801e76f33618592ba4da6523c03abd60a Mon Sep 17 00:00:00 2001
From: sebo <sebastian.bergandy@external.mgm-cp.com>
Date: Wed, 26 Feb 2025 18:37:53 +0100
Subject: [PATCH] OZG-5977 fix upload in progress in editor

---
 .../multi-file-upload-editor.component.spec.ts     | 14 ++++++++++++--
 .../multi-file-upload-editor.component.ts          |  3 +--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/alfa-client/libs/binary-file/src/lib/multi-file-upload-editor/multi-file-upload-editor.component.spec.ts b/alfa-client/libs/binary-file/src/lib/multi-file-upload-editor/multi-file-upload-editor.component.spec.ts
index 0620a5f506..dc42e69a0f 100644
--- a/alfa-client/libs/binary-file/src/lib/multi-file-upload-editor/multi-file-upload-editor.component.spec.ts
+++ b/alfa-client/libs/binary-file/src/lib/multi-file-upload-editor/multi-file-upload-editor.component.spec.ts
@@ -1,7 +1,8 @@
-import { BinaryFileService, ToUploadFile } from '@alfa-client/binary-file-shared';
+import { BinaryFileService, FileUploadType, ToUploadFile } from '@alfa-client/binary-file-shared';
 import { ConvertForDataTestPipe } from '@alfa-client/tech-shared';
 import { existsAsHtmlElement, getElementComponentFromFixtureByCss, mock, Mock } from '@alfa-client/test-utils';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { faker } from '@faker-js/faker/.';
 import { expect } from '@jest/globals';
 import { getUrl, Resource } from '@ngxp/rest';
 import { FileUploadButtonComponent, SpinnerIconComponent } from '@ods/system';
@@ -17,7 +18,8 @@ describe('MultiFileUploadEditorComponent', () => {
   let component: MultiFileUploadEditorComponent;
   let fixture: ComponentFixture<MultiFileUploadEditorComponent>;
 
-  const uploadLinkRel: string = 'upload';
+  const fileUploadType: FileUploadType = faker.word.noun();
+  const uploadLinkRel: string = faker.word.noun();
   const uploadResource: Resource = createDummyResource([uploadLinkRel]);
 
   const buttonTestId: string = getDataTestIdOf('Ein_Label-file-upload-button');
@@ -58,6 +60,14 @@ describe('MultiFileUploadEditorComponent', () => {
 
   describe('component', () => {
     describe('ngOnInit', () => {
+      it('should get upload in progress', () => {
+        component.fileUploadType = fileUploadType;
+
+        component.ngOnInit();
+
+        expect(binaryFileService.isUploadInProgress).toHaveBeenCalledWith(fileUploadType);
+      });
+
       it('should set upload in progress', () => {
         binaryFileService.isUploadInProgress = jest.fn().mockReturnValue(of(true));
 
diff --git a/alfa-client/libs/binary-file/src/lib/multi-file-upload-editor/multi-file-upload-editor.component.ts b/alfa-client/libs/binary-file/src/lib/multi-file-upload-editor/multi-file-upload-editor.component.ts
index f69f78656a..4c057b3f3d 100644
--- a/alfa-client/libs/binary-file/src/lib/multi-file-upload-editor/multi-file-upload-editor.component.ts
+++ b/alfa-client/libs/binary-file/src/lib/multi-file-upload-editor/multi-file-upload-editor.component.ts
@@ -1,6 +1,5 @@
 import { BinaryFileModule } from '@alfa-client/binary-file';
 import { BinaryFileService, FileUploadType } from '@alfa-client/binary-file-shared';
-import { KOMMENTAR_UPLOADED_ATTACHMENTS } from '@alfa-client/kommentar-shared';
 import { ConvertForDataTestPipe } from '@alfa-client/tech-shared';
 import { AsyncPipe } from '@angular/common';
 import { Component, HostListener, inject, Input, OnInit } from '@angular/core';
@@ -39,7 +38,7 @@ export class MultiFileUploadEditorComponent implements OnInit {
   public readonly uploadButtonId: string = uniqueId();
 
   ngOnInit(): void {
-    this.isUploadInProgress$ = this.binaryFileService.isUploadInProgress(KOMMENTAR_UPLOADED_ATTACHMENTS);
+    this.isUploadInProgress$ = this.binaryFileService.isUploadInProgress(this.fileUploadType);
   }
 
   @HostListener('change', ['$event.target.files'])
-- 
GitLab