release test fixes (#496)

* refactor: handle missing type

* fix: prevent stale data on cancel delay
This commit is contained in:
Carlos Valente
2023-08-24 22:53:23 +02:00
committed by GitHub
parent 1d4dc3a26f
commit af99882919
3 changed files with 6 additions and 4 deletions
@@ -132,12 +132,13 @@ export async function cachedDelete(eventId: string) {
}
let updatedRundown = DataProvider.getRundown();
const eventBack = { ...updatedRundown[eventIndex] };
updatedRundown = deleteAtIndex(eventIndex, updatedRundown);
if (eventId !== delayedRundown[eventIndex].id) {
invalidateFromError();
} else {
delayedRundown = deleteAtIndex(eventIndex, delayedRundown);
if (isOntimeDelay(updatedRundown[eventIndex]) || isOntimeBlock(updatedRundown[eventIndex])) {
if (isOntimeDelay(eventBack) || isOntimeBlock(eventBack)) {
// for events, we do not have to worry
// the following event, would have taken the place of the deleted event by now
delayedRundown = calculateRuntimeDelaysFromIndex(eventIndex, delayedRundown);
@@ -47,6 +47,7 @@ test('delay blocks add time to events', async ({ page }) => {
// cancel delay
await page.getByRole('button', { name: 'Cancel' }).click();
await expect(page.getByTestId('panel-rundown').getByTestId('time-input-timeStart')).toHaveValue('00:08:00');
await expect(page.getByText('+10 minNew start: 00:18:00')).toHaveCount(0);
});
test('delays are show correctly', async ({ page }) => {
+3 -3
View File
@@ -2,13 +2,13 @@ import { OntimeRundownEntry } from '../definitions/core/Rundown.type.js';
import { OntimeBlock, OntimeDelay, OntimeEvent, SupportedEvent } from '../definitions/core/OntimeEvent.type.js';
export function isOntimeEvent(event: OntimeRundownEntry | Partial<OntimeRundownEntry>): event is OntimeEvent {
return event.type === SupportedEvent.Event;
return event?.type === SupportedEvent.Event;
}
export function isOntimeDelay(event: OntimeRundownEntry | Partial<OntimeRundownEntry>): event is OntimeDelay {
return event.type === SupportedEvent.Delay;
return event?.type === SupportedEvent.Delay;
}
export function isOntimeBlock(event: OntimeRundownEntry | Partial<OntimeRundownEntry>): event is OntimeBlock {
return event.type === SupportedEvent.Block;
return event?.type === SupportedEvent.Block;
}