import EditDashboardPage from "./EditDashboard" ; class AddChartPage { constructor ( ) { cy . contains ( "Add chart" ) ; } selectStaticDataset ( ) { cy . findByTestId ( "staticDatasetRadioButton" ) . check ( { force : true } ) ; } uploadDataset ( fixture ) { cy . contains ( "Drag file here or choose from folder" ) ; cy . findByLabelText ( "Static datasets" ) . attachFile ( fixture ) ; cy . wait ( 200 ) ; cy . get ( "button" ) . contains ( "Continue" ) . click ( ) ; } selectColumns ( ) { cy . get ( "button" ) . contains ( "Continue" ) . click ( { force : true } ) ; } fillTitle ( title ) { cy . findByLabelText ( "Chart title*" ) . type ( title ) ; } fillSummary ( summary ) { cy . findByLabelText ( "Chart summary (optional)" ) . type ( summary ) ; } verifyPreview ( title , summary ) { cy . get ( "span.recharts-legend-item-text" ) . contains ( "Series 1" ) ; cy . get ( "span.recharts-legend-item-text" ) . contains ( "Series 2" ) ; cy . get ( "span.recharts-legend-item-text" ) . contains ( "Series 3" ) ; cy . get ( "span.recharts-legend-item-text" ) . contains ( "Series 4" ) ; cy . get ( "span.recharts-legend-item-text" ) . contains ( "Series 5" ) ; cy . findByRole ( "heading" , { name : title } ) . should ( "exist" ) ; cy . contains ( summary ) . should ( "exist" ) ; } submit ( ) { cy . intercept ( { method : "PUT" , url : new RegExp ( /\/public\/.+/ ) , } ) . as ( "addChartRequest" ) ; cy . intercept ( { method : "POST" , url : new RegExp ( /\/prod\/dashboard\/.+\/widget/ ) , } ) . as ( "createWidgetRequest" ) ; cy . intercept ( { method : "GET" , url : new RegExp ( /\/prod\/dashboard\/.+/ ) , } ) . as ( "viewDashboardRequest" ) ; cy . intercept ( { method : "GET" , url : new RegExp ( /\/prod\/dashboard\/.+\/versions/ ) , } ) . as ( "viewDashboardVersionsRequest" ) ; cy . get ( "button" ) . contains ( "Add chart" ) . click ( ) ; cy . wait ( [ "@addChartRequest" , "@addChartRequest" , "@createWidgetRequest" , "@viewDashboardRequest" , "@viewDashboardVersionsRequest" , ] ) ; return new EditDashboardPage ( ) ; } } export default AddChartPage ;