Skip to content

Commit

Permalink
Fixing specflow test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros committed Apr 29, 2015
1 parent 8b9c25a commit 91e1c72
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 41 deletions.
20 changes: 18 additions & 2 deletions src/Orchard.Specs/Bindings/WebAppHosting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,26 @@ public void WhenIHit(string submitText) {
var submit = _doc.DocumentNode
.SelectSingleNode(string.Format("(//input[@type='submit'][@value='{0}']|//button[@type='submit'][text()='{0}'])", submitText));

var form = Form.LocateAround(submit);
var urlPath = HttpUtility.HtmlDecode(form.Start.GetAttributeValue("action", Details.UrlPath));
string urlPath = null;

if (submit == null) {
// could be a simple link using "unsafeurl" property

submit = _doc.DocumentNode
.SelectNodes("//a")
.SingleOrDefault(elt => elt.InnerHtml == submitText)
?? _doc.DocumentNode
.SelectSingleNode(string.Format("//a[@title='{0}']", submitText));

urlPath = HttpUtility.HtmlDecode(submit.Attributes["href"].Value);
}

var form = Form.LocateAround(submit);

if (urlPath == null) {
urlPath = HttpUtility.HtmlDecode(form.Start.GetAttributeValue("action", Details.UrlPath));
}

var inputs = form.Children
.SelectMany(elt => elt.DescendantsAndSelf("input").Concat(elt.Descendants("textarea")))
.Where(node => !((node.GetAttributeValue("type", "") == "radio" || node.GetAttributeValue("type", "") == "checkbox") && node.GetAttributeValue("checked", "") != "checked"))
Expand Down
10 changes: 7 additions & 3 deletions src/Orchard.Specs/Users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -256,32 +256,36 @@ Scenario: I should be able to filter users by status
| Options.Search | user1 |
And I hit "Filter"
Then I should see "<a[^>]*>user1</a>"
When I follow "Disable"
When I hit "Disable"
And I am redirected
Then I should see "User user1 disabled"
When I fill in
| name | value |
| Options.Search | |
| Options.Filter | Pending |
And I hit "Filter"
Then I should see "<a[^>]*>user1</a>"
And I should not see "<a[^>]*>user2</a>"
And I should not see "<a[^>]*>admin</a>"
When I fill in
| name | value |
| Options.Filter | EmailPending |
| Options.Search | |
| Options.Filter | EmailPending |
And I hit "Filter"
Then I should not see "<a[^>]*>user1</a>"
And I should not see "<a[^>]*>user2</a>"
And I should not see "<a[^>]*>admin</a>"
When I fill in
| name | value |
| Options.Filter | Approved |
| Options.Search | |
| Options.Filter | Approved |
And I hit "Filter"
Then I should not see "<a[^>]*>user1</a>"
And I should see "<a[^>]*>user2</a>"
And I should see "<a[^>]*>admin</a>"
When I fill in
| name | value |
| Options.Search | |
| Options.Filter | All |
And I hit "Filter"
Then I should see "<a[^>]*>user1</a>"
Expand Down
84 changes: 48 additions & 36 deletions src/Orchard.Specs/Users.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 91e1c72

Please sign in to comment.