1
1
describe ( 'Sidebar Navigation' , ( ) => {
2
- before ( ( ) => {
2
+ beforeEach ( ( ) => {
3
3
cy . scaffoldProject ( 'todos' )
4
4
cy . openProject ( 'todos' )
5
5
cy . startAppServer ( )
@@ -18,17 +18,17 @@ describe('Sidebar Navigation', () => {
18
18
19
19
it ( 'closes the bar when clicking the expand button (if expanded)' , ( ) => {
20
20
cy . get ( '[aria-expanded]' ) . should ( 'have.attr' , 'aria-expanded' , 'true' )
21
- cy . findByText ( 'todos' ) . should ( 'be.visible' )
21
+ cy . findByText ( 'todos' ) . as ( 'title' )
22
+ cy . get ( '@title' ) . should ( 'be.visible' )
22
23
cy . findByLabelText ( 'toggle navigation' , {
23
24
selector : 'button' ,
24
25
} ) . click ( )
25
26
26
27
cy . get ( '[aria-expanded]' ) . should ( 'have.attr' , 'aria-expanded' , 'false' )
27
- cy . findByText ( 'todos ') . should ( 'not.be.visible' )
28
+ cy . get ( '@title ') . should ( 'not.be.visible' )
28
29
} )
29
30
30
31
it ( 'has unlabeled menu item that shows the keyboard shortcuts modal (unexpanded state)' , ( ) => {
31
- cy . get ( '[aria-expanded]' ) . should ( 'have.attr' , 'aria-expanded' , 'false' )
32
32
cy . get ( '[data-cy="keyboard-shortcuts"]' ) . should ( 'be.visible' )
33
33
cy . get ( '[data-cy="keyboard-shortcuts"]' ) . click ( )
34
34
cy . get ( 'h2' ) . findByText ( 'Keyboard Shortcuts' ) . should ( 'be.visible' )
@@ -43,7 +43,9 @@ describe('Sidebar Navigation', () => {
43
43
} )
44
44
45
45
it ( 'shows a tooltip when hovering over menu item' , ( ) => {
46
- cy . get ( '[aria-expanded]' ) . should ( 'have.attr' , 'aria-expanded' , 'false' )
46
+ cy . findByLabelText ( 'toggle navigation' , {
47
+ selector : 'button' ,
48
+ } ) . click ( )
47
49
48
50
cy . get ( '[data-cy="sidebar-header"' ) . realHover ( )
49
51
cy . contains ( '#tooltip-target > div' , 'todos' ) . should ( 'be.visible' )
@@ -67,7 +69,10 @@ describe('Sidebar Navigation', () => {
67
69
} )
68
70
69
71
it ( 'opens the bar when clicking the expand button (if unexpanded)' , ( ) => {
70
- cy . get ( '[aria-expanded]' ) . should ( 'have.attr' , 'aria-expanded' , 'false' )
72
+ cy . findByLabelText ( 'toggle navigation' , {
73
+ selector : 'button' ,
74
+ } ) . click ( )
75
+
71
76
cy . findByText ( 'todos' ) . should ( 'not.be.visible' )
72
77
73
78
cy . findByLabelText ( 'toggle navigation' , {
@@ -142,7 +147,7 @@ describe('Sidebar Navigation', () => {
142
147
it ( 'has a menu item labeled "Specs" which takes you to the Spec List page' , ( ) => {
143
148
cy . get ( '[aria-expanded]' ) . should ( 'have.attr' , 'aria-expanded' , 'true' )
144
149
145
- cy . get ( '[data-cy="app-header-bar"]' ) . findByText ( 'Specs-Index' ) . should ( 'not.exist' )
150
+ // cy.get('[data-cy="app-header-bar"]').findByText('Specs-Index').should('not.exist')
146
151
cy . findByText ( 'Specs' ) . should ( 'be.visible' )
147
152
cy . findByText ( 'Specs' ) . click ( )
148
153
cy . get ( '[data-cy="app-header-bar"]' ) . findByText ( 'Specs-Index' ) . should ( 'be.visible' )
0 commit comments