diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/ema-contentlet-tools/ema-contentlet-tools.component.html b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/ema-contentlet-tools/ema-contentlet-tools.component.html
index 0dc2d484ce1f..50b395c77bf3 100644
--- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/ema-contentlet-tools/ema-contentlet-tools.component.html
+++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/ema-contentlet-tools/ema-contentlet-tools.component.html
@@ -9,16 +9,16 @@
[ngStyle]="styles.bottomButton"
data-testId="add-bottom-button"
icon="pi pi-plus">
-
+
@if (contentletArea.payload.vtlFiles?.length) {
-
-
+
+
}
{
() =>
(spectator = createComponent({
props: {
- contentletArea: contentletAreaMock
+ contentletArea: contentletAreaMock,
+ isEnterprise: false
}
}))
);
@@ -77,7 +78,7 @@ describe('EmaContentletToolsComponent', () => {
const hideMenu = jest.spyOn(spectator.component.menu, 'hide');
// Open menu
- spectator.click('[data-testId="menu-add"]');
+ spectator.click(byTestId('menu-add'));
//Change contentlet hover
spectator.setInput('contentletArea', {
@@ -98,13 +99,13 @@ describe('EmaContentletToolsComponent', () => {
describe('events', () => {
it('should emit delete on delete button click', () => {
const deleteSpy = jest.spyOn(spectator.component.delete, 'emit');
- spectator.click('[data-testId="delete-button"]');
+ spectator.click(byTestId('delete-button'));
expect(deleteSpy).toHaveBeenCalledWith(contentletAreaMock.payload);
});
it('should emit edit on edit button click', () => {
const deleteSpy = jest.spyOn(spectator.component.edit, 'emit');
- spectator.click('[data-testId="edit-button"]');
+ spectator.click(byTestId('edit-button'));
expect(deleteSpy).toHaveBeenCalledWith(contentletAreaMock.payload);
});
@@ -126,13 +127,13 @@ describe('EmaContentletToolsComponent', () => {
describe('top button', () => {
it('should open menu on add button click', () => {
- spectator.click('[data-testId="add-top-button"]');
+ spectator.click(byTestId('add-top-button'));
expect(spectator.query('.p-menu-overlay')).not.toBeNull();
});
it('should call addContent on Content option click', () => {
const addSpy = jest.spyOn(spectator.component.addContent, 'emit');
- spectator.click('[data-testId="add-top-button"]');
+ spectator.click(byTestId('add-top-button'));
spectator.click(byText('Content'));
expect(addSpy).toHaveBeenCalledWith({
...contentletAreaMock.payload,
@@ -140,60 +141,108 @@ describe('EmaContentletToolsComponent', () => {
} as ActionPayload);
});
- it('should call addForm on Form option click', () => {
- const addSpy = jest.spyOn(spectator.component.addForm, 'emit');
- spectator.click('[data-testId="add-top-button"]');
- spectator.click(byText('Form'));
- expect(addSpy).toHaveBeenCalledWith({
- ...contentletAreaMock.payload,
- position: 'before'
- } as ActionPayload);
+ it('should not call addForm on Form option click', () => {
+ spectator.click(byTestId('add-bottom-button'));
+ const formOption = spectator.query(byText('Form'));
+ expect(formOption).toBeNull();
});
it('should call addWidget on Widget option click', () => {
const addSpy = jest.spyOn(spectator.component.addWidget, 'emit');
- spectator.click('[data-testId="add-top-button"]');
+ spectator.click(byTestId('add-top-button'));
spectator.click(byText('Widget'));
expect(addSpy).toHaveBeenCalledWith({
...contentletAreaMock.payload,
position: 'before'
} as ActionPayload);
});
+
+ describe('isEnterprise', () => {
+ beforeEach(
+ () =>
+ (spectator = createComponent({
+ props: {
+ contentletArea: contentletAreaMock,
+ isEnterprise: true
+ }
+ }))
+ );
+
+ it('should render form option', () => {
+ spectator.click(byTestId('add-top-button'));
+ expect(spectator.query(byText('Form'))).toBeDefined();
+ });
+
+ it('should call addForm on Form option click', () => {
+ const addSpy = jest.spyOn(spectator.component.addForm, 'emit');
+ spectator.click(byTestId('add-top-button'));
+ spectator.click(byText('Form'));
+ expect(addSpy).toHaveBeenCalledWith({
+ ...contentletAreaMock.payload,
+ position: 'before'
+ } as ActionPayload);
+ });
+ });
});
describe('bottom button', () => {
it('should open menu on button click', () => {
- spectator.click('[data-testId="add-bottom-button"]');
+ spectator.click(byTestId('add-bottom-button'));
expect(spectator.query('.p-menu-overlay')).not.toBeNull();
});
it('should call addContent on Content option click', () => {
const addSpy = jest.spyOn(spectator.component.addContent, 'emit');
- spectator.click('[data-testId="add-bottom-button"]');
+ spectator.click(byTestId('add-bottom-button'));
spectator.click(byText('Content'));
expect(addSpy).toHaveBeenCalledWith({
...contentletAreaMock.payload,
position: 'after'
} as ActionPayload);
});
- it('should call addForm on Form option click', () => {
- const addSpy = jest.spyOn(spectator.component.addForm, 'emit');
- spectator.click('[data-testId="add-bottom-button"]');
- spectator.click(byText('Form'));
- expect(addSpy).toHaveBeenCalledWith({
- ...contentletAreaMock.payload,
- position: 'after'
- } as ActionPayload);
+
+ it('should not call addForm on Form option click', () => {
+ spectator.click(byTestId('add-bottom-button'));
+ const formOption = spectator.query(byText('Form'));
+ expect(formOption).toBeNull();
});
+
it('should call addWidget on Widget option click', () => {
const addSpy = jest.spyOn(spectator.component.addWidget, 'emit');
- spectator.click('[data-testId="add-bottom-button"]');
+ spectator.click(byTestId('add-bottom-button'));
spectator.click(byText('Widget'));
expect(addSpy).toHaveBeenCalledWith({
...contentletAreaMock.payload,
position: 'after'
} as ActionPayload);
});
+
+ describe('isEnterprise', () => {
+ beforeEach(
+ () =>
+ (spectator = createComponent({
+ props: {
+ contentletArea: contentletAreaMock,
+ isEnterprise: true
+ }
+ }))
+ );
+
+ it('should render form option', () => {
+ spectator.click(byTestId('add-bottom-button'));
+ expect(spectator.query(byText('Form'))).toBeDefined();
+ });
+
+ it('should call addForm on Form option click', () => {
+ const addSpy = jest.spyOn(spectator.component.addForm, 'emit');
+ spectator.click(byTestId('add-bottom-button'));
+ spectator.click(byText('Form'));
+ expect(addSpy).toHaveBeenCalledWith({
+ ...contentletAreaMock.payload,
+ position: 'after'
+ } as ActionPayload);
+ });
+ });
});
});
diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/ema-contentlet-tools/ema-contentlet-tools.component.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/ema-contentlet-tools/ema-contentlet-tools.component.ts
index 650ecf85508f..d21894ac0bea 100644
--- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/ema-contentlet-tools/ema-contentlet-tools.component.ts
+++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/ema-contentlet-tools/ema-contentlet-tools.component.ts
@@ -10,7 +10,8 @@ import {
Output,
SimpleChanges,
ViewChild,
- inject
+ inject,
+ signal
} from '@angular/core';
import { MenuItem } from 'primeng/api';
@@ -41,12 +42,12 @@ export class EmaContentletToolsComponent implements OnChanges {
@ViewChild('menu') menu: Menu;
@ViewChild('menuVTL') menuVTL: Menu;
@ViewChild('dragImage') dragImage: ElementRef;
- private dotMessageService = inject(DotMessageService);
- private buttonPosition: 'after' | 'before' = 'after';
+ @HostBinding('class.hide') @Input() hide = false;
@Input() contentletArea: ContentletArea;
- @HostBinding('class.hide') @Input() hide = false;
+ @Input() isEnterprise: boolean;
+
@Output() addContent = new EventEmitter();
@Output() addForm = new EventEmitter();
@Output() addWidget = new EventEmitter();
@@ -54,40 +55,44 @@ export class EmaContentletToolsComponent implements OnChanges {
@Output() editVTL = new EventEmitter();
@Output() delete = new EventEmitter();
- items: MenuItem[] = [
+ #dotMessageService = inject(DotMessageService);
+ ACTIONS_CONTAINER_WIDTH = INITIAL_ACTIONS_CONTAINER_WIDTH; // Now is dynamic based on the page type (Headless - VTL)
+ vtlFiles: MenuItem[] = [];
+ #buttonPosition: 'after' | 'before' = 'after';
+
+ readonly #comunityItems: MenuItem[] = [
{
- label: this.dotMessageService.get('content'),
+ label: this.#dotMessageService.get('content'),
command: () => {
this.addContent.emit({
...this.contentletArea.payload,
- position: this.buttonPosition
+ position: this.#buttonPosition
});
}
},
{
- label: this.dotMessageService.get('Widget'),
+ label: this.#dotMessageService.get('Widget'),
command: () => {
this.addWidget.emit({
...this.contentletArea.payload,
- position: this.buttonPosition
+ position: this.#buttonPosition
});
}
- },
+ }
+ ];
+ readonly #enterpriseItems: MenuItem[] = [
{
- label: this.dotMessageService.get('form'),
+ label: this.#dotMessageService.get('form'),
command: () => {
this.addForm.emit({
...this.contentletArea.payload,
- position: this.buttonPosition
+ position: this.#buttonPosition
});
}
}
];
- vtlFiles: MenuItem[] = [];
-
- ACTIONS_CONTAINER_WIDTH = INITIAL_ACTIONS_CONTAINER_WIDTH; // Now is dynamic based on the page type (Headless - VTL)
-
+ readonly items = signal