From a47e27f3a8ce0a5071ca5da8712d03898e5375d2 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Wed, 4 Dec 2024 16:40:55 -0300 Subject: [PATCH 1/6] add and connect persona selector --- .../dot-uve-toolbar.component.html | 9 +- .../dot-uve-toolbar.component.ts | 86 ++++++++++++++++++- .../edit-ema-persona-selector.component.ts | 3 +- .../src/lib/store/features/editor/models.ts | 9 +- .../features/editor/toolbar/withUVEToolbar.ts | 14 +-- 5 files changed, 106 insertions(+), 15 deletions(-) diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.html b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.html index 34b3e7ca45e3..4863d9bf4da3 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.html +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.html @@ -38,7 +38,14 @@ } Language - Persona + + Workflows diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts index 0e8495d4a3f9..80ba569be9dd 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts @@ -1,16 +1,19 @@ import { ClipboardModule } from '@angular/cdk/clipboard'; -import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; +import { ChangeDetectionStrategy, Component, inject, viewChild } from '@angular/core'; -import { MessageService } from 'primeng/api'; +import { ConfirmationService, MessageService } from 'primeng/api'; import { ButtonModule } from 'primeng/button'; import { ToolbarModule } from 'primeng/toolbar'; -import { DotMessageService } from '@dotcms/data-access'; +import { DotMessageService, DotPersonalizeService } from '@dotcms/data-access'; +import { DotPersona } from '@dotcms/dotcms-models'; +import { DEFAULT_PERSONA } from '../../../shared/consts'; import { UVEStore } from '../../../store/dot-uve.store'; import { DotEmaBookmarksComponent } from '../dot-ema-bookmarks/dot-ema-bookmarks.component'; import { DotEmaInfoDisplayComponent } from '../dot-ema-info-display/dot-ema-info-display.component'; import { DotEmaRunningExperimentComponent } from '../dot-ema-running-experiment/dot-ema-running-experiment.component'; +import { EditEmaPersonaSelectorComponent } from '../edit-ema-persona-selector/edit-ema-persona-selector.component'; @Component({ selector: 'dot-uve-toolbar', @@ -21,19 +24,27 @@ import { DotEmaRunningExperimentComponent } from '../dot-ema-running-experiment/ DotEmaBookmarksComponent, DotEmaInfoDisplayComponent, DotEmaRunningExperimentComponent, + EditEmaPersonaSelectorComponent, ClipboardModule ], + providers: [DotPersonalizeService], templateUrl: './dot-uve-toolbar.component.html', styleUrl: './dot-uve-toolbar.component.scss', changeDetection: ChangeDetectionStrategy.OnPush }) export class DotUveToolbarComponent { + personaSelector = viewChild(EditEmaPersonaSelectorComponent); + #store = inject(UVEStore); + readonly #messageService = inject(MessageService); readonly #dotMessageService = inject(DotMessageService); + readonly #confirmationService = inject(ConfirmationService); + readonly #personalizeService = inject(DotPersonalizeService); readonly $toolbar = this.#store.$uveToolbar; readonly $apiURL = this.#store.$apiURL; + readonly $personaSelector = this.#store.$personaSelector; togglePreviewMode(preview: boolean) { this.#store.togglePreviewMode(preview); @@ -46,4 +57,73 @@ export class DotUveToolbarComponent { life: 3000 }); } + + /** + * Handle the persona selection + * + * @param {DotPersona} persona + * @memberof DotEmaComponent + */ + onPersonaSelected(persona: DotPersona & { pageId: string }) { + if (persona.identifier === DEFAULT_PERSONA.identifier || persona.personalized) { + this.#store.loadPageAsset({ + 'com.dotmarketing.persona.id': persona.identifier + }); + } else { + this.#confirmationService.confirm({ + header: this.#dotMessageService.get('editpage.personalization.confirm.header'), + message: this.#dotMessageService.get( + 'editpage.personalization.confirm.message', + persona.name + ), + acceptLabel: this.#dotMessageService.get('dot.common.dialog.accept'), + rejectLabel: this.#dotMessageService.get('dot.common.dialog.reject'), + accept: () => { + this.#personalizeService + .personalized(persona.pageId, persona.keyTag) + .subscribe(() => { + this.#store.loadPageAsset({ + 'com.dotmarketing.persona.id': persona.identifier + }); + + this.personaSelector().fetchPersonas(); + }); // This does a take 1 under the hood + }, + reject: () => { + this.personaSelector().resetValue(); + } + }); + } + } + + /** + * Handle the persona despersonalization + * + * @param {(DotPersona & { pageId: string })} persona + * @memberof EditEmaToolbarComponent + */ + onDespersonalize(persona: DotPersona & { pageId: string; selected: boolean }) { + this.#confirmationService.confirm({ + header: this.#dotMessageService.get('editpage.personalization.delete.confirm.header'), + message: this.#dotMessageService.get( + 'editpage.personalization.delete.confirm.message', + persona.name + ), + acceptLabel: this.#dotMessageService.get('dot.common.dialog.accept'), + rejectLabel: this.#dotMessageService.get('dot.common.dialog.reject'), + accept: () => { + this.#personalizeService + .despersonalized(persona.pageId, persona.keyTag) + .subscribe(() => { + this.personaSelector().fetchPersonas(); + + if (persona.selected) { + this.#store.loadPageAsset({ + 'com.dotmarketing.persona.id': DEFAULT_PERSONA.identifier + }); + } + }); // This does a take 1 under the hood + } + }); + } } diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-persona-selector/edit-ema-persona-selector.component.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-persona-selector/edit-ema-persona-selector.component.ts index fbd23688f3da..a934c9cbed14 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-persona-selector/edit-ema-persona-selector.component.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-persona-selector/edit-ema-persona-selector.component.ts @@ -111,8 +111,7 @@ export class EditEmaPersonaSelectorComponent implements AfterViewInit, OnChanges * @memberof EditEmaPersonaSelectorComponent */ resetValue(): void { - this.listbox.value = this.value; - this.listbox.cd.detectChanges(); + this.listbox.writeValue(this.value); } /** diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/models.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/models.ts index a51fb31413c4..fea55a82c03a 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/models.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/models.ts @@ -128,10 +128,6 @@ export interface UVEToolbarProps { hideSocialMedia: boolean; }; }; - personaSelector: { - pageId: string; - value: DotPersona; - }; runningExperiment?: DotExperiment; currentLanguage: DotLanguage; workflowActionsInode?: string; @@ -141,3 +137,8 @@ export interface UVEToolbarProps { }; showInfoDisplay?: boolean; } + +export interface PersonaSelectorProps { + pageId: string; + value: DotPersona; +} diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.ts index 047bb34bdbec..297b39476be4 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.ts @@ -22,7 +22,7 @@ import { sanitizeURL } from '../../../../utils'; import { UVEState } from '../../../models'; -import { EditorToolbarState, UVEToolbarProps } from '../models'; +import { EditorToolbarState, PersonaSelectorProps, UVEToolbarProps } from '../models'; /** * The initial state for the editor toolbar. @@ -109,14 +109,18 @@ export function withUVEToolbar() { : null, runningExperiment: isExperimentRunning ? experiment : null, workflowActionsInode: store.canEditPage() ? pageAPIResponse?.page.inode : null, - personaSelector: { - pageId: pageAPIResponse?.page.identifier, - value: pageAPIResponse?.viewAs.persona ?? DEFAULT_PERSONA - }, unlockButton: shouldShowUnlock ? unlockButton : null, showInfoDisplay: shouldShowInfoDisplay }; }), + $personaSelector: computed(() => { + const pageAPIResponse = store.pageAPIResponse(); + + return { + pageId: pageAPIResponse?.page.identifier, + value: pageAPIResponse?.viewAs.persona ?? DEFAULT_PERSONA + }; + }), $apiURL: computed(() => { const pageParams = store.pageParams(); const url = sanitizeURL(pageParams?.url); From 98496e8db8742163801aab2615222bd88db36322 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Wed, 4 Dec 2024 17:17:08 -0300 Subject: [PATCH 2/6] add test for store --- .../store/features/editor/toolbar/withUVEToolbar.spec.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.spec.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.spec.ts index 6a3b044ff152..445abbcf4d9c 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.spec.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.spec.ts @@ -8,6 +8,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { withUVEToolbar } from './withUVEToolbar'; import { DotPageApiService } from '../../../../services/dot-page-api.service'; +import { DEFAULT_PERSONA } from '../../../../shared/consts'; import { UVE_STATUS } from '../../../../shared/enums'; import { MOCK_RESPONSE_HEADLESS } from '../../../../shared/mocks'; import { UVEState } from '../../../models'; @@ -47,7 +48,6 @@ describe('withEditor', () => { mockProvider(Router), mockProvider(ActivatedRoute), mockProvider(Router), - mockProvider(ActivatedRoute), { provide: DotPageApiService, useValue: { @@ -79,5 +79,12 @@ describe('withEditor', () => { expect(store.$apiURL()).toBe(expectURL); }); + + it('should return the personaSelector props', () => { + expect(store.$personaSelector()).toEqual({ + pageId: '123', + value: DEFAULT_PERSONA + }); + }); }); }); From 912ba263a4856962f230c6b95738f4e37abeea53 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Wed, 4 Dec 2024 17:57:17 -0300 Subject: [PATCH 3/6] add missing tests --- .../dot-uve-toolbar.component.spec.ts | 140 ++++++++++++++++-- .../dot-uve-toolbar.component.ts | 14 +- .../edit-ema-editor.component.spec.ts | 3 +- .../store/features/editor/withEditor.spec.ts | 4 - 4 files changed, 141 insertions(+), 20 deletions(-) diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts index 70b5c8518936..c54996765cc6 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts @@ -1,5 +1,5 @@ -import { byTestId, mockProvider, Spectator } from '@ngneat/spectator'; -import { createComponentFactory } from '@ngneat/spectator/jest'; +import { expect, describe, it } from '@jest/globals'; +import { byTestId, mockProvider, Spectator, createComponentFactory } from '@ngneat/spectator/jest'; import { MockComponent } from 'ng-mocks'; import { of } from 'rxjs'; @@ -7,9 +7,14 @@ import { HttpClientTestingModule, provideHttpClientTesting } from '@angular/comm import { DebugElement, signal } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { MessageService } from 'primeng/api'; +import { ConfirmationService, MessageService } from 'primeng/api'; -import { DotExperimentsService, DotLanguagesService, DotLicenseService } from '@dotcms/data-access'; +import { + DotExperimentsService, + DotLanguagesService, + DotLicenseService, + DotPersonalizeService +} from '@dotcms/data-access'; import { LoginService } from '@dotcms/dotcms-js'; import { DotExperimentsServiceMock, @@ -36,23 +41,30 @@ import { } from '../../../utils'; import { DotEmaBookmarksComponent } from '../dot-ema-bookmarks/dot-ema-bookmarks.component'; import { DotEmaRunningExperimentComponent } from '../dot-ema-running-experiment/dot-ema-running-experiment.component'; +import { EditEmaPersonaSelectorComponent } from '../edit-ema-persona-selector/edit-ema-persona-selector.component'; const $apiURL = '/api/v1/page/json/123-xyz-567-xxl?host_id=123-xyz-567-xxl&language_id=1'; describe('DotUveToolbarComponent', () => { let spectator: Spectator; let messageService: MessageService; + let confirmationService: ConfirmationService; + let store: InstanceType; const createComponent = createComponentFactory({ component: DotUveToolbarComponent, imports: [ HttpClientTestingModule, MockComponent(DotEmaBookmarksComponent), - MockComponent(DotEmaRunningExperimentComponent) + MockComponent(DotEmaRunningExperimentComponent), + MockComponent(EditEmaPersonaSelectorComponent) ], providers: [ UVEStore, provideHttpClientTesting(), + mockProvider(ConfirmationService, { + confirm: jest.fn() + }), { provide: DotLanguagesService, useValue: new DotLanguagesServiceMock() @@ -83,6 +95,14 @@ describe('DotUveToolbarComponent', () => { add: jest.fn() } } + ], + componentProviders: [ + { + provide: DotPersonalizeService, + useValue: { + getPersonalize: jest.fn() + } + } ] }); @@ -114,11 +134,7 @@ describe('DotUveToolbarComponent', () => { runningExperiment: null, workflowActionsInode: pageAPIResponse?.page.inode, unlockButton: null, - showInfoDisplay: shouldShowInfoDisplay, - personaSelector: { - pageId: pageAPIResponse?.page.identifier, - value: pageAPIResponse?.viewAs.persona ?? DEFAULT_PERSONA - } + showInfoDisplay: shouldShowInfoDisplay }; const baseUVEState = { @@ -128,6 +144,10 @@ describe('DotUveToolbarComponent', () => { pageParams: signal(params), pageAPIResponse: signal(MOCK_RESPONSE_VTL), $apiURL: signal($apiURL), + $personaSelector: signal({ + pageId: pageAPIResponse?.page.identifier, + value: pageAPIResponse?.viewAs.persona ?? DEFAULT_PERSONA + }), reloadCurrentPage: jest.fn(), loadPageAsset: jest.fn() }; @@ -139,6 +159,8 @@ describe('DotUveToolbarComponent', () => { }); messageService = spectator.inject(MessageService); + confirmationService = spectator.inject(ConfirmationService); + store = spectator.inject(UVEStore); }); describe('dot-ema-bookmarks', () => { @@ -216,6 +238,104 @@ describe('DotUveToolbarComponent', () => { expect(btn.getAttribute('href')).toBe($apiURL); }); }); + + describe('dot-edit-ema-persona-selector', () => { + it('should have attr', () => { + const personaSelector = spectator.query(EditEmaPersonaSelectorComponent); + + expect(personaSelector.pageId).toBe('123'); + expect(personaSelector.value).toEqual({ + archived: false, + baseType: 'PERSONA', + contentType: 'persona', + folder: 'SYSTEM_FOLDER', + hasLiveVersion: false, + hasTitleImage: false, + host: 'SYSTEM_HOST', + hostFolder: 'SYSTEM_HOST', + hostName: 'System Host', + identifier: 'modes.persona.no.persona', + inode: '', + keyTag: 'dot:persona', + languageId: 1, + live: false, + locked: false, + modDate: '0', + modUser: 'system', + modUserName: 'system user system user', + name: 'Default Visitor', + owner: 'SYSTEM_USER', + personalized: false, + sortOrder: 0, + stInode: 'c938b15f-bcb6-49ef-8651-14d455a97045', + title: 'Default Visitor', + titleImage: 'TITLE_IMAGE_NOT_FOUND', + url: 'demo.dotcms.com', + working: false + }); + }); + + it('should personalize - no confirmation', () => { + const spyloadPageAsset = jest.spyOn(store, 'loadPageAsset'); + spectator.triggerEventHandler(EditEmaPersonaSelectorComponent, 'selected', { + identifier: '123', + pageId: '123', + personalized: true + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any); + spectator.detectChanges(); + + expect(spyloadPageAsset).toHaveBeenCalledWith({ + 'com.dotmarketing.persona.id': '123' + }); + }); + + it('should personalize - confirmation', () => { + spectator.triggerEventHandler(EditEmaPersonaSelectorComponent, 'selected', { + identifier: '123', + pageId: '123', + personalized: false + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any); + spectator.detectChanges(); + + expect(confirmationService.confirm).toHaveBeenCalledWith({ + accept: expect.any(Function), + acceptLabel: 'dot.common.dialog.accept', + header: 'editpage.personalization.confirm.header', + message: 'editpage.personalization.confirm.message', + reject: expect.any(Function), + rejectLabel: 'dot.common.dialog.reject' + }); + }); + + xit('should personalize - call service', () => { + expect(true).toBe(true); + }); + + it('should despersonalize', () => { + spectator.triggerEventHandler(EditEmaPersonaSelectorComponent, 'despersonalize', { + identifier: '123', + pageId: '123', + personalized: true + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any); + + spectator.detectChanges(); + + expect(confirmationService.confirm).toHaveBeenCalledWith({ + accept: expect.any(Function), + acceptLabel: 'dot.common.dialog.accept', + header: 'editpage.personalization.delete.confirm.header', + message: 'editpage.personalization.delete.confirm.message', + rejectLabel: 'dot.common.dialog.reject' + }); + }); + + xit('should dpersonalize - call service', () => { + expect(true).toBe(true); + }); + }); }); describe('State changes', () => { diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts index 80ba569be9dd..40ea4ad8bb8d 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts @@ -1,5 +1,5 @@ import { ClipboardModule } from '@angular/cdk/clipboard'; -import { ChangeDetectionStrategy, Component, inject, viewChild } from '@angular/core'; +import { ChangeDetectionStrategy, Component, inject, ViewChild } from '@angular/core'; import { ConfirmationService, MessageService } from 'primeng/api'; import { ButtonModule } from 'primeng/button'; @@ -33,7 +33,11 @@ import { EditEmaPersonaSelectorComponent } from '../edit-ema-persona-selector/ed changeDetection: ChangeDetectionStrategy.OnPush }) export class DotUveToolbarComponent { - personaSelector = viewChild(EditEmaPersonaSelectorComponent); + // I tried to use the new viewChild signal API but is not supported on MockComponent + // Revisit this ticket to see if it's supported already, so we can move on to signals + // https://github.com/help-me-mom/ng-mocks/issues/8634 + @ViewChild('personaSelector') + personaSelector!: EditEmaPersonaSelectorComponent; #store = inject(UVEStore); @@ -86,11 +90,11 @@ export class DotUveToolbarComponent { 'com.dotmarketing.persona.id': persona.identifier }); - this.personaSelector().fetchPersonas(); + this.personaSelector.fetchPersonas(); }); // This does a take 1 under the hood }, reject: () => { - this.personaSelector().resetValue(); + this.personaSelector.resetValue(); } }); } @@ -115,7 +119,7 @@ export class DotUveToolbarComponent { this.#personalizeService .despersonalized(persona.pageId, persona.keyTag) .subscribe(() => { - this.personaSelector().fetchPersonas(); + this.personaSelector.fetchPersonas(); if (persona.selected) { this.#store.loadPageAsset({ diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.spec.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.spec.ts index 3a6be73e8669..2f069e5b20c7 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.spec.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.spec.ts @@ -138,7 +138,8 @@ const createRouting = () => MockComponent(DotEditEmaWorkflowActionsComponent), MockComponent(DotResultsSeoToolComponent), MockComponent(DotEmaRunningExperimentComponent), - MockComponent(EditEmaToolbarComponent) + MockComponent(EditEmaToolbarComponent), + MockComponent(DotUveToolbarComponent) ], detectChanges: false, componentProviders: [ diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts index 60e16bc29bdb..82f5298bc27c 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts @@ -541,10 +541,6 @@ describe('withEditor', () => { urlContentMap: null, runningExperiment: null, workflowActionsInode: MOCK_RESPONSE_HEADLESS.page.inode, - personaSelector: { - pageId: MOCK_RESPONSE_HEADLESS.page.identifier, - value: MOCK_RESPONSE_HEADLESS.viewAs.persona ?? DEFAULT_PERSONA - }, unlockButton: null, showInfoDisplay: false }); From 478fde022dfbbe6a528c8d695d15e93154a1601a Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Thu, 5 Dec 2024 13:40:23 -0300 Subject: [PATCH 4/6] fix for missing content --- .../portlets/edit-ema/portlet/src/lib/utils/index.ts | 5 ++++- .../edit-ema/portlet/src/lib/utils/utils.spec.ts | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/utils/index.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/utils/index.ts index 0c822ff9ca1c..b52def13b532 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/utils/index.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/utils/index.ts @@ -109,7 +109,10 @@ export function deleteContentletFromContainer(action: ActionPayload): { }; } - return currentContainer; + return { + ...currentContainer, + personaTag + }; }); return { diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/utils/utils.spec.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/utils/utils.spec.ts index e3d312039e26..9419124736a7 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/utils/utils.spec.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/utils/utils.spec.ts @@ -63,6 +63,11 @@ describe('utils functions', () => { identifier: 'test', uuid: 'test', contentletsId: ['test'] + }, + { + identifier: 'test-2', + uuid: 'test', + contentletsId: ['test'] } ], contentlet: { @@ -82,6 +87,12 @@ describe('utils functions', () => { uuid: 'test', contentletsId: [], personaTag: 'test' + }, + { + identifier: 'test-2', + uuid: 'test', + contentletsId: ['test'], + personaTag: 'test' // In the last version this was not being added and it lead to saving content to the default persona and messing up with the pages } ], contentletsId: [] From f053bc1d6b9e11e0e129e76d5ef69d22f2f6fc3a Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Thu, 5 Dec 2024 17:09:38 -0300 Subject: [PATCH 5/6] Update edit-ema-editor.component.spec.ts --- .../lib/edit-ema-editor/edit-ema-editor.component.spec.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.spec.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.spec.ts index 9ec425e8ee8d..450bc1f9e114 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.spec.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.spec.ts @@ -34,6 +34,7 @@ import { DotPropertiesService, DotSeoMetaTagsService, DotSeoMetaTagsUtilService, + DotSessionStorageService, DotTempFileUploadService, DotWorkflowActionsFireService, PushPublishService @@ -138,8 +139,7 @@ const createRouting = () => MockComponent(DotEditEmaWorkflowActionsComponent), MockComponent(DotResultsSeoToolComponent), MockComponent(DotEmaRunningExperimentComponent), - MockComponent(EditEmaToolbarComponent), - MockComponent(DotUveToolbarComponent) + MockComponent(EditEmaToolbarComponent) ], detectChanges: false, componentProviders: [ @@ -148,6 +148,7 @@ const createRouting = () => UVEStore, DotFavoritePageService, DotESContentService, + DotSessionStorageService, { provide: DotPropertiesService, useValue: { From 4336bfdf6742c5ffac306819259d85f0d14454c0 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Thu, 5 Dec 2024 18:40:44 -0300 Subject: [PATCH 6/6] Update dot-uve-toolbar.component.spec.ts --- .../dot-uve-toolbar/dot-uve-toolbar.component.spec.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts index 7a6b4b195ff8..24b8b490d289 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts @@ -334,10 +334,6 @@ describe('DotUveToolbarComponent', () => { }); }); - xit('should personalize - call service', () => { - expect(true).toBe(true); - }); - it('should despersonalize', () => { spectator.triggerEventHandler(EditEmaPersonaSelectorComponent, 'despersonalize', { identifier: '123', @@ -356,10 +352,6 @@ describe('DotUveToolbarComponent', () => { rejectLabel: 'dot.common.dialog.reject' }); }); - - xit('should dpersonalize - call service', () => { - expect(true).toBe(true); - }); }); });