feat(ui): add enhanced user popover + rearrange sidebar (#1246)

Co-authored-by: brios <127139797+balazs-szucs@users.noreply.github.com>
This commit is contained in:
Alex
2026-05-10 14:23:55 +01:00
committed by GitHub
co-authored by brios
parent 868e8e6262
commit 1042cad74a
12 changed files with 579 additions and 140 deletions
@@ -1,5 +1,6 @@
import { computed, signal, WritableSignal } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BehaviorSubject } from 'rxjs';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { getTranslocoModule } from '../../../core/testing/transloco-testing';
@@ -15,6 +16,7 @@ import { SeriesDataService } from '../../../features/series-browser/service/seri
import { UserService } from '../../../features/settings/user-management/user.service';
import { CommandPaletteService } from '../../../features/command-palette/command-palette.service';
import { AuthService } from '../../service/auth.service';
import { AppVersion, VersionService } from '../../service/version.service';
import { DialogLauncherService } from '../../services/dialog-launcher.service';
import { LayoutService } from '../layout.service';
@@ -50,6 +52,7 @@ describe('AppSidebarComponent', () => {
let component: AppSidebarComponent;
let commandPaletteService: { open: ReturnType<typeof vi.fn> };
let currentUser: WritableSignal<TestUser | null>;
let versionInfo: BehaviorSubject<AppVersion>;
const sidebarCollapsed = signal(false);
const isDesktop = signal(true);
const layoutService = {
@@ -65,6 +68,7 @@ describe('AppSidebarComponent', () => {
beforeEach(() => {
commandPaletteService = { open: vi.fn() };
currentUser = signal<TestUser | null>(null);
versionInfo = new BehaviorSubject<AppVersion>({ current: '1.2.3', latest: '1.2.3' });
TestBed.configureTestingModule({
imports: [AppSidebarComponent, getTranslocoModule()],
@@ -92,6 +96,7 @@ describe('AppSidebarComponent', () => {
{ provide: CommandPaletteService, useValue: commandPaletteService },
{ provide: BookDialogHelperService, useValue: { openShelfCreatorDialog: vi.fn() } },
{ provide: AuthService, useValue: { logout: vi.fn() } },
{ provide: VersionService, useValue: { getVersion: vi.fn(() => versionInfo) } },
{ provide: LayoutService, useValue: layoutService },
{ provide: UserService, useValue: { currentUser } },
{ provide: MagicShelfService, useValue: { shelves: signal([]), bookCountByMagicShelfId: signal(new Map()) } },
@@ -182,6 +187,32 @@ describe('AppSidebarComponent', () => {
expect(component.userInitials()).toBe('');
});
it('normalizes semantic version labels with or without a leading v', () => {
const sidebar = component as unknown as { appVersionLabel: () => string };
versionInfo.next({ current: '1.2.3', latest: '1.2.3' });
expect(sidebar.appVersionLabel()).toBe('v1.2.3');
versionInfo.next({ current: 'v1.2.3', latest: '1.2.3' });
expect(sidebar.appVersionLabel()).toBe('v1.2.3');
versionInfo.next({ current: 'development', latest: 'v1.2.3' });
expect(sidebar.appVersionLabel()).toBe('development');
});
it('compares update versions numerically after normalizing a leading v', () => {
const sidebar = component as unknown as { updateAvailable: () => boolean };
versionInfo.next({ current: '1.2.3', latest: 'v1.2.3' });
expect(sidebar.updateAvailable()).toBe(false);
versionInfo.next({ current: 'v1.10.0', latest: 'v1.2.0' });
expect(sidebar.updateAvailable()).toBe(false);
versionInfo.next({ current: '1.2.3', latest: 'v1.2.4' });
expect(sidebar.updateAvailable()).toBe(true);
});
it('anchors notifications above the trigger and keeps them inside the viewport on mobile', () => {
layoutService.isDesktop.set(false);