From 6b684a6eb76c9f0b4468015791b178f0e2ebd1e4 Mon Sep 17 00:00:00 2001 From: Chen-I Lim Date: Tue, 13 Oct 2020 22:24:03 -0700 Subject: [PATCH] Test code: Add multiple cards --- src/client/components/boardComponent.tsx | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/client/components/boardComponent.tsx b/src/client/components/boardComponent.tsx index 8932c5ba5..a2ead7735 100644 --- a/src/client/components/boardComponent.tsx +++ b/src/client/components/boardComponent.tsx @@ -279,6 +279,8 @@ class BoardComponent extends React.Component { Menu.shared.options = [ { id: "exportBoardArchive", name: "Export board archive" }, + { id: "testAdd100Cards", name: "TEST: Add 100 cards" }, + { id: "testAdd1000Cards", name: "TEST: Add 1,000 cards" }, ] Menu.shared.onMenuClicked = async (id: string) => { @@ -287,11 +289,37 @@ class BoardComponent extends React.Component { Archiver.exportBoardTree(boardTree) break } + case "testAdd100Cards": { + this.testAddCards(100) + } + case "testAdd1000Cards": { + this.testAddCards(1000) + } } } Menu.shared.showAtElement(e.target as HTMLElement) } + private async testAddCards(count: number) { + const { mutator, boardTree } = this.props + const { board, activeView } = boardTree + + let optionIndex = 0 + + for (let i = 0; i < count; i++) { + const properties = CardFilter.propertiesThatMeetFilterGroup(activeView.filter, board.cardProperties) + const card = new Block({ type: "card", parentId: boardTree.board.id, properties }) + if (boardTree.groupByProperty && boardTree.groupByProperty.options.length > 0) { + // Cycle through options + const option = boardTree.groupByProperty.options[optionIndex] + optionIndex = (optionIndex + 1) % boardTree.groupByProperty.options.length + card.properties[boardTree.groupByProperty.id] = option.value + card.title = `Test Card ${i + 1}` + } + await mutator.insertBlock(card, "test add card") + } + } + private async propertiesClicked(e: React.MouseEvent) { const { mutator, boardTree } = this.props const { activeView } = boardTree