Skip to content

Commit 0eb6ff4

Browse files
committed
test(edit-content): align sidebar + form specs with UVE-style toggle
- dot-edit-content-sidebar.component.spec.ts: drop the 'should have toggle-button element' assertion and the whole 'Sidebar Controls' describe block — the inline toggle button and its append-content template were removed from the sidebar in the previous commit - dot-edit-content-form.component.spec.ts: drop the 'sidebar is closed so the toggle renders' precondition (the toggle is now always visible); add a new assertion that both sidebar-open-icon and sidebar-close-icon exist and that exactly one is hidden at any time All 1774 tests in edit-content pass (28 skipped, 0 failed).
1 parent 643b28a commit 0eb6ff4

2 files changed

Lines changed: 11 additions & 34 deletions

File tree

core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.spec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,6 @@ describe('DotFormComponent', () => {
324324
depth: DotContentletDepths.ONE
325325
}); // called with the inode of the contentlet
326326
spectator.flushEffects(); // Wait for async store effects to complete
327-
// Close sidebar so the sidebar toggle button is rendered (it only shows when !showSidebar)
328-
store.toggleSidebar();
329327
spectator.detectChanges();
330328
});
331329

@@ -361,12 +359,6 @@ describe('DotFormComponent', () => {
361359
});
362360

363361
it('should call toggleSidebar when sidebar button is clicked', () => {
364-
// Ensure sidebar is closed (button only renders when !showSidebar)
365-
if (store.isSidebarOpen()) {
366-
store.toggleSidebar();
367-
spectator.detectChanges();
368-
}
369-
370362
const sidebarToggle = spectator.query(byTestId('sidebar-toggle'));
371363
const sidebarButton =
372364
spectator.query(byTestId('sidebar-toggle-button')) ??
@@ -381,6 +373,17 @@ describe('DotFormComponent', () => {
381373
expect(toggleSidebarSpy).toHaveBeenCalled();
382374
});
383375

376+
it('should render both open and close sidebar icons, hiding one per state', () => {
377+
const openIcon = spectator.query(byTestId('sidebar-open-icon'));
378+
const closeIcon = spectator.query(byTestId('sidebar-close-icon'));
379+
expect(openIcon).toBeTruthy();
380+
expect(closeIcon).toBeTruthy();
381+
// One of the two icons must be hidden at any given time
382+
const openHidden = openIcon?.classList.contains('hidden');
383+
const closeHidden = closeIcon?.classList.contains('hidden');
384+
expect(openHidden).not.toBe(closeHidden);
385+
});
386+
384387
describe('TabView Styling', () => {
385388
it('should apply single-tab class when only one tab exists', () => {
386389
const tabView = spectator.query('.dot-edit-content-tabview');

core-web/libs/edit-content/src/lib/components/dot-edit-content-sidebar/dot-edit-content-sidebar.component.spec.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ describe('DotEditContentSidebarComponent', () => {
247247
expect(spectator.query(byTestId('sidebar-tabs'))).toBeTruthy();
248248
});
249249

250-
it('should have toggle-button element', () => {
251-
expect(spectator.query(byTestId('toggle-button'))).toBeTruthy();
252-
});
253-
254250
it('should render information section with data-testId when on info tab', () => {
255251
expect(store.activeSidebarTab()).toBe(0);
256252
const informationElement = spectator.query(byTestId('information'));
@@ -565,28 +561,6 @@ describe('DotEditContentSidebarComponent', () => {
565561
});
566562
});
567563

568-
describe('Sidebar Controls', () => {
569-
it('should render toggle button', () => {
570-
const toggleButton = spectator.query(byTestId('toggle-button'));
571-
expect(toggleButton).toBeTruthy();
572-
});
573-
574-
it('should render append content in Tabs', () => {
575-
const appendContent = spectator.query(byTestId('tabview-append-content'));
576-
expect(appendContent).toBeTruthy();
577-
});
578-
579-
it('should call toggleSidebar when toggle button is clicked', () => {
580-
spectator.detectChanges();
581-
const storeSpy = jest.spyOn(store, 'toggleSidebar');
582-
const toggleButton = spectator.query(byTestId('toggle-button'));
583-
const innerButton = toggleButton?.querySelector('button') as HTMLButtonElement;
584-
spectator.click(innerButton ?? (toggleButton as HTMLElement));
585-
spectator.detectChanges();
586-
expect(storeSpy).toHaveBeenCalled();
587-
});
588-
});
589-
590564
describe('Tabs Behavior', () => {
591565
beforeEach(fakeAsync(() => {
592566
const dotContentTypeService = spectator.inject(DotContentTypeService);

0 commit comments

Comments
 (0)