1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-24 13:43:12 +02:00
focalboard/webapp/cypress/integration/cardBadges.ts
kamre 342c8df39d
[GH-1754] Feature: card badges (#2025)
* First shot implementation of badges for the card.

* Showing and hiding card badges in board/gallery views via header menu action added.

* Counting of checkboxes in markdown supported.

* Use Intl.formatMessage for badge titles.

* Unit tests for `CardBadges` component added. Some other unit tests fixed.

* Unit test for 'Show card badges' action in the view header menu added.

* Cypress test for card badges added:
 - card with comments, description and checkboxes added for testing
 - card badges are shown and hidden via view menu
 - new Cypress command `uiAddNewCard` added
 - label property added to `MenuWrapper` and used in `ViewHeaderActionsMenu`

* Unit tests fixed after change of the label for view menu.

* Fix stylelint issues.

* Class name for `CardBadges` component fixed.

* Show and hide for card badges moved to `Properties` menu:
 - field `cardBadgesVisible` removed from `BoardViewFields`
 - new constant `badgesColumnId` introduced and used as an element in `visiblePropertyIds`
 - card badges added to calendar view
 - added `role` and `aria-label` for menu component `SwitchOption`
 - unit and Cypress tests updated

* Fix Cypress test: use `blur` after typing text.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-01-13 09:26:27 -07:00

68 lines
2.4 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
describe('Card badges', () => {
beforeEach(() => {
cy.apiInitServer()
cy.apiResetBoards()
localStorage.setItem('welcomePageViewed', 'true')
})
it('Shows and hides card badges', () => {
cy.visit('/')
// Create new board
cy.uiCreateNewBoard('Testing')
// Add a new card
cy.uiAddNewCard('Card')
// Add some comments
cy.log('**Add some comments**')
addComment('Some comment')
addComment('Another comment')
addComment('Additional comment')
// Add card description
cy.log('**Add card description**')
cy.findByText('Add a description...').click()
cy.findByRole('combobox').type('## Header\n- [ ] one\n- [x] two{esc}')
// Add checkboxes
cy.log('**Add checkboxes**')
cy.findByRole('button', {name: 'Add content'}).click()
cy.findByRole('button', {name: 'checkbox'}).click()
cy.findByDisplayValue('').type('three{enter}')
cy.findByDisplayValue('').type('four{enter}')
cy.findByDisplayValue('').type('{esc}')
cy.findByDisplayValue('three').prev().click()
// Close card dialog
cy.log('**Close card dialog**')
cy.findByRole('button', {name: 'Close dialog'}).click()
cy.findByRole('dialog').should('not.exist')
// Show card badges
cy.log('**Show card badges**')
cy.findByRole('button', {name: 'Properties menu'}).click()
cy.findByRole('button', {name: 'Comments and Description'}).click()
cy.findByTitle('This card has a description').should('exist')
cy.findByTitle('Comments').contains('3').should('exist')
cy.findByTitle('Checkboxes').contains('2/4').should('exist')
// Hide card badges
cy.log('**Hide card badges**')
cy.findByRole('button', {name: 'Properties menu'}).click()
cy.findByRole('button', {name: 'Comments and Description'}).click()
cy.findByTitle('This card has a description').should('not.exist')
cy.findByTitle('Comments').should('not.exist')
cy.findByTitle('Checkboxes').should('not.exist')
})
const addComment = (text: string) => {
cy.findByText('Add a comment...').click()
cy.findByRole('combobox').type(text).blur()
cy.findByRole('button', {name: 'Send'}).click()
}
})