forked from mattermost/focalboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from JesusMurguia/mattermostGH-4476-No-card-de…
…lete-confirmation-status Gh 4476 no card delete confirmation status
- Loading branch information
Showing
9 changed files
with
981 additions
and
92 deletions.
There are no files selected for viewing
616 changes: 616 additions & 0 deletions
616
webapp/src/components/calendar/__snapshots__/fullCalendarCard.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
186 changes: 186 additions & 0 deletions
186
webapp/src/components/calendar/fullCalendarCard.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
import React from 'react' | ||
import {render, screen, within} from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import {MemoryRouter} from 'react-router-dom' | ||
|
||
import {Provider as ReduxProvider} from 'react-redux' | ||
|
||
import userEvent from '@testing-library/user-event' | ||
|
||
import {mocked} from 'jest-mock' | ||
|
||
import Mutator from '../../mutator' | ||
import {Utils} from '../../utils' | ||
|
||
import {TestBlockFactory} from '../../test/testBlockFactory' | ||
import {IPropertyTemplate} from '../../blocks/board' | ||
import {mockStateStore, wrapDNDIntl} from '../../testUtils' | ||
|
||
import FullCalendarCard from './fullCalendarCard' | ||
|
||
jest.mock('../../mutator') | ||
jest.mock('../../utils') | ||
jest.mock('../../telemetry/telemetryClient') | ||
const mockedUtils = mocked(Utils, true) | ||
const mockedMutator = mocked(Mutator, true) | ||
|
||
describe('src/components/calendar/fullCalendarCard', () => { | ||
const board = TestBlockFactory.createBoard() | ||
const card = TestBlockFactory.createCard(board) | ||
const propertyTemplate: IPropertyTemplate = { | ||
id: 'id', | ||
name: 'name', | ||
type: 'text', | ||
options: [ | ||
{ | ||
color: 'propColorOrange', | ||
id: 'property_value_id_1', | ||
value: 'Q1', | ||
}, | ||
{ | ||
color: 'propColorBlue', | ||
id: 'property_value_id_2', | ||
value: 'Q2', | ||
}, | ||
], | ||
} | ||
const state = { | ||
cards: { | ||
cards: [card], | ||
}, | ||
teams: { | ||
current: {id: 'team-id'}, | ||
}, | ||
boards: { | ||
current: 'board_id_1', | ||
boards: { | ||
board_id_1: {id: 'board_id_1'}, | ||
}, | ||
myBoardMemberships: { | ||
board_id_1: {userId: 'user_id_1', schemeAdmin: true}, | ||
}, | ||
}, | ||
contents: {}, | ||
comments: { | ||
comments: {}, | ||
}, | ||
users: { | ||
me: { | ||
id: 'user_id_1', | ||
props: {}, | ||
}, | ||
}, | ||
} | ||
const store = mockStateStore([], state) | ||
beforeEach(jest.clearAllMocks) | ||
test('should match snapshot', () => { | ||
const {container} = render(wrapDNDIntl( | ||
<ReduxProvider store={store}> | ||
<FullCalendarCard | ||
card={card} | ||
board={board} | ||
visiblePropertyTemplates={[propertyTemplate]} | ||
visibleBadges={false} | ||
readonly={false} | ||
showCard={jest.fn()} | ||
/> | ||
</ReduxProvider>, | ||
), {wrapper: MemoryRouter}) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
test('should match snapshot with readonly', () => { | ||
const {container} = render(wrapDNDIntl( | ||
<ReduxProvider store={store}> | ||
<FullCalendarCard | ||
card={card} | ||
board={board} | ||
visiblePropertyTemplates={[propertyTemplate]} | ||
visibleBadges={false} | ||
readonly={true} | ||
showCard={jest.fn()} | ||
/> | ||
</ReduxProvider>, | ||
), {wrapper: MemoryRouter}) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
test('return FullCalendarCard and click on delete menu ', () => { | ||
const result = render(wrapDNDIntl( | ||
<ReduxProvider store={store}> | ||
<FullCalendarCard | ||
card={card} | ||
board={board} | ||
visiblePropertyTemplates={[propertyTemplate]} | ||
visibleBadges={false} | ||
readonly={false} | ||
showCard={jest.fn()} | ||
/> | ||
</ReduxProvider>, | ||
), {wrapper: MemoryRouter}) | ||
|
||
const {container} = result | ||
|
||
const elementMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'}) | ||
expect(elementMenuWrapper).not.toBeNull() | ||
userEvent.click(elementMenuWrapper) | ||
expect(container).toMatchSnapshot() | ||
const elementButtonDelete = within(elementMenuWrapper).getByRole('button', {name: 'Delete'}) | ||
expect(elementButtonDelete).not.toBeNull() | ||
userEvent.click(elementButtonDelete) | ||
|
||
const confirmDialog = screen.getByTitle('Confirmation Dialog Box') | ||
expect(confirmDialog).toBeDefined() | ||
const confirmButton = within(confirmDialog).getByRole('button', {name: 'Delete'}) | ||
expect(confirmButton).toBeDefined() | ||
userEvent.click(confirmButton) | ||
|
||
expect(mockedMutator.deleteBlock).toBeCalledWith(card, 'delete card') | ||
}) | ||
|
||
test('return FullCalendarCard and click on duplicate menu ', () => { | ||
const {container} = render(wrapDNDIntl( | ||
<ReduxProvider store={store}> | ||
<FullCalendarCard | ||
card={card} | ||
board={board} | ||
visiblePropertyTemplates={[propertyTemplate]} | ||
visibleBadges={false} | ||
readonly={false} | ||
showCard={jest.fn()} | ||
/> | ||
</ReduxProvider>, | ||
), {wrapper: MemoryRouter}) | ||
const elementMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'}) | ||
expect(elementMenuWrapper).not.toBeNull() | ||
userEvent.click(elementMenuWrapper) | ||
expect(container).toMatchSnapshot() | ||
const elementButtonDuplicate = within(elementMenuWrapper).getByRole('button', {name: 'Duplicate'}) | ||
expect(elementButtonDuplicate).not.toBeNull() | ||
userEvent.click(elementButtonDuplicate) | ||
expect(mockedMutator.duplicateCard).toBeCalledTimes(1) | ||
}) | ||
|
||
test('return FullCalendarCard and click on copy link menu ', () => { | ||
const {container} = render(wrapDNDIntl( | ||
<ReduxProvider store={store}> | ||
<FullCalendarCard | ||
card={card} | ||
board={board} | ||
visiblePropertyTemplates={[propertyTemplate]} | ||
visibleBadges={false} | ||
readonly={false} | ||
showCard={jest.fn()} | ||
/> | ||
</ReduxProvider>, | ||
), {wrapper: MemoryRouter}) | ||
const elementMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'}) | ||
expect(elementMenuWrapper).not.toBeNull() | ||
userEvent.click(elementMenuWrapper) | ||
expect(container).toMatchSnapshot() | ||
const elementButtonCopyLink = within(elementMenuWrapper).getByRole('button', {name: 'Copy link'}) | ||
expect(elementButtonCopyLink).not.toBeNull() | ||
userEvent.click(elementButtonCopyLink) | ||
expect(mockedUtils.copyTextToClipboard).toBeCalledTimes(1) | ||
}) | ||
}) |
Oops, something went wrong.