2022-01-25 13:56:26 +02: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 13:28:16 +02:00
|
|
|
cy.apiGetMe().then((userID) => cy.apiSkipTour(userID))
|
2022-01-25 13:56:26 +02:00
|
|
|
localStorage.setItem('welcomePageViewed', 'true')
|
2022-04-06 16:22:47 +02:00
|
|
|
localStorage.setItem('language', 'en')
|
2022-01-25 13:56:26 +02: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**`)
|
2022-09-14 15:11:50 +02:00
|
|
|
|
2022-07-10 18:19:02 +02:00
|
|
|
// Intercept and wait for getUser request because it is the last one in the effects for BoardPage
|
|
|
|
// After this last request the BoardPage component will not have additional rerenders
|
2022-07-29 22:28:00 +02:00
|
|
|
cy.intercept('POST', '/api/v2/users').as('getUser')
|
2022-01-25 13:56:26 +02:00
|
|
|
cy.findByRole('button', {name: 'View menu'}).click()
|
2022-03-29 22:45:20 +02:00
|
|
|
cy.findByText('Add view').realHover()
|
2022-01-25 13:56:26 +02:00
|
|
|
cy.findByRole('button', {name: type}).click()
|
2022-07-10 18:19:02 +02:00
|
|
|
cy.wait('@getUser')
|
2022-01-25 13:56:26 +02:00
|
|
|
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')
|
|
|
|
}
|
|
|
|
})
|