Skip to content

Commit

Permalink
Merge pull request #413 from webkom/e2e-stv-admin
Browse files Browse the repository at this point in the history
Some more E2E tests
  • Loading branch information
SmithPeder authored Feb 9, 2021
2 parents 2c4ebd4 + 8b62a00 commit 2570b15
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
9 changes: 6 additions & 3 deletions app/views/partials/admin/editElection.pug
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@
tbody
tr
th.th-left Stemmer
th.th-right = {{ election.voteCount }}
th.th-right =
span(ng-bind='election.voteCount') {{ election.voteCount }}
tr
th.th-left ∟ Hvorav blanke stemmer
th.th-right = {{ election.blankVoteCount }}
th.th-right =
span(ng-bind='election.blankVoteCount') {{ election.blankVoteCount }}
tr
th.th-left Plasser
th.th-right = {{ election.seats }}
th.th-right =
span(ng-bind='election.seats') {{ election.seats }}
tr
th.th-left Terskel
th.th-right
Expand Down
25 changes: 24 additions & 1 deletion features/admin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,42 @@ Feature: Admin
When I am on page "/admin"
Then I see a list of elections

Scenario: Create election
Scenario: Create basic election
Given There is an inactive election
And I am on page "/admin/create_election"
When I create an election
Then The election should exist

Scenario: Create invalid election
Given There is an inactive election
And I am on page "/admin/create_election"
When I fill in "title" with "test election"
And I fill in "seats" with "2"
And I fill in "alternative0" with "A"
Then Button "Submit" should be disabled

Scenario: Create election with more seats
Given There is an inactive election
And I am on page "/admin/create_election"
When I fill in "title" with "test election"
And I fill in "seats" with "2"
And I fill in "alternative0" with "A"
And I click anchor "new-alternative"
And I fill in "alternative1" with "B"
Then Button "Submit" should not be disabled
When I click "Submit"
Then I see alert "Avstemning lagret"

Scenario: Count votes
Given There is an active election
And The election has votes
And The election is deactivated
And I am on the edit election page
When I click "Kalkuler resultat"
Then I should see votes
And I should see 1 in "election.voteCount"
And I should see 0 in "election.blankVoteCount"
And I should see 1 in "election.seats"
And There should be 1 winner
And I should see "test alternative" as winner 1

Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/adminSteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module.exports = function () {
});

this.Then(/^I should see ([\d]+) in "([^"]*)"$/, (count, binding) => {
const countElement = element(by.binding(binding));
const countElement = element.all(by.binding(binding)).first();
return expect(countElement.getText()).to.eventually.equal(String(count));
});
};
13 changes: 13 additions & 0 deletions features/step_definitions/webSteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ module.exports = function () {
button.click();
});

this.When(/^I click anchor "([^"]*)"$/, (classname) => {
const anchor = element(by.className(classname));
anchor.click();
});

this.Then(/^I should find "([^"]*)"$/, (selector) =>
expect(element(by.css(selector)).isPresent()).to.eventually.equal(true)
);
Expand Down Expand Up @@ -88,4 +93,12 @@ module.exports = function () {
const found = element.all(by.css(css));
expect(found.count()).to.eventually.equal(Number(count));
});

this.Then(
/^Button "([^"]*)" should( not)? be disabled$/,
(buttonText, not) => {
const button = element(by.buttonText(buttonText));
expect(button.isEnabled()).to.eventually.equal(!!not);
}
);
};

0 comments on commit 2570b15

Please sign in to comment.