Socialify

Folder ..

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

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

  describe('user creates note 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 note scope', () => {
      return expect(
        app.client
          .click('.switcher .tooltip-context:nth-child(2)')
          .getText('.body .list')
      ).to.eventually.equal('No Items')
    })

    it('shows add note form', () => {
      return expect(
        app.client
          .click('.add-button')
          .waitForExist('.aside input[name=title]')
          .waitForExist('.aside textarea[name=note]')
          .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 note 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 textarea[name=note]')
          .getText('.aside .actions')
      ).to.eventually.equal('CancelSave')
    })

    it('creates note entry', () => {
      return expect(
        app.client
          .setValue('input[name=title]', 'Example')
          .setValue('textarea[name=note]', 'This is secure note')
          .click('.aside .actions .button')
          .getText('.body .list')
      ).to.eventually.equal('Example')
    })

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