mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-30 04:19:55 -05:00
3db6bcf892
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
describe('The status bar text length info', () => {
|
|
const warningTestContent = ('0123456789'.repeat(10))
|
|
const dangerTestContent = ('0123456789'.repeat(20))
|
|
const tooMuchTestContent = `${dangerTestContent}a`
|
|
|
|
beforeEach(() => {
|
|
cy.visit('/n/test')
|
|
|
|
cy.get('.CodeMirror ')
|
|
.click()
|
|
cy.get('.CodeMirror textarea')
|
|
.as('codeinput')
|
|
})
|
|
|
|
it('shows the maximal length of the document as number of available characters in the tooltip', () => {
|
|
cy.get('.status-bar [data-cy="remainingCharacters"]')
|
|
.attribute('title')
|
|
.should('contain', ' 200 ')
|
|
})
|
|
|
|
it('color is set to "warning" on <= 100 characters remaining', () => {
|
|
cy.get('@codeinput')
|
|
.fill(warningTestContent)
|
|
cy.get('.status-bar [data-cy="remainingCharacters"]')
|
|
.should('have.class', 'text-warning')
|
|
})
|
|
|
|
it('color is set to danger on <= 0 characters remaining', () => {
|
|
cy.get('@codeinput')
|
|
.fill(dangerTestContent)
|
|
cy.get('.status-bar [data-cy="remainingCharacters"]')
|
|
.should('have.class', 'text-danger')
|
|
})
|
|
|
|
it('shows a warning and opens a modal', () => {
|
|
cy.get('@codeinput')
|
|
.fill(tooMuchTestContent)
|
|
cy.get('[data-cy="limitReachedModal"]')
|
|
.should('be.visible')
|
|
cy.get('[data-cy="limitReachedMessage"]')
|
|
.should('be.visible')
|
|
})
|
|
|
|
})
|