-
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.
Added more tests to cover all features
- Loading branch information
1 parent
8d5e1e2
commit 79658c2
Showing
2 changed files
with
103 additions
and
33 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
cypress/screenshots |
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,33 @@ | ||
/* eslint-disable no-undef */ | ||
describe('Testing Election Site', () => { | ||
describe("Authentication Tests", () => { | ||
it('Sign up', () => { | ||
cy.visit('/signup'); | ||
cy.get("input[name='firstName']").type('First'); | ||
cy.get("input[name='lastName']").type('last'); | ||
cy.get("input[name='email']").type('[email protected]'); | ||
cy.get("input[name='password']").type('testpassword'); | ||
cy.get("button[type='submit']").click(); | ||
cy.location().should((loc) => { | ||
expect(loc.pathname).to.eq("/elections"); | ||
}); | ||
}); | ||
|
||
it('Login', () => { | ||
cy.visit('/signout'); | ||
cy.visit('/login'); | ||
cy.get("input[name='email']").type('[email protected]'); | ||
cy.get("input[name='password']").type('testpassword'); | ||
cy.get("button[type='submit']").click(); | ||
cy.location().should((loc) => { | ||
expect(loc.pathname).to.eq("/elections"); | ||
}); | ||
}); | ||
}) | ||
|
||
describe('Election Organizer Test Suite', () => { | ||
beforeEach(() => { | ||
cy.session("Signup Session", () => { | ||
cy.visit("/signup") | ||
// cy.visit('/login'); | ||
// cy.get("input[name='email']").type('[email protected]'); | ||
// cy.get("input[name='password']").type('testpassword'); | ||
// cy.get("button[type='submit']").click(); | ||
cy.get("input[name='firstName']").type('First'); | ||
cy.get("input[name='lastName']").type('last'); | ||
cy.session("Login Session", () => { | ||
cy.visit('/login'); | ||
cy.get("input[name='email']").type('[email protected]'); | ||
cy.get("input[name='password']").type('testpassword'); | ||
cy.get("button[type='submit']").click(); | ||
|
@@ -18,29 +37,6 @@ describe('Testing Election Site', () => { | |
}) | ||
}) | ||
|
||
// it('Sign up', () => { | ||
// cy.visit('/signup'); | ||
// cy.get("input[name='firstName']").type('First'); | ||
// cy.get("input[name='lastName']").type('last'); | ||
// cy.get("input[name='email']").type('[email protected]'); | ||
// cy.get("input[name='password']").type('testpassword'); | ||
// cy.get("button[type='submit']").click(); | ||
// cy.location().should((loc) => { | ||
// expect(loc.pathname).to.eq("/elections"); | ||
// }); | ||
// }); | ||
|
||
// it('Login', () => { | ||
// cy.visit('/signout'); | ||
// cy.visit('/login'); | ||
// cy.get("input[name='email']").type('[email protected]'); | ||
// cy.get("input[name='password']").type('testpassword'); | ||
// cy.get("button[type='submit']").click(); | ||
// cy.location().should((loc) => { | ||
// expect(loc.pathname).to.eq("/elections"); | ||
// }); | ||
// }); | ||
|
||
it('Create Election', () => { | ||
cy.visit('/elections'); | ||
cy.get("input[name='title']").type('WD Election'); | ||
|
@@ -75,6 +71,13 @@ describe('Testing Election Site', () => { | |
cy.contains("voter2") | ||
}) | ||
|
||
it('Start Election without Question', () => { | ||
cy.visit("/elections") | ||
cy.get("a").eq(5).click() | ||
cy.url().should('contain', "preview") | ||
cy.contains("Cannot start an election without any question") | ||
}) | ||
|
||
it('Manage Questions', () => { | ||
cy.visit('/elections') | ||
cy.get("a").eq(4).click() | ||
|
@@ -92,6 +95,72 @@ describe('Testing Election Site', () => { | |
cy.contains("Question added Successfully") | ||
}) | ||
|
||
it('Start Election after adding question', () => { | ||
cy.visit("/elections") | ||
cy.get("a").eq(5).click() | ||
cy.url().should('contain', "preview") | ||
cy.get("button[type='submit']").click() | ||
}) | ||
|
||
|
||
it('Signout', () => { | ||
cy.visit("/elections") | ||
cy.get("a").contains('Signout').click() | ||
cy.location().should((loc) => { | ||
expect(loc.pathname).to.eq("/"); | ||
}); | ||
}) | ||
}); | ||
|
||
|
||
describe('Voting Suite', () => { | ||
beforeEach(() => { | ||
cy.session("Voter Login Session", () => { | ||
cy.visit("/vote/election/wdpoll") | ||
cy.get("input[name='voterid']").type('voter1'); | ||
cy.get("input[name='password']").type('p1'); | ||
cy.get("button[type='submit']").click(); | ||
}) | ||
}) | ||
|
||
it('Vote', () => { | ||
cy.visit("/vote/election/wdpoll") | ||
cy.contains("How is the WD401 Course?") | ||
cy.get("input[type='radio']").check("3") | ||
cy.get("button[type='submit']").click(); | ||
cy.contains("You have already voted. Please wait for the result") | ||
}) | ||
|
||
it('Same voter voting again', () => { | ||
cy.visit("/vote/election/wdpoll") | ||
cy.contains("You have already voted. Please wait for the result") | ||
}) | ||
}) | ||
|
||
describe("After Election", () => { | ||
beforeEach(() => { | ||
cy.session("Admin Signin after election", () => { | ||
cy.visit('/login'); | ||
cy.get("input[name='email']").type('[email protected]'); | ||
cy.get("input[name='password']").type('testpassword'); | ||
cy.get("button[type='submit']").click(); | ||
cy.location().should((loc) => { | ||
expect(loc.pathname).to.eq("/elections"); | ||
}); | ||
}) | ||
}) | ||
|
||
it('Check Results', () => { | ||
cy.visit("/elections") | ||
cy.get("a").eq(5).click() | ||
cy.url().should('contain', "status/bar") | ||
cy.contains("Total Voters: 2") | ||
cy.contains("No of voters polled: 1") | ||
cy.contains("Voters remaining: 1") | ||
}) | ||
|
||
it('End Election', () => { | ||
cy.visit('/elections') | ||
cy.get("button").eq(1).click() | ||
cy.contains("Ended") | ||
}) | ||
}) |