Merge pull request #167 from mirumee/login-tests

Modified login tests
This commit is contained in:
Marcin Gębala 2019-09-23 16:45:36 +02:00 committed by GitHub
commit 637403d44f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 13 deletions

View file

@ -0,0 +1 @@
export const MAIN_PAGE_URL = "http://localhost:9000/";

View file

@ -0,0 +1,2 @@
export const DEFAULT_USER_EMAIL = "admin@example.com";
export const DEFAULT_USER_PASSWORD = "admin";

View file

@ -0,0 +1,11 @@
import { Selector, t } from "testcafe";
export default class HomePage {
constructor() {
this.header = Selector('[data-tc="home-header"]');
this.catalogMenu = Selector('[data-tc="Catalog"]');
this.productsSubMenu = Selector(
'[data-tc="catalogue"]>[aria-label="products"]'
);
}
}

View file

@ -0,0 +1,16 @@
import { Selector, t } from "testcafe";
export default class LoginPage {
constructor() {
this.email = Selector('[data-tc="email"]');
this.password = Selector('[data-tc="password"]');
this.submitButton = Selector('[data-tc="submit"]');
}
async performLogin(putEmail, putPassword) {
await t
.typeText(this.email, putEmail)
.typeText(this.password, putPassword)
.click(this.submitButton);
}
}

View file

@ -0,0 +1,7 @@
import * as verifier from "../Verifications/loginPageVerifications";
import { MAIN_PAGE_URL } from "../Data/systemData";
fixture`Login Tests`.page(MAIN_PAGE_URL);
verifier.verifyEmailAndPasswordDisplayed();
verifier.verifyIfUserCanLogin();

View file

@ -0,0 +1,20 @@
import LoginPage from "../Models/loginPageModel";
import HomePage from "../Models/homePageModel";
import { DEFAULT_USER_EMAIL, DEFAULT_USER_PASSWORD } from "../Data/userData";
const loginPage = new LoginPage();
const homePage = new HomePage();
export function verifyEmailAndPasswordDisplayed() {
test("Verify that Email and Password are displayed", async t => {
await t.expect(loginPage.email.exists).ok();
await t.expect(loginPage.password.exists).ok();
});
}
export function verifyIfUserCanLogin() {
test("PerformLogin", async t => {
await loginPage.performLogin(DEFAULT_USER_EMAIL, DEFAULT_USER_PASSWORD);
await t.expect(homePage.header.exists).ok();
});
}

View file

@ -1,13 +0,0 @@
import { Selector } from "testcafe";
fixture("Example test").page("http://localhost:8000/dashboard/next");
test("User can log in", async t => {
await t
.typeText('[name="email"]', "admin@example.com")
.typeText('[name="password"]', "admin")
.click('[type="submit"]');
const header = await Selector('[data-tc="home-header"]').exists;
await t.expect(header).ok();
});