import * as Chance from "chance" ; import DashboardListingPage from "../pages/DashboardListing" ; import LoginPage from "../pages/Login" ; const random = new Chance ( ) ; describe ( "Admin user" , ( ) => { beforeEach ( ( ) => { const loginPage = new LoginPage ( ) ; loginPage . visit ( ) ; loginPage . loginAsAdmin ( ) ; } ) ; it ( "can create a new dashboard and delete it" , ( ) => { const dashboardListingPage = new DashboardListingPage ( ) ; dashboardListingPage . visit ( ) ; const createDashboardPage = dashboardListingPage . goToCreateDashboard ( ) ; const dashboardName = random . company ( ) ; const description = random . sentence ( ) ; createDashboardPage . fillName ( dashboardName ) ; createDashboardPage . fillDescription ( description ) ; cy . findByRole ( "heading" , { name : dashboardName } ) . should ( "exist" ) ; cy . findByText ( description ) . should ( "exist" ) ; let editDashboardPage = createDashboardPage . submit ( ) ; cy . contains ( `"${ dashboardName }" draft dashboard successfully created.` ) ; dashboardListingPage . visit ( ) ; cy . intercept ( { method : "GET" , url : "/prod/dashboard" , } ) . as ( "listDashboardsRequest" ) ; dashboardListingPage . deleteDashboard ( dashboardName ) ; cy . wait ( [ "@listDashboardsRequest" ] ) ; cy . contains ( `${ dashboardName } draft dashboard was successfully deleted.` ) ; } ) ; } ) ;