diff --git a/webapp/src/mutator.test.ts b/webapp/src/mutator.test.ts index 4a3870ba3..86aac8744 100644 --- a/webapp/src/mutator.test.ts +++ b/webapp/src/mutator.test.ts @@ -38,7 +38,7 @@ describe('Mutator', () => { const board = TestBlockFactory.createBoard() FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify([card]))) - FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify({}))) + FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify([]))) const [newBlocks, newCardID] = await mutator.duplicateCard(card.id, board) expect(newBlocks).toHaveLength(1) diff --git a/webapp/src/mutator.ts b/webapp/src/mutator.ts index eb7187999..81d8a054d 100644 --- a/webapp/src/mutator.ts +++ b/webapp/src/mutator.ts @@ -682,7 +682,12 @@ class Mutator { newBlocks, description, async (respBlocks: Block[]) => { - await afterRedo?.(respBlocks[0].id) + const card = respBlocks.find((block) => block.type === 'card') + if (card) { + await afterRedo?.(card.id) + } else { + Utils.logError('card not found for opening.') + } }, beforeUndo, )