11const { By, Key, until, Builder } = require ( 'selenium-webdriver' )
22require ( 'chromedriver' )
33const assert = require ( 'assert' )
4- const { buildDriver, goToHome, captureScreensFor, teardown } = require ( '../../utils' )
4+ const { buildDriver, goToHome, captureScreensFor, teardown, delay } = require ( '../../utils' )
55
66const LoginPage = require ( '../../pageobjects/LoginPage' )
77const OverviewPage = require ( '../../pageobjects/OverviewPage' )
@@ -10,7 +10,7 @@ const ConnectionPage = require('../../pageobjects/ConnectionPage')
1010
1111var container = require ( 'rhea' ) // https://github.com/amqp/rhea
1212var receivedAmqpMessageCount = 0
13- var connectionEstablishedPromise = new Promise ( ( resolve , reject ) => {
13+ var untilConnectionEstablished = new Promise ( ( resolve , reject ) => {
1414 container . on ( 'connection_open' , function ( context ) {
1515 resolve ( )
1616 } )
@@ -20,7 +20,7 @@ container.on('message', function (context) {
2020 receivedAmqpMessageCount ++
2121} )
2222container . once ( 'sendable' , function ( context ) {
23- context . sender . send ( { body :'Hello World! ' } )
23+ context . sender . send ( { body :'first message ' } )
2424} )
2525
2626
@@ -54,12 +54,12 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
5454 target : 'receiver-target' ,
5555 name : 'receiver-link'
5656 } )
57- connection . open_sender ( {
57+ sender = connection . open_sender ( {
5858 target : 'examples' ,
5959 source : 'sender-source' ,
6060 name : 'sender-link'
6161 } )
62- await connectionEstablishedPromise
62+ await untilConnectionEstablished
6363 await overview . clickOnConnectionsTab ( )
6464 await connectionsPage . isLoaded ( )
6565
@@ -74,7 +74,7 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
7474 let sessions = await connectionPage . getSessions ( )
7575 assert . equal ( 1 , sessions . sessions . length )
7676 let session = connectionPage . getSessionInfo ( sessions . sessions , 0 )
77- // console.log("session: " + JSON.stringify(session))
77+ console . log ( "session: " + JSON . stringify ( session ) )
7878 assert . equal ( 0 , session . channelNumber )
7979 assert . equal ( 1 , session . nextIncomingId )
8080 assert . equal ( 0 , session . outgoingUnsettledDeliveries )
@@ -84,17 +84,18 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
8484 let sessions = await connectionPage . getSessions ( )
8585 assert . equal ( 1 , sessions . incoming_links . length )
8686 assert . equal ( 1 , sessions . outgoing_links . length )
87-
87+
8888 let incomingLink = connectionPage . getIncomingLinkInfo ( sessions . incoming_links , 0 )
89- // console.log("incomingLink: " + JSON.stringify(incomingLink))
89+ console . log ( "incomingLink: " + JSON . stringify ( incomingLink ) )
9090 assert . equal ( 1 , incomingLink . handle )
9191 assert . equal ( "sender-link" , incomingLink . name )
9292 assert . equal ( "examples" , incomingLink . targetAddress )
9393 assert . equal ( "mixed" , incomingLink . sndSettleMode )
9494 assert . equal ( "0" , incomingLink . unconfirmedMessages )
95-
95+ assert . equal ( 1 , incomingLink . deliveryCount )
96+
9697 let outgoingLink = connectionPage . getOutgoingLinkInfo ( sessions . outgoing_links , 0 )
97- // console.log("outgoingLink: " + JSON.stringify(outgoingLink))
98+ console . log ( "outgoingLink: " + JSON . stringify ( outgoingLink ) )
9899 assert . equal ( 0 , outgoingLink . handle )
99100 assert . equal ( "receiver-link" , outgoingLink . name )
100101 assert . equal ( "examples" , outgoingLink . sourceAddress )
@@ -105,6 +106,28 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
105106
106107 } )
107108
109+ it ( 'display live link information' , async function ( ) {
110+ var untilMessageReceived = new Promise ( ( resolve , reject ) => {
111+ container . on ( 'message' , function ( context ) {
112+ resolve ( )
113+ } )
114+ } )
115+ sender . send ( { body :'second message' } )
116+ await untilMessageReceived
117+ assert . equal ( 2 , receivedAmqpMessageCount )
118+
119+ await delay ( 5 * 1000 ) // wait until page refreshes
120+ let sessions = await connectionPage . getSessions ( )
121+ let session = connectionPage . getSessionInfo ( sessions . sessions , 0 )
122+ let incomingLink = connectionPage . getIncomingLinkInfo ( sessions . incoming_links , 0 )
123+ let outgoingLink = connectionPage . getOutgoingLinkInfo ( sessions . outgoing_links , 0 )
124+ assert . equal ( 2 , incomingLink . deliveryCount )
125+
126+ //console.log("incomingLink: " + JSON.stringify(incomingLink))
127+ //console.log("outgoingLink: " + JSON.stringify(outgoingLink))
128+ } )
129+
130+
108131 after ( async function ( ) {
109132 await teardown ( driver , this , captureScreen )
110133 try {
0 commit comments