Socialify

Folder ..

Viewing create.spec.js
74 lines (64 loc) • 2.2 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
const { beforeHelper, afterHelper } = require('./../../helper')

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

  describe('user createst credentials entry', () => {
    before(() => beforeHelper({ storage: 'empty' }))

    after(() => afterHelper())

    it('shows credentials form', () => {
      return expect(
        app.client
          .setValue('input[type=password]', 'password')
          .keys("\uE007")
          .waitForExist('.body .list .empty')
          .click('.add-button')
          .getText('.aside .actions')
      ).to.eventually.equal('CancelSave')
    })
    
    it('shows validation errors', () => {
      return expect(
        app.client
          .click('.aside .actions .button')
          .isExisting('.field.error:nth-of-type(3)')
      ).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('input[name=title]')
          .getValue('input[name=title]')
      ).to.eventually.equal('')
    })

    it('creates credentials entry', () => {
      return expect(
        app.client
          .setValue('input[name=title]', 'Example')
          .setValue('input[name=website]', 'https://example.com')
          .setValue('input[name=username]', 'myuser')
          .setValue('input[name=password]', 'mypassword')
          .click('.aside .actions .button')
          .getText('.body .list')
      ).to.eventually.equal('Example\nmyuser')
    })

    it('displays show view instead of form', () => {
      return expect(
        app.client
          .waitForExist('.entry-details')
          .getText('.entry-details')
      ).to.eventually.equal(`Website\nhttps://example.com\nUsername\nmyuser\nPassword\nmypassword`)
    })
  })
})