Socialify

Folder ..

Viewing create.spec.js
119 lines (105 loc) • 3.7 KB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const { beforeHelper, afterHelper } = require('./../../helper')

describe('Create credit card entry', function() {
  this.timeout(10000)

  describe('user creates credit card entry', () => {
    before(() => beforeHelper({ storage: 'empty' }))

    after(() => afterHelper())

    it('shows credentials view', () => {
      return expect(
        app.client
          .setValue('input[type=password]', 'password')
          .keys('\uE007')
          .waitForExist('.body .list')
          .getText('.body .list')
      ).to.eventually.equal('No Items')
    })

    it('switches to credit card scope', () => {
      return expect(
        app.client
          .click('.switcher .tooltip-context:nth-child(3) .item')
          .getText('.body .list')
      ).to.eventually.equal('No Items')
    })

    it('shows add credit card form', () => {
      return expect(
        app.client
          .click('.add-button')
          .waitForExist('.aside input[name=title]')
          .waitForExist('.aside input[name=number]')
          .waitForExist('.aside input[name=year]')
          .waitForExist('.aside input[name=month]')
          .waitForExist('.aside input[name=cvc]')
          .waitForExist('.aside input[name=pin]')
          .waitForExist('.aside input[name=name]')
          .getText('.aside .actions')
      ).to.eventually.equal('CancelSave')
    })

    it('highlights title field with error', () => {
      return expect(
        app.client
          .click('.aside .actions .button')
          .isExisting('.field.error:nth-of-type(1)')
      ).to.eventually.equal(true)
    })

    it('highlights credit card number field with error', () => {
      return expect(
        app.client
          .click('.aside .actions .button')
          .isExisting('.field.error:nth-of-type(2)')
      ).to.eventually.equal(true)
    })

    it('cancels entry creation', () => {
      return expect(
        app.client
          .setValue('input[name=title]', 'Example')
          .click('.aside .actions .cancel')
          .isExisting('.list .entry')
      ).to.eventually.equal(false)
    })

    it('hides creation form', () => {
      return expect(app.client.isExisting('.aside .empty')).to.eventually.equal(
        true
      )
    })

    it('opens creation form again', () => {
      return expect(
        app.client
          .click('.add-button')
          .waitForExist('.aside input[name=title]')
          .waitForExist('.aside input[name=number]')
          .waitForExist('.aside input[name=year]')
          .waitForExist('.aside input[name=month]')
          .waitForExist('.aside input[name=cvc]')
          .waitForExist('.aside input[name=pin]')
          .waitForExist('.aside input[name=name]')
          .getText('.aside .actions')
      ).to.eventually.equal('CancelSave')
    })

    it('creates credit card entry', () => {
      return expect(
        app.client
          .setValue('input[name=title]', 'Visa Card')
          .setValue('input[name=number]', '4242424242424242')
          .setValue('input[name=year]', '2050')
          .setValue('input[name=month]', '06')
          .setValue('input[name=cvc]', '123')
          .setValue('input[name=pin]', '1234')
          .setValue('input[name=name]', 'Mister Miyagi')
          .click('.aside .actions .button')
          .getText('.body .list')
      ).to.eventually.equal('Visa Card')
    })

    it('shows details of created credit card', () => {
      return expect(
        app.client.getText('.aside .entry-title h1')
      ).to.eventually.equal('Visa Card')
    })

    it('shows card detail', () => {
      return expect(
        app.client.getText('.aside .entry-details')
      ).to.eventually.equal(
        'Number\n4242 4242 4242 4242\nYear\n2050\nMonth\n06\nCVC\n123\nPin\n1234\nName\nMister Miyagi'
      )
    })
  })
})