11const { By, Key, until, Builder } = require ( 'selenium-webdriver' )
22require ( 'chromedriver' )
33const assert = require ( 'assert' )
4- const { buildDriver, goToHome, captureScreensFor, teardown, doWhile, log } = require ( '../utils' )
4+ const { buildDriver, goToHome, captureScreensFor, teardown, doWhile, log, delay } = require ( '../utils' )
55const { getManagementUrl, createVhost, deleteVhost } = require ( '../mgt-api' )
66
77const LoginPage = require ( '../pageobjects/LoginPage' )
@@ -51,15 +51,51 @@ describe('Virtual Hosts in Admin tab', function () {
5151 await overview . clickOnOverviewTab ( )
5252 await overview . clickOnAdminTab ( )
5353 await adminTab . clickOnVhosts ( )
54+ await doWhile ( async function ( ) { return vhostsTab . getVhostsTable ( ) } ,
55+ function ( table ) { return table . length > 1 } )
56+
5457 await vhostsTab . clickOnSelectTableColumns ( )
5558 let table = await vhostsTab . getSelectableTableColumns ( )
56- log ( "Table: " + table )
57- await doWhile ( async function ( ) {
58- return vhostsTab . getVhostsTable ( )
59- } , function ( table ) {
60- return table . length > 0 && vhost . localeCompare ( table [ 0 ] [ 0 ] )
61- } )
59+
60+ assert . equal ( 4 , table . length )
61+ let overviewGroup = {
62+ "name" : "Overview:" ,
63+ "columns" : [
64+ { "name:" :"Default queue type" , "id" :"checkbox-vhosts-default-queue-type" } ,
65+ { "name:" :"Cluster state" , "id" :"checkbox-vhosts-cluster-state" } ,
66+ { "name:" :"Description" , "id" :"checkbox-vhosts-description" } ,
67+ { "name:" :"Tags" , "id" :"checkbox-vhosts-tags" }
68+ ]
69+ }
70+ assert . equal ( JSON . stringify ( table [ 0 ] ) , JSON . stringify ( overviewGroup ) )
71+ let messagesGroup = {
72+ "name" : "Messages:" ,
73+ "columns" : [
74+ { "name:" :"Ready" , "id" :"checkbox-vhosts-msgs-ready" } ,
75+ { "name:" :"Unacknowledged" , "id" :"checkbox-vhosts-msgs-unacked" } ,
76+ { "name:" :"Total" , "id" :"checkbox-vhosts-msgs-total" }
77+ ]
78+ }
79+ assert . equal ( JSON . stringify ( table [ 1 ] ) , JSON . stringify ( messagesGroup ) )
80+ let networkGroup = {
81+ "name" : "Network:" ,
82+ "columns" : [
83+ { "name:" :"From client" , "id" :"checkbox-vhosts-from_client" } ,
84+ { "name:" :"To client" , "id" :"checkbox-vhosts-to_client" }
85+ ]
86+ }
87+ assert . equal ( JSON . stringify ( table [ 2 ] ) , JSON . stringify ( networkGroup ) )
88+ let messageRatesGroup = {
89+ "name" : "Message rates:" ,
90+ "columns" : [
91+ { "name:" :"publish" , "id" :"checkbox-vhosts-rate-publish" } ,
92+ { "name:" :"deliver / get" , "id" :"checkbox-vhosts-rate-deliver" }
93+ ]
94+ }
95+ assert . equal ( JSON . stringify ( table [ 3 ] ) , JSON . stringify ( messageRatesGroup ) )
96+
6297 } )
98+
6399 describe ( 'given there is a new virtualhost with a tag' , async function ( ) {
64100 let vhost = "test_" + Math . floor ( Math . random ( ) * 1000 )
65101 before ( async function ( ) {
@@ -70,23 +106,27 @@ describe('Virtual Hosts in Admin tab', function () {
70106 await adminTab . clickOnVhosts ( )
71107 } )
72108 it ( 'vhost is listed with tag' , async function ( ) {
73- log ( "Searching for vhost" )
74- await vhostsTab . searchForVhosts ( vhost )
75- await vhostsTab . clickOnSelectTableColumns ( )
76- let table = vhostsTab . getSelectableTableColumns ( )
77- log ( "Table: " + table )
78- await doWhile ( async function ( ) {
79- return vhostsTab . getVhostsTable ( )
80- } , function ( table ) {
81- return table . length > 0 && vhost . localeCompare ( table [ 0 ] [ 0 ] )
109+ log ( "Searching for vhost " + vhost )
110+ await doWhile ( async function ( ) { return vhostsTab . searchForVhosts ( vhost ) } ,
111+ function ( table ) {
112+ return table . length == 1 && table [ 1 ] [ 0 ] . localeCompare ( vhost )
113+ } )
114+ log ( "Found vhost " + vhost )
115+ await vhostsTab . selectTableColumnsById ( [ "checkbox-vhosts-tags" ] )
116+
117+ await doWhile ( async function ( ) { return vhostsTab . getVhostsTable ( ) } ,
118+ function ( table ) {
119+ return table . length == 1 && table [ 1 ] [ 3 ] . localeCompare ( "selenium-tag" )
82120 } )
121+
83122 } )
84123 after ( async function ( ) {
85124 log ( "Deleting vhost" )
86125 deleteVhost ( getManagementUrl ( ) , vhost )
87126 } )
88127
89128 } )
129+
90130
91131 after ( async function ( ) {
92132 await teardown ( driver , this , captureScreen )
0 commit comments