M5-T06: add Energy device management UI and sidebar entry

This commit is contained in:
2026-06-22 13:52:33 +02:00
parent 702a1cec00
commit 2dc469274a
11 changed files with 2301 additions and 8 deletions
+15 -3
View File
@@ -1,15 +1,16 @@
/**
* Tests for AppSidebar (M5-T01).
* Tests for AppSidebar (M5-T01, updated M5-T06).
*
* Strategy: render AppSidebar inside a minimal AppShell (required by
* AppShell.Navbar) + MemoryRouter so useLocation() works.
*
* Coverage:
* 1. All three nav items render (Home, Records, Config).
* 1. All four nav items render (Home, Records, Energy, Config).
* 2. Home nav item is active when pathname is '/'.
* 3. Records nav item is active when pathname is '/records'.
* 4. Config nav item is active when pathname is '/config'.
* 5. Home is NOT active when on '/records'.
* 6. Energy nav item is active when on '/energy'.
*/
import { describe, it, expect, vi } from 'vitest'
@@ -76,10 +77,11 @@ describe('AppSidebar', () => {
// 1. All nav items render
// -------------------------------------------------------------------------
it('renders Home, Records, and Config nav items', () => {
it('renders Home, Records, Energy, and Config nav items', () => {
renderSidebar('/')
expect(screen.getByTestId('nav-home')).toBeInTheDocument()
expect(screen.getByTestId('nav-records')).toBeInTheDocument()
expect(screen.getByTestId('nav-energy')).toBeInTheDocument()
expect(screen.getByTestId('nav-config')).toBeInTheDocument()
})
@@ -123,4 +125,14 @@ describe('AppSidebar', () => {
const homeLink = screen.getByTestId('nav-home')
expect(homeLink).not.toHaveAttribute('data-active', 'true')
})
// -------------------------------------------------------------------------
// 6. Energy active on '/energy'
// -------------------------------------------------------------------------
it('marks Energy nav item as active when on "/energy"', () => {
renderSidebar('/energy')
const energyLink = screen.getByTestId('nav-energy')
expect(energyLink).toHaveAttribute('data-active', 'true')
})
})