-
Notifications
You must be signed in to change notification settings - Fork 621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution #618
Open
Jakdet
wants to merge
1
commit into
mate-academy:master
Choose a base branch
from
Jakdet:develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
solution #618
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,11 +1,96 @@ | ||
/// <reference types="cypress" /> | ||
/// <reference types='cypress' /> | ||
|
||
describe('Sign In page', () => { | ||
const login = 'tomsmith'; | ||
const pass = 'SuperSecretPassword!'; | ||
const rightSite = 'https://the-internet.herokuapp.com/secure'; | ||
const mainSite = 'https://the-internet.herokuapp.com/login'; | ||
|
||
beforeEach(() => { | ||
cy.visit(mainSite); | ||
}); | ||
|
||
describe('Site contents', () => { | ||
it('should contain "Login Page" in header', () => { | ||
cy.get('h2').should('have.text', 'Login Page'); | ||
}); | ||
|
||
it('should contain instruction in subheader', () => { | ||
cy.get('h4') | ||
.invoke('text') | ||
.should((text) => { | ||
expect(text.length).to.be.greaterThan(50); | ||
}); | ||
}); | ||
|
||
it('should have a "Login" button', () => { | ||
cy.get('.radius') | ||
.should('have.text', ' Login') | ||
.and('exist') | ||
.and('be.visible') | ||
.and('have.attr', 'type', 'submit'); | ||
}); | ||
}); | ||
|
||
describe('Valid login', () => { | ||
beforeEach(() => { | ||
cy.get('#username').type(login); | ||
cy.get('#password').type(pass); | ||
}); | ||
|
||
it('should login with valid data', () => { | ||
cy.get('form').find('button[type="submit"]').click(); | ||
}); | ||
|
||
it('should return code 200 for POST method', () => { | ||
cy.request({ | ||
method: 'POST', | ||
url: 'https://the-internet.herokuapp.com/authenticate', | ||
body: { username: login, password: pass } | ||
}).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
}); | ||
|
||
it('should redirect to the correct site', () => { | ||
cy.get('form').find('button[type="submit"]').click(); | ||
cy.url().should('eq', rightSite); | ||
}); | ||
}); | ||
|
||
describe('Invalid login', () => { | ||
it('should display error message for invalid login', () => { | ||
cy.get('#username').type('tommssmith'); | ||
cy.get('#password').type(pass); | ||
cy.get('form').find('button[type="submit"]').click(); | ||
|
||
cy.get('#flash') | ||
.should('be.visible') | ||
.and('contain', 'Your username is invalid!'); | ||
}); | ||
|
||
it(`should display error message for valid login | ||
but invalid password`, () => { | ||
cy.get('#username').type(login); | ||
cy.get('#password').type('randompassword'); | ||
cy.get('form').find('button[type="submit"]').click(); | ||
|
||
cy.get('#flash') | ||
.should('be.visible') | ||
.and('contain', 'Your password is invalid!'); | ||
}); | ||
}); | ||
|
||
it('', () => { | ||
describe('User Logout', () => { | ||
beforeEach(() => { | ||
cy.get('#username').type(login); | ||
cy.get('#password').type(pass); | ||
cy.get('form').find('button[type="submit"]').click(); | ||
}); | ||
|
||
it('should properly log out user', () => { | ||
cy.get('.button').click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The selector |
||
cy.url().should('eq', mainSite); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL assertion is incorrect. The
cy.url().should('eq', rightSite);
should usecy.url().should('eq', rightSite);
instead ofcy.url().should('eq', rightSite);
. Make sure to usecy.url().should('eq', rightSite);
to correctly compare the current URL with the expected URL.