2022-01-25 12:56:26 +01:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
// See LICENSE.txt for license information.
|
|
|
|
|
|
|
|
describe('Card URL Property', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.apiInitServer()
|
|
|
|
cy.apiResetBoards()
|
2022-02-28 12:28:16 +01:00
|
|
|
cy.apiGetMe().then((userID) => cy.apiSkipTour(userID))
|
2022-01-25 12:56:26 +01:00
|
|
|
localStorage.setItem('welcomePageViewed', 'true')
|
2022-04-06 16:22:47 +02:00
|
|
|
localStorage.setItem('language', 'en')
|
2022-01-25 12:56:26 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
const url = 'https://mattermost.com'
|
|
|
|
const changedURL = 'https://mattermost.com/blog'
|
|
|
|
|
|
|
|
it('Allows to create and edit URL property', () => {
|
|
|
|
cy.visit('/')
|
|
|
|
|
|
|
|
// Create new board
|
|
|
|
cy.uiCreateNewBoard('Testing')
|
|
|
|
|
|
|
|
// Add a new card
|
|
|
|
cy.uiAddNewCard('Card')
|
|
|
|
|
|
|
|
// Add URL property
|
|
|
|
cy.log('**Add URL property**')
|
|
|
|
cy.findByRole('button', {name: '+ Add a property'}).click()
|
|
|
|
cy.findByRole('button', {name: 'URL'}).click()
|
|
|
|
cy.findByRole('textbox', {name: 'URL'}).type('{enter}')
|
|
|
|
|
|
|
|
// Enter URL
|
|
|
|
cy.log('**Enter URL**')
|
|
|
|
cy.findByPlaceholderText('Empty').type(`${url}{enter}`)
|
|
|
|
|
|
|
|
// Check buttons
|
|
|
|
cy.log('**Check buttons**')
|
|
|
|
cy.findByRole('link', {name: url}).realHover()
|
|
|
|
cy.findByRole('button', {name: 'Edit'}).should('exist')
|
|
|
|
cy.findByRole('button', {name: 'Copy'}).should('exist')
|
|
|
|
|
|
|
|
// Change URL
|
|
|
|
cy.log('**Change URL**')
|
|
|
|
cy.findByRole('link', {name: url}).realHover()
|
|
|
|
cy.findByRole('button', {name: 'Edit'}).click()
|
|
|
|
cy.findByRole('textbox', {name: url}).clear().type(`${changedURL}{enter}`)
|
|
|
|
cy.findByRole('link', {name: changedURL}).should('exist')
|
|
|
|
|
|
|
|
// Close card dialog
|
|
|
|
cy.log('**Close card dialog**')
|
|
|
|
cy.findByRole('button', {name: 'Close dialog'}).click()
|
|
|
|
cy.findByRole('dialog').should('not.exist')
|
|
|
|
|
|
|
|
// Show URL property
|
|
|
|
showURLProperty()
|
|
|
|
|
|
|
|
// Copy URL to clipboard
|
|
|
|
cy.log('**Copy URL to clipboard**')
|
|
|
|
cy.document().then((doc) => cy.spy(doc, 'execCommand')).as('exec')
|
|
|
|
cy.findByRole('link', {name: changedURL}).realHover()
|
|
|
|
cy.findByRole('button', {name: 'Edit'}).should('not.exist')
|
|
|
|
cy.findByRole('button', {name: 'Copy'}).click()
|
|
|
|
cy.findByText('Copied!').should('exist')
|
|
|
|
cy.findByText('Copied!').should('not.exist')
|
|
|
|
cy.get('@exec').should('have.been.calledOnceWith', 'copy')
|
|
|
|
|
|
|
|
// Add table view
|
|
|
|
addView('Table')
|
|
|
|
|
|
|
|
// Check buttons
|
|
|
|
cy.log('**Check buttons**')
|
|
|
|
cy.findByRole('link', {name: changedURL}).realHover()
|
|
|
|
cy.findByRole('button', {name: 'Edit'}).should('exist')
|
|
|
|
cy.findByRole('button', {name: 'Copy'}).should('not.exist')
|
|
|
|
|
|
|
|
// Add gallery view
|
|
|
|
addView('Gallery')
|
|
|
|
showURLProperty()
|
|
|
|
|
|
|
|
// Check buttons
|
|
|
|
cy.log('**Check buttons**')
|
|
|
|
cy.findByRole('link', {name: changedURL}).realHover()
|
|
|
|
cy.findByRole('button', {name: 'Edit'}).should('not.exist')
|
|
|
|
cy.findByRole('button', {name: 'Copy'}).should('exist')
|
|
|
|
|
|
|
|
// Add calendar view
|
|
|
|
addView('Calendar')
|
|
|
|
showURLProperty()
|
|
|
|
|
|
|
|
// Check buttons
|
|
|
|
cy.log('**Check buttons**')
|
|
|
|
cy.findByRole('link', {name: changedURL}).realHover()
|
|
|
|
cy.findByRole('button', {name: 'Edit'}).should('not.exist')
|
|
|
|
cy.findByRole('button', {name: 'Copy'}).should('exist')
|
|
|
|
})
|
|
|
|
|
|
|
|
type ViewType = 'Board' | 'Table' | 'Gallery' | 'Calendar'
|
|
|
|
|
|
|
|
const addView = (type: ViewType) => {
|
|
|
|
cy.log(`**Add ${type} view**`)
|
|
|
|
cy.findByRole('button', {name: 'View menu'}).click()
|
2022-03-29 22:45:20 +02:00
|
|
|
cy.findByText('Add view').realHover()
|
2022-01-25 12:56:26 +01:00
|
|
|
cy.findByRole('button', {name: type}).click()
|
|
|
|
cy.findByRole('textbox', {name: `${type} view`}).should('exist')
|
|
|
|
}
|
|
|
|
|
|
|
|
const showURLProperty = () => {
|
|
|
|
cy.log('**Show URL property**')
|
|
|
|
cy.findByRole('button', {name: 'Properties'}).click()
|
|
|
|
cy.findByRole('button', {name: 'URL'}).click()
|
|
|
|
cy.findByRole('link', {name: changedURL}).should('exist')
|
|
|
|
}
|
|
|
|
})
|