2020-11-22 15:50:07 -05:00
|
|
|
/*
|
2022-06-08 07:19:51 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022 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', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
const warningTestContent = '0123456789'.repeat(10)
|
|
|
|
const dangerTestContent = '0123456789'.repeat(20)
|
|
|
|
const tooMuchTestContent = `${dangerTestContent}a`
|
2020-09-05 10:36:46 -04:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-01-30 15:46:43 -05:00
|
|
|
cy.visitTestNote()
|
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', () => {
|
2021-12-25 10:44:24 -05:00
|
|
|
cy.getByCypressId('remainingCharacters').attribute('title').should('contain', ' 200 ')
|
2020-09-05 10:36:46 -04:00
|
|
|
})
|
|
|
|
|
2021-01-11 17:22:11 -05:00
|
|
|
it('color is set to "warning" on <= 100 characters remaining', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent(warningTestContent)
|
2021-12-25 10:44:24 -05:00
|
|
|
cy.getByCypressId('remainingCharacters').should('have.class', 'text-warning')
|
2020-09-05 10:36:46 -04:00
|
|
|
})
|
|
|
|
|
2021-01-11 17:22:11 -05:00
|
|
|
it('color is set to danger on <= 0 characters remaining', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent(dangerTestContent)
|
2021-12-25 10:44:24 -05:00
|
|
|
cy.getByCypressId('remainingCharacters').should('have.class', 'text-danger')
|
2020-09-05 10:36:46 -04:00
|
|
|
})
|
|
|
|
|
2021-12-14 04:16:25 -05:00
|
|
|
it('opens a modal', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent(tooMuchTestContent)
|
2021-12-25 10:44:24 -05:00
|
|
|
cy.getByCypressId('limitReachedModal').should('be.visible')
|
2020-09-05 10:36:46 -04:00
|
|
|
})
|
|
|
|
})
|