1+ import { customClass , customId , loadDocument , renderViewer } from "../utils" ;
2+ import { helpWindowShouldBeOpen , initialScreenShouldBeVisible , optionsWindowShouldBeOpen } from "../shared" ;
3+
4+ const menuShouldNotBeVisible = ( ) => cy . get ( customId ( 'menu' ) ) . should ( 'not.be.visible' ) ;
5+
6+ describe ( 'Document menu opens and closes' , ( ) => {
7+ before ( ( ) => {
8+ cy . visit ( '/' ) ;
9+ renderViewer ( ) ;
10+ } ) ;
11+
12+ beforeEach ( loadDocument ) ;
13+
14+ it ( 'Menu opens and closes via menu button' , ( ) => {
15+ cy . contains ( "Menu" ) . should ( 'not.be.visible' ) ;
16+ cy . get ( customId ( 'menu_button' ) ) . click ( ) ;
17+ cy . contains ( "Menu" ) . should ( 'be.visible' ) ;
18+ cy . get ( customId ( 'menu_button' ) ) . click ( ) ;
19+ menuShouldNotBeVisible ( ) ;
20+ } ) ;
21+
22+ it ( 'Menu can be closed with the close button' , ( ) => {
23+ cy . get ( customId ( 'menu_button' ) ) . click ( ) . wait ( 500 ) ;
24+ cy . get ( customId ( 'menu' ) ) . should ( 'be.visible' )
25+ . find ( customClass ( 'close_button' ) ) . first ( ) . click ( ) ;
26+ menuShouldNotBeVisible ( ) ;
27+ } ) ;
28+ } ) ;
29+
30+ describe ( 'Document menu controls' , ( ) => {
31+ before ( ( ) => {
32+ cy . visit ( '/' ) ;
33+ renderViewer ( ) ;
34+ } ) ;
35+
36+ beforeEach ( ( ) => {
37+ loadDocument ( ) ;
38+ cy . get ( customId ( 'menu_button' ) ) . click ( ) . wait ( 500 ) ;
39+ } ) ;
40+
41+ it ( 'Options inside menu and menu closes' , ( ) => {
42+ cy . contains ( 'Options' ) . click ( ) ;
43+ optionsWindowShouldBeOpen ( ) ;
44+ menuShouldNotBeVisible ( ) ;
45+ } ) ;
46+
47+ it ( 'Help button inside menu' , ( ) => {
48+ cy . contains ( 'About' ) . click ( ) ;
49+ helpWindowShouldBeOpen ( ) ;
50+ menuShouldNotBeVisible ( ) ;
51+ } ) ;
52+
53+ it ( 'Print document' , ( ) => {
54+ cy . contains ( 'Print' ) . click ( ) ;
55+ menuShouldNotBeVisible ( ) ;
56+ cy . get ( customClass ( 'modal_window' ) ) . within ( ( ) => {
57+ cy . contains ( 'Pages must be rendered before printing' ) . should ( 'be.visible' ) ;
58+ cy . contains ( 'From' ) . should ( 'be.visible' ) ;
59+ cy . contains ( 'to' ) . should ( 'be.visible' ) ;
60+ cy . contains ( 'Prepare pages for printing' ) . click ( ) ;
61+ } ) ;
62+
63+ cy . contains ( 'Prepare pages for printing' ) . should ( 'not.exist' ) ;
64+ cy . get ( customClass ( 'modal_window' ) )
65+ . contains ( 'Preparing pages for printing...' ) . should ( 'be.visible' ) ;
66+ } ) ;
67+
68+ it ( 'Close document' , ( ) => {
69+ cy . contains ( 'test_document' ) . should ( 'be.visible' ) ;
70+ cy . contains ( 'Close' ) . click ( ) ;
71+ cy . get ( customId ( 'menu' ) ) . should ( 'not.exist' ) ;
72+ initialScreenShouldBeVisible ( ) ;
73+ } ) ;
74+ } ) ;
0 commit comments