import selectors from "../utils/selectors" ; import CreateDashboardPage from "./CreateDashboard" ; class DashboardListingPage { constructor ( ) { } visit ( ) { cy . intercept ( { method : "GET" , url : "/prod/dashboard" , } ) . as ( "listDashboardsRequest" ) ; cy . get ( selectors . navBar ) . get ( "a" ) . contains ( "Dashboards" ) . click ( ) ; cy . wait ( [ "@listDashboardsRequest" ] ) ; } goToCreateDashboard ( ) { cy . intercept ( { method : "GET" , url : "/prod/topicarea" , } ) . as ( "topicAreasRequest" ) ; cy . contains ( "Create dashboard" ) ; cy . findByRole ( "button" , { name : "Create dashboard" } ) . click ( ) ; cy . wait ( [ "@topicAreasRequest" ] ) ; cy . contains ( "Create dashboard" ) ; return new CreateDashboardPage ( ) ; } deleteDashboard ( dashboardName ) { cy . intercept ( { method : "DELETE" , pathname : "/prod/dashboard" , } ) . as ( "deleteDashboardsRequest" ) ; cy . intercept ( { method : "GET" , pathname : "/prod/dashboard" , } ) . as ( "listDashboardRequest" ) ; cy . findByRole ( "searchbox" ) . type ( dashboardName ) ; cy . get ( "form[role='search']" ) . submit ( ) ; cy . get ( `input[title="${ dashboardName }"]` ) . click ( { force : true , multiple : true , } ) ; cy . findByRole ( "button" , { name : "Actions" } ) . click ( ) ; cy . get ( "div" ) . contains ( "Delete" ) . click ( ) ; cy . findByRole ( "button" , { name : "Delete" } ) . click ( ) ; cy . wait ( [ "@deleteDashboardsRequest" , "@listDashboardRequest" ] ) ; } } export default DashboardListingPage ;