Open platform to collect and prioritize feedback
tooling: extend prettier to e2e tests (#333)
Guilherme Oenning864f0048cdad
diff --git a/Makefile b/Makefileindex fb3deaff0..585041ec3 100644--- a/Makefile+++ b/Makefile@@ -7,10 +7,10 @@ build:npx webpack -plint:- npx tslint -c tslint.json 'public/**/*.{ts,tsx}'+ npx tslint -c tslint.json 'public/**/*.{ts,tsx}' 'tests/**/*.{ts,tsx}'lint-fix:- npx tslint -c tslint.json 'public/**/*.{ts,tsx}' --fix+ npx tslint -c tslint.json 'public/**/*.{ts,tsx}' 'tests/**/*.{ts,tsx}' --fix# Testingtest:diff --git a/main.go b/main.goindex 9bae3ca99..2a15b3598 100644--- a/main.go+++ b/main.go@@ -13,7 +13,7 @@ import ()var buildtime string-var version = "0.11.0"+var version = "0.12.0-beta"func main() {fmt.Printf("Application is starting...\n")diff --git a/tests/components/CommentList.ts b/tests/components/CommentList.tsindex b43bf26a6..2e67dc715 100644--- a/tests/components/CommentList.ts+++ b/tests/components/CommentList.ts@@ -1,12 +1,8 @@-import { WebElement, By } from 'selenium-webdriver';-import { Browser, WebComponent } from '../lib';+import { WebElement, By } from "selenium-webdriver";+import { Browser, WebComponent } from "../lib";export class CommentList {- constructor(- private elements: Promise<WebElement[]>,- private selector: string,- private browser: Browser) {- }+ constructor(private elements: Promise<WebElement[]>, private selector: string, private browser: Browser) {}public async count(): Promise<number> {return (await this.elements).length;diff --git a/tests/components/IdeaList.ts b/tests/components/IdeaList.tsindex 150952ef9..ede9a4805 100644--- a/tests/components/IdeaList.ts+++ b/tests/components/IdeaList.ts@@ -1,24 +1,20 @@-import { WebElement, By } from 'selenium-webdriver';-import { Browser, WebComponent, WaitCondition } from '../lib';+import { WebElement, By } from "selenium-webdriver";+import { Browser, WebComponent, WaitCondition } from "../lib";export class IdeaList {- constructor(- private elements: Promise<WebElement[]>,- private selector: string,- private browser: Browser) {- }+ constructor(private elements: Promise<WebElement[]>, private selector: string, private browser: Browser) {}public async want(index: number) {- await (await this.elements)[index].findElement(By.css('.c-support-counter button')).click();+ await (await this.elements)[index].findElement(By.css(".c-support-counter button")).click();}public async navigateAndWait(index: number, condition: WaitCondition) {- await (await this.elements)[index].findElement(By.css('a.title')).click();+ await (await this.elements)[index].findElement(By.css("a.title")).click();await this.browser.wait(condition);}public async at(index: number): Promise<WebComponent> {- const selector = '.c-support-counter button';+ const selector = ".c-support-counter button";const counter = (await this.elements)[index].findElement(By.css(selector));return new WebComponent(counter, selector);}diff --git a/tests/config.ts b/tests/config.tsindex e15280e68..8b7c3e9cd 100644--- a/tests/config.ts+++ b/tests/config.ts@@ -1,5 +1,5 @@const config = {- baseUrl: process.env.BASE_URL || 'http://demo.dev.fider.io:3000'+ baseUrl: process.env.BASE_URL || "http://demo.dev.fider.io:3000"};export default config;diff --git a/tests/context.ts b/tests/context.tsindex 9616c166d..f73f1dccb 100644--- a/tests/context.ts+++ b/tests/context.ts@@ -1,5 +1,5 @@-import { Browser } from './lib';-import { AllPages } from './pages';+import { Browser } from "./lib";+import { AllPages } from "./pages";export let pages: AllPages;export let browser: Browser;@@ -14,8 +14,8 @@ export const setBrowser = (value: Browser) => {};export const setTenant = (value: string) => {- if (process.env.HOST_MODE === 'single') {- tenant = 'login';+ if (process.env.HOST_MODE === "single") {+ tenant = "login";} else {tenant = value;}diff --git a/tests/e2e-multi.ts b/tests/e2e-multi.tsindex 9d4e17798..df7eb830a 100644--- a/tests/e2e-multi.ts+++ b/tests/e2e-multi.ts@@ -1,3 +1,3 @@-process.env.HOST_MODE = 'multi';-require('./testcases/email-signup');-require('./testcases/entry');+process.env.HOST_MODE = "multi";+require("./testcases/email-signup");+require("./testcases/entry");diff --git a/tests/e2e-single.ts b/tests/e2e-single.tsindex bee5bc4bf..cb4c7dddc 100644--- a/tests/e2e-single.ts+++ b/tests/e2e-single.ts@@ -1,2 +1,2 @@-process.env.HOST_MODE = 'single';-require('./testcases/entry');+process.env.HOST_MODE = "single";+require("./testcases/entry");diff --git a/tests/lib/browser.ts b/tests/lib/browser.tsindex 194562a8f..66b5dc6a2 100644--- a/tests/lib/browser.ts+++ b/tests/lib/browser.ts@@ -1,11 +1,15 @@-import 'chromedriver';-import { Builder, ThenableWebDriver, WebElement, Capabilities, By, WebElementPromise } from 'selenium-webdriver';-import { Page, NewablePage, WebComponent, WaitCondition, timeout } from './';+import "chromedriver";+import { Builder, ThenableWebDriver, WebElement, Capabilities, By, WebElementPromise } from "selenium-webdriver";+import { Page, NewablePage, WebComponent, WaitCondition, timeout } from "./";export class Browser {private driver: ThenableWebDriver;public constructor(private browserName: string) {- this.driver = new Builder().forBrowser('chrome').build();+ this.driver = new Builder().forBrowser("chrome").build();+ this.driver+ .manage()+ .timeouts()+ .implicitlyWait(2000);}public async navigate(url: string): Promise<void> {@@ -31,7 +35,7 @@ export class Browser {}public async switchTo(element: string | WebElement): Promise<void> {- if (typeof element === 'string') {+ if (typeof element === "string") {await this.driver.switchTo().frame(this.findElement(element));} else {return await this.driver.switchTo().frame(element);@@ -43,12 +47,12 @@ export class Browser {}public async waitAny(conditions: WaitCondition | WaitCondition[]): Promise<void> {- const all = (!(conditions instanceof Array)) ? [ conditions ] : conditions;+ const all = !(conditions instanceof Array) ? [conditions] : conditions;await this.driver.wait(async () => {for (const condition of all) {try {- if (await condition(this) === true) {+ if ((await condition(this)) === true) {return true;}continue;diff --git a/tests/lib/components.ts b/tests/lib/components.tsindex 8c03683cf..574f12913 100644--- a/tests/lib/components.ts+++ b/tests/lib/components.ts@@ -1,14 +1,14 @@-import { WebElementPromise, Key, By } from 'selenium-webdriver';+import { WebElementPromise, Key, By } from "selenium-webdriver";export class WebComponent {- constructor(protected element: WebElementPromise, public selector: string) { }+ constructor(protected element: WebElementPromise, public selector: string) {}public async click() {try {return await this.element.click();} catch (clickErr) {try {- await this.element.getDriver().executeScript('arguments[0].click();', this.element);+ await this.element.getDriver().executeScript("arguments[0].click();", this.element);} catch (jsErr) {throw clickErr;}@@ -28,8 +28,8 @@ export class WebComponent {}public async getText() {- if (await this.element.getTagName() === 'input') {- return await this.element.getAttribute('value');+ if ((await this.element.getTagName()) === "input") {+ return await this.element.getAttribute("value");}return await this.element.getText();}@@ -42,7 +42,7 @@ export class Button extends WebComponent {public async isDisabled() {try {- return await this.element.getAttribute('disabled') === 'disabled';+ return (await this.element.getAttribute("disabled")) === "disabled";} catch (ex) {return false;}@@ -55,9 +55,9 @@ export class DropDownList extends WebComponent {}public async selectByText(text: string) {- const options = await this.element.findElements(By.tagName('option'));+ const options = await this.element.findElements(By.tagName("option"));for (const option of options) {- if (await option.getText() === text) {+ if ((await option.getText()) === text) {return await option.click();}}diff --git a/tests/lib/conditions.ts b/tests/lib/conditions.tsindex 7058492c0..0e92084b0 100644--- a/tests/lib/conditions.ts+++ b/tests/lib/conditions.ts@@ -1,4 +1,4 @@-import { Browser, WebComponent, NewablePage, Page } from './';+import { Browser, WebComponent, NewablePage, Page } from "./";export type WaitCondition = (browser: Browser) => Promise<boolean>;@@ -7,11 +7,11 @@ export function elementIsVisible(locator: () => WebComponent): WaitCondition {}export function elementIsNotVisible(locator: () => WebComponent): WaitCondition {- return async () => await locator().isDisplayed() === false;+ return async () => (await locator().isDisplayed()) === false;}export function elementIsPresent(locator: () => WebComponent): WaitCondition {- return async () => await locator() !== undefined;+ return async () => (await locator()) !== undefined;}export function pageHasLoaded<T extends Page>(page: NewablePage<T>): WaitCondition {diff --git a/tests/lib/ensure.ts b/tests/lib/ensure.tsindex 9e7346321..12e1d8379 100644--- a/tests/lib/ensure.ts+++ b/tests/lib/ensure.ts@@ -1,5 +1,5 @@-import { WebElementPromise } from 'selenium-webdriver';-import { WebComponent, Button, TextInput, delay } from './';+import { WebElementPromise } from "selenium-webdriver";+import { WebComponent, Button, TextInput, delay } from "./";class WebComponentEnsurer {public async retry(fn: () => Promise<void>) {@@ -17,8 +17,7 @@ class WebComponentEnsurer {throw lastErr;}- constructor(private component: WebComponent) {- }+ constructor(private component: WebComponent) {}public async textIs(expected: string) {await this.retry(async () => {@@ -35,7 +34,9 @@ class WebComponentEnsurer {const value = await this.component.getAttribute(attrName);if (value.trim() !== expected.trim()) {- throw new Error(`Element ${this.component.selector} attribute '${attrName}' is '${value}'. Expected value is '${expected}'`);+ throw new Error(+ `Element ${this.component.selector} attribute '${attrName}' is '${value}'. Expected value is '${expected}'`+ );}});}@@ -83,9 +84,9 @@ export function ensure(component: Button): ButtonEnsurer;export function ensure(component: TextInput): TextInputEnsurer;export function ensure(component: WebComponent): WebComponentEnsurer;export function ensure(component: WebComponent | Button): any {- if (component instanceof Button) {- return new ButtonEnsurer(component);- } else if (component instanceof WebComponent) {- return new WebComponentEnsurer(component);- }+ if (component instanceof Button) {+ return new ButtonEnsurer(component);+ } else if (component instanceof WebComponent) {+ return new WebComponentEnsurer(component);+ }}diff --git a/tests/lib/index.ts b/tests/lib/index.tsindex 3618507ef..9b19d737c 100644--- a/tests/lib/index.ts+++ b/tests/lib/index.ts@@ -1,7 +1,7 @@-export * from './page';-export * from './browser';-export * from './utils';-export * from './ensure';-export * from './components';-export * from './conditions';-export * from './mailgun';+export * from "./page";+export * from "./browser";+export * from "./utils";+export * from "./ensure";+export * from "./components";+export * from "./conditions";+export * from "./mailgun";diff --git a/tests/lib/mailgun/index.ts b/tests/lib/mailgun/index.tsindex b084f4ea7..e80c73148 100644--- a/tests/lib/mailgun/index.ts+++ b/tests/lib/mailgun/index.ts@@ -1,8 +1,8 @@-require('dotenv').config();-import { parse as parseURL } from 'url';-import * as http from 'http';-import * as https from 'https';-import { delay } from '../';+require("dotenv").config();+import { parse as parseURL } from "url";+import * as http from "http";+import * as https from "https";+import { delay } from "../";const httpGet = (endpoint: string): Promise<any> => {const url = parseURL(endpoint);@@ -10,26 +10,28 @@ const httpGet = (endpoint: string): Promise<any> => {const opts = {host: url.host,port: 443,- method: 'GET',+ method: "GET",auth: `api:${process.env.EMAIL_MAILGUN_API}`,- path: url.path,+ path: url.path};https.get(opts, (res: http.IncomingMessage) => {const content: any[] = [];- res.on('data', (chunk) => content.push(chunk));- res.on('end', () => resolve(JSON.parse(content.join(''))));+ res.on("data", chunk => content.push(chunk));+ res.on("end", () => resolve(JSON.parse(content.join(""))));});});};export const mailgun = {getLinkFromLastEmailTo: async (to: string): Promise<string> => {- let messageUrl = '';+ let messageUrl = "";let count = 0;do {count++;- const url = `https://api.mailgun.net/v3/${process.env.EMAIL_MAILGUN_DOMAIN}/events?to=${to}&event=accepted&limit=1&ascending=no`;+ const url = `https://api.mailgun.net/v3/${+ process.env.EMAIL_MAILGUN_DOMAIN+ }/events?to=${to}&event=accepted&limit=1&ascending=no`;const events = await httpGet(url);if (events.items.length > 0 && events.items[0].recipient === to) {messageUrl = events.items[0].storage.url;@@ -44,11 +46,11 @@ export const mailgun = {const messages = await httpGet(messageUrl);- const matches = /<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/.exec(messages['body-html']);+ const matches = /<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/.exec(messages["body-html"]);if (matches) {return matches[2];}- return '';+ return "";}};diff --git a/tests/lib/mocha-bdd.ts b/tests/lib/mocha-bdd.tsindex f9a164f22..fb566c76c 100644--- a/tests/lib/mocha-bdd.ts+++ b/tests/lib/mocha-bdd.ts@@ -1,4 +1,4 @@-import { ISuiteCallbackContext } from 'mocha';+import { ISuiteCallbackContext } from "mocha";export const specification = (name: string, callback: (this: ISuiteCallbackContext) => void) => {return describe(`Specification: ${name}`, callback);diff --git a/tests/lib/page.ts b/tests/lib/page.tsindex cfb9e52c8..32a0d14bb 100644--- a/tests/lib/page.ts+++ b/tests/lib/page.ts@@ -1,11 +1,10 @@-import { Browser, WaitCondition } from './';+import { Browser, WaitCondition } from "./";export interface NewablePage<T extends Page> {- new(browser: Browser): T;+ new (browser: Browser): T;}export abstract class Page {-public async navigate(): Promise<void> {await this.browser.navigate(this.getUrl());await this.browser.wait(this.loadCondition());@@ -13,10 +12,8 @@ export abstract class Page {public abstract loadCondition(): WaitCondition;protected getUrl(): string {- throw new Error('getUrl not implemented');+ throw new Error("getUrl not implemented");}- public constructor(protected browser: Browser) {-- }+ public constructor(protected browser: Browser) {}}diff --git a/tests/lib/utils.ts b/tests/lib/utils.tsindex cd520434c..3e54668bd 100644--- a/tests/lib/utils.ts+++ b/tests/lib/utils.ts@@ -1,41 +1,41 @@-import 'reflect-metadata';-import { ThenableWebDriver, WebElementPromise } from 'selenium-webdriver';-import { Browser } from './';+import "reflect-metadata";+import { ThenableWebDriver, WebElementPromise } from "selenium-webdriver";+import { Browser } from "./";export const delay = (ms: number) => {- return new Promise((resolve) => setTimeout(resolve, ms));+ return new Promise(resolve => setTimeout(resolve, ms));};export const timeout = (ms: number) => {- return new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), ms));+ return new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), ms));};-export function findBy(selector: string, t?: new(element: WebElementPromise, selector: string) => any) {+export function findBy(selector: string, t?: new (element: WebElementPromise, selector: string) => any) {return (target: any, propertyKey: string) => {- const type = Reflect.getMetadata('design:type', target, propertyKey);+ const type = Reflect.getMetadata("design:type", target, propertyKey);Object.defineProperty(target, propertyKey, {- configurable: true,- enumerable: true,- get() {- const browser = (this as any).browser;- const promise = (browser as Browser).findElement(selector);- return new type(promise, selector, browser);- },+ configurable: true,+ enumerable: true,+ get() {+ const browser = (this as any).browser;+ const promise = (browser as Browser).findElement(selector);+ return new type(promise, selector, browser);+ }});};}-export function findMultipleBy(selector: string, t?: new(element: WebElementPromise, selector: string) => any) {+export function findMultipleBy(selector: string, t?: new (element: WebElementPromise, selector: string) => any) {return (target: any, propertyKey: string) => {- const type = Reflect.getMetadata('design:type', target, propertyKey);+ const type = Reflect.getMetadata("design:type", target, propertyKey);Object.defineProperty(target, propertyKey, {- configurable: true,- enumerable: true,- get() {- const browser = (this as any).browser;- const promise = (browser as Browser).findElements(selector);- return new type(promise, selector, browser);- },+ configurable: true,+ enumerable: true,+ get() {+ const browser = (this as any).browser;+ const promise = (browser as Browser).findElements(selector);+ return new type(promise, selector, browser);+ }});};}diff --git a/tests/pages/AdminSettingsPage.ts b/tests/pages/AdminSettingsPage.tsindex 55e17c1e7..feafcb070 100644--- a/tests/pages/AdminSettingsPage.ts+++ b/tests/pages/AdminSettingsPage.ts@@ -1,5 +1,16 @@-import { WebComponent, Browser, Page, findBy, findMultipleBy, Button, TextInput, elementIsVisible, elementIsNotVisible, pageHasLoaded } from '../lib';-import { tenant } from '../context';+import {+ WebComponent,+ Browser,+ Page,+ findBy,+ findMultipleBy,+ Button,+ TextInput,+ elementIsVisible,+ elementIsNotVisible,+ pageHasLoaded+} from "../lib";+import { tenant } from "../context";export class AdminSettingsPage extends Page {constructor(browser: Browser) {@@ -10,17 +21,10 @@ export class AdminSettingsPage extends Page {return `http://${tenant}.dev.fider.io:3000/admin`;}- @findBy('#title')- public TitleInput!: TextInput;-- @findBy('#welcome-message')- public WelcomeMessageInput!: TextInput;-- @findBy('#invitation')- public InvitationInput!: TextInput;-- @findBy('button.green')- public ConfirmButton!: Button;+ @findBy("#title") public TitleInput!: TextInput;+ @findBy("#welcome-message") public WelcomeMessageInput!: TextInput;+ @findBy("#invitation") public InvitationInput!: TextInput;+ @findBy("button.green") public ConfirmButton!: Button;public loadCondition() {return elementIsVisible(() => this.TitleInput);diff --git a/tests/pages/FacebookSignInPage.ts b/tests/pages/FacebookSignInPage.tsindex 46cb2ab75..7f3cbfcc0 100644--- a/tests/pages/FacebookSignInPage.ts+++ b/tests/pages/FacebookSignInPage.ts@@ -1,40 +1,32 @@-import { TextInput, Button, Browser, WebComponent, Page, findBy, elementIsPresent, pageHasLoaded } from '../lib';-import { HomePage, SignUpPage } from './';-import config from '../config';+import { TextInput, Button, Browser, WebComponent, Page, findBy, elementIsPresent, pageHasLoaded } from "../lib";+import { HomePage, SignUpPage } from "./";+import config from "../config";export class FacebookSignInPage extends Page {constructor(browser: Browser) {super(browser);}- @findBy('#email')- public Email!: TextInput;-- @findBy('input[type="password"]')- public Password!: TextInput;-- @findBy('#loginbutton')- public Confirm!: Button;+ @findBy("#email") public Email!: TextInput;+ @findBy('input[type="password"]') public Password!: TextInput;+ @findBy("#loginbutton") public Confirm!: Button;public loadCondition() {return elementIsPresent(() => this.Email);}public async signInAsJonSnow() {- await this.signInAs('[email protected]', 'jon_jdrtrsd_snow');+ await this.signInAs("[email protected]", "jon_jdrtrsd_snow");}public async signInAsAryaStark() {- await this.signInAs('[email protected]', 'arya_xittsrj_stark');+ await this.signInAs("[email protected]", "arya_xittsrj_stark");}public async signInAs(email: string, password: string) {await this.Email.type(email);await this.Password.type(password);await this.Confirm.click();- await this.browser.waitAny([- pageHasLoaded(HomePage),- pageHasLoaded(SignUpPage)- ]);+ await this.browser.waitAny([pageHasLoaded(HomePage), pageHasLoaded(SignUpPage)]);}}diff --git a/tests/pages/GoogleSignInPage.ts b/tests/pages/GoogleSignInPage.tsindex 53d9f2ab5..03d04478c 100644--- a/tests/pages/GoogleSignInPage.ts+++ b/tests/pages/GoogleSignInPage.ts@@ -1,37 +1,37 @@-import { TextInput, Button, Browser, WebComponent, Page, findBy, elementIsVisible, elementIsPresent, pageHasLoaded } from '../lib';-import { HomePage, SignUpPage } from './';-import config from '../config';+import {+ TextInput,+ Button,+ Browser,+ WebComponent,+ Page,+ findBy,+ elementIsVisible,+ elementIsPresent,+ pageHasLoaded+} from "../lib";+import { HomePage, SignUpPage } from "./";+import config from "../config";export class GoogleSignInPage extends Page {constructor(browser: Browser) {super(browser);}- @findBy('#view_container')- private Container!: WebComponent;-- @findBy('#identifierId')- public Email!: TextInput;-- @findBy('#identifierNext')- public ConfirmEmail!: Button;-- @findBy('input[type="password"]')- public Password!: TextInput;-- @findBy('#passwordNext')- public ConfirmPassword!: Button;+ @findBy("#view_container") private Container!: WebComponent;+ @findBy("#identifierId") public Email!: TextInput;+ @findBy("#identifierNext") public ConfirmEmail!: Button;+ @findBy('input[type="password"]') public Password!: TextInput;+ @findBy("#passwordNext") public ConfirmPassword!: Button;public loadCondition() {return elementIsPresent(() => this.Container);}public async signInAsDarthVader() {- return this.signInAs('[email protected]', process.env.DARTHVADER_PASSWORD!);+ return this.signInAs("[email protected]", process.env.DARTHVADER_PASSWORD!);}public async signInAs(email: string, password: string) {-try {const element = await this.browser.findElement(`p[data-email='${email}']`);await element.click();@@ -44,9 +44,6 @@ export class GoogleSignInPage extends Page {await this.browser.wait(elementIsVisible(() => this.Password));await this.Password.type(password);await this.ConfirmPassword.click();- await this.browser.waitAny([- pageHasLoaded(HomePage),- pageHasLoaded(SignUpPage)- ]);+ await this.browser.waitAny([pageHasLoaded(HomePage), pageHasLoaded(SignUpPage)]);}}diff --git a/tests/pages/HomePage.ts b/tests/pages/HomePage.tsindex 4816873e7..65b6ba572 100644--- a/tests/pages/HomePage.ts+++ b/tests/pages/HomePage.ts@@ -1,9 +1,20 @@-import { WebComponent, Browser, Page, findBy, findMultipleBy, Button, TextInput, elementIsVisible, elementIsNotVisible, pageHasLoaded } from '../lib';-import { ShowIdeaPage, GoogleSignInPage, FacebookSignInPage } from './';-import config from '../config';-import { tenant } from '../context';--import { IdeaList } from '../components/IdeaList';+import {+ WebComponent,+ Browser,+ Page,+ findBy,+ findMultipleBy,+ Button,+ TextInput,+ elementIsVisible,+ elementIsNotVisible,+ pageHasLoaded+} from "../lib";+import { ShowIdeaPage, GoogleSignInPage, FacebookSignInPage } from "./";+import config from "../config";+import { tenant } from "../context";++import { IdeaList } from "../components/IdeaList";export class HomePage extends Page {constructor(browser: Browser) {@@ -14,56 +25,23 @@ export class HomePage extends Page {return `http://${tenant}.dev.fider.io:3000/`;}- @findBy('.menu a.header')- public MenuTitle!: WebComponent;-- @findBy('.page .welcome-message')- public WelcomeMessage!: WebComponent;-- @findBy('#new-idea-input')- public IdeaTitle!: TextInput;-- @findBy('.ui.form textarea')- public IdeaDescription!: TextInput;-- @findBy('.c-button.green')- public SubmitIdea!: Button;-- @findBy('.signin')- public UserMenu!: WebComponent;-- @findBy('.signin .name')- public UserName!: WebComponent;-- @findBy('.c-modal__window')- public SignInModal!: WebComponent;-- @findBy('.c-modal__window .c-button.google')- public GoogleSignIn!: Button;-- @findBy('.c-modal__window .c-button.facebook')- public FacebookSignIn!: Button;-- @findBy('#email-signin input')- private EmailSignInInput!: TextInput;-- @findBy('#email-signin button')- private EmailSignInButton!: TextInput;-- @findBy('.ui.form .ui.negative.message')- public ErrorBox!: WebComponent;-- @findBy('.signout')- private SignOut!: Button;-- @findMultipleBy('.fdr-idea-list > .item')- public IdeaList!: IdeaList;-- @findBy('.c-modal__window input')- private CompleteEmailSignInInput!: TextInput;-- @findBy('.c-modal__window button')- private CompleteEmailSignInButton!: Button;+ @findBy(".menu a.header") public MenuTitle!: WebComponent;+ @findBy(".page .welcome-message") public WelcomeMessage!: WebComponent;+ @findBy("#new-idea-input") public IdeaTitle!: TextInput;+ @findBy(".ui.form textarea") public IdeaDescription!: TextInput;+ @findBy(".c-button.green") public SubmitIdea!: Button;+ @findBy(".signin") public UserMenu!: WebComponent;+ @findBy(".signin .name") public UserName!: WebComponent;+ @findBy(".c-modal__window") public SignInModal!: WebComponent;+ @findBy(".c-modal__window .c-button.google") public GoogleSignIn!: Button;+ @findBy(".c-modal__window .c-button.facebook") public FacebookSignIn!: Button;+ @findBy("#email-signin input") private EmailSignInInput!: TextInput;+ @findBy("#email-signin button") private EmailSignInButton!: TextInput;+ @findBy(".ui.form .ui.negative.message") public ErrorBox!: WebComponent;+ @findBy(".signout") private SignOut!: Button;+ @findMultipleBy(".fdr-idea-list > .item") public IdeaList!: IdeaList;+ @findBy(".c-modal__window input") private CompleteEmailSignInInput!: TextInput;+ @findBy(".c-modal__window button") private CompleteEmailSignInButton!: Button;public loadCondition() {return elementIsVisible(() => this.IdeaTitle);@@ -86,25 +64,19 @@ export class HomePage extends Page {}public async signInWithGoogle(): Promise<void> {- await this.browser.clearCookies('https://accounts.google.com');+ await this.browser.clearCookies("https://accounts.google.com");await this.signOut();await this.signIn(() => this.GoogleSignIn);- await this.browser.waitAny([- pageHasLoaded(GoogleSignInPage),- pageHasLoaded(HomePage)- ]);+ await this.browser.waitAny([pageHasLoaded(GoogleSignInPage), pageHasLoaded(HomePage)]);}public async signInWithFacebook(): Promise<void> {- await this.browser.clearCookies('https://facebook.com');+ await this.browser.clearCookies("https://facebook.com");await this.signOut();await this.signIn(() => this.FacebookSignIn);- await this.browser.waitAny([- pageHasLoaded(FacebookSignInPage),- pageHasLoaded(HomePage)- ]);+ await this.browser.waitAny([pageHasLoaded(FacebookSignInPage), pageHasLoaded(HomePage)]);}public async signInWithEmail(email: string): Promise<void> {@@ -113,9 +85,7 @@ export class HomePage extends Page {await this.browser.wait(elementIsVisible(() => this.EmailSignInInput));await this.EmailSignInInput.type(email);await this.EmailSignInButton.click();- await this.browser.wait(- elementIsNotVisible(() => this.EmailSignInButton)- );+ await this.browser.wait(elementIsNotVisible(() => this.EmailSignInButton));}public async completeSignIn(name: string): Promise<void> {diff --git a/tests/pages/ShowIdeaPage.ts b/tests/pages/ShowIdeaPage.tsindex 35b1dfa27..12eea57b2 100644--- a/tests/pages/ShowIdeaPage.ts+++ b/tests/pages/ShowIdeaPage.ts@@ -1,49 +1,34 @@-import { WebComponent, TextInput, Button, DropDownList, Browser, Page, findBy, findMultipleBy, elementIsVisible } from '../lib';-import { CommentList } from '../components/CommentList';+import {+ WebComponent,+ TextInput,+ Button,+ DropDownList,+ Browser,+ Page,+ findBy,+ findMultipleBy,+ elementIsVisible+} from "../lib";+import { CommentList } from "../components/CommentList";export class ShowIdeaPage extends Page {constructor(browser: Browser) {super(browser);}- @findBy('.idea-header .header')- public Title!: WebComponent;-- @findBy('.description')- public Description!: WebComponent;-- @findBy('.fdr-response .ui.label')- public Status!: WebComponent;-- @findBy('.fdr-response .content')- public ResponseText!: WebComponent;-- @findBy('.c-support-counter button')- public SupportCounter!: WebComponent;-- @findBy('.comment-input textarea')- public CommentInput!: TextInput;-- @findBy('.comment-input button')- public SubmitCommentButton!: Button;-- @findMultipleBy('.ui.comments > .comment')- public CommentList!: CommentList;-- @findBy('.action-col button.respond')- public RespondButton!: Button;-- @findBy('.c-modal__window .fdr-response-form')- public ResponseModal!: WebComponent;-- @findBy('.c-modal__window .fdr-response-form select')- private ResponseModalStatus!: DropDownList;-- @findBy('.c-modal__window .fdr-response-form textarea')- private ResponseModalText!: TextInput;-- @findBy('.c-modal__window .c-modal__footer button.green')- private ResponseModalSubmitButton!: Button;+ @findBy(".idea-header .header") public Title!: WebComponent;+ @findBy(".description") public Description!: WebComponent;+ @findBy(".fdr-response .ui.label") public Status!: WebComponent;+ @findBy(".fdr-response .content") public ResponseText!: WebComponent;+ @findBy(".c-support-counter button") public SupportCounter!: WebComponent;+ @findBy(".comment-input textarea") public CommentInput!: TextInput;+ @findBy(".comment-input button") public SubmitCommentButton!: Button;+ @findMultipleBy(".ui.comments > .comment") public CommentList!: CommentList;+ @findBy(".action-col button.respond") public RespondButton!: Button;+ @findBy(".c-modal__window .fdr-response-form") public ResponseModal!: WebComponent;+ @findBy(".c-modal__window .fdr-response-form select") private ResponseModalStatus!: DropDownList;+ @findBy(".c-modal__window .fdr-response-form textarea") private ResponseModalText!: TextInput;+ @findBy(".c-modal__window .c-modal__footer button.green") private ResponseModalSubmitButton!: Button;public loadCondition() {return elementIsVisible(() => this.Title);diff --git a/tests/pages/SignUpPage.ts b/tests/pages/SignUpPage.tsindex 04d814e07..0c60bfe96 100644--- a/tests/pages/SignUpPage.ts+++ b/tests/pages/SignUpPage.ts@@ -1,5 +1,5 @@-import { WebComponent, Browser, Page, Button, TextInput, findBy, elementIsVisible, pageHasLoaded } from '../lib';-import { GoogleSignInPage, FacebookSignInPage, HomePage } from './';+import { WebComponent, Browser, Page, Button, TextInput, findBy, elementIsVisible, pageHasLoaded } from "../lib";+import { GoogleSignInPage, FacebookSignInPage, HomePage } from "./";export class SignUpPage extends Page {constructor(browser: Browser) {@@ -10,35 +10,16 @@ export class SignUpPage extends Page {return `http://login.dev.fider.io:3000/signup`;}- @findBy('#p-signup')- private Container!: WebComponent;-- @findBy('#p-signup .c-button.google')- public GoogleSignIn!: Button;-- @findBy('#p-signup .c-button.facebook')- public FacebookSignIn!: Button;-- @findBy('#p-signup .form #name')- public UserName!: TextInput;-- @findBy('#p-signup .form #email')- public UserEmail!: TextInput;-- @findBy('#p-signup .form #tenantName')- public TenantName!: TextInput;-- @findBy('#p-signup .form #subdomain')- public Subdomain!: TextInput;-- @findBy('#p-signup .c-button.green')- public Confirm!: Button;-- @findBy('#p-signup .page .green.basic.label')- private SubdomainOk!: WebComponent;-- @findBy('.c-modal__window')- private ConfirmationModal!: WebComponent;+ @findBy("#p-signup") private Container!: WebComponent;+ @findBy("#p-signup .c-button.google") public GoogleSignIn!: Button;+ @findBy("#p-signup .c-button.facebook") public FacebookSignIn!: Button;+ @findBy("#p-signup .form #name") public UserName!: TextInput;+ @findBy("#p-signup .form #email") public UserEmail!: TextInput;+ @findBy("#p-signup .form #tenantName") public TenantName!: TextInput;+ @findBy("#p-signup .form #subdomain") public Subdomain!: TextInput;+ @findBy("#p-signup .c-button.green") public Confirm!: Button;+ @findBy("#p-signup .page .green.basic.label") private SubdomainOk!: WebComponent;+ @findBy(".c-modal__window") private ConfirmationModal!: WebComponent;public loadCondition() {return elementIsVisible(() => this.Container);@@ -66,9 +47,6 @@ export class SignUpPage extends Page {await this.browser.wait(elementIsVisible(() => this.SubdomainOk));}await this.Confirm.click();- await this.browser.waitAny([- pageHasLoaded(HomePage),- elementIsVisible(() => this.ConfirmationModal)- ]);+ await this.browser.waitAny([pageHasLoaded(HomePage), elementIsVisible(() => this.ConfirmationModal)]);}}diff --git a/tests/pages/index.ts b/tests/pages/index.tsindex f3b9d9e91..d861148f2 100644--- a/tests/pages/index.ts+++ b/tests/pages/index.ts@@ -1,42 +1,35 @@-import { GoogleSignInPage } from './GoogleSignInPage';-import { FacebookSignInPage } from './FacebookSignInPage';-import { HomePage } from './HomePage';-import { AdminSettingsPage } from './AdminSettingsPage';-import { ShowIdeaPage } from './ShowIdeaPage';-import { SignUpPage } from './SignUpPage';-import { Browser } from '../lib';+import { GoogleSignInPage } from "./GoogleSignInPage";+import { FacebookSignInPage } from "./FacebookSignInPage";+import { HomePage } from "./HomePage";+import { AdminSettingsPage } from "./AdminSettingsPage";+import { ShowIdeaPage } from "./ShowIdeaPage";+import { SignUpPage } from "./SignUpPage";+import { Browser } from "../lib";-export {- GoogleSignInPage,- HomePage,- SignUpPage,- ShowIdeaPage,- FacebookSignInPage,- AdminSettingsPage,-};+export { GoogleSignInPage, HomePage, SignUpPage, ShowIdeaPage, FacebookSignInPage, AdminSettingsPage };export class AllPages {- public google: GoogleSignInPage;- public facebook: FacebookSignInPage;- public home: HomePage;- public adminSettings: AdminSettingsPage;- public signup: SignUpPage;- public showIdea: ShowIdeaPage;+ public google: GoogleSignInPage;+ public facebook: FacebookSignInPage;+ public home: HomePage;+ public adminSettings: AdminSettingsPage;+ public signup: SignUpPage;+ public showIdea: ShowIdeaPage;- constructor(public browser: Browser) {- this.google = new GoogleSignInPage(browser);- this.facebook = new FacebookSignInPage(browser);- this.home = new HomePage(browser);- this.signup = new SignUpPage(browser);- this.showIdea = new ShowIdeaPage(browser);- this.adminSettings = new AdminSettingsPage(browser);- }+ constructor(public browser: Browser) {+ this.google = new GoogleSignInPage(browser);+ this.facebook = new FacebookSignInPage(browser);+ this.home = new HomePage(browser);+ this.signup = new SignUpPage(browser);+ this.showIdea = new ShowIdeaPage(browser);+ this.adminSettings = new AdminSettingsPage(browser);+ }- public async goTo(url: string): Promise<void> {- return this.browser.navigate(url);- }+ public async goTo(url: string): Promise<void> {+ return this.browser.navigate(url);+ }- public async dispose(): Promise<void> {- await this.browser.close();- }+ public async dispose(): Promise<void> {+ await this.browser.close();+ }}diff --git a/tests/testcases/admin.ts b/tests/testcases/admin.tsindex 94e2279a1..0c3054175 100644--- a/tests/testcases/admin.ts+++ b/tests/testcases/admin.ts@@ -1,34 +1,34 @@-import { ensure, elementIsVisible, elementIsNotVisible, } from '../lib';-import { pages, browser } from '../context';+import { ensure, elementIsVisible, elementIsNotVisible } from "../lib";+import { pages, browser } from "../context";-it('User is authenticated after sign up', async () => {+it("User is authenticated after sign up", async () => {// Actionawait pages.home.navigate();await pages.home.UserMenu.click();// Assert- await ensure(pages.home.UserName).textIs('JON SNOW');+ await ensure(pages.home.UserName).textIs("JON SNOW");});-it('User doesn\'t lose what they typed', async () => {+it("User doesn't lose what they typed", async () => {// Actionawait pages.home.navigate();- await pages.home.IdeaTitle.type('My Great Idea');- await pages.home.IdeaDescription.type('With an awesome description');+ await pages.home.IdeaTitle.type("My Great Idea");+ await pages.home.IdeaDescription.type("With an awesome description");await pages.home.IdeaTitle.clear();- await pages.home.IdeaTitle.type('My Great Idea has a new title');+ await pages.home.IdeaTitle.type("My Great Idea has a new title");// Assert- await ensure(pages.home.IdeaTitle).textIs('My Great Idea has a new title');- await ensure(pages.home.IdeaDescription).textIs('With an awesome description');+ await ensure(pages.home.IdeaTitle).textIs("My Great Idea has a new title");+ await ensure(pages.home.IdeaDescription).textIs("With an awesome description");// Actionawait pages.home.navigate();// Assert- await ensure(pages.home.IdeaTitle).textIs('My Great Idea has a new title');- await ensure(pages.home.IdeaDescription).textIs('With an awesome description');+ await ensure(pages.home.IdeaTitle).textIs("My Great Idea has a new title");+ await ensure(pages.home.IdeaDescription).textIs("With an awesome description");// Actionawait pages.home.IdeaDescription.clear();@@ -36,22 +36,22 @@ it('User doesn\'t lose what they typed', async () => {await pages.home.navigate();// Assert- await ensure(pages.home.IdeaTitle).textIs('');+ await ensure(pages.home.IdeaTitle).textIs("");await browser.wait(elementIsNotVisible(() => pages.home.IdeaDescription));});-it('Can submit ideas', async () => {+it("Can submit ideas", async () => {// Actionawait pages.home.navigate();- await pages.home.submitNewIdea('Add support to TypeScript', 'Because the language and community is awesome! :)');+ await pages.home.submitNewIdea("Add support to TypeScript", "Because the language and community is awesome! :)");// Assert- await ensure(pages.showIdea.Title).textIs('Add support to TypeScript');- await ensure(pages.showIdea.Description).textIs('Because the language and community is awesome! :)');- await ensure(pages.showIdea.SupportCounter).textIs('1');+ await ensure(pages.showIdea.Title).textIs("Add support to TypeScript");+ await ensure(pages.showIdea.Description).textIs("Because the language and community is awesome! :)");+ await ensure(pages.showIdea.SupportCounter).textIs("1");});-it('Can change status', async () => {+it("Can change status", async () => {// Action & Assertawait pages.home.navigate();await pages.home.IdeaList.navigateAndWait(0, pages.showIdea.loadCondition());@@ -59,54 +59,54 @@ it('Can change status', async () => {await browser.wait(elementIsVisible(() => pages.showIdea.ResponseModal));// Action & Assert- await pages.showIdea.changeStatus('Planned', 'We will work on this soon...');+ await pages.showIdea.changeStatus("Planned", "We will work on this soon...");await browser.wait(elementIsVisible(() => pages.showIdea.Status));- await ensure(pages.showIdea.Status).textIs('PLANNED');- await ensure(pages.showIdea.ResponseText).textIs('We will work on this soon...');+ await ensure(pages.showIdea.Status).textIs("PLANNED");+ await ensure(pages.showIdea.ResponseText).textIs("We will work on this soon...");});-it('Can change status to another one', async () => {+it("Can change status to another one", async () => {// Action & Assertawait pages.showIdea.RespondButton.click();await browser.wait(elementIsVisible(() => pages.showIdea.ResponseModal));- await pages.showIdea.changeStatus('Planned', 'We will work on this soon...');+ await pages.showIdea.changeStatus("Planned", "We will work on this soon...");await browser.wait(elementIsVisible(() => pages.showIdea.Status));- await ensure(pages.showIdea.Status).textIs('PLANNED');- await ensure(pages.showIdea.ResponseText).textIs('We will work on this soon...');+ await ensure(pages.showIdea.Status).textIs("PLANNED");+ await ensure(pages.showIdea.ResponseText).textIs("We will work on this soon...");});-it('Can comment on an idea', async () => {+it("Can comment on an idea", async () => {// Action & Assertawait pages.home.navigate();await pages.home.IdeaList.navigateAndWait(0, pages.showIdea.loadCondition());await ensure(pages.showIdea.SubmitCommentButton).isNotVisible();// Action & Assert- await pages.showIdea.CommentInput.type('This is my first comment');+ await pages.showIdea.CommentInput.type("This is my first comment");await ensure(pages.showIdea.SubmitCommentButton).isVisible();// Action & Assertawait pages.showIdea.SubmitCommentButton.click();- await browser.wait(async () => await pages.showIdea.CommentList.count() === 1);+ await browser.wait(async () => (await pages.showIdea.CommentList.count()) === 1);});-it('Can change Title, Invitation and Welcome Message', async () => {+it("Can change Title, Invitation and Welcome Message", async () => {await pages.adminSettings.navigate();await pages.adminSettings.TitleInput.clear();- await pages.adminSettings.TitleInput.type('Selenium Feedback');+ await pages.adminSettings.TitleInput.type("Selenium Feedback");await pages.adminSettings.WelcomeMessageInput.clear();- await pages.adminSettings.WelcomeMessageInput.type('Welcome to our Selenium Feedback Forum');+ await pages.adminSettings.WelcomeMessageInput.type("Welcome to our Selenium Feedback Forum");await pages.adminSettings.InvitationInput.clear();- await pages.adminSettings.InvitationInput.type('Say something...');+ await pages.adminSettings.InvitationInput.type("Say something...");await pages.adminSettings.ConfirmButton.click();await browser.wait(pages.home.loadCondition());- await ensure(pages.home.MenuTitle).textIs('Selenium Feedback');- await ensure(pages.home.WelcomeMessage).textIs('Welcome to our Selenium Feedback Forum');- await ensure(pages.home.IdeaTitle).attributeIs('placeholder', 'Say something...');+ await ensure(pages.home.MenuTitle).textIs("Selenium Feedback");+ await ensure(pages.home.WelcomeMessage).textIs("Welcome to our Selenium Feedback Forum");+ await ensure(pages.home.IdeaTitle).attributeIs("placeholder", "Say something...");});diff --git a/tests/testcases/anonymous.ts b/tests/testcases/anonymous.tsindex 027acfe48..971985269 100644--- a/tests/testcases/anonymous.ts+++ b/tests/testcases/anonymous.ts@@ -1,7 +1,7 @@-import { ensure, elementIsVisible } from '../lib';-import { pages, browser } from '../context';+import { ensure, elementIsVisible } from "../lib";+import { pages, browser } from "../context";-it('Cannot submit ideas', async () => {+it("Cannot submit ideas", async () => {// Actionawait pages.home.navigate();await pages.home.IdeaTitle.click();@@ -10,7 +10,7 @@ it('Cannot submit ideas', async () => {await browser.wait(elementIsVisible(() => pages.home.SignInModal));});-it('Cannot see actions or comment on an idea', async () => {+it("Cannot see actions or comment on an idea", async () => {// Action & Assertawait pages.home.navigate();await pages.home.IdeaList.navigateAndWait(0, pages.showIdea.loadCondition());diff --git a/tests/testcases/email-signup.ts b/tests/testcases/email-signup.tsindex 9183757cb..6e4eceb1e 100644--- a/tests/testcases/email-signup.ts+++ b/tests/testcases/email-signup.ts@@ -1,12 +1,12 @@-import { ensure, elementIsVisible, mailgun, Browser } from '../lib';-import { AllPages } from '../pages';+import { ensure, elementIsVisible, mailgun, Browser } from "../lib";+import { AllPages } from "../pages";-describe('Sign up by email', () => {+describe("Sign up by email", () => {let browser: Browser;let pages: AllPages;before(async () => {- browser = new Browser('chrome');+ browser = new Browser("chrome");pages = new AllPages(browser);});@@ -14,7 +14,7 @@ describe('Sign up by email', () => {await pages.dispose();});- it('User can sign up using email', async () => {+ it("User can sign up using email", async () => {const now = new Date().getTime();// Actiondiff --git a/tests/testcases/entry.ts b/tests/testcases/entry.tsindex 76ee67aa8..b17add66e 100644--- a/tests/testcases/entry.ts+++ b/tests/testcases/entry.ts@@ -1,8 +1,8 @@-import { Browser } from '../lib';-import { setPages, setBrowser, setTenant } from '../context';-import { AllPages } from '../pages';+import { Browser } from "../lib";+import { setPages, setBrowser, setTenant } from "../context";+import { AllPages } from "../pages";-describe('Using Fider', () => {+describe("Using Fider", () => {let browser: Browser;let pages: AllPages;@@ -12,7 +12,7 @@ describe('Using Fider', () => {const tenantSubdomain = `selenium${now}`;setTenant(tenantSubdomain);- browser = new Browser('chrome');+ browser = new Browser("chrome");pages = new AllPages(browser);setBrowser(browser);@@ -29,20 +29,19 @@ describe('Using Fider', () => {await pages.dispose();});- describe('As an Admin', () => {- require('./admin');+ describe("As an Admin", () => {+ require("./admin");});- describe('As an anonymous user', () => {+ describe("As an anonymous user", () => {before(async () => {await pages.home.navigate();await pages.home.signOut();});- require('./anonymous');+ require("./anonymous");});- describe('Alternative sign in', () => {- require('./signin');+ describe("Alternative sign in", () => {+ require("./signin");});-});diff --git a/tests/testcases/signin.ts b/tests/testcases/signin.tsindex 3b1a6c50b..246202dc9 100644--- a/tests/testcases/signin.ts+++ b/tests/testcases/signin.ts@@ -1,20 +1,20 @@-import { ensure, elementIsVisible, mailgun } from '../lib';-import { pages, browser } from '../context';+import { ensure, elementIsVisible, mailgun } from "../lib";+import { pages, browser } from "../context";-it('Can sign in with Google and support an idea', async () => {+it("Can sign in with Google and support an idea", async () => {// Action & Assertawait pages.home.navigate();await pages.home.signInWithGoogle();await pages.google.signInAsDarthVader();await pages.home.UserMenu.click();- await ensure(pages.home.UserName).textIs('DARTH VADER');+ await ensure(pages.home.UserName).textIs("DARTH VADER");// Action & Assertawait pages.home.IdeaList.want(0);- await ensure(await pages.home.IdeaList.at(0)).textIs('2');+ await ensure(await pages.home.IdeaList.at(0)).textIs("2");});-it('User can sign in using email on existing tenant', async () => {+it("User can sign in using email on existing tenant", async () => {const now = new Date().getTime();// Action