test(spa): close remaining playout gate gaps
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 8s
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 9s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 9s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 8s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 3m50s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 7m52s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Docs update reminder (push) Has been skipped
Build ErsatzTV Image / decisions.md append-only (push) Has been skipped
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (push) Has been skipped
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (push) Has been skipped
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (push) Successful in 4m39s
Build ErsatzTV Image / Build & test (.NET) (push) Successful in 6m5s
Build ErsatzTV Image / Build & push image (amd64) (push) Successful in 5m19s
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 8s
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 9s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 9s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 8s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 3m50s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 7m52s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Docs update reminder (push) Has been skipped
Build ErsatzTV Image / decisions.md append-only (push) Has been skipped
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (push) Has been skipped
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (push) Has been skipped
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (push) Successful in 4m39s
Build ErsatzTV Image / Build & test (.NET) (push) Successful in 6m5s
Build ErsatzTV Image / Build & push image (amd64) (push) Successful in 5m19s
Cover the None action matrix, required add inputs, file-edit blank/trim/payload/refresh/error behavior, and clearing a default deco to null. Refs #245 Co-Authored-By: OpenAI Codex <codex@openai.com>
This commit was merged in pull request #351.
This commit is contained in:
@@ -257,14 +257,19 @@ function fetchCount(path: string): number {
|
||||
}
|
||||
|
||||
function requestBodyFor(path: string): Record<string, unknown> {
|
||||
const call = vi
|
||||
.mocked(window.fetch)
|
||||
.mock.calls.find(([input, init]) => input.toString() === path && init?.body != null);
|
||||
if (!call) {
|
||||
const body = requestBodiesFor(path)[0];
|
||||
if (!body) {
|
||||
throw new Error('no request captured for ' + path);
|
||||
}
|
||||
|
||||
return JSON.parse(call[1]?.body as string) as Record<string, unknown>;
|
||||
return body;
|
||||
}
|
||||
|
||||
function requestBodiesFor(path: string): Array<Record<string, unknown>> {
|
||||
return vi
|
||||
.mocked(window.fetch)
|
||||
.mock.calls.filter(([input, init]) => input.toString() === path && init?.body != null)
|
||||
.map(([, init]) => JSON.parse(init?.body as string) as Record<string, unknown>);
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
@@ -626,6 +631,7 @@ describe('PlayoutsScreen', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
['None', { alternate: false, defaultDeco: false, eraseHistory: false, eraseItems: false, templates: false }],
|
||||
['Classic', { alternate: true, defaultDeco: false, eraseHistory: true, eraseItems: false, templates: false }],
|
||||
['Block', { alternate: false, defaultDeco: true, eraseHistory: true, eraseItems: true, templates: true }],
|
||||
['Sequential', { alternate: false, defaultDeco: false, eraseHistory: true, eraseItems: false, templates: false }],
|
||||
@@ -648,7 +654,7 @@ describe('PlayoutsScreen', () => {
|
||||
expect(Boolean(screen.queryByRole('button', { name: 'Erase items and history' }))).toBe(expected.eraseHistory);
|
||||
});
|
||||
|
||||
it('updates a Block playout default deco and refreshes playout data', async () => {
|
||||
it('sets and clears a Block playout default deco and refreshes after each save', async () => {
|
||||
mockApi({
|
||||
decos: [{ decoGroupId: 2, decoGroupName: 'Prime', id: 4, name: 'Movie Night' }],
|
||||
playoutDetails: playout({ decoId: null, id: 20, scheduleKind: 'Block' }),
|
||||
@@ -674,6 +680,16 @@ describe('PlayoutsScreen', () => {
|
||||
await waitFor(() => {
|
||||
expect(fetchCount('/api/v1/playouts')).toBe(playoutFetchesBeforeSave + 1);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByLabelText('Default deco')).toBeEnabled();
|
||||
});
|
||||
fireEvent.change(screen.getByLabelText('Default deco'), { target: { value: '' } });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(requestBodiesFor('/api/v1/playouts/20/deco')).toEqual([{ decoId: 4 }, { decoId: null }]);
|
||||
expect(fetchCount('/api/v1/playouts')).toBe(playoutFetchesBeforeSave + 2);
|
||||
});
|
||||
});
|
||||
|
||||
it('shows a Block default-deco save error without closing the control', async () => {
|
||||
@@ -892,13 +908,17 @@ describe('PlayoutsScreen', () => {
|
||||
expect(await screen.findByRole('heading', { name: 'Retro Cartoons' })).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Add Playout' }));
|
||||
expect(await screen.findByText('Add playout')).toBeInTheDocument();
|
||||
const dialog = await screen.findByRole('dialog');
|
||||
const createButton = within(dialog).getByRole('button', { name: 'Create' });
|
||||
expect(createButton).toBeDisabled();
|
||||
|
||||
fireEvent.change(screen.getByLabelText('Channel'), { target: { value: '1' } });
|
||||
await screen.findByRole('option', { name: 'Weekend Lineup' });
|
||||
fireEvent.change(screen.getByLabelText('Classic schedule'), { target: { value: '7' } });
|
||||
fireEvent.change(within(dialog).getByLabelText('Channel'), { target: { value: '1' } });
|
||||
await within(dialog).findByRole('option', { name: 'Weekend Lineup' });
|
||||
expect(createButton).toBeDisabled();
|
||||
fireEvent.change(within(dialog).getByLabelText('Classic schedule'), { target: { value: '7' } });
|
||||
expect(createButton).toBeEnabled();
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Create' }));
|
||||
fireEvent.click(createButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(requestBodyFor('/api/v1/playouts')).toMatchObject({
|
||||
@@ -931,6 +951,8 @@ describe('PlayoutsScreen', () => {
|
||||
expect(await screen.findByRole('heading', { name: 'Retro Cartoons' })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Add Playout' }));
|
||||
const dialog = await screen.findByRole('dialog');
|
||||
const createButton = within(dialog).getByRole('button', { name: 'Create' });
|
||||
expect(createButton).toBeDisabled();
|
||||
|
||||
fireEvent.change(within(dialog).getByLabelText('Kind'), { target: { value: scheduleKind } });
|
||||
fireEvent.change(within(dialog).getByLabelText('Channel'), { target: { value: '1' } });
|
||||
@@ -939,12 +961,14 @@ describe('PlayoutsScreen', () => {
|
||||
if (fileLabel) {
|
||||
const scheduleFile = within(dialog).getByLabelText(fileLabel);
|
||||
expect(within(dialog).getByText(helperText)).toBeInTheDocument();
|
||||
expect(createButton).toBeDisabled();
|
||||
fireEvent.change(scheduleFile, { target: { value: ' schedule-source ' } });
|
||||
} else {
|
||||
expect(within(dialog).getByText(helperText)).toBeInTheDocument();
|
||||
}
|
||||
expect(createButton).toBeEnabled();
|
||||
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: 'Create' }));
|
||||
fireEvent.click(createButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(requestBodyFor('/api/v1/playouts')).toEqual({
|
||||
@@ -1036,10 +1060,54 @@ describe('PlayoutsScreen', () => {
|
||||
|
||||
const scheduleFile = within(dialog).queryByLabelText(/^(Sequential|Scripted|JSON \(dizqueTV\)) schedule$/);
|
||||
if (fileLabel) {
|
||||
expect(within(dialog).getByLabelText(fileLabel)).toBeInTheDocument();
|
||||
const scheduleFileInput = within(dialog).getByLabelText(fileLabel);
|
||||
expect(scheduleFile).toBeInTheDocument();
|
||||
fireEvent.change(scheduleFileInput, { target: { value: ' ' } });
|
||||
expect(within(dialog).getByRole('button', { name: 'Save changes' })).toBeDisabled();
|
||||
fireEvent.change(scheduleFileInput, { target: { value: ' updated-source ' } });
|
||||
expect(within(dialog).getByRole('button', { name: 'Save changes' })).toBeEnabled();
|
||||
const playoutFetchesBeforeSave = fetchCount('/api/v1/playouts');
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(requestBodyFor('/api/v1/playouts/20')).toMatchObject({ scheduleFile: 'updated-source' });
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(fetchCount('/api/v1/playouts')).toBe(playoutFetchesBeforeSave + 1);
|
||||
});
|
||||
} else {
|
||||
expect(scheduleFile).not.toBeInTheDocument();
|
||||
expect(within(dialog).getByRole('button', { name: 'Save changes' })).toBeEnabled();
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps a file-backed edit dialog open and shows an inline save error', async () => {
|
||||
mockApi({
|
||||
mutationFailures: {
|
||||
'/api/v1/playouts/20': {
|
||||
detail: 'Schedule file could not be saved',
|
||||
status: 422,
|
||||
title: 'Validation failed'
|
||||
}
|
||||
},
|
||||
playoutDetails: playout({ id: 20, scheduleFile: '/config/schedule.yml', scheduleKind: 'Sequential' }),
|
||||
playoutItems: [playoutItem()],
|
||||
playouts: { page: [listPlayout({ id: 20, scheduleKind: 'Sequential' })], totalCount: 1 }
|
||||
});
|
||||
|
||||
render(<PlayoutsScreen />);
|
||||
|
||||
expect(await screen.findByRole('heading', { name: 'Retro Cartoons' })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Edit details' }));
|
||||
const dialog = await screen.findByRole('dialog');
|
||||
|
||||
fireEvent.change(within(dialog).getByLabelText('Sequential schedule'), {
|
||||
target: { value: '/config/rejected.yml' }
|
||||
});
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));
|
||||
|
||||
expect(await within(dialog).findByText('Schedule file could not be saved')).toBeInTheDocument();
|
||||
expect(dialog).toBeInTheDocument();
|
||||
expect(within(dialog).getByLabelText('Sequential schedule')).toBeEnabled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user