Skip to content

Commit ab3b858

Browse files
chore(uve): Fix Today button interaction with calendar picker on Published UVE mode (dotCMS#32161)
This pull request introduces a new test case for the `DotUveToolbarComponent` and simplifies the component's code by removing unused imports and eliminating the use of `untracked` in a computed property. Below is a summary of the most important changes: ### New Test Case Addition: * Added a test to verify that clicking the "Today" button updates the calendar date to today's date in `dot-uve-toolbar.component.spec.ts`. ### Code Simplification: * Removed the unused `untracked` import from `@angular/core` in `dot-uve-toolbar.component.ts`. * Simplified the `$previewDate` computed property by directly accessing `publishDate` from `$pageParams`, removing the use of `untracked`. Co-authored-by: Kevin <[email protected]>
1 parent a86353f commit ab3b858

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,15 @@ describe('DotUveToolbarComponent', () => {
741741
});
742742
});
743743

744+
it('should change the date to today when button "Today" is clicked', () => {
745+
const calendar = spectator.query('p-calendar');
746+
747+
spectator.triggerEventHandler('p-calendar', 'click', new Event('click'));
748+
749+
expect(calendar.getAttribute('ng-reflect-model')).toBeDefined();
750+
expect(new Date(calendar.getAttribute('ng-reflect-model'))).toEqual(new Date());
751+
});
752+
744753
it('should track event on date when date is selected', () => {
745754
const spyTrackUVECalendarChange = jest.spyOn(
746755
baseUVEState,

core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import {
1111
Output,
1212
viewChild,
1313
Signal,
14-
signal,
15-
untracked
14+
signal
1615
} from '@angular/core';
1716
import { toSignal } from '@angular/core/rxjs-interop';
1817
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@@ -120,7 +119,7 @@ export class DotUveToolbarComponent {
120119

121120
protected readonly $pageParams = this.#store.pageParams;
122121
protected readonly $previewDate = computed<Date>(() => {
123-
const publishDate = untracked(() => this.$pageParams().publishDate);
122+
const publishDate = this.$pageParams().publishDate;
124123

125124
const previewDate = publishDate ? new Date(publishDate) : new Date();
126125

0 commit comments

Comments
 (0)