Test code: Add multiple cards

This commit is contained in:
Chen-I Lim 2020-10-13 22:24:03 -07:00
parent 0b53e083dc
commit 6b684a6eb7

View file

@ -279,6 +279,8 @@ class BoardComponent extends React.Component<Props, State> {
Menu.shared.options = [ Menu.shared.options = [
{ id: "exportBoardArchive", name: "Export board archive" }, { 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) => { Menu.shared.onMenuClicked = async (id: string) => {
@ -287,11 +289,37 @@ class BoardComponent extends React.Component<Props, State> {
Archiver.exportBoardTree(boardTree) Archiver.exportBoardTree(boardTree)
break break
} }
case "testAdd100Cards": {
this.testAddCards(100)
}
case "testAdd1000Cards": {
this.testAddCards(1000)
}
} }
} }
Menu.shared.showAtElement(e.target as HTMLElement) 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) { private async propertiesClicked(e: React.MouseEvent) {
const { mutator, boardTree } = this.props const { mutator, boardTree } = this.props
const { activeView } = boardTree const { activeView } = boardTree