Modified LogIn tests
This commit is contained in:
parent
0768591255
commit
a3bf7d1079
5 changed files with 54 additions and 13 deletions
7
.testcafe/Models/homePageModel.js
Normal file
7
.testcafe/Models/homePageModel.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import {Selector,t} from 'testcafe';
|
||||
|
||||
export default class HomePage{
|
||||
constructor(){
|
||||
this.header = Selector ('[data-tc="home-header"]');
|
||||
}
|
||||
}
|
17
.testcafe/Models/loginPageModel.js
Normal file
17
.testcafe/Models/loginPageModel.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import {Selector,t} from 'testcafe';
|
||||
|
||||
export default class LoginPage{
|
||||
constructor(){
|
||||
this.mainPageURL='http://localhost:9000/';
|
||||
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';
|
||||
|
||||
fixture `Login Tests`
|
||||
.page(verifier.mainPageURL);
|
||||
|
||||
verifier.verifyEmailAndPasswordDisplayed();
|
||||
verifier.verifyIfUserCanLogin();
|
23
.testcafe/Verifications/loginPageVerifications.js
Normal file
23
.testcafe/Verifications/loginPageVerifications.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import LoginPage from '../Models/loginPageModel';
|
||||
import HomePage from '../Models/homePageModel';
|
||||
|
||||
const loginPage = new LoginPage();
|
||||
const homePage = new HomePage();
|
||||
export const mainPageURL = loginPage.mainPageURL;
|
||||
|
||||
const USER_EMAIL = 'admin@example.com';
|
||||
const USER_PASSWORD = 'admin';
|
||||
|
||||
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.only('PerformLogin', async t =>{
|
||||
await loginPage.performLogin(USER_EMAIL, 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