Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e7f99e7
feat(web): consolidated single-component header for Unraid 7.3+
elibosley Jul 9, 2026
e9f8439
feat(web): array-usage bar in consolidated header
elibosley Jul 9, 2026
1ae725d
feat(web): app-style responsive grid layout for consolidated header
elibosley Jul 9, 2026
925471d
fix(web): make consolidated header custom element fill its width
elibosley Jul 9, 2026
ffa88cd
feat(web): lift uptime/license to the top of the consolidated header
elibosley Jul 9, 2026
deb43f5
feat(web): consolidated header mirrors desktop layout at all sizes
elibosley Jul 9, 2026
171e605
fix(web): tighten consolidated header control spacing
elibosley Jul 9, 2026
b07813d
fix(web): use independent header columns on mobile
elibosley Jul 9, 2026
6a086d7
fix(web): align header metadata above nav row
elibosley Jul 9, 2026
1cadc92
fix(web): align header version under logo
elibosley Jul 9, 2026
fff9e0d
feat(web): add adaptive header logo style
elibosley Jul 9, 2026
0e0ce16
fix(web): render adaptive logo as transparent mask
elibosley Jul 9, 2026
a1f74df
fix(web): use transparent inline adaptive logo
elibosley Jul 9, 2026
eb17187
fix(web): isolate header logo link from legacy block styles
elibosley Jul 9, 2026
81d4e4f
fix(web): rely on consolidated header block reset
elibosley Jul 9, 2026
91d56cb
fix(web): let webgui own consolidated header padding
elibosley Jul 9, 2026
fb0550e
fix(web): align header logo and version rows
elibosley Jul 9, 2026
ac1ec3c
fix(web): center header logo independent of version row
elibosley Jul 9, 2026
27aca7b
fix(web): center header entries in middle band
elibosley Jul 9, 2026
67345f9
fix(web): use compact mirrored header rows
elibosley Jul 9, 2026
ae0a69b
fix(web): flip compact header logo and version
elibosley Jul 9, 2026
0ed01c8
fix(web): tune compact header vertical spacing
elibosley Jul 9, 2026
26bff15
fix(web): anchor compact header columns independently
elibosley Jul 9, 2026
30c97ca
fix(web): center compact header primary entries
elibosley Jul 9, 2026
003854b
fix(web): reserve compact header tag rows
elibosley Jul 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 236 additions & 0 deletions web/__test__/components/Header.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
import { ref } from 'vue';
import { setActivePinia } from 'pinia';
import { provideApolloClient } from '@vue/apollo-composable';
import { mount } from '@vue/test-utils';

import { ApolloClient, InMemoryCache } from '@apollo/client/core';
import { createTestingPinia } from '@pinia/testing';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import type { VueWrapper } from '@vue/test-utils';
import type { Server, ServerconnectPluginInstalled, ServerState } from '~/types/server';
import type { Pinia } from 'pinia';

import Header from '~/components/Header.standalone.vue';
import { useServerStore } from '~/store/server';
import { useThemeStore } from '~/store/theme';

const mockCopy = vi.fn();
const mockCopied = ref(false);
const mockIsSupported = ref(true);

vi.mock('@vueuse/core', () => ({
useClipboard: () => {
const actualCopy = (text: string) => {
if (mockIsSupported.value) {
mockCopy(text);
mockCopied.value = true;
} else {
mockCopied.value = false;
}
};
return {
copy: actualCopy,
copied: mockCopied,
isSupported: mockIsSupported,
};
},
useLocalStorage: <T>(key: string, initialValue: T) => {
const storage = new Map<string, T>();
if (!storage.has(key)) {
storage.set(key, initialValue);
}
return ref(storage.get(key) ?? initialValue);
},
}));

