all repos — caroster @ 2c780811863358fa4809ec82bf6f0b0834bde5a6

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

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

 1/* eslint-disable class-methods-use-this */
 2'use strict';
 3import {cast} from './utils/cast';
 4export class Page {
 5  constructor(path) {
 6    this._path = path;
 7  }
 8
 9  get name() {
10    return 'undefined';
11  }
12
13  /**
14   * @return {string}
15   */
16  get path() {
17    return this._path;
18  }
19
20  /**
21   * @param {string} path
22   */
23  set path(path) {
24    this._path = path;
25  }
26
27  async open() {
28    console.log('browse url', this.path);
29    await browser.url(this.path);
30    await this.waitForDisplayed();
31  }
32
33  /**
34   *
35   * @param {string} selector
36   */
37  field(selector) {
38    throw new Error('Not implemented for ' + selector);
39  }
40
41  async submit() {
42    const field = this.field('submit');
43    const element = await $(field);
44    await browser.saveScreenshotByName(`${this.name}--filled`);
45    await element.click();
46  }
47
48  /**
49   *
50   * @param {string} selector
51   * @param {string} value
52   * @return {Promise<void>}
53   */
54  async type(selector, value = undefined) {
55    const field = this.field(selector);
56    if (typeof value === 'undefined') value = selector;
57    const element = await $(field);
58    await element.addValue(cast(value));
59  }
60  /**
61   *
62   * @param {string} selector
63   * @param {string} value
64   * @return {Promise<void>}
65   */
66  async pick(selector, value = undefined) {
67    const field = this.field(selector);
68    if (typeof value === 'undefined') value = selector;
69    const range = cast(value);
70    const container = await $(field);
71    const element = await container.$(
72      `.MuiSlider-markLabel[aria-hidden='true'][data-index='${range}']`
73    );
74    await element.click();
75  }
76
77  /**
78   *
79   * @param {string} selector
80   * @return {Promise<void>}
81   */
82  async click(selector) {
83    const field = this.field(selector);
84    const element = await $(field);
85    await element.click();
86  }
87
88  async waitForDisplayed(timeout = 1200) {
89    await new Promise(resolve => {
90      setTimeout(resolve, timeout);
91    });
92    await browser.saveScreenshotByName(this.name);
93  }
94}