const expect = require('chai').expect

const dataHelper = require('../helpers/data/aggregated-data-helper')

var offenderManagerId
var offenderManagerUrl

describe('View adding a new reduction', () => {
  before(function () {
    return dataHelper.getAnyExistingWorkloadOwnerId()    
        .then(function (results) {
          offenderManagerId = results
          offenderManagerUrl = '/offender-manager/' + offenderManagerId + '/add-reduction'
        })
  })

 describe('should navigate to the add reduction screen', () => {
    it('with the correct breadcrumbs and heading title', () => {
      return browser.url(offenderManagerUrl)
        .waitForExist('.breadcrumbs')
        .waitForExist('.heading-xlarge')   
        .getText('.heading-xlarge')
        .then(function (text) {
          expect(text).to.equal('New reduction')
        })
    })
  
    it('and submit a new reduction form', () => {
      return browser.url(offenderManagerUrl)
        browser.setValue('#reductionType', 'Reduction 1')
        browser.setValue('#hours', '10')
        browser.setValue('#red_start_day', '1')
        browser.setValue('#red_start_month', '2')
        browser.setValue('#red_start_year', '2017')
        browser.setValue('#red_start_day', '1')
        browser.setValue('#red_start_month', '2')
        browser.setValue('#red_start_year', '2018')        
        browser.setValue('#notes', 'New note')
        browser.submitForm('#reductionForm')
    })   
  })

})


@@ -272,21 +272,17 @@
 wnerId()
-    
 %0A
+
         
@@ -454,16 +454,17 @@
 )%0A  %7D)%0A%0A
+ 
  describ
@@ -516,24 +516,24 @@
 n', () =%3E %7B%0A
-
     it('with
@@ -708,19 +708,16 @@
 xlarge')
-   
 %0A       
@@ -844,19 +844,17 @@
 %0A    %7D)%0A
-  
 %0A
+
     it('
@@ -899,55 +899,8 @@
 %3E %7B%0A
-      return browser.url(offenderManagerUrl)%0A  
     
@@ -949,34 +949,32 @@
 ction 1')%0A      
- 
- 
 browser.setValue
@@ -990,18 +990,16 @@
 , '10')%0A
-  
       br
@@ -1028,34 +1028,32 @@
 tart_day', '1')%0A
-  
       browser.se
@@ -1082,34 +1082,32 @@
 th', '2')%0A      
-  
 browser.setValue
@@ -1134,18 +1134,16 @@
 '2017')%0A
-  
       br
@@ -1178,34 +1178,32 @@
 ay', '1')%0A      
-  
 browser.setValue
@@ -1224,26 +1224,24 @@
 onth', '2')%0A
-  
       browse
@@ -1281,19 +1281,9 @@
 18')
-        %0A  
+%0A
     
@@ -1325,26 +1325,24 @@
 ote')%0A      
- 
- 
 browser.subm
@@ -1376,18 +1376,13 @@
   %7D)
-   
 %0A  %7D)%0A
-%0A
 %7D)%0A
-%0A

fix standard errors