1
1
import { When , Then } from '@badeball/cypress-cucumber-preprocessor'
2
2
import {
3
- starSel ,
3
+ getNavigationMenuItem ,
4
+ closeNavigationMenu ,
5
+ } from '../../elements/navigationMenu.js'
6
+ import {
4
7
dashboardStarredSel ,
5
8
dashboardUnstarredSel ,
6
- dashboardChipSel ,
7
- chipStarSel ,
9
+ navMenuItemStarIconSel ,
8
10
} from '../../elements/viewDashboard.js'
9
11
import { TEST_DASHBOARD_TITLE } from './edit_dashboard.js'
10
12
11
13
// Scenario: I star the dashboard
12
14
When ( 'I click to star the dashboard' , ( ) => {
13
15
cy . intercept ( 'POST' , '**/favorite' ) . as ( 'starDashboard' )
14
16
15
- cy . get ( starSel ) . click ( )
17
+ cy . get ( dashboardUnstarredSel ) . click ( )
16
18
cy . wait ( '@starDashboard' ) . its ( 'response.statusCode' ) . should ( 'eq' , 200 )
17
19
} )
18
20
19
21
When ( 'I click to unstar the dashboard' , ( ) => {
20
22
cy . intercept ( 'DELETE' , '**/favorite' ) . as ( 'unstarDashboard' )
21
23
22
- cy . get ( starSel ) . click ( )
24
+ cy . get ( dashboardStarredSel ) . click ( )
23
25
cy . wait ( '@unstarDashboard' ) . its ( 'response.statusCode' ) . should ( 'eq' , 200 )
24
26
} )
25
27
@@ -28,22 +30,21 @@ Then('the dashboard is starred', () => {
28
30
cy . get ( dashboardStarredSel ) . should ( 'be.visible' )
29
31
cy . get ( dashboardUnstarredSel ) . should ( 'not.exist' )
30
32
31
- cy . get ( dashboardChipSel )
32
- . contains ( TEST_DASHBOARD_TITLE )
33
- . parent ( )
34
- . siblings ( chipStarSel )
35
- . first ( )
33
+ getNavigationMenuItem ( TEST_DASHBOARD_TITLE )
34
+ . find ( navMenuItemStarIconSel )
36
35
. should ( 'be.visible' )
36
+
37
+ closeNavigationMenu ( )
37
38
} )
38
39
39
40
Then ( 'the dashboard is not starred' , ( ) => {
40
41
// check for the unfilled star next to the title
41
42
cy . get ( dashboardUnstarredSel ) . should ( 'be.visible' )
42
43
cy . get ( dashboardStarredSel ) . should ( 'not.exist' )
43
44
44
- cy . get ( dashboardChipSel )
45
- . contains ( TEST_DASHBOARD_TITLE )
46
- . parent ( )
47
- . siblings ( )
45
+ getNavigationMenuItem ( TEST_DASHBOARD_TITLE )
46
+ . find ( navMenuItemStarIconSel )
48
47
. should ( 'not.exist' )
48
+
49
+ closeNavigationMenu ( )
49
50
} )
0 commit comments