
import moment from 'moment'

describe('Availability spec', function() {
  beforeEach(() => {
    cy.app('clean') // have a look at cypress/app_commands/clean.rb
    cy.appEval('ActiveJob::Base.queue_adapter = :test')
    cy.appEval('ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true')
  })

  it('next week', function() {
    cy.appScenario('basic')
    const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
    const yesterday = moment().add(-1, 'hours')
    const weekday = days[yesterday._d.getDay()]

    cy.appEval(`App.last.update(timezone: 'UTC', 
    team_schedule: [{ day: "${weekday.toLowerCase()}", from: '01:00' , to: '01:30' }])`)
    
    cy.appEval("App.last").then((results) => {
      const appKey = results.key
      cy.visit(`/tester/${appKey}`).then(()=>{
        cy.get('iframe:first')
        .then(function ($iframe) {
            const $body = $iframe.contents().find('body')
            cy.wrap($body).find("#chaskiq-prime").click()
        })
        cy.get('iframe:first')
        .then(function ($iframe) {
            const $body = $iframe.contents().find('body')
            expect($body.html()).to.contain("next week")
        })
      })
    })

    cy.appEval("App.last").then((results) => {
      const appKey = results.key
      cy.visit(`/tester/${appKey}?lang=es`).then(()=>{
        cy.get('iframe:first')
        .then(function ($iframe) {
            const $body = $iframe.contents().find('body')
            cy.wrap($body).find("#chaskiq-prime").click()
        })
        cy.get('iframe:first')
        .then(function ($iframe) {
            const $body = $iframe.contents().find('body')
            expect($body.html()).to.contain("proxima semana")
        })
      })
    })

  })


})
@@ -423,16 +423,41 @@
  'Sat'%5D%0A
+    const now = moment()%0A
     cons
@@ -470,24 +470,19 @@
 erday = 
-moment()
+now
 .add(-1,
@@ -540,16 +540,203 @@
 Day()%5D%0A%0A
+    const startTime = %60$%7Bnow._d.getHours()%7D:$%7Bnow._d.getMinutes()%7D%60%0A%0A    const moremin = now.add(30, 'minutes')%0A    const endTime = %60$%7Bmoremin._d.getHours()%7D:$%7Bmoremin._d.getMinutes()%7D%60%0A%0A
     cy.a
@@ -842,29 +842,40 @@
 om: 
-'01:00' , to: '01:30'
+%22$%7BstartTime%7D%22, to: %22$%7BendTime%7D%22
  %7D%5D)

Update availability.spec.js