1
- import { Chance } from 'chance' ;
2
1
import { rte } from '../../../helpers/constants' ;
3
2
import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database' ;
4
3
import { BrowserPage , CliPage } from '../../../pageObjects' ;
@@ -7,15 +6,16 @@ import {
7
6
ossStandaloneConfig
8
7
} from '../../../helpers/conf' ;
9
8
import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database' ;
9
+ import { Common } from '../../../helpers/common' ;
10
10
11
11
const browserPage = new BrowserPage ( ) ;
12
12
const cliPage = new CliPage ( ) ;
13
- const chance = new Chance ( ) ;
13
+ const common = new Common ( ) ;
14
14
15
- let keyName = chance . word ( { length : 20 } ) ;
16
- let consumerGroupName = chance . word ( { length : 20 } ) ;
17
- const keyField = chance . word ( { length : 20 } ) ;
18
- const keyValue = chance . word ( { length : 20 } ) ;
15
+ let keyName = common . generateWord ( 20 ) ;
16
+ let consumerGroupName = common . generateWord ( 20 ) ;
17
+ const keyField = common . generateWord ( 20 ) ;
18
+ const keyValue = common . generateWord ( 20 ) ;
19
19
const entryIds = [
20
20
'0' ,
21
21
'$' ,
@@ -29,7 +29,7 @@ fixture `Consumer group`
29
29
await acceptLicenseTermsAndAddDatabaseApi ( ossStandaloneConfig , ossStandaloneConfig . databaseName ) ;
30
30
} )
31
31
. afterEach ( async t => {
32
- //Clear and delete database
32
+ // Clear and delete database
33
33
if ( await browserPage . closeKeyButton . visible ) {
34
34
await t . click ( browserPage . closeKeyButton ) ;
35
35
}
@@ -46,69 +46,62 @@ test('Verify that user can create a new Consumer Group in the current Stream', a
46
46
'0' ,
47
47
'fetches the entire stream from the beginning.'
48
48
] ;
49
- keyName = chance . word ( { length : 20 } ) ;
50
- consumerGroupName = `qwerty123456${ chance . word ( { length : 20 } ) } !@#$%^&*()_+=` ;
49
+ keyName = common . generateWord ( 20 ) ;
50
+ consumerGroupName = `qwerty123456${ common . generateWord ( 20 ) } !@#$%^&*()_+=` ;
51
51
// Add New Stream Key
52
52
await browserPage . addStreamKey ( keyName , keyField , keyValue ) ;
53
53
await t . click ( browserPage . fullScreenModeButton ) ;
54
54
// Open Stream consumer groups and add group
55
55
await t . click ( browserPage . streamTabGroups ) ;
56
56
await browserPage . createConsumerGroup ( consumerGroupName ) ;
57
- await t . expect ( browserPage . streamGroupsContainer . textContent ) . contains ( consumerGroupName , 'The new Consumer Group is added' ) ;
57
+ await t . expect ( browserPage . streamGroupsContainer . textContent ) . contains ( consumerGroupName , 'The new Consumer Group is not added' ) ;
58
58
// Verify the tooltip under 'i' element
59
59
await t . click ( browserPage . addKeyValueItemsButton ) ;
60
60
await t . hover ( browserPage . entryIdInfoIcon ) ;
61
61
for ( const text of toolTip ) {
62
- await t . expect ( await browserPage . tooltip . innerText ) . contains ( text , 'The toolTip message' ) ;
62
+ await t . expect ( await browserPage . tooltip . innerText ) . contains ( text , 'The toolTip message not displayed ' ) ;
63
63
}
64
64
} ) ;
65
65
test ( 'Verify that user can input the 0, $ and Valid Entry ID in the ID field' , async t => {
66
- keyName = chance . word ( { length : 20 } ) ;
67
- consumerGroupName = chance . word ( { length : 20 } ) ;
66
+ keyName = common . generateWord ( 20 ) ;
67
+ consumerGroupName = common . generateWord ( 20 ) ;
68
68
// Add New Stream Key
69
69
await browserPage . addStreamKey ( keyName , keyField , keyValue ) ;
70
70
await t . click ( browserPage . fullScreenModeButton ) ;
71
71
// Open Stream consumer groups and add group with different IDs
72
72
await t . click ( browserPage . streamTabGroups ) ;
73
73
for ( const entryId of entryIds ) {
74
74
await browserPage . createConsumerGroup ( `${ consumerGroupName } ${ entryId } ` , entryId ) ;
75
- await t . expect ( browserPage . streamGroupsContainer . textContent ) . contains ( `${ consumerGroupName } ${ entryId } ` , 'The new Consumer Group is added' ) ;
75
+ await t . expect ( browserPage . streamGroupsContainer . textContent ) . contains ( `${ consumerGroupName } ${ entryId } ` , 'The new Consumer Group is not added' ) ;
76
76
}
77
77
} ) ;
78
78
test ( 'Verify that user can see the Consumer group columns (Group Name, Consumers, Pending, Last Delivered ID)' , async t => {
79
- keyName = chance . word ( { length : 20 } ) ;
80
- consumerGroupName = chance . word ( { length : 20 } ) ;
79
+ keyName = common . generateWord ( 20 ) ;
80
+ consumerGroupName = common . generateWord ( 20 ) ;
81
81
const groupColumns = [
82
82
'Group Name' ,
83
83
'Consumers' ,
84
84
'Pending' ,
85
85
'Last Delivered ID'
86
86
] ;
87
+ const message = 'Your Consumer Group has no Consumers available.' ;
88
+
87
89
// Add New Stream Key
88
90
await browserPage . addStreamKey ( keyName , keyField , keyValue ) ;
89
91
await t . click ( browserPage . fullScreenModeButton ) ;
90
92
// Open Stream consumer groups and add group with different IDs
91
93
await t . click ( browserPage . streamTabGroups ) ;
92
94
await browserPage . createConsumerGroup ( consumerGroupName ) ;
93
95
for ( let i = 0 ; i < groupColumns . length ; i ++ ) {
94
- await t . expect ( browserPage . scoreButton . nth ( i ) . textContent ) . eql ( groupColumns [ i ] , `The ${ i } Consumer group column name` ) ;
96
+ await t . expect ( browserPage . scoreButton . nth ( i ) . textContent ) . eql ( groupColumns [ i ] , `The ${ i } Consumer group column name not correct ` ) ;
95
97
}
96
- } ) ;
97
- test ( 'Verify that user can see the message when there are no Consumers in the Consumer Group' , async t => {
98
- keyName = chance . word ( { length : 20 } ) ;
99
- consumerGroupName = chance . word ( { length : 20 } ) ;
100
- const message = 'Your Consumer Group has no Consumers available.' ;
101
- // Add New Stream Key
102
- await browserPage . addStreamKey ( keyName , keyField , keyValue ) ;
103
- // Open Stream consumer group and check message
104
- await t . click ( browserPage . streamTabGroups ) ;
105
- await browserPage . createConsumerGroup ( consumerGroupName ) ;
98
+ // Verify that user can see the message when there are no Consumers in the Consumer Group
106
99
await t . click ( browserPage . consumerGroup ) ;
107
- await t . expect ( browserPage . streamConsumersContainer . textContent ) . contains ( message , 'The message for empty Consumer Group' ) ;
100
+ await t . expect ( browserPage . streamConsumersContainer . textContent ) . contains ( message , 'The message for empty Consumer Group not displayed ' ) ;
108
101
} ) ;
109
102
test ( 'Verify that user can see the Consumer information columns (Consumer Name, Pendings, Idle Time,ms)' , async t => {
110
- keyName = chance . word ( { length : 20 } ) ;
111
- consumerGroupName = chance . word ( { length : 20 } ) ;
103
+ keyName = common . generateWord ( 20 ) ;
104
+ consumerGroupName = common . generateWord ( 20 ) ;
112
105
const cliCommands = [
113
106
`XGROUP CREATE ${ keyName } ${ consumerGroupName } $ MKSTREAM` ,
114
107
`XADD ${ keyName } * message apple` ,
@@ -128,33 +121,16 @@ test('Verify that user can see the Consumer information columns (Consumer Name,
128
121
await t . click ( browserPage . streamTabGroups ) ;
129
122
await t . click ( browserPage . consumerGroup ) ;
130
123
for ( let i = 0 ; i < consumerColumns . length ; i ++ ) {
131
- await t . expect ( browserPage . scoreButton . nth ( i ) . textContent ) . eql ( consumerColumns [ i ] , `The ${ i } Consumers info column name` ) ;
124
+ await t . expect ( browserPage . scoreButton . nth ( i ) . textContent ) . eql ( consumerColumns [ i ] , `The ${ i } Consumers info column name not correct ` ) ;
132
125
}
133
- } ) ;
134
- test ( 'Verify that user can navigate to Consumer Groups screen using the link in the breadcrumbs' , async t => {
135
- keyName = chance . word ( { length : 20 } ) ;
136
- consumerGroupName = chance . word ( { length : 20 } ) ;
137
- const cliCommands = [
138
- `XGROUP CREATE ${ keyName } ${ consumerGroupName } $ MKSTREAM` ,
139
- `XADD ${ keyName } * message apple` ,
140
- `XREADGROUP GROUP ${ consumerGroupName } Alice COUNT 1 STREAMS ${ keyName } >`
141
- ] ;
142
- // Add New Stream Key with groups and consumers
143
- for ( const command of cliCommands ) {
144
- await cliPage . sendCommandInCli ( command ) ;
145
- }
146
- // Open Stream consumer info view
147
- await browserPage . openKeyDetails ( keyName ) ;
148
- await t . click ( browserPage . streamTabGroups ) ;
149
- await t . click ( browserPage . consumerGroup ) ;
150
- // Check navigation
126
+ // Verify that user can navigate to Consumer Groups screen using the link in the breadcrumbs
151
127
await t . expect ( browserPage . streamTabs . visible ) . ok ( 'Stream navigation tabs visibility' ) ;
152
128
await t . click ( browserPage . streamTabGroups ) ;
153
- await t . expect ( browserPage . streamTabGroups . withAttribute ( 'aria-selected' , 'true' ) . exists ) . ok ( 'The Consumer Groups screen is opened' ) ;
129
+ await t . expect ( browserPage . streamTabGroups . withAttribute ( 'aria-selected' , 'true' ) . exists ) . ok ( 'The Consumer Groups screen is not opened' ) ;
154
130
} ) ;
155
131
test ( 'Verify that user can delete the Consumer from the Consumer Group' , async t => {
156
- keyName = chance . word ( { length : 20 } ) ;
157
- let consumerGroupName = chance . word ( { length : 20 } ) ;
132
+ keyName = common . generateWord ( 20 ) ;
133
+ const consumerGroupName = common . generateWord ( 20 ) ;
158
134
const cliCommands = [
159
135
`XGROUP CREATE ${ keyName } ${ consumerGroupName } $ MKSTREAM` ,
160
136
`XADD ${ keyName } * message apple` ,
@@ -173,34 +149,13 @@ test('Verify that user can delete the Consumer from the Consumer Group', async t
173
149
// Delete consumer and check results
174
150
const consumerCountBefore = await browserPage . streamConsumerName . count ;
175
151
await t . click ( browserPage . removeConsumerButton ) ;
176
- await t . expect ( browserPage . confirmationMessagePopover . textContent ) . contains ( `will be removed from Consumer Group ${ consumerGroupName } ` , 'The confirmation message' ) ;
152
+ await t . expect ( browserPage . confirmationMessagePopover . textContent ) . contains ( `will be removed from Consumer Group ${ consumerGroupName } ` , 'The confirmation message not displayed ' ) ;
177
153
await t . click ( browserPage . removeConsumerButton . nth ( 2 ) ) ;
178
- await t . expect ( browserPage . streamConsumerName . count ) . eql ( consumerCountBefore - 1 , 'The Consumers number after deletion' ) ;
154
+ await t . expect ( browserPage . streamConsumerName . count ) . eql ( consumerCountBefore - 1 , 'The Consumers number after deletion not correct ' ) ;
179
155
} ) ;
180
156
test ( 'Verify that user can delete a Consumer Group' , async t => {
181
- keyName = chance . word ( { length : 20 } ) ;
182
- let consumerGroupName = chance . word ( { length : 20 } ) ;
183
- const cliCommands = [
184
- `XGROUP CREATE ${ keyName } ${ consumerGroupName } $ MKSTREAM` ,
185
- `XADD ${ keyName } * message apple` ,
186
- `XREADGROUP GROUP ${ consumerGroupName } Alice COUNT 1 STREAMS ${ keyName } >`
187
- ] ;
188
- // Add New Stream Key with groups and consumers
189
- for ( const command of cliCommands ) {
190
- await cliPage . sendCommandInCli ( command ) ;
191
- }
192
- // Open Stream consumer info view
193
- await browserPage . openKeyDetails ( keyName ) ;
194
- await t . click ( browserPage . streamTabGroups ) ;
195
- // Delete consumer group and check results
196
- await t . click ( browserPage . removeConsumerGroupButton ) ;
197
- await t . expect ( browserPage . confirmationMessagePopover . textContent ) . contains ( `${ consumerGroupName } and all its consumers will be removed from ${ keyName } ` , 'The confirmation message' ) ;
198
- await t . click ( browserPage . removeConsumerGroupButton . nth ( 1 ) ) ;
199
- await t . expect ( browserPage . streamGroupsContainer . textContent ) . contains ( 'Your Key has no Consumer Groups available.' , 'The Consumer Group is removed from the table' ) ;
200
- } ) ;
201
- test ( 'Verify that user can change the ID set for the Consumer Group when click on the Pencil button' , async t => {
202
- keyName = chance . word ( { length : 20 } ) ;
203
- let consumerGroupName = chance . word ( { length : 20 } ) ;
157
+ keyName = common . generateWord ( 20 ) ;
158
+ const consumerGroupName = common . generateWord ( 20 ) ;
204
159
const cliCommands = [
205
160
`XGROUP CREATE ${ keyName } ${ consumerGroupName } $ MKSTREAM` ,
206
161
`XADD ${ keyName } * message apple` ,
@@ -213,12 +168,17 @@ test('Verify that user can change the ID set for the Consumer Group when click o
213
168
// Open Stream consumer info view
214
169
await browserPage . openKeyDetails ( keyName ) ;
215
170
await t . click ( browserPage . streamTabGroups ) ;
216
- // Change the ID set for the Consumer Group
171
+ // Verify that user can change the ID set for the Consumer Group when click on the Pencil button
217
172
for ( const id of entryIds ) {
218
173
const idBefore = await browserPage . streamGroupId . textContent ;
219
174
await t . click ( browserPage . editStreamLastIdButton ) ;
220
175
await t . typeText ( browserPage . lastIdInput , id , { replace : true } ) ;
221
176
await t . click ( browserPage . saveButton ) ;
222
- await t . expect ( browserPage . streamGroupId . textContent ) . notEql ( idBefore , 'The last delivered ID is modified and the table is reloaded' ) ;
177
+ await t . expect ( browserPage . streamGroupId . textContent ) . notEql ( idBefore , 'The last delivered ID is modified and the table is not reloaded' ) ;
223
178
}
179
+ // Delete consumer group and check results
180
+ await t . click ( browserPage . removeConsumerGroupButton ) ;
181
+ await t . expect ( browserPage . confirmationMessagePopover . textContent ) . contains ( `${ consumerGroupName } and all its consumers will be removed from ${ keyName } ` , 'The confirmation message not displayed' ) ;
182
+ await t . click ( browserPage . removeConsumerGroupButton . nth ( 1 ) ) ;
183
+ await t . expect ( browserPage . streamGroupsContainer . textContent ) . contains ( 'Your Key has no Consumer Groups available.' , 'The Consumer Group is not removed from the table' ) ;
224
184
} ) ;
0 commit comments