mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-23 10:16:32 -05:00
79469c5ddc
* Add maximum document length config option * Show remaining characters in tooltip of status-bar length-info * Remove unnecessary checkDocumentLength function * Add max-length warning * Update translation wording * Set dialog to medium size * Add coloring to status-bar length info * Improve wording in warning modal * Add cypress e2e tests I included the cypress-commands package and set the language level to ES6 to allow easier testing e.g. of element attributes. * Changed way how the modal-advice was styled and positioned * Show warning modal only on first length exceeding * Improved length tooltip by adding messages when exceeding or reaching limit
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
const tenChars: string = '0123456789'
|
|
|
|
describe('status-bar text-length info', () => {
|
|
beforeEach(() => {
|
|
cy.visit('/n/test')
|
|
cy.get('.CodeMirror textarea')
|
|
.type('{ctrl}a', { force: true })
|
|
.type('{backspace}')
|
|
})
|
|
|
|
it('tooltip shows full remaining on empty text', () => {
|
|
cy.get('.status-bar div:nth-child(2) span:nth-child(2)')
|
|
.attribute('title')
|
|
.should('contain', ' 200 ')
|
|
})
|
|
|
|
it('color is warning on <= 100 chars remaining', () => {
|
|
cy.get('.CodeMirror textarea')
|
|
.type(`${tenChars.repeat(10)}`)
|
|
cy.get('.status-bar div:nth-child(2) span:nth-child(2)')
|
|
.should('have.class', 'text-warning')
|
|
})
|
|
|
|
it('color is danger on <= 0 chars remaining', () => {
|
|
cy.get('.CodeMirror textarea')
|
|
.type(`${tenChars.repeat(20)}`)
|
|
cy.get('.status-bar div:nth-child(2) span:nth-child(2)')
|
|
.should('have.class', 'text-danger')
|
|
})
|
|
})
|
|
|
|
describe('show warning if content length > configured max length', () => {
|
|
beforeEach(() => {
|
|
cy.visit('/n/test')
|
|
cy.get('.CodeMirror textarea')
|
|
.type('{ctrl}a', { force: true })
|
|
.type('{backspace}')
|
|
.type(`${tenChars.repeat(20)}`)
|
|
})
|
|
|
|
it('show warning alert in renderer and as modal', () => {
|
|
cy.get('.CodeMirror textarea')
|
|
.type('a')
|
|
cy.get('.modal-body.limit-warning')
|
|
.should('be.visible')
|
|
cy.get('.splitter .alert-danger')
|
|
.should('be.visible')
|
|
})
|
|
})
|