@@ -22,6 +22,7 @@ const REASON_LABEL = 'Reason';
2222const SELECT_OPTION_ALL = 'all' ;
2323const TYPE_VM_RECONFIGURE = 'vm_reconfigure' ;
2424const REQUEST_DATE_LAST_7_DAYS = '7' ;
25+ const REQUEST_DATE_LAST_30_DAYS = '30' ;
2526
2627// Checkbox labels
2728const PENDING_APPROVAL_LABEL = 'Pending Approval' ;
@@ -57,11 +58,8 @@ describe('Automate Service Requests form operations: Services > Requests', () =>
5758 } ) ;
5859
5960 describe ( 'Verify form fields' , ( ) => {
60- beforeEach ( ( ) => {
61- cy . menu ( SERVICES_MENU_OPTION , REQUESTS_MENU_OPTION ) ;
62- } ) ;
63-
6461 it ( 'Verify form’s initial UI state' , ( ) => {
62+ cy . menu ( SERVICES_MENU_OPTION , REQUESTS_MENU_OPTION ) ;
6563 cy . contains ( '#main-content h1' , FORM_HEADER ) ;
6664 cy . getFormLegendByText ( { legendText : APPROVAL_STATE_HEADER } ) ;
6765 cy . validateFormLabels ( [
@@ -212,9 +210,10 @@ describe('Automate Service Requests form operations: Services > Requests', () =>
212210 } ) ;
213211
214212 it ( 'Validate reset & apply buttons' , ( ) => {
213+ cy . menu ( SERVICES_MENU_OPTION , REQUESTS_MENU_OPTION ) ;
215214 /* Reset */
216215 cy . getFormSelectFieldById ( { selectId : 'selectedUser' } ) . select (
217- 'Administrator '
216+ 'Test User 1 '
218217 ) ;
219218 cy . getFormLabelByForAttribute ( {
220219 forValue : 'approvalStates-pending_approval' ,
@@ -238,7 +237,7 @@ describe('Automate Service Requests form operations: Services > Requests', () =>
238237 inputType : 'checkbox' ,
239238 } ) . should ( 'not.be.checked' ) ;
240239 cy . getFormSelectFieldById ( { selectId : 'types' } ) . select (
241- TYPE_VM_PROVISION
240+ TYPE_VM_RECONFIGURE
242241 ) ;
243242 cy . getFormSelectFieldById ( { selectId : 'selectedPeriod' } ) . select (
244243 'Last 30 Days'
@@ -278,7 +277,7 @@ describe('Automate Service Requests form operations: Services > Requests', () =>
278277 ''
279278 ) ;
280279 /* Apply */
281- // Filter data with approval state
280+ // Filter data with approval state: Denied
282281 cy . getFormLabelByForAttribute ( {
283282 forValue : 'approvalStates-pending_approval' ,
284283 } ) . click ( ) ;
@@ -297,29 +296,105 @@ describe('Automate Service Requests form operations: Services > Requests', () =>
297296 buttonText : APPLY_BUTTON_TEXT ,
298297 buttonType : 'submit' ,
299298 } ) . click ( ) ;
300- cy . expect_gtl_no_records_with_text ( ) ;
299+ cy . gtlGetRows ( [ 7 ] ) . then ( ( data ) => {
300+ expect ( data . length ) . to . equal ( 1 ) ;
301+ expect ( data [ 0 ] [ 0 ] ) . to . equal ( DENIED_LABEL ) ;
302+ } ) ;
301303 cy . getFormButtonByTypeWithText ( {
302304 buttonText : RESET_BUTTON_TEXT ,
303305 } ) . click ( ) ;
304306 cy . gtlGetRows ( [ 0 ] ) . then ( ( data ) => {
307+ expect ( data . length ) . to . equal ( 3 ) ;
308+ } ) ;
309+ // Filter data with approval state: Approved
310+ cy . getFormLabelByForAttribute ( {
311+ forValue : 'approvalStates-pending_approval' ,
312+ } ) . click ( ) ;
313+ cy . getFormInputFieldByIdAndType ( {
314+ inputId : 'approvalStates-pending_approval' ,
315+ inputType : 'checkbox' ,
316+ } ) . should ( 'not.be.checked' ) ;
317+ cy . getFormLabelByForAttribute ( {
318+ forValue : 'approvalStates-denied' ,
319+ } ) . click ( ) ;
320+ cy . getFormInputFieldByIdAndType ( {
321+ inputId : 'approvalStates-denied' ,
322+ inputType : 'checkbox' ,
323+ } ) . should ( 'not.be.checked' ) ;
324+ cy . getFormButtonByTypeWithText ( {
325+ buttonText : APPLY_BUTTON_TEXT ,
326+ buttonType : 'submit' ,
327+ } ) . click ( ) ;
328+ cy . gtlGetRows ( [ 7 ] ) . then ( ( data ) => {
329+ expect ( data . length ) . to . equal ( 1 ) ;
330+ expect ( data [ 0 ] [ 0 ] ) . to . equal ( APPROVED_LABEL ) ;
331+ } ) ;
332+ cy . getFormButtonByTypeWithText ( {
333+ buttonText : RESET_BUTTON_TEXT ,
334+ } ) . click ( ) ;
335+ cy . gtlGetRows ( [ 0 ] ) . then ( ( data ) => {
336+ expect ( data . length ) . to . equal ( 3 ) ;
337+ } ) ;
338+ // Filter data with approval state: Pending approval
339+ cy . getFormLabelByForAttribute ( {
340+ forValue : 'approvalStates-approved' ,
341+ } ) . click ( ) ;
342+ cy . getFormInputFieldByIdAndType ( {
343+ inputId : 'approvalStates-approved' ,
344+ inputType : 'checkbox' ,
345+ } ) . should ( 'not.be.checked' ) ;
346+ cy . getFormLabelByForAttribute ( {
347+ forValue : 'approvalStates-denied' ,
348+ } ) . click ( ) ;
349+ cy . getFormInputFieldByIdAndType ( {
350+ inputId : 'approvalStates-denied' ,
351+ inputType : 'checkbox' ,
352+ } ) . should ( 'not.be.checked' ) ;
353+ cy . getFormButtonByTypeWithText ( {
354+ buttonText : APPLY_BUTTON_TEXT ,
355+ buttonType : 'submit' ,
356+ } ) . click ( ) ;
357+ cy . gtlGetRows ( [ 7 ] ) . then ( ( data ) => {
305358 expect ( data . length ) . to . equal ( 1 ) ;
359+ expect ( data [ 0 ] [ 0 ] ) . to . equal ( PENDING_APPROVAL_LABEL ) ;
306360 } ) ;
307- // Filter data with type
361+ cy . getFormButtonByTypeWithText ( {
362+ buttonText : RESET_BUTTON_TEXT ,
363+ } ) . click ( ) ;
364+ cy . gtlGetRows ( [ 0 ] ) . then ( ( data ) => {
365+ expect ( data . length ) . to . equal ( 3 ) ;
366+ } ) ;
367+ // Filter data with type: VM Reconfigure
308368 cy . getFormSelectFieldById ( { selectId : 'types' } ) . select (
309- TYPE_VM_PROVISION
369+ TYPE_VM_RECONFIGURE
310370 ) ;
311371 cy . getFormButtonByTypeWithText ( {
312372 buttonText : APPLY_BUTTON_TEXT ,
313373 buttonType : 'submit' ,
314374 } ) . click ( ) ;
315- cy . expect_gtl_no_records_with_text ( ) ;
375+ cy . gtlGetRows ( [ 4 ] ) . then ( ( data ) => {
376+ expect ( data . length ) . to . equal ( 1 ) ;
377+ expect ( data [ 0 ] [ 0 ] ) . to . equal ( 'VM Reconfigure' ) ;
378+ } ) ;
316379 cy . getFormButtonByTypeWithText ( {
317380 buttonText : RESET_BUTTON_TEXT ,
318381 } ) . click ( ) ;
319382 cy . gtlGetRows ( [ 0 ] ) . then ( ( data ) => {
320- expect ( data . length ) . to . equal ( 1 ) ;
383+ expect ( data . length ) . to . equal ( 3 ) ;
321384 } ) ;
322- // Filter data with
385+ // Filter data with request date: last 30 days
386+ cy . getFormSelectFieldById ( { selectId : 'selectedPeriod' } ) . select (
387+ REQUEST_DATE_LAST_30_DAYS
388+ ) ;
389+ cy . getFormButtonByTypeWithText ( {
390+ buttonText : APPLY_BUTTON_TEXT ,
391+ buttonType : 'submit' ,
392+ } ) . click ( ) ;
393+ cy . gtlGetRows ( [ 6 ] ) . then ( ( data ) => {
394+ expect ( data . length ) . to . equal ( 4 ) ;
395+ expect ( data [ 0 ] [ 0 ] ) . to . include ( 'request made in the last 30 days' ) ;
396+ } ) ;
397+ // Filter data with reason text
323398 cy . getFormInputFieldByIdAndType ( { inputId : 'reasonText' } ) . type ( 'r@ndOm' ) ;
324399 cy . getFormButtonByTypeWithText ( {
325400 buttonText : APPLY_BUTTON_TEXT ,
@@ -330,7 +405,7 @@ describe('Automate Service Requests form operations: Services > Requests', () =>
330405 buttonText : RESET_BUTTON_TEXT ,
331406 } ) . click ( ) ;
332407 cy . gtlGetRows ( [ 0 ] ) . then ( ( data ) => {
333- expect ( data . length ) . to . equal ( 1 ) ;
408+ expect ( data . length ) . to . equal ( 3 ) ;
334409 } ) ;
335410 } ) ;
336411
0 commit comments