diff --git a/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx b/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx index ebc96d73452aff066c29856c4756573d28435bb2..956d0b7212baf5a3eed212c86e9946550b66e72f 100644 --- a/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx +++ b/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx @@ -13,7 +13,7 @@ it('renders presentation editor', () => { id: 0, year: 0, city_id: 0, - slides: [], + slides: [{ id: 5 }], teams: [], }, } diff --git a/client/src/pages/presentationEditor/components/SlideEditor.tsx b/client/src/pages/presentationEditor/components/SlideEditor.tsx index f9e9ce62929dd62928ab0b11e30c1ca927e1068f..9baa97918f2b11276bd12bf17ba8fc4f466cf9b2 100644 --- a/client/src/pages/presentationEditor/components/SlideEditor.tsx +++ b/client/src/pages/presentationEditor/components/SlideEditor.tsx @@ -9,9 +9,9 @@ import TextComponentDisplay from './TextComponentDisplay' const SlideEditor: React.FC = () => { const components = useAppSelector( - (state) => state.editor.competition.slides.find((slide) => slide.id === state.editor.activeSlideId)?.components + (state) => + state.editor.competition.slides.find((slide) => slide && slide.id === state.editor.activeSlideId)?.components ) - console.log(components) return ( <SlideEditorContainer> {components && diff --git a/client/src/pages/presentationEditor/components/SlideSettings.tsx b/client/src/pages/presentationEditor/components/SlideSettings.tsx index 96f76bb00f877575521f67c5c5a17bd74f50f079..cc6b343e7a62f69607f7747b3ea3ed48481031df 100644 --- a/client/src/pages/presentationEditor/components/SlideSettings.tsx +++ b/client/src/pages/presentationEditor/components/SlideSettings.tsx @@ -205,7 +205,8 @@ const SlideSettings: React.FC = () => { secondary="(Fyll i rutan höger om textfältet för att markera korrekt svar)" /> </ListItem> - {currentSlide.questions[0] && + {currentSlide && + currentSlide.questions[0] && currentSlide.questions[0].question_alternatives.map((alt) => ( <div key={alt.id}> <ListItem divider> diff --git a/client/src/pages/presentationEditor/components/TextComponentDisplay.test.tsx b/client/src/pages/presentationEditor/components/TextComponentDisplay.test.tsx index 8f61ee36f8bb86e9e422b135c76448c31d60a6d4..c448987894fedee6731d3610fe850871e608388d 100644 --- a/client/src/pages/presentationEditor/components/TextComponentDisplay.test.tsx +++ b/client/src/pages/presentationEditor/components/TextComponentDisplay.test.tsx @@ -1,12 +1,18 @@ import { Editor } from '@tinymce/tinymce-react' import { mount } from 'enzyme' import React from 'react' +import { Provider } from 'react-redux' +import store from '../../../store' import TextComponentDisplay from './TextComponentDisplay' it('renders text component display', () => { const testText = 'TEST' const container = mount( - <TextComponentDisplay component={{ id: 0, x: 0, y: 0, w: 0, h: 0, text: testText, type: 2, font: '123123' }} /> + <Provider store={store}> + <TextComponentDisplay + component={{ id: 0, x: 0, y: 0, w: 0, h: 0, data: { text: testText, font: '123123' }, type_id: 2 }} + /> + </Provider> ) expect(container.find(Editor).prop('initialValue')).toBe(testText) })