-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automated test cases for login feature
- Loading branch information
1 parent
0cd6e06
commit 6249ebd
Showing
3 changed files
with
31 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class LoginPage { | ||
|
||
get username () { return $('#email') } | ||
get password () { return $('#password') } | ||
get enterBtn () { return $('button=Entrar') } | ||
|
||
async fillSubmitForm (user, pass) { | ||
await this.username.setValue(user) | ||
await this.password.setValue(pass) | ||
await this.enterBtn.click() | ||
} | ||
|
||
} | ||
|
||
export default new LoginPage() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
describe('My Login application', () => { | ||
it('should login with valid credentials', async () => { | ||
await browser.url(`https://the-internet.herokuapp.com/login`) | ||
import LoginPage from '../pages/login.page.js' | ||
|
||
await $('#username').setValue('tomsmith') | ||
await $('#password').setValue('SuperSecretPassword!') | ||
await $('button[type="submit"]').click() | ||
describe('Application login', () => { | ||
it('signs in with valid credentials', async () => { | ||
await browser.url('/') | ||
|
||
await expect($('#flash')).toBeExisting() | ||
await expect($('#flash')).toHaveTextContaining( | ||
'You logged into a secure area!') | ||
await LoginPage.fillSubmitForm('[email protected]', 'generic') | ||
|
||
await expect(browser).toHaveUrlContaining('home') | ||
await expect($('h1')).toHaveTextContaining('Serverest Store') | ||
}) | ||
|
||
it('shows error message with wrong password', async () => { | ||
await browser.url('/') | ||
|
||
await LoginPage.fillSubmitForm('[email protected]', 'wrong') | ||
|
||
await expect($('.alert')).toHaveTextContaining('Email e/ou senha inválidos') | ||
}) | ||
}) | ||
|