vi.mock('@unraid/ui', () => ({
DropdownMenu: {
template: '<div data-testid="dropdown-menu"><slot name="trigger" /><slot name="content" /></div>',
},
Button: {
template: '<button><slot /></button>',
props: ['variant', 'size'],
},
cn: (...classes: string[]) => classes.filter(Boolean).join(' '),
isDarkModeActive: vi.fn(() => false),
}));

const mockWatcher = vi.fn();

vi.mock('~/store/callbackActions', () => ({
useCallbackActionsStore: vi.fn(() => ({
watcher: mockWatcher,
callbackData: ref(null),
})),
}));

const t = (key: string, args?: unknown[]) => (args ? `${key} ${JSON.stringify(args)}` : key);
vi.mock('vue-i18n', () => ({
useI18n: () => ({ t }),
}));

const initialServerData: Server = {
name: 'DEVGEN',
description: 'Dev Server',
guid: 'TEST-GUID',
keyfile: 'keyfile.key',
lanIp: '192.168.1.100',
connectPluginInstalled: 'dynamix.unraid.net.plg' as ServerconnectPluginInstalled,
state: 'PRO' as ServerState,
dateTimeFormat: { date: 'YYYY-MM-DD', time: 'HH:mm' },
deviceCount: 5,
flashProduct: 'TestFlash',
flashVendor: 'TestVendor',
regGuid: 'REG-GUID',
regTm: 1678886400,
regTo: 'Test User',
regTy: 'Pro',
regExp: undefined,
regUpdatesExpired: false,
registered: true,
wanIp: '8.8.8.8',
};

// Stub the heavier child components; the consolidated header is responsible for
// layout composition, which is what these tests exercise.
const stubs = {
HeaderVersion: { template: '<div data-testid="header-version"></div>' },
ArrayUsage: { template: '<div data-testid="array-usage"></div>' },
UpcServerStatus: {
template: '<div data-testid="server-status"></div>',
props: ['class'],
},
NotificationsSidebar: { template: '<div data-testid="notifications-sidebar"></div>' },
DropdownMenu: {
template: '<div data-testid="dropdown-menu"><slot name="trigger" /><slot name="content" /></div>',
},
UpcDropdownContent: { template: '<div data-testid="dropdown-content"></div>' },
UpcDropdownTrigger: { template: '<button data-testid="dropdown-trigger"></button>' },
};

