aboutsummaryrefslogtreecommitdiffstats
path: root/test/integration/lib/mascara-first-time.js
blob: 564852585603a64fea37c184b7a433932551e5d6 (plain) (blame)
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
const PASSWORD = 'password123'
const reactTriggerChange = require('react-trigger-change')
const {
  timeout,
  findAsync,
  queryAsync,
} = require('../../lib/util')

async function runFirstTimeUsageTest (assert, done) {
  await timeout(4000)

  const app = await queryAsync($, '#app-content')

  await skipNotices(app)

  // Scroll through terms
  const title = (await findAsync(app, '.create-password__title')).text()
  assert.equal(title, 'Create Password', 'create password screen')

  // enter password
  const pwBox = (await findAsync(app, '.first-time-flow__input'))[0]
  const confBox = (await findAsync(app, '.first-time-flow__input'))[1]
  pwBox.value = PASSWORD
  confBox.value = PASSWORD
  reactTriggerChange(pwBox)
  reactTriggerChange(confBox)

  // Create Password
  const createButton = (await findAsync(app, 'button.first-time-flow__button'))[0]
  createButton.click()

  const created = (await findAsync(app, '.unique-image__title'))[0]
  assert.equal(created.textContent, 'Your unique account image', 'unique image screen')

  // Agree button
  let button = (await findAsync(app, 'button'))[0]
  assert.ok(button, 'button present')
  button.click()

  await skipNotices(app)

  // secret backup phrase
  const seedTitle = (await findAsync(app, '.backup-phrase__title'))[0]
  assert.equal(seedTitle.textContent, 'Secret Backup Phrase', 'seed phrase screen')
  ;(await findAsync(app, '.backup-phrase__reveal-button')).click()
  const seedPhrase = (await findAsync(app, '.backup-phrase__secret-words')).text().split(' ')
  ;(await findAsync(app, '.first-time-flow__button')).click()

  await timeout()
  const selectPhrase = text => {
    const option = $('.backup-phrase__confirm-seed-option')
      .filter((i, d) => d.textContent === text)[0]
    $(option).click()
  }

  seedPhrase.forEach(sp => selectPhrase(sp))
  ;(await findAsync(app, '.first-time-flow__button')).click()

  // Deposit Ether Screen
  const depositEthTitle = (await findAsync(app, '.page-container__title'))[0]
  assert.equal(depositEthTitle.textContent, 'Deposit Ether', 'deposit ether screen')
  ;(await findAsync(app, '.page-container__header-close')).click()

  const menu = (await findAsync(app, '.account-menu__icon'))[0]
  menu.click()

  const lock = (await findAsync(app, '.account-menu__logout-button'))[0]
  assert.ok(lock, 'Lock menu item found')
  lock.click()

  const pwBox2 = (await findAsync(app, '#password-box'))[0]
  pwBox2.value = PASSWORD

  const createButton2 = (await findAsync(app, 'button.primary'))[0]
  createButton2.click()

  const detail2 = (await findAsync(app, '.wallet-view'))[0]
  assert.ok(detail2, 'Account detail section loaded again.')

  // open account settings dropdown
  const qrButton = (await findAsync(app, '.wallet-view__details-button'))[0]
  qrButton.click()

  const qrHeader = (await findAsync(app, '.editable-label__value'))[0]
  const qrContainer = (await findAsync(app, '.qr-wrapper'))[0]
  assert.equal(qrHeader.textContent, 'Account 1', 'Should show account label.')
  assert.ok(qrContainer, 'QR Container found')

  const networkMenu = (await findAsync(app, '.network-component'))[0]
  networkMenu.click()

  const networkMenu2 = (await findAsync(app, '.network-indicator'))[0]
  const children2 = networkMenu2.children
  children2.length[3]
  assert.ok(children2, 'All network options present')
}

module.exports = runFirstTimeUsageTest

async function skipNotices (app) {
  while (true) {
    const button = await findAsync(app, 'button')
    if (button && button.html() === 'Accept') {
      // still notices to accept
      const termsPage = (await findAsync(app, '.markdown'))[0]
      if (!termsPage) {
        break
      }
      termsPage.scrollTop = termsPage.scrollHeight
      await timeout()
      button.click()
      await timeout()
    } else {
      console.log('No more notices...')
      break
    }
  }
}