all repos — caroster @ f23ba3d49ddd49492d4bb06c4a345acf3ec0235c

[Octree] Group carpool to your event https://caroster.io

e2e/test/pages/mail.js (view raw)

 1'use strict'
 2
 3/* global browser, $ */
 4/* eslint-disable class-methods-use-this */
 5
 6class Mail {
 7  get recipient() {
 8    return $('#recipient')
 9  }
10  get subject() {
11    return $('#subject')
12  }
13  get content() {
14    return $('#content')
15  }
16  get attachments() {
17    return $('#attachments')
18  }
19  get submit() {
20    return $('#submit')
21  }
22  get result() {
23    return $('#result')
24  }
25  get back() {
26    return $('#back').$('a')
27  }
28  get logoutButton() {
29    return $('#logout')
30  }
31  get password() {
32    return $('#password')
33  }
34  /**
35   * Opens the mail form.
36   *
37   * @param {number} [timeout] Wait timeout
38   * @returns {Mail} Mail object
39   */
40  open(timeout) {
41    browser.url('/')
42    this.recipient.waitForExist({ timeout })
43    return this
44  }
45  /**
46   * Sends mail.
47   *
48   * @param {string} recipient Mail recipient
49   * @param {string} [subject] Mail subject
50   * @param {string} [content] Mail text content
51   * @param {Array<string>} [attachments] Mail attachments
52   * @param {number} [timeout] Wait timeout
53   * @returns {Mail} Mail object
54   */
55  send(recipient, subject, content, attachments, timeout) {
56    this.recipient.setValue(recipient)
57    if (subject) this.subject.setValue(subject)
58    if (content) this.content.setValue(content)
59    if (attachments) this.attachments.addValue(attachments.join('\n'))
60    this.submit.scrollIntoView()
61    this.submit.click()
62    this.result.waitForExist({ timeout })
63    return this
64  }
65  /**
66   * Returns to the mail form.
67   *
68   * @param {number} [timeout] Wait timeout
69   * @returns {Mail} Mail object
70   */
71  return(timeout) {
72    this.back.click()
73    this.recipient.waitForExist({ timeout })
74    return this
75  }
76  /**
77   * Performs signout.
78   *
79   * @param {number} [timeout] Wait timeout
80   * @returns {Mail} Mail object
81   */
82  logout(timeout) {
83    this.logoutButton.click()
84    this.password.waitForExist({ timeout })
85    return this
86  }
87}
88
89module.exports = new Mail()