33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
55
6- import { initUserAndFiles , randUser } from '../utils/index.js'
6+ import { randUser } from '../utils/index.js'
77
88const user = randUser ( )
9- const fileName = 'empty.md'
109
1110describe ( 'Test the rich text editor menu bar' , function ( ) {
12- before ( ( ) => initUserAndFiles ( user , fileName ) )
11+ before ( function ( ) {
12+ cy . createUser ( user )
13+ } )
1314
1415 beforeEach ( function ( ) {
1516 cy . login ( user )
16- cy . visit ( '/apps/files' , {
17- onBeforeLoad ( win ) {
18- cy . stub ( win , 'open' ) . as ( 'winOpen' )
19- } ,
20- } )
21-
22- cy . openFile ( fileName )
17+ cy . uploadTestFile ( )
2318 } )
2419
2520 describe ( 'word count' , function ( ) {
@@ -32,30 +27,78 @@ describe('Test the rich text editor menu bar', function () {
3227 . get ( '[data-text-action-entry="character-count"]' )
3328 }
3429
35- beforeEach ( cy . clearContent )
30+ beforeEach ( function ( ) {
31+ cy . visit ( '/apps/files' )
32+ cy . openTestFile ( )
33+ } )
34+
3635 it ( 'empty file' , ( ) => {
37- cy . getFile ( fileName ) . then ( ( $el ) => {
38- cy . getActionEntry ( 'remain' ) . click ( )
39- getWordCount ( ) . should ( 'include.text' , '0 words, 0 chars' )
40- } )
36+ cy . getContent ( )
37+ cy . getActionEntry ( 'remain' ) . click ( )
38+ getWordCount ( ) . should ( 'include.text' , '0 words, 0 chars' )
4139 } )
4240
4341 it ( 'single word' , ( ) => {
44- cy . getFile ( fileName ) . then ( ( $el ) => {
45- cy . clearContent ( )
46- cy . getContent ( ) . type ( ' Hello ' )
47- cy . getActionEntry ( 'remain' ) . click ( )
48- getWordCount ( ) . should ( 'include.text' , '1 word, 9 chars' )
49- } )
42+ cy . getContent ( ) . type ( ' Hello ' )
43+ cy . getActionEntry ( 'remain' ) . click ( )
44+ getWordCount ( ) . should ( 'include.text' , '1 word, 9 chars' )
5045 } )
5146
5247 it ( 'multiple words' , ( ) => {
53- cy . getFile ( fileName ) . then ( ( $el ) => {
54- cy . clearContent ( )
55- cy . getContent ( ) . type ( 'Hello \nworld' )
56- cy . getActionEntry ( 'remain' ) . click ( )
57- getWordCount ( ) . should ( 'include.text' , '2 words, 11 chars' )
58- } )
48+ cy . getContent ( ) . type ( 'Hello \nworld' )
49+ cy . getActionEntry ( 'remain' ) . click ( )
50+ getWordCount ( ) . should ( 'include.text' , '2 words, 11 chars' )
51+ } )
52+ } )
53+
54+ describe ( 'text width toggle' , function ( ) {
55+ beforeEach ( ( ) => {
56+ cy . configureText ( 'is_full_width_editor' , 0 )
57+ cy . visit ( '/apps/files' )
58+ cy . window ( )
59+ . its ( 'document.documentElement.style' )
60+ . invoke ( 'getPropertyValue' , '--text-editor-max-width' )
61+ . as ( 'maxWidth' )
62+ } )
63+
64+ it ( 'applys default' , function ( ) {
65+ cy . openTestFile ( )
66+ cy . get ( '@maxWidth' ) . should ( 'equal' , '80ch' )
67+ } )
68+
69+ it ( 'toggles value' , function ( ) {
70+ cy . openTestFile ( )
71+ cy . getActionEntry ( 'remain' ) . click ( )
72+ cy . contains ( 'Full width editor' ) . click ( )
73+ cy . get ( '@maxWidth' ) . should ( 'equal' , '100%' )
74+ } )
75+
76+ it ( 'preserves on reopen' , function ( ) {
77+ cy . openTestFile ( )
78+ cy . getActionEntry ( 'remain' ) . click ( )
79+ cy . contains ( 'Full width editor' ) . click ( )
80+ cy . closeFile ( )
81+ cy . openTestFile ( )
82+ cy . get ( '@maxWidth' ) . should ( 'equal' , '100%' )
83+ } )
84+
85+ it ( 'preserves on reload' , function ( ) {
86+ cy . openTestFile ( )
87+ cy . getActionEntry ( 'remain' ) . click ( )
88+ cy . contains ( 'Full width editor' ) . click ( )
89+ cy . visit ( '/apps/files' )
90+ cy . openTestFile ( )
91+ cy . get ( '@maxWidth' ) . should ( 'equal' , '100%' )
92+ } )
93+
94+ it ( 'does not interfere if width is already set' , function ( ) {
95+ cy . window ( )
96+ . its ( 'document.body.style' )
97+ . invoke ( 'setProperty' , '--text-editor-max-width' , '987px' )
98+ cy . openTestFile ( )
99+ cy . getActionEntry ( 'remain' ) . click ( )
100+ cy . contains ( 'Full width editor' ) . should ( 'not.exist' )
101+ cy . get ( '@maxWidth' ) . should ( 'equal' , '' )
59102 } )
60103 } )
61104} )
0 commit comments