commit
637403d44f
7 changed files with 57 additions and 13 deletions
1
.testcafe/Data/systemData.js
Normal file
1
.testcafe/Data/systemData.js
Normal file
|
@ -0,0 +1 @@
|
|||
export const MAIN_PAGE_URL = "http://localhost:9000/";
|
2
.testcafe/Data/userData.js
Normal file
2
.testcafe/Data/userData.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
export const DEFAULT_USER_EMAIL = "admin@example.com";
|
||||
export const DEFAULT_USER_PASSWORD = "admin";
|
11
.testcafe/Models/homePageModel.js
Normal file
11
.testcafe/Models/homePageModel.js
Normal 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"]'
|
||||
);
|
||||
}
|
||||
}
|
16
.testcafe/Models/loginPageModel.js
Normal file
16
.testcafe/Models/loginPageModel.js
Normal 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);
|
||||
}
|
||||
}
|
7
.testcafe/Tests/loginPageTests.js
Normal file
7
.testcafe/Tests/loginPageTests.js
Normal 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();
|
20
.testcafe/Verifications/loginPageVerifications.js
Normal file
20
.testcafe/Verifications/loginPageVerifications.js
Normal 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();
|
||||
});
|
||||
}
|
|
@ -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();
|
||||
});
|
Loading…
Reference in a new issue