aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/po/signup.po.ts
blob: 4da35a7d457431a251f5164425a0c00c6b1f55b8 (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
import { getCheckbox } from '../utils'

export class SignupPage {

  getRegisterMenuButton () {
    return $('.create-account-button')
  }

  async clickOnRegisterInMenu () {
    const button = this.getRegisterMenuButton()

    await button.waitForClickable()
    await button.click()
  }

  async validateStep () {
    const next = $('button[type=submit]')

    await next.waitForClickable()
    await next.click()
  }

  async checkTerms () {
    const terms = await getCheckbox('terms')
    await terms.waitForClickable()

    return terms.click()
  }

  async getEndMessage () {
    const alert = $('.pt-alert-primary')
    await alert.waitForDisplayed()

    return alert.getText()
  }

  async fillRegistrationReason (reason: string) {
    await $('#registrationReason').setValue(reason)
  }

  async fillAccountStep (options: {
    username: string
    password?: string
    displayName?: string
    email?: string
  }) {
    await $('#displayName').setValue(options.displayName || `${options.username} display name`)

    await $('#username').setValue(options.username)
    await $('#password').setValue(options.password || 'password')

    // Fix weird bug on firefox that "cannot scroll into view" when using just `setValue`
    await $('#email').scrollIntoView({ block: 'center' })
    await $('#email').waitForClickable()
    await $('#email').setValue(options.email || `${options.username}@example.com`)
  }

  async fillChannelStep (options: {
    name: string
    displayName?: string
  }) {
    await $('#displayName').setValue(options.displayName || `${options.name} channel display name`)
    await $('#name').setValue(options.name)
  }

  async fullSignup ({ accountInfo, channelInfo }: {
    accountInfo: {
      username: string
      password?: string
      displayName?: string
      email?: string
    }
    channelInfo: {
      name: string
    }
  }) {
    await this.clickOnRegisterInMenu()
    await this.validateStep()
    await this.checkTerms()
    await this.validateStep()
    await this.fillAccountStep(accountInfo)
    await this.validateStep()
    await this.fillChannelStep(channelInfo)
    await this.validateStep()
    await this.getEndMessage()
  }
}