diff --git a/marketplace-ui/src/app/modules/release-preview/release-preview.component.html b/marketplace-ui/src/app/modules/release-preview/release-preview.component.html
index 810bca8a..8865d982 100644
--- a/marketplace-ui/src/app/modules/release-preview/release-preview.component.html
+++ b/marketplace-ui/src/app/modules/release-preview/release-preview.component.html
@@ -91,7 +91,7 @@
[lang]="languageService.selectedLanguage()"
class="readme-content"
[data]="
- getProductModuleContentValue(displayedTab)
+ getReadmeContentValue(displayedTab)
| multilingualism: languageService.selectedLanguage()
">
diff --git a/marketplace-ui/src/app/modules/release-preview/release-preview.component.spec.ts b/marketplace-ui/src/app/modules/release-preview/release-preview.component.spec.ts
index e69de29b..0a276cff 100644
--- a/marketplace-ui/src/app/modules/release-preview/release-preview.component.spec.ts
+++ b/marketplace-ui/src/app/modules/release-preview/release-preview.component.spec.ts
@@ -0,0 +1,159 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { ReleasePreviewComponent } from './release-preview.component';
+import { ReleasePreviewService } from './release-preview.service';
+import { of, throwError } from 'rxjs';
+import { TranslateService } from '@ngx-translate/core';
+import { LanguageService } from '../../core/services/language/language.service';
+import { ThemeService } from '../../core/services/theme/theme.service';
+import { CommonUtils } from '../../shared/utils/common.utils';
+import { FormsModule } from '@angular/forms';
+import { CommonModule } from '@angular/common';
+import { TranslateModule } from '@ngx-translate/core';
+import { MarkdownModule } from 'ngx-markdown';
+import {
+ provideHttpClient,
+ withInterceptorsFromDi
+} from '@angular/common/http';
+import { provideHttpClientTesting } from '@angular/common/http/testing';
+
+class MockReleasePreviewService {
+ extractZipDetails(file: File) {
+ return of({
+ description: {
+ en: 'Description in English',
+ de: 'Beschreibung auf Deutsch'
+ },
+ setup: { en: 'Setup in English', de: 'Setup auf Deutsch' },
+ demo: { en: 'Demo in English', de: 'Demo auf Deutsch' }
+ });
+ }
+}
+
+describe('ReleasePreviewComponent', () => {
+ let component: ReleasePreviewComponent;
+ let fixture: ComponentFixture;
+ let releasePreviewService: ReleasePreviewService;
+ let languageService: jasmine.SpyObj;
+
+ beforeEach(async () => {
+ const routingQueryParamServiceSpy = jasmine.createSpyObj(
+ 'RoutingQueryParamService',
+ ['getDesignerVersionFromSessionStorage', 'isDesignerEnv']
+ );
+
+ const languageServiceSpy = jasmine.createSpyObj('LanguageService', [
+ 'selectedLanguage'
+ ]);
+
+ await TestBed.configureTestingModule({
+ imports: [
+ ReleasePreviewComponent,
+ TranslateModule.forRoot(),
+ MarkdownModule.forRoot()
+ ],
+ providers: [
+ provideHttpClient(withInterceptorsFromDi()),
+ provideHttpClientTesting(),
+ {
+ provide: LanguageService,
+ useValue: languageServiceSpy
+ }
+ ]
+ }).compileComponents();
+ languageService = TestBed.inject(
+ LanguageService
+ ) as jasmine.SpyObj;
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ReleasePreviewComponent);
+ component = fixture.componentInstance;
+ releasePreviewService = TestBed.inject(ReleasePreviewService);
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+ it('should set selected file on file selection', () => {
+ const mockFile = new File(['content'], 'test.zip', {
+ type: 'application/zip'
+ });
+ const event = {
+ target: {
+ files: [mockFile]
+ }
+ } as unknown as Event;
+
+ component.onFileSelected(event);
+
+ expect(component.selectedFile).toEqual(mockFile);
+ expect(component.isZipFile).toBeTrue();
+ expect(component.errorMessage).toBe('');
+ });
+
+ it('should display error for non-zip file', () => {
+ const mockFile = new File(['content'], 'test.txt', { type: 'text/plain' });
+ const event = {
+ target: {
+ files: [mockFile]
+ }
+ } as unknown as Event;
+
+ component.onFileSelected(event);
+
+ expect(component.selectedFile).toEqual(mockFile);
+ expect(component.isZipFile).toBeFalse();
+ expect(component.errorMessage).toBe('Please upload a valid ZIP file.');
+ });
+
+ it('should update tabs on valid response', () => {
+ const mockResponse = {
+ description: {
+ en: 'Description in English',
+ de: 'Beschreibung auf Deutsch'
+ },
+ setup: { en: 'Setup in English', de: 'Setup auf Deutsch' },
+ demo: { en: 'Demo in English', de: 'Demo auf Deutsch' }
+ };
+
+ component.updateTabs(mockResponse);
+
+ expect(component.tabs.length).toBe(3);
+ expect(component.tabs[0].label).toBe('Description');
+ expect(component.tabs[0].content).toBe('Description in English');
+ });
+
+ it('should handle file upload and call service', () => {
+ spyOn(releasePreviewService, 'extractZipDetails').and.callThrough();
+
+ const mockFile = new File(['content'], 'test.zip', {
+ type: 'application/zip'
+ });
+ component.selectedFile = mockFile;
+ component.isZipFile = true;
+
+ component.onSubmit();
+
+ expect(releasePreviewService.extractZipDetails).toHaveBeenCalledWith(
+ mockFile
+ );
+ });
+
+ it('should display error message on service error', () => {
+ spyOn(releasePreviewService, 'extractZipDetails').and.returnValue(
+ throwError(() => new Error('Service error'))
+ );
+
+ const mockFile = new File(['content'], 'test.zip', {
+ type: 'application/zip'
+ });
+ component.selectedFile = mockFile;
+ component.isZipFile = true;
+
+ component.onSubmit();
+
+ expect(component.errorMessage).toBe('Service error');
+ });
+});
diff --git a/marketplace-ui/src/app/modules/release-preview/release-preview.component.ts b/marketplace-ui/src/app/modules/release-preview/release-preview.component.ts
index cbea55d7..24b62d7f 100644
--- a/marketplace-ui/src/app/modules/release-preview/release-preview.component.ts
+++ b/marketplace-ui/src/app/modules/release-preview/release-preview.component.ts
@@ -48,7 +48,7 @@ export class ReleasePreviewComponent {
availableLanguages = ['en', 'de'];
selectedLanguage = 'en';
isZipFile = false;
- productModuleContent: WritableSignal = signal(
+ readmeContent: WritableSignal = signal(
{} as ReleasePreviewData
);
languageService = inject(LanguageService);
@@ -124,7 +124,7 @@ export class ReleasePreviewComponent {
this.releasePreviewService.extractZipDetails(this.selectedFile).subscribe({
next: response => {
this.loading = false;
- this.productModuleContent.set(response);
+ this.readmeContent.set(response);
this.updateTabs(response);
},
error: error => {
@@ -146,7 +146,7 @@ export class ReleasePreviewComponent {
}
getContent(value: string): boolean {
- const content = this.productModuleContent();
+ const content = this.readmeContent();
if (!content || Object.keys(content).length === 0) {
return false;
@@ -180,9 +180,9 @@ export class ReleasePreviewComponent {
return CommonUtils.getLabel(this.activeTab, PRODUCT_DETAIL_TABS);
}
- getProductModuleContentValue(key: ItemDropdown): DisplayValue | null {
+ getReadmeContentValue(key: ItemDropdown): DisplayValue | null {
type tabName = 'description' | 'demo' | 'setup';
const value = key.value as tabName;
- return this.productModuleContent()[value];
+ return this.readmeContent()[value];
}
}