describe('Header.standalone.vue', () => {
let wrapper: VueWrapper<InstanceType<typeof Header>>;
let pinia: Pinia;
let serverStore: ReturnType<typeof useServerStore>;
let themeStore: ReturnType<typeof useThemeStore>;
let consoleSpies: Array<ReturnType<typeof vi.spyOn>> = [];

beforeEach(() => {
Object.defineProperty(window, 'location', {
value: {
hostname: 'localhost',
port: '3000',
pathname: '/',
protocol: 'http:',
href: 'http://localhost:3000/',
},
writable: true,
configurable: true,
});

provideApolloClient(new ApolloClient({ cache: new InMemoryCache() }));

consoleSpies = [
vi.spyOn(console, 'log').mockImplementation(() => {}),
vi.spyOn(console, 'warn').mockImplementation(() => {}),
vi.spyOn(console, 'debug').mockImplementation(() => {}),
vi.spyOn(console, 'error').mockImplementation(() => {}),
];

mockCopied.value = false;
mockIsSupported.value = true;

pinia = createTestingPinia({
createSpy: vi.fn,
initialState: { server: { ...initialServerData } },
stubActions: false,
});
setActivePinia(pinia);

serverStore = useServerStore();
themeStore = useThemeStore();
themeStore.setTheme({
name: 'white',
banner: true,
bannerGradient: true,
descriptionShow: true,
textColor: '',
metaColor: '',
bgColor: '',
});

vi.spyOn(serverStore, 'setServer').mockImplementation((server) => {
Object.assign(serverStore, server);
return server;
});

vi.clearAllMocks();

wrapper = mount(Header, {
props: { server: JSON.stringify(initialServerData) },
global: { plugins: [pinia], stubs },
});
});

afterEach(() => {
wrapper?.unmount();
consoleSpies.forEach((spy) => spy.mockRestore());
vi.restoreAllMocks();
});

it('renders every header region in a single component', () => {
expect(wrapper.find('[data-testid="header-version"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="server-status"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="notifications-sidebar"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="dropdown-menu"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="dropdown-trigger"]').exists()).toBe(true);
expect(wrapper.find('button').text()).toContain('DEVGEN');
});

it('hydrates the server store from the prop and starts the callback watcher', () => {
expect(serverStore.setServer).toHaveBeenCalledTimes(1);
expect(serverStore.setServer).toHaveBeenCalledWith(JSON.parse(JSON.stringify(initialServerData)));
expect(mockWatcher).toHaveBeenCalledTimes(1);
});

it('throws when the server prop is missing', () => {
expect(() => mount(Header, { props: {}, global: { plugins: [pinia], stubs } })).toThrow(
'Server data not present'
);
});
Comment on lines +197 to +201

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Avoid asserting the exact error message text.

Per coding guidelines, tests should assert that an error is thrown, not the exact wording, to avoid breaking on incidental message changes.

✏️ Proposed fix
   it('throws when the server prop is missing', () => {
-    expect(() => mount(Header, { props: {}, global: { plugins: [pinia], stubs } })).toThrow(
-      'Server data not present'
-    );
+    expect(() => mount(Header, { props: {}, global: { plugins: [pinia], stubs } })).toThrow();
   });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('throws when the server prop is missing', () => {
expect(() => mount(Header, { props: {}, global: { plugins: [pinia], stubs } })).toThrow(
'Server data not present'
);
});
it('throws when the server prop is missing', () => {
expect(() => mount(Header, { props: {}, global: { plugins: [pinia], stubs } })).toThrow();
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/__test__/components/Header.test.ts` around lines 197 - 201, The Header
test is over-constrained by checking the exact thrown message text. Update the
test in Header.test.ts so it only asserts that mounting Header without the
server prop throws, using the existing mount/Header setup, and remove the exact
string expectation to make the assertion resilient to wording changes.

Source: Coding guidelines


it('lays out on a responsive grid with each region in its own area (no overlap)', () => {
const root = wrapper.get('#UnraidHeader');
// A single grid owns the responsive layout (breakpoints live in scoped CSS).
expect(root.classes()).toContain('unraid-header-grid');

Check failure on line 206 in web/__test__/components/Header.test.ts

View workflow job for this annotation

GitHub Actions / Test API

__test__/components/Header.test.ts > Header.standalone.vue > lays out on a responsive grid with each region in its own area (no overlap)

AssertionError: expected [ 'unraid-header-shell', …(5) ] to include 'unraid-header-grid' ❯ __test__/components/Header.test.ts:206:28

Check failure on line 206 in web/__test__/components/Header.test.ts

View workflow job for this annotation

GitHub Actions / Test API

__test__/components/Header.test.ts > Header.standalone.vue > lays out on a responsive grid with each region in its own area (no overlap)

AssertionError: expected [ 'unraid-header-shell', …(5) ] to include 'unraid-header-grid' ❯ __test__/components/Header.test.ts:206:28
// Every header region is placed in its own grid area, so nothing is absolutely
// positioned on top of anything else (the root cause of the old mobile overlap).
expect(root.find('.uh-logo').exists()).toBe(true);
expect(root.find('.uh-meta').exists()).toBe(true);
expect(root.find('.uh-status').exists()).toBe(true);
expect(root.find('.uh-name').exists()).toBe(true);
expect(root.find('.uh-actions').exists()).toBe(true);
// The only absolutely-positioned element allowed is the banner gradient layer.
expect(root.classes()).not.toContain('absolute');
expect(root.find('.absolute:not(.unraid-banner-gradient-layer)').exists()).toBe(false);
});

it('hides the array-usage bar by default and shows it when enabled', async () => {
expect(wrapper.find('[data-testid="array-usage"]').exists()).toBe(false);

const withUsage = mount(Header, {
props: { server: JSON.stringify(initialServerData), showArrayUsage: 'true' },
global: { plugins: [pinia], stubs },
});
expect(withUsage.find('[data-testid="array-usage"]').exists()).toBe(true);
withUsage.unmount();
});

it('copies the LAN IP when the server name is clicked', async () => {
mockIsSupported.value = true;
await wrapper.find('button').trigger('click');
await wrapper.vm.$nextTick();
expect(mockCopy).toHaveBeenCalledWith(initialServerData.lanIp);
});
});
8 changes: 5 additions & 3 deletions web/__test__/components/Wrapper/component-registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ describe('component-registry', () => {
it('should have priority components listed first', async () => {
const { componentMappings } = await import('~/components/Wrapper/component-registry');

// Priority components should be first
expect(componentMappings[0].appId).toBe('header-os-version');
expect(componentMappings[1].appId).toBe('user-profile');
// Priority components should be first: the consolidated header (7.3+) leads,
// followed by the legacy multi-component header used as the < 7.3 fallback.
expect(componentMappings[0].appId).toBe('header');
expect(componentMappings[1].appId).toBe('header-os-version');
expect(componentMappings[2].appId).toBe('user-profile');
});

it('should support multiple selectors for modals', async () => {
Expand Down
4 changes: 4 additions & 0 deletions web/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ declare module 'vue' {
'ApiKeyPage.standalone': typeof import('./src/components/ApiKeyPage.standalone.vue')['default']
ApiStatus: typeof import('./src/components/ApiStatus/ApiStatus.vue')['default']
'ApiStatus.standalone': typeof import('./src/components/ApiStatus/ApiStatus.standalone.vue')['default']
ArrayUsage: typeof import('./src/components/Header/ArrayUsage.vue')['default']
'Auth.standalone': typeof import('./src/components/Auth.standalone.vue')['default']
Avatar: typeof import('./src/components/Brand/Avatar.vue')['default']
BaseLogViewer: typeof import('./src/components/Logs/BaseLogViewer.vue')['default']
Expand Down Expand Up @@ -74,8 +75,11 @@ declare module 'vue' {
EffectivePermissions: typeof import('./src/components/ApiKey/EffectivePermissions.vue')['default']
FileViewer: typeof import('./src/components/FileViewer.vue')['default']
FilteredLogModal: typeof import('./src/components/Logs/FilteredLogModal.vue')['default']
'Header.standalone': typeof import('./src/components/Header.standalone.vue')['default']
HeaderContent: typeof import('./src/components/Docker/HeaderContent.vue')['default']
HeaderLogo: typeof import('./src/components/Header/HeaderLogo.vue')['default']
'HeaderOsVersion.standalone': typeof import('./src/components/HeaderOsVersion.standalone.vue')['default']
HeaderVersion: typeof import('./src/components/Header/HeaderVersion.vue')['default']
IgnoredRelease: typeof import('./src/components/UpdateOs/IgnoredRelease.vue')['default']
Indicator: typeof import('./src/components/Notifications/Indicator.vue')['default']
InternalBootConfirmDialog: typeof import('./src/components/Onboarding/components/InternalBootConfirmDialog.vue')['default']
Expand Down
8 changes: 8 additions & 0 deletions web/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ unraid-modals.unapi {
isolation: isolate;
}

/* Consolidated header (7.3+): custom elements default to display:inline, which
shrink-wraps the grid. Make it fill the header so the layout can space the logo
and account controls across the full available width. */
unraid-header.unapi {
display: block;
width: 100%;
}

/* Style for Unraid progress frame */
iframe#progressFrame {
background-color: var(--background-color);
Expand Down
Loading
Loading