be28b7dad5
* Migrating workspace tree to redux * More changes for use the redux store for boads and views * Taking into account the templates on websocket event updates * Fixing bug on boardTree maintenance * Websocket client now connects once and subscribe/desubscribe on the fly * Including usage of the new websocket client * More work around migrating to redux * WIP * WIP * WIP * WIP * WIP * WIP * Fixing some things * WIP * WIP * Another small fix * Restoring filtering, sorting and grouping * Fixing some other bugs * Add search text reducer * Fixing another drag and drop problem * Improve store names and api * Fixing small bgus * Some small fixes * fixing login * Fixing register page * Some other improvements * Removing unneeded old files * Removing the need of userCache * Fixing comments and fixing content ordering * Fixing sort * Fixing some TODOs * Fixing tests * Fixing snapshot * Fixing cypress tests * Fix eslint * Fixing server tests * Updating the add cards actions * Fixing some tiny navigation problems * Mocking the api calls to pass the tests * Migrating a new test to redux * Adding the card right after the insert of the block (not wait for ws event) * Showing the ws disconnect banner only after 5 seconds of disconnection * Fixing share view * Fix eslint * Fixing problem with sort/groupby modifications * Fixing some details on redirections and templates creation * Fixing small bugs around undo * Fix update properties on click outside the dialog * Improving the column resize look and feel * Removing the class based objects from the store (now they are all plain objects * Fix eslint * Fixing tests * Removing unneeded code
82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
// Disable console log
|
|
console.log = jest.fn()
|
|
|
|
import {Block} from './blocks/block'
|
|
import {createBoard} from './blocks/board'
|
|
import octoClient from './octoClient'
|
|
import 'isomorphic-fetch'
|
|
import {FetchMock} from './test/fetchMock'
|
|
|
|
global.fetch = FetchMock.fn
|
|
|
|
beforeEach(() => {
|
|
FetchMock.fn.mockReset()
|
|
})
|
|
|
|
test('OctoClient: get blocks', async () => {
|
|
const blocks = createBoards()
|
|
|
|
FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify(blocks)))
|
|
let boards = await octoClient.getBlocksWithType('board')
|
|
expect(boards.length).toBe(blocks.length)
|
|
|
|
FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify(blocks)))
|
|
boards = await octoClient.getSubtree()
|
|
expect(boards.length).toBe(blocks.length)
|
|
|
|
FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify(blocks)))
|
|
boards = await octoClient.exportArchive()
|
|
expect(boards.length).toBe(blocks.length)
|
|
|
|
FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify(blocks)))
|
|
const parentId = 'id1'
|
|
boards = await octoClient.getBlocksWithParent(parentId)
|
|
expect(boards.length).toBe(blocks.length)
|
|
|
|
FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify(blocks)))
|
|
boards = await octoClient.getBlocksWithParent(parentId, 'board')
|
|
expect(boards.length).toBe(blocks.length)
|
|
})
|
|
|
|
test('OctoClient: insert blocks', async () => {
|
|
const blocks = createBoards()
|
|
|
|
await octoClient.insertBlocks(blocks)
|
|
|
|
expect(FetchMock.fn).toBeCalledTimes(1)
|
|
expect(FetchMock.fn).toHaveBeenCalledWith(
|
|
expect.anything(),
|
|
expect.objectContaining({
|
|
method: 'POST',
|
|
body: JSON.stringify(blocks),
|
|
}))
|
|
})
|
|
|
|
test('OctoClient: importFullArchive', async () => {
|
|
const blocks = createBoards()
|
|
|
|
await octoClient.importFullArchive(blocks)
|
|
|
|
expect(FetchMock.fn).toBeCalledTimes(1)
|
|
expect(FetchMock.fn).toHaveBeenCalledWith(
|
|
expect.anything(),
|
|
expect.objectContaining({
|
|
method: 'POST',
|
|
body: JSON.stringify(blocks),
|
|
}))
|
|
})
|
|
|
|
function createBoards(): Block[] {
|
|
const blocks = []
|
|
|
|
for (let i = 0; i < 5; i++) {
|
|
const board = createBoard()
|
|
board.id = `board${i + 1}`
|
|
blocks.push(board)
|
|
}
|
|
|
|
return blocks
|
|
}
|