2020-11-22 15:50:07 -05:00
|
|
|
/*
|
2021-01-06 15:37:59 -05:00
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
2020-11-22 15:50:07 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2021-01-11 17:22:11 -05:00
|
|
|
describe('The status bar text length info', () => {
|
|
|
|
const warningTestContent = ('0123456789'.repeat(10))
|
|
|
|
const dangerTestContent = ('0123456789'.repeat(20))
|
2021-02-03 16:13:04 -05:00
|
|
|
const tooMuchTestContent = `${ dangerTestContent }a`
|
2020-09-05 10:36:46 -04:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-03-09 17:00:14 -05:00
|
|
|
cy.loadConfig()
|
2021-02-01 16:55:49 -05:00
|
|
|
cy.visitTestEditor()
|
2020-09-05 10:36:46 -04:00
|
|
|
})
|
|
|
|
|
2021-01-11 17:22:11 -05:00
|
|
|
it('shows the maximal length of the document as number of available characters in the tooltip', () => {
|
|
|
|
cy.get('.status-bar [data-cy="remainingCharacters"]')
|
2020-09-05 10:36:46 -04:00
|
|
|
.attribute('title')
|
|
|
|
.should('contain', ' 200 ')
|
|
|
|
})
|
|
|
|
|
2021-01-11 17:22:11 -05:00
|
|
|
it('color is set to "warning" on <= 100 characters remaining', () => {
|
2021-01-15 16:54:43 -05:00
|
|
|
cy.codemirrorFill(warningTestContent)
|
2021-01-11 17:22:11 -05:00
|
|
|
cy.get('.status-bar [data-cy="remainingCharacters"]')
|
2020-09-05 10:36:46 -04:00
|
|
|
.should('have.class', 'text-warning')
|
|
|
|
})
|
|
|
|
|
2021-01-11 17:22:11 -05:00
|
|
|
it('color is set to danger on <= 0 characters remaining', () => {
|
2021-01-15 16:54:43 -05:00
|
|
|
cy.codemirrorFill(dangerTestContent)
|
2021-01-11 17:22:11 -05:00
|
|
|
cy.get('.status-bar [data-cy="remainingCharacters"]')
|
|
|
|
.should('have.class', 'text-danger')
|
2020-09-05 10:36:46 -04:00
|
|
|
})
|
|
|
|
|
2021-01-11 17:22:11 -05:00
|
|
|
it('shows a warning and opens a modal', () => {
|
2021-01-15 16:54:43 -05:00
|
|
|
cy.codemirrorFill(tooMuchTestContent)
|
2021-01-11 17:22:11 -05:00
|
|
|
cy.get('[data-cy="limitReachedModal"]')
|
|
|
|
.should('be.visible')
|
2021-01-24 14:50:51 -05:00
|
|
|
cy.getMarkdownRenderer()
|
|
|
|
.find('[data-cy="limitReachedMessage"]')
|
2020-09-05 10:36:46 -04:00
|
|
|
.should('be.visible')
|
|
|
|
})
|
2021-01-11 17:22:11 -05:00
|
|
|
|
2020-09-05 10:36:46 -04:00
|
|
|
})
|