feat(386): Auto-Tune per-channel DetailPanel slide-over (SPA)
Adds a right-hand "Configure" slide-over to each Auto-Tune Preview row, making a proposed channel editable before bulk-create — against the shipped #384/#385 backend only, so no control lacks a wire target. - New reusable SlideOver primitive (components/overlay.tsx), sharing a useOverlayBehavior hook (focus/scroll-lock/Escape/scrim) with Dialog. - Extract the Channel Builder's advanced-options model to builder/advancedOptions.tsx (enum catalogs, ADVANCED_KEYS, effectiveValue, INHERIT/omit useAdvancedOverrides hook); ChannelBuilder imports it unchanged (its tests pass byte-for-byte). The DetailPanel writes its own field JSX over the same hook — shared logic, per-screen layout. - Panes: identity (name/number + logo upload), Playback (Shuffle/Always-playing → advanced.playbackOrder/playoutMode), per-channel template picker, Advanced disclosure, lean read-only Query&size, read-only Content-sources via GET /members. - getAutoTuneChannelMembers API client (#384 read endpoint) + tests. - Screen-scoped §8 unsaved-changes guard + "Edited" row badge. - Dropped as backend-less decoration: MiniEpg, bug-initials generator, query text. Deferred to #425 with an in-pane hint: per-source weight steppers + corrections. - Docs: spa-conventions §11 (SlideOver + shared advanced-options), decisions.md. Refs #386
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createAutoTunedChannels, previewAutoTune } from './autoTune';
|
||||
import { createAutoTunedChannels, getAutoTuneChannelMembers, previewAutoTune } from './autoTune';
|
||||
|
||||
const sampleMembers = {
|
||||
totalCount: 3,
|
||||
page: [
|
||||
{ id: 1, mediaType: 'TelevisionShow', title: 'The Office', artwork: '/artwork/1' },
|
||||
{ id: 2, mediaType: 'TelevisionShow', title: 'Parks and Rec', artwork: '/artwork/2' }
|
||||
]
|
||||
};
|
||||
|
||||
const sampleProposals = [
|
||||
{ axis: 'TvShow', value: 'The Office', name: 'The Office', number: '500', itemCount: 201, alreadyExists: false },
|
||||
@@ -86,4 +94,87 @@ describe('createAutoTunedChannels', () => {
|
||||
channels: [{ axis: 'TvShow', value: 'The Office', name: 'The Office', number: '500' }]
|
||||
});
|
||||
});
|
||||
|
||||
it('sends per-channel overrides (templateId, logo, advanced) verbatim when present', async () => {
|
||||
const fetchSpy = vi.spyOn(window, 'fetch').mockResolvedValue(
|
||||
new Response(JSON.stringify(sampleResult), {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
status: 200
|
||||
})
|
||||
);
|
||||
|
||||
await createAutoTunedChannels({
|
||||
templateId: 3,
|
||||
group: 'Auto-Tuned',
|
||||
channels: [
|
||||
{
|
||||
axis: 'TvGenre',
|
||||
value: 'Comedy',
|
||||
name: 'Comedy',
|
||||
number: '501',
|
||||
templateId: 9,
|
||||
logo: { path: 'logos/comedy.png', contentType: 'image/png' },
|
||||
advanced: { shuffleScheduleItems: true, ffmpegProfileId: 4 }
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const [, init] = fetchSpy.mock.calls[0];
|
||||
expect(JSON.parse(String(init?.body)).channels[0]).toEqual({
|
||||
axis: 'TvGenre',
|
||||
value: 'Comedy',
|
||||
name: 'Comedy',
|
||||
number: '501',
|
||||
templateId: 9,
|
||||
logo: { path: 'logos/comedy.png', contentType: 'image/png' },
|
||||
advanced: { shuffleScheduleItems: true, ffmpegProfileId: 4 }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAutoTuneChannelMembers', () => {
|
||||
beforeEach(() => {
|
||||
window.localStorage.clear();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('GETs /api/v1/channels/auto-tune/members with axis+value and optional paging', async () => {
|
||||
const fetchSpy = vi.spyOn(window, 'fetch').mockResolvedValue(
|
||||
new Response(JSON.stringify(sampleMembers), {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
status: 200
|
||||
})
|
||||
);
|
||||
|
||||
await expect(
|
||||
getAutoTuneChannelMembers({ axis: 'TvGenre', value: 'Comedy', pageNum: 1, pageSize: 50 })
|
||||
).resolves.toMatchObject({ totalCount: 3 });
|
||||
|
||||
const [url, init] = fetchSpy.mock.calls[0];
|
||||
expect((init?.method ?? 'GET').toUpperCase()).toBe('GET');
|
||||
const parsed = new URL(String(url), 'http://localhost');
|
||||
expect(parsed.pathname).toBe('/api/v1/channels/auto-tune/members');
|
||||
expect(parsed.searchParams.get('axis')).toBe('TvGenre');
|
||||
expect(parsed.searchParams.get('value')).toBe('Comedy');
|
||||
expect(parsed.searchParams.get('pageNum')).toBe('1');
|
||||
expect(parsed.searchParams.get('pageSize')).toBe('50');
|
||||
});
|
||||
|
||||
it('omits paging params when not provided but always sends axis+value', async () => {
|
||||
const fetchSpy = vi.spyOn(window, 'fetch').mockResolvedValue(
|
||||
new Response(JSON.stringify(sampleMembers), {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
status: 200
|
||||
})
|
||||
);
|
||||
|
||||
await getAutoTuneChannelMembers({ axis: 'TvShow', value: 'The Office' });
|
||||
|
||||
const [url] = fetchSpy.mock.calls[0];
|
||||
const parsed = new URL(String(url), 'http://localhost');
|
||||
expect(parsed.searchParams.get('axis')).toBe('TvShow');
|
||||
expect(parsed.searchParams.get('value')).toBe('The Office');
|
||||
expect(parsed.searchParams.has('pageNum')).toBe(false);
|
||||
expect(parsed.searchParams.has('pageSize')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,6 +8,15 @@ export type AutoTunedChannelRequest = components['schemas']['AutoTunedChannelReq
|
||||
export type CreateAutoTunedChannelsRequest = components['schemas']['CreateAutoTunedChannelsRequest'];
|
||||
export type AutoTuneChannelResult = components['schemas']['AutoTuneChannelResultModel'];
|
||||
export type AutoTuneResult = components['schemas']['AutoTuneResultResponseModel'];
|
||||
export type PagedAutoTuneMembers = components['schemas']['PagedLibraryBrowseItemsResponseModel'];
|
||||
export type AutoTuneMember = components['schemas']['LibraryBrowseItemResponseModel'];
|
||||
|
||||
export interface GetAutoTuneMembersParams {
|
||||
axis: AutoTuneAxis;
|
||||
value: string;
|
||||
pageNum?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
export function previewAutoTune(body: PreviewAutoTuneChannelsRequest): Promise<AutoTuneProposal[]> {
|
||||
return request<AutoTuneProposal[]>('/api/v1/channels/auto-tune/preview', {
|
||||
@@ -23,6 +32,25 @@ export function createAutoTunedChannels(body: CreateAutoTunedChannelsRequest): P
|
||||
});
|
||||
}
|
||||
|
||||
// #384 read endpoint: the distinct members a proposed channel's smart collection
|
||||
// resolves to (axis+value identify the proposal). Read-only source list for the
|
||||
// DetailPanel; per-source rotation weights + corrections are #425, not here.
|
||||
export function getAutoTuneChannelMembers(params: GetAutoTuneMembersParams): Promise<PagedAutoTuneMembers> {
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.set('axis', params.axis);
|
||||
searchParams.set('value', params.value);
|
||||
|
||||
if (params.pageNum != null) {
|
||||
searchParams.set('pageNum', String(params.pageNum));
|
||||
}
|
||||
|
||||
if (params.pageSize != null) {
|
||||
searchParams.set('pageSize', String(params.pageSize));
|
||||
}
|
||||
|
||||
return request<PagedAutoTuneMembers>(`/api/v1/channels/auto-tune/members?${searchParams.toString()}`);
|
||||
}
|
||||
|
||||
export function messageFromAutoTuneError(error: unknown, fallback = 'Unable to auto-tune channels'): string {
|
||||
if (error instanceof ApiError) {
|
||||
return error.detail ?? error.message;
|
||||
|
||||
Reference in New Issue
Block a user