text: const Utils = require('../utils')
  
  describe('Preference Screen Tests', () => {
    before(async () => {
      await device.reloadReactNative()
      await Utils.loginAsUser()
    })
    after(async () => {
      await element(by.type('_UIBackButtonContainerView')).tap()
      await element(by.type('_UIBackButtonContainerView')).tap()
      await Utils.logout()
    })
  
    beforeEach(async () => {
      await device.reloadReactNative()
      await navigateToPreferenceScreen()
    })
  
    const navigateToPreferenceScreen = async () => {
      await expect(element(by.id('launchScreen'))).toBeVisible()
      await element(by.id('menuButton')).tap()
      await element(by.id('entitiesDrawerButton')).tap()
      await element(by.id('preferenceEntityScreenButton')).tap()
    }
  
    it('should allow you to create an entity', async () => {
      await expect(element(by.id('preferenceScreen'))).toBeVisible()
      await expect(element(by.text('Create'))).toBeVisible()
      // create
      await element(by.text('Create').and(by.type('UIButtonLabel'))).tap()
      await element(by.id('weeklyGoalInput')).replaceText('123')
      await waitFor(element(by.id('submitButton'))).toBeVisible().whileElement(by.id('entityScrollView')).scroll(50, 'down')
      await element(by.id('submitButton')).tap()
      await element(by.text('View')).tap()
      await expect(element(by.id('weeklyGoal'))).toHaveText('WeeklyGoal: 123')
      // update
      await element(by.text('EDIT')).tap()
      await element(by.id('weeklyGoalInput')).replaceText('1234')
      await waitFor(element(by.id('submitButton'))).toBeVisible().whileElement(by.id('entityScrollView')).scroll(50, 'down')
      await element(by.id('submitButton')).tap()
      await element(by.text('OK')).tap()
      await expect(element(by.id('weeklyGoal'))).toHaveText('WeeklyGoal: 1234')
      // delete
      await element(by.text('DELETE')).tap()
      await element(by.text('OK')).tap()
      await expect(element(by.id('preferenceScreen'))).toBeVisible()
    })
  })
  