diff --git a/cypress/e2e/MenuBar.spec.js b/cypress/e2e/MenuBar.spec.js
index 01a4206150b..76c885a9be4 100644
--- a/cypress/e2e/MenuBar.spec.js
+++ b/cypress/e2e/MenuBar.spec.js
@@ -3,23 +3,18 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import { initUserAndFiles, randUser } from '../utils/index.js'
+import { randUser } from '../utils/index.js'
const user = randUser()
-const fileName = 'empty.md'
describe('Test the rich text editor menu bar', function () {
- before(() => initUserAndFiles(user, fileName))
+ before(function () {
+ cy.createUser(user)
+ })
beforeEach(function () {
cy.login(user)
- cy.visit('/apps/files', {
- onBeforeLoad(win) {
- cy.stub(win, 'open').as('winOpen')
- },
- })
-
- cy.openFile(fileName)
+ cy.uploadTestFile()
})
describe('word count', function () {
@@ -32,30 +27,78 @@ describe('Test the rich text editor menu bar', function () {
.get('[data-text-action-entry="character-count"]')
}
- beforeEach(cy.clearContent)
+ beforeEach(function () {
+ cy.visit('/apps/files')
+ cy.openTestFile()
+ })
+
it('empty file', () => {
- cy.getFile(fileName).then(($el) => {
- cy.getActionEntry('remain').click()
- getWordCount().should('include.text', '0 words, 0 chars')
- })
+ cy.getContent()
+ cy.getActionEntry('remain').click()
+ getWordCount().should('include.text', '0 words, 0 chars')
})
it('single word', () => {
- cy.getFile(fileName).then(($el) => {
- cy.clearContent()
- cy.getContent().type(' Hello ')
- cy.getActionEntry('remain').click()
- getWordCount().should('include.text', '1 word, 9 chars')
- })
+ cy.getContent().type(' Hello ')
+ cy.getActionEntry('remain').click()
+ getWordCount().should('include.text', '1 word, 9 chars')
})
it('multiple words', () => {
- cy.getFile(fileName).then(($el) => {
- cy.clearContent()
- cy.getContent().type('Hello \nworld')
- cy.getActionEntry('remain').click()
- getWordCount().should('include.text', '2 words, 11 chars')
- })
+ cy.getContent().type('Hello \nworld')
+ cy.getActionEntry('remain').click()
+ getWordCount().should('include.text', '2 words, 11 chars')
+ })
+ })
+
+ describe('text width toggle', function () {
+ beforeEach(() => {
+ cy.configureText('is_full_width_editor', 0)
+ cy.visit('/apps/files')
+ cy.window()
+ .its('document.documentElement.style')
+ .invoke('getPropertyValue', '--text-editor-max-width')
+ .as('maxWidth')
+ })
+
+ it('applys default', function () {
+ cy.openTestFile()
+ cy.get('@maxWidth').should('equal', '80ch')
+ })
+
+ it('toggles value', function () {
+ cy.openTestFile()
+ cy.getActionEntry('remain').click()
+ cy.contains('Full width editor').click()
+ cy.get('@maxWidth').should('equal', '100%')
+ })
+
+ it('preserves on reopen', function () {
+ cy.openTestFile()
+ cy.getActionEntry('remain').click()
+ cy.contains('Full width editor').click()
+ cy.closeFile()
+ cy.openTestFile()
+ cy.get('@maxWidth').should('equal', '100%')
+ })
+
+ it('preserves on reload', function () {
+ cy.openTestFile()
+ cy.getActionEntry('remain').click()
+ cy.contains('Full width editor').click()
+ cy.visit('/apps/files')
+ cy.openTestFile()
+ cy.get('@maxWidth').should('equal', '100%')
+ })
+
+ it('does not interfere if width is already set', function () {
+ cy.window()
+ .its('document.body.style')
+ .invoke('setProperty', '--text-editor-max-width', '987px')
+ cy.openTestFile()
+ cy.getActionEntry('remain').click()
+ cy.contains('Full width editor').should('not.exist')
+ cy.get('@maxWidth').should('equal', '')
})
})
})
diff --git a/src/components/Editor.vue b/src/components/Editor.vue
index 099141f2597..a4e9840260e 100644
--- a/src/components/Editor.vue
+++ b/src/components/Editor.vue
@@ -50,8 +50,7 @@
:dirty="dirty"
:sessions="filteredSessions"
:sync-error="syncError"
- :has-connection-issue="requireReconnect"
- @editor-width-change="handleEditorWidthChange" />
+ :has-connection-issue="requireReconnect" />