diff --git a/app/src/components/admin/ControllerPage.js b/app/src/components/admin/ControllerPage.js index 5c39d240..05d1284c 100644 --- a/app/src/components/admin/ControllerPage.js +++ b/app/src/components/admin/ControllerPage.js @@ -270,7 +270,9 @@ function ServiceLogsModal({ } // Mobile service row - simplified layout -function MobileServiceRow({service, onAction}) { +// Exported so tests can mount a row directly: `Media` renders neither branch in jsdom, +// where no media query matches, so `ServicesSection` produces no rows at all there. +export function MobileServiceRow({service, onAction}) { const { loading, logsOpen, setLogsOpen, logs, logsLoading, linesCount, countdown, logsRef, handleAction, fetchLogs, handleViewLogs, handleLinesChange, handleDownloadLogs, @@ -320,6 +322,17 @@ function MobileServiceRow({service, onAction}) { role='primary' onClick={handleViewLogs} /> + {viewUrl && ( + + )} - {viewUrl && ( - - )} ); } // Desktop service row - full layout with all columns -function DesktopServiceRow({service, onAction, dockerized}) { +export function DesktopServiceRow({service, onAction, dockerized}) { const { loading, logsOpen, setLogsOpen, logs, logsLoading, linesCount, countdown, logsRef, handleAction, fetchLogs, handleViewLogs, handleLinesChange, handleDownloadLogs, @@ -402,6 +404,17 @@ function DesktopServiceRow({service, onAction, dockerized}) { role='primary' onClick={handleViewLogs} /> + {viewUrl && ( + + )} - {viewUrl && ( - - )} {!dockerized && ( diff --git a/app/src/components/admin/ControllerPage.test.js b/app/src/components/admin/ControllerPage.test.js index e2ff6c83..3ebc1901 100644 --- a/app/src/components/admin/ControllerPage.test.js +++ b/app/src/components/admin/ControllerPage.test.js @@ -4,7 +4,8 @@ import {BrowserRouter} from 'react-router'; import {MantineProvider} from '@mantine/core'; import {ThemeContext, SettingsContext} from '../../contexts/contexts'; import {cssVariablesResolver, mantineTheme} from '../../themes/mantine'; -import {ControllerPage} from './ControllerPage'; +import {ControllerPage, DesktopServiceRow, MobileServiceRow} from './ControllerPage'; +import {Table} from '../ui'; // Mock the controller API jest.mock('../../api/controller', () => ({ @@ -352,3 +353,44 @@ describe('ControllerPage in Docker mode', () => { }); }); }); + +describe('service action buttons', () => { + // `Media` renders neither branch in jsdom -- no media query matches -- so `ServicesSection` + // produces no rows there. Mount the rows themselves instead. + const renderRow = (RowComponent, extraProps = {}) => render( + + + + + + +
+
+
+ ); + + test.each([ + ['mobile', MobileServiceRow, {}], + ['desktop', DesktopServiceRow, {dockerized: false}], + ])('the %s row keeps Open on the same line as the other actions', (_name, RowComponent, extraProps) => { + renderRow(RowComponent, extraProps); + // Open used to sit outside `.wrolpi-button-row`, after the logs modal, which put it on a + // line of its own below the rest. It belongs in the flex row with them. + const row = screen.getByLabelText('Open wrolpi-api').closest('.wrolpi-button-row'); + expect(row).not.toBeNull(); + expect(within(row).getByLabelText('Stop wrolpi-api')).toBeInTheDocument(); + expect(within(row).getByLabelText('Restart wrolpi-api')).toBeInTheDocument(); + expect(within(row).getByLabelText('View logs for wrolpi-api')).toBeInTheDocument(); + }); +});