@@ -30,11 +30,13 @@ test.describe("Visual Regression", () => {
3030 tmpPath,
3131 } ) => {
3232 const notebook = "3_widget_example.ipynb" ;
33+ const namespace = 'default' ;
3334 await page . notebook . openByPath ( `${ tmpPath } /${ notebook } ` ) ;
3435 await page . notebook . activate ( notebook ) ;
3536
3637 const captures : ( Buffer | null ) [ ] = [ ] ; // Array to store cell screenshots
3738 const cellCount = await page . notebook . getCellCount ( ) ;
39+ console . log ( `Cell count: ${ cellCount } ` ) ;
3840
3941 // Run all cells and capture their screenshots
4042 await page . notebook . runCellByCell ( {
@@ -59,25 +61,27 @@ test.describe("Visual Regression", () => {
5961 }
6062 }
6163
62- const widgetCellIndex = 3 ;
64+ // At this point, all cells have been ran, and their screenshots have been captured.
65+ // We now interact with the widgets in the notebook.
66+ const upDownWidgetCellIndex = 3 ; // 4 on OpenShift
6367
64- await waitForWidget ( page , widgetCellIndex , 'input[type="checkbox"]' ) ;
65- await waitForWidget ( page , widgetCellIndex , 'button:has-text("Cluster Down")' ) ;
66- await waitForWidget ( page , widgetCellIndex , 'button:has-text("Cluster Up")' ) ;
68+ await waitForWidget ( page , upDownWidgetCellIndex , 'input[type="checkbox"]' ) ;
69+ await waitForWidget ( page , upDownWidgetCellIndex , 'button:has-text("Cluster Down")' ) ;
70+ await waitForWidget ( page , upDownWidgetCellIndex , 'button:has-text("Cluster Up")' ) ;
6771
68- await interactWithWidget ( page , widgetCellIndex , 'input[type="checkbox"]' , async ( checkbox ) => {
72+ await interactWithWidget ( page , upDownWidgetCellIndex , 'input[type="checkbox"]' , async ( checkbox ) => {
6973 await checkbox . click ( ) ;
7074 const isChecked = await checkbox . isChecked ( ) ;
7175 expect ( isChecked ) . toBe ( true ) ;
7276 } ) ;
7377
74- await interactWithWidget ( page , widgetCellIndex , 'button:has-text("Cluster Down")' , async ( button ) => {
78+ await interactWithWidget ( page , upDownWidgetCellIndex , 'button:has-text("Cluster Down")' , async ( button ) => {
7579 await button . click ( ) ;
7680 const clusterDownMessage = await page . waitForSelector ( 'text=No instances found, nothing to be done.' , { timeout : 5000 } ) ;
7781 expect ( clusterDownMessage ) . not . toBeNull ( ) ;
7882 } ) ;
7983
80- await interactWithWidget ( page , widgetCellIndex , 'button:has-text("Cluster Up")' , async ( button ) => {
84+ await interactWithWidget ( page , upDownWidgetCellIndex , 'button:has-text("Cluster Up")' , async ( button ) => {
8185 await button . click ( ) ;
8286
8387 const successMessage = await page . waitForSelector ( 'text=Ray Cluster: \'raytest\' has successfully been created' , { timeout : 10000 } ) ;
@@ -95,13 +99,51 @@ test.describe("Visual Regression", () => {
9599
96100 await runPreviousCell ( page , cellCount , '(<CodeFlareClusterStatus.READY: 1>, True)' ) ;
97101
98- await interactWithWidget ( page , widgetCellIndex , 'button:has-text("Cluster Down")' , async ( button ) => {
102+ await interactWithWidget ( page , upDownWidgetCellIndex , 'button:has-text("Cluster Down")' , async ( button ) => {
99103 await button . click ( ) ;
100104 const clusterDownMessage = await page . waitForSelector ( 'text=Ray Cluster: \'raytest\' has successfully been deleted' , { timeout : 5000 } ) ;
101105 expect ( clusterDownMessage ) . not . toBeNull ( ) ;
102106 } ) ;
103107
104108 await runPreviousCell ( page , cellCount , '(<CodeFlareClusterStatus.UNKNOWN: 6>, False)' ) ;
109+
110+ // view_clusters table with buttons
111+ await interactWithWidget ( page , upDownWidgetCellIndex , 'input[type="checkbox"]' , async ( checkbox ) => {
112+ await checkbox . click ( ) ;
113+ const isChecked = await checkbox . isChecked ( ) ;
114+ expect ( isChecked ) . toBe ( false ) ;
115+ } ) ;
116+
117+ await interactWithWidget ( page , upDownWidgetCellIndex , 'button:has-text("Cluster Up")' , async ( button ) => {
118+ await button . click ( ) ;
119+ const successMessage = await page . waitForSelector ( 'text=Ray Cluster: \'raytest\' has successfully been created' , { timeout : 10000 } ) ;
120+ expect ( successMessage ) . not . toBeNull ( ) ;
121+ } ) ;
122+
123+ const viewClustersCellIndex = 4 ; // 5 on OpenShift
124+ await page . notebook . runCell ( cellCount - 2 , true ) ;
125+ await interactWithWidget ( page , viewClustersCellIndex , 'button:has-text("Open Ray Dashboard")' , async ( button ) => {
126+ await button . click ( ) ;
127+ const successMessage = await page . waitForSelector ( 'text=Opening Ray Dashboard for raytest cluster' , { timeout : 5000 } ) ;
128+ expect ( successMessage ) . not . toBeNull ( ) ;
129+ } ) ;
130+
131+ await interactWithWidget ( page , viewClustersCellIndex , 'button:has-text("View Jobs")' , async ( button ) => {
132+ await button . click ( ) ;
133+ const successMessage = await page . waitForSelector ( 'text=Opening Ray Jobs Dashboard for raytest cluster' , { timeout : 5000 } ) ;
134+ expect ( successMessage ) . not . toBeNull ( ) ;
135+ } ) ;
136+
137+ await interactWithWidget ( page , viewClustersCellIndex , 'button:has-text("Delete Cluster")' , async ( button ) => {
138+ await button . click ( ) ;
139+
140+ const noClustersMessage = await page . waitForSelector ( `text=No clusters found in the ${ namespace } namespace.` , { timeout : 5000 } ) ;
141+ expect ( noClustersMessage ) . not . toBeNull ( ) ;
142+ const successMessage = await page . waitForSelector ( `text=Cluster raytest in the ${ namespace } namespace was deleted successfully.` , { timeout : 5000 } ) ;
143+ expect ( successMessage ) . not . toBeNull ( ) ;
144+ } ) ;
145+
146+ await runPreviousCell ( page , cellCount , '(<CodeFlareClusterStatus.UNKNOWN: 6>, False)' ) ;
105147 } ) ;
106148} ) ;
107149
0 commit comments