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