diff --git a/web/src/App.tsx b/web/src/App.tsx
index a0b6f159f..634f0d5da 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -2859,7 +2859,7 @@ function ScreenContent({
}
if (route.id === 'editChannel') {
- return ;
+ return ;
}
if (route.id === 'guide') {
diff --git a/web/src/screens/ChannelEditScreen.test.tsx b/web/src/screens/ChannelEditScreen.test.tsx
index 32a9e5fe3..afa5ea441 100644
--- a/web/src/screens/ChannelEditScreen.test.tsx
+++ b/web/src/screens/ChannelEditScreen.test.tsx
@@ -34,6 +34,14 @@ const channel = {
showInEpg: true
};
+// The PUT body is the GET response minus the read-only id / playoutCount fields.
+function expectedPutBody(overrides: Record = {}): Record {
+ const { id, playoutCount, ...rest } = channel;
+ void id;
+ void playoutCount;
+ return { ...rest, ...overrides };
+}
+
function json(body: unknown, status = 200): Response {
return new Response(JSON.stringify(body), {
headers: { 'Content-Type': 'application/json' },
@@ -115,14 +123,34 @@ describe('ChannelEditScreen', () => {
fireEvent.click(saveButton);
await waitFor(() => expect(puts).toHaveLength(1));
- expect(puts[0]).toMatchObject({ name: 'Renamed', number: '5', playoutSource: 'Generated' });
- // Read-only fields are not part of the PUT contract.
- expect(puts[0]).not.toHaveProperty('id');
- expect(puts[0]).not.toHaveProperty('playoutCount');
+
+ expect(puts[0]).toEqual(expectedPutBody({ name: 'Renamed' }));
expect(await screen.findByText('Channel saved')).toBeInTheDocument();
});
+ it('forces showInEpg off in the PUT body when Enabled is turned off', async () => {
+ const puts: unknown[] = [];
+ mockApi({ onPut: (body) => puts.push(body) });
+ render();
+
+ await screen.findByDisplayValue('Cartoons');
+
+ // The General pane renders exactly two switches, in document order: Enabled, then Show in EPG.
+ const [enabledSwitch, showInEpgSwitch] = screen.getAllByRole('switch');
+ fireEvent.click(enabledSwitch);
+
+ expect(showInEpgSwitch).toHaveAttribute('aria-checked', 'false');
+ expect(showInEpgSwitch).toHaveAttribute('aria-disabled', 'true');
+
+ const saveButton = await screen.findByRole('button', { name: 'Save changes' });
+ fireEvent.click(saveButton);
+
+ await waitFor(() => expect(puts).toHaveLength(1));
+
+ expect(puts[0]).toEqual(expectedPutBody({ isEnabled: false, showInEpg: false }));
+ });
+
it('shows an error state when the channel is not found', async () => {
mockApi({ channelStatus: 404 });
render();
diff --git a/web/src/screens/ChannelEditScreen.tsx b/web/src/screens/ChannelEditScreen.tsx
index 457e43f9e..44da62e7a 100644
--- a/web/src/screens/ChannelEditScreen.tsx
+++ b/web/src/screens/ChannelEditScreen.tsx
@@ -252,10 +252,19 @@ function GeneralPane({
/>
- set({ isEnabled: next })} size="sm" />
+ set(next ? { isEnabled: next } : { isEnabled: next, showInEpg: false })}
+ size="sm"
+ />
- set({ showInEpg: next })} size="sm" />
+ set({ showInEpg: next })}
+ size="sm"
+ />