2021-06-17 16:31:28 -04:00
|
|
|
/*
|
2023-04-16 16:21:29 -04:00
|
|
|
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
2021-06-17 16:31:28 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
describe('Test word count with', () => {
|
|
|
|
beforeEach(() => {
|
2022-01-30 15:46:43 -05:00
|
|
|
cy.visitTestNote()
|
2021-06-17 16:31:28 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('empty note', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('')
|
2023-04-16 16:21:29 -04:00
|
|
|
cy.getByCypressId('sidebar-menu-info').click()
|
|
|
|
cy.getByCypressId('document-info-word-count').should('be.visible')
|
2022-11-06 11:39:42 -05:00
|
|
|
cy.getByCypressId('document-info-word-count').contains('0')
|
2021-06-17 16:31:28 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('simple words', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('five words should be enough')
|
2022-11-06 11:39:42 -05:00
|
|
|
cy.getMarkdownBody().contains('five words should be enough')
|
2023-04-16 16:21:29 -04:00
|
|
|
cy.getByCypressId('sidebar-menu-info').click()
|
|
|
|
cy.getByCypressId('document-info-word-count').should('be.visible')
|
2022-11-06 11:39:42 -05:00
|
|
|
cy.getByCypressId('document-info-word-count').contains('5')
|
2021-06-17 16:31:28 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('excluded codeblocks', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('```\nthis is should be ignored\n```\n\ntwo `words`')
|
2022-11-06 11:39:42 -05:00
|
|
|
cy.getMarkdownBody().contains('two words')
|
2023-04-16 16:21:29 -04:00
|
|
|
cy.getByCypressId('sidebar-menu-info').click()
|
|
|
|
cy.getByCypressId('document-info-word-count').should('be.visible')
|
2022-11-06 11:39:42 -05:00
|
|
|
cy.getByCypressId('document-info-word-count').contains('2')
|
2021-06-17 16:31:28 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('excluded images', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('![ignored alt text](https://dummyimage.com/48) not ignored text')
|
2022-11-06 11:39:42 -05:00
|
|
|
cy.getMarkdownBody().contains('not ignored text')
|
2023-04-16 16:21:29 -04:00
|
|
|
cy.getByCypressId('sidebar-menu-info').click()
|
|
|
|
cy.getByCypressId('document-info-word-count').should('be.visible')
|
2022-11-06 11:39:42 -05:00
|
|
|
cy.getByCypressId('document-info-word-count').contains('3')
|
2021-06-17 16:31:28 -04:00
|
|
|
})
|
|
|
|
})
|