Skip to content

Commit

Permalink
refactor: removed isFocalboardPlugin from test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajat-Dabade committed Jul 24, 2024
1 parent cb79b98 commit 8a2d87c
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {Provider as ReduxProvider} from 'react-redux'
import {MemoryRouter, Router} from 'react-router-dom'

import Mutator from '../../mutator'
import {Utils} from '../../utils'
import {Team} from '../../store/teams'
import {createBoard, Board} from '../../blocks/board'
import {IUser} from '../../user'
Expand Down Expand Up @@ -48,7 +47,6 @@ jest.mock('../../telemetry/telemetryClient')
const mockedTelemetry = mocked(TelemetryClient, true)

describe('components/boardTemplateSelector/boardTemplateSelector', () => {
const mockedUtils = mocked(Utils, true)
const mockedMutator = mocked(Mutator, true)
const mockedOctoClient = mocked(client, true)
const team1: Team = {
Expand Down Expand Up @@ -160,9 +158,6 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
jest.useRealTimers()
})
describe('not a focalboard Plugin', () => {
beforeAll(() => {
mockedUtils.isFocalboardPlugin.mockReturnValue(false)
})
test('should match snapshot', () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
Expand All @@ -174,9 +169,6 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
})
})
describe('a focalboard Plugin', () => {
beforeAll(() => {
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
})
test('should match snapshot', () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
Expand Down
16 changes: 1 addition & 15 deletions webapp/src/components/boardsSwitcher/boardsSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import React, {useEffect, useState} from 'react'

import {FormattedMessage, useIntl} from 'react-intl'

import MenuWrapper from '../../widgets/menuWrapper'
import CompassIcon from '../../widgets/icons/compassIcon'
import Menu from '../../widgets/menu'
import Search from '../../widgets/icons/search'
import CreateCategory from '../createCategory/createCategory'
import {useAppSelector} from '../../store/hooks'
Expand All @@ -18,21 +15,14 @@ import {
import {getCurrentCard} from '../../store/cards'

import './boardsSwitcher.scss'
import AddIcon from '../../widgets/icons/add'
import BoardSwitcherDialog from '../boardsSwitcherDialog/boardSwitcherDialog'
import {Utils} from '../../utils'
import {Constants} from '../../constants'
import {TOUR_SIDEBAR, SidebarTourSteps} from '../../components/onboardingTour'

import IconButton from '../../widgets/buttons/iconButton'
import SearchForBoardsTourStep from '../../components/onboardingTour/searchForBoards/searchForBoards'

type Props = {
onBoardTemplateSelectorOpen: () => void
userIsGuest?: boolean
}

const BoardsSwitcher = (props: Props): JSX.Element => {
const BoardsSwitcher = (): JSX.Element => {
const intl = useIntl()

const [showSwitcher, setShowSwitcher] = useState<boolean>(false)
Expand Down Expand Up @@ -70,10 +60,6 @@ const BoardsSwitcher = (props: Props): JSX.Element => {
}
}

const handleCreateNewCategory = () => {
setShowCreateCategoryModal(true)
}

useEffect(() => {
document.addEventListener('keydown', handleQuickSwitchKeyPress)
document.addEventListener('keydown', handleEscKeyPress)
Expand Down
1 change: 0 additions & 1 deletion webapp/src/components/cardDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const mockedUtils = mocked(Utils, true)
const mockedMutator = mocked(mutator, true)
const mockedOctoClient = mocked(octoClient, true)
mockedUtils.createGuid.mockReturnValue('test-id')
mockedUtils.isFocalboardPlugin.mockReturnValue(true)

beforeAll(() => {
mockDOM()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {Channel} from '../../store/channels'
import {TestBlockFactory} from '../../test/testBlockFactory'
import {mockStateStore, wrapDNDIntl} from '../../testUtils'
import client from '../../octoClient'
import {Utils} from '../../utils'

import ChannelPermissionsRow from './channelPermissionsRow'

Expand All @@ -26,7 +25,6 @@ jest.mock('../../utils')
jest.mock('../../octoClient')

const mockedOctoClient = mocked(client, true)
const mockedUtils = mocked(Utils, true)

const board = TestBlockFactory.createBoard()
board.id = boardId
Expand Down Expand Up @@ -80,7 +78,6 @@ describe('src/components/shareBoard/channelPermissionsRow', () => {

test('should match snapshot', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const store = mockStateStore([thunk], state)
await act(async () => {
const result = render(
Expand All @@ -98,7 +95,6 @@ describe('src/components/shareBoard/channelPermissionsRow', () => {

test('should match snapshot with unknown channel', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
mockedOctoClient.getChannel.mockResolvedValue(undefined)
const store = mockStateStore([thunk], state)
await act(async () => {
Expand All @@ -117,7 +113,6 @@ describe('src/components/shareBoard/channelPermissionsRow', () => {

test('should match snapshot with menu open', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const store = mockStateStore([thunk], state)
await act(async () => {
const result = render(
Expand All @@ -139,7 +134,6 @@ describe('src/components/shareBoard/channelPermissionsRow', () => {

test('should match snapshot when no plugin mode', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(false)
const store = mockStateStore([thunk], state)
await act(async () => {
const result = render(
Expand All @@ -157,7 +151,6 @@ describe('src/components/shareBoard/channelPermissionsRow', () => {

test('should match snapshot when board has no channel id', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const newState = {
...state,
boards: {
Expand All @@ -184,7 +177,6 @@ describe('src/components/shareBoard/channelPermissionsRow', () => {

test('should match snapshot in plugin mode', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const store = mockStateStore([thunk], state)
await act(async () => {
const result = render(
Expand All @@ -206,7 +198,6 @@ describe('src/components/shareBoard/channelPermissionsRow', () => {

test('should match snapshot in template', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const testState = {
...state,
boards: {
Expand Down
3 changes: 0 additions & 3 deletions webapp/src/components/shareBoard/shareBoard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ describe('src/components/shareBoard/shareBoard', () => {
token: '',
}
mockedOctoClient.getSharing.mockResolvedValue(sharing)
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
mockedUtils.getUserDisplayName.mockImplementation((u) => u.username)

const users: IUser[] = [
Expand Down Expand Up @@ -595,7 +594,6 @@ describe('src/components/shareBoard/shareBoard', () => {
token: '',
}
mockedOctoClient.getSharing.mockResolvedValue(sharing)
mockedUtils.isFocalboardPlugin.mockReturnValue(true)

let container: Element | DocumentFragment | null = null
await act(async () => {
Expand Down Expand Up @@ -670,7 +668,6 @@ describe('src/components/shareBoard/shareBoard', () => {
token: '',
}
mockedOctoClient.getSharing.mockResolvedValue(sharing)
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
mockedUtils.getUserDisplayName.mockImplementation((u) => u.username)

const users: IUser[] = [
Expand Down
7 changes: 0 additions & 7 deletions webapp/src/components/shareBoard/teamPermissionsRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import thunk from 'redux-thunk'

import React from 'react'
import {MemoryRouter} from 'react-router'
import {mocked} from 'jest-mock'

import {IUser} from '../../user'
import {TestBlockFactory} from '../../test/testBlockFactory'
import {mockStateStore, wrapDNDIntl} from '../../testUtils'
import {Utils} from '../../utils'

import {MemberRole} from '../../blocks/board'

Expand All @@ -24,8 +22,6 @@ const boardId = '1'

jest.mock('../../utils')

const mockedUtils = mocked(Utils, true)

const board = TestBlockFactory.createBoard()
board.id = boardId
board.teamId = 'team-id'
Expand Down Expand Up @@ -78,7 +74,6 @@ describe('src/components/shareBoard/teamPermissionsRow', () => {

test('should match snapshot', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(false)
const store = mockStateStore([thunk], state)
await act(async () => {
const result = render(
Expand All @@ -100,7 +95,6 @@ describe('src/components/shareBoard/teamPermissionsRow', () => {

test('should match snapshot in plugin mode', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const store = mockStateStore([thunk], state)
await act(async () => {
const result = render(
Expand All @@ -122,7 +116,6 @@ describe('src/components/shareBoard/teamPermissionsRow', () => {

test('should match snapshot in template', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const testState = {
...state,
boards: {
Expand Down
8 changes: 0 additions & 8 deletions webapp/src/components/shareBoard/userPermissionsRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import thunk from 'redux-thunk'

import React from 'react'
import {MemoryRouter} from 'react-router'
import {mocked} from 'jest-mock'

import {BoardMember} from '../../blocks/board'

import {IUser} from '../../user'
import {TestBlockFactory} from '../../test/testBlockFactory'
import {mockStateStore, wrapDNDIntl} from '../../testUtils'
import {Utils} from '../../utils'

import UserPermissionsRow from './userPermissionsRow'

Expand All @@ -24,8 +22,6 @@ const boardId = '1'

jest.mock('../../utils')

const mockedUtils = mocked(Utils, true)

const board = TestBlockFactory.createBoard()
board.id = boardId
board.teamId = 'team-id'
Expand Down Expand Up @@ -77,7 +73,6 @@ describe('src/components/shareBoard/userPermissionsRow', () => {

test('should match snapshot', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(false)
const store = mockStateStore([thunk], state)
await act(async () => {
const result = render(
Expand Down Expand Up @@ -106,7 +101,6 @@ describe('src/components/shareBoard/userPermissionsRow', () => {

test('should match snapshot-admin', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(false)
const store = mockStateStore([thunk], state)

const newMe = Object.assign({}, me)
Expand Down Expand Up @@ -138,7 +132,6 @@ describe('src/components/shareBoard/userPermissionsRow', () => {

test('should match snapshot in plugin mode', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const store = mockStateStore([thunk], state)
await act(async () => {
const result = render(
Expand Down Expand Up @@ -167,7 +160,6 @@ describe('src/components/shareBoard/userPermissionsRow', () => {

test('should match snapshot in template', async () => {
let container: Element | undefined
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const testState = {
...state,
boards: {
Expand Down
5 changes: 1 addition & 4 deletions webapp/src/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,7 @@ const Sidebar = (props: Props) => {
<div className='WorkspaceTitle'/>
}

<BoardsSwitcher
onBoardTemplateSelectorOpen={props.onBoardTemplateSelectorOpen}
userIsGuest={me?.is_guest}
/>
<BoardsSwitcher/>

<DragDropContext
onDragEnd={onDragEnd}
Expand Down
5 changes: 0 additions & 5 deletions webapp/src/components/topBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,24 @@
// See LICENSE.txt for license information.
import {render} from '@testing-library/react'
import React from 'react'
import {mocked} from 'jest-mock'

import {wrapDNDIntl} from '../testUtils'
import {Constants} from '../constants'
import {Utils} from '../utils'

import TopBar from './topBar'

Object.defineProperty(Constants, 'versionString', {value: '1.0.0'})
jest.mock('../utils')
const mockedUtils = mocked(Utils, true)

describe('src/components/topBar', () => {
beforeEach(jest.resetAllMocks)
test('should match snapshot for focalboardPlugin', () => {
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const {container} = render(wrapDNDIntl(
<TopBar/>,
))
expect(container).toMatchSnapshot()
})
test('should match snapshot for none focalboardPlugin', () => {
mockedUtils.isFocalboardPlugin.mockReturnValue(false)
const {container} = render(wrapDNDIntl(
<TopBar/>,
))
Expand Down
4 changes: 0 additions & 4 deletions webapp/src/components/workspace.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ describe('src/components/workspace', () => {
})

test('show open card tooltip', async () => {
mockedUtils.isFocalboardPlugin.mockReturnValue(true)

const welcomeBoard = TestBlockFactory.createBoard()
welcomeBoard.title = 'Welcome to Boards!'

Expand Down Expand Up @@ -519,8 +517,6 @@ describe('src/components/workspace', () => {
})

test('show copy link tooltip', async () => {
mockedUtils.isFocalboardPlugin.mockReturnValue(true)

const welcomeBoard = TestBlockFactory.createBoard()
welcomeBoard.title = 'Welcome to Boards!'

Expand Down

0 comments on commit 8a2d87c

Please sign in to comment.