mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Updating the SpecFlow form data collection to include textarea elements
--HG-- branch : dev
This commit is contained in:
@@ -156,7 +156,7 @@ namespace Orchard.Specs.Bindings {
|
|||||||
[When(@"I fill in")]
|
[When(@"I fill in")]
|
||||||
public void WhenIFillIn(Table table) {
|
public void WhenIFillIn(Table table) {
|
||||||
var inputs = _doc.DocumentNode
|
var inputs = _doc.DocumentNode
|
||||||
.SelectNodes("//input") ?? Enumerable.Empty<HtmlNode>();
|
.SelectNodes("(//input|//textarea)") ?? Enumerable.Empty<HtmlNode>();
|
||||||
|
|
||||||
foreach (var row in table.Rows) {
|
foreach (var row in table.Rows) {
|
||||||
var r = row;
|
var r = row;
|
||||||
@@ -191,12 +191,15 @@ namespace Orchard.Specs.Bindings {
|
|||||||
var form = Form.LocateAround(submit);
|
var form = Form.LocateAround(submit);
|
||||||
var urlPath = form.Start.GetAttributeValue("action", Details.UrlPath);
|
var urlPath = form.Start.GetAttributeValue("action", Details.UrlPath);
|
||||||
var inputs = form.Children
|
var inputs = form.Children
|
||||||
.SelectMany(elt => elt.DescendantsAndSelf("input"))
|
.SelectMany(elt => elt.DescendantsAndSelf("input").Concat(elt.Descendants("textarea")))
|
||||||
.Where(node => !((node.GetAttributeValue("type", "") == "radio" || node.GetAttributeValue("type", "") == "checkbox") && node.GetAttributeValue("checked", "") != "checked"))
|
.Where(node => !((node.GetAttributeValue("type", "") == "radio" || node.GetAttributeValue("type", "") == "checkbox") && node.GetAttributeValue("checked", "") != "checked"))
|
||||||
.GroupBy(elt => elt.GetAttributeValue("name", elt.GetAttributeValue("id", "")), elt => elt.GetAttributeValue("value", ""))
|
.GroupBy(elt => elt.GetAttributeValue("name", elt.GetAttributeValue("id", "")), elt => elt.GetAttributeValue("value", ""))
|
||||||
.Where(g => !string.IsNullOrEmpty(g.Key))
|
.Where(g => !string.IsNullOrEmpty(g.Key))
|
||||||
.ToDictionary(elt => elt.Key, elt => (IEnumerable<string>)elt);
|
.ToDictionary(elt => elt.Key, elt => (IEnumerable<string>)elt);
|
||||||
|
|
||||||
|
if (submit.Attributes.Contains("name"))
|
||||||
|
inputs.Add(submit.GetAttributeValue("name", ""), new[] {submit.GetAttributeValue("value", "yes")});
|
||||||
|
|
||||||
Details = Host.SendRequest(urlPath, inputs);
|
Details = Host.SendRequest(urlPath, inputs);
|
||||||
_doc = new HtmlDocument();
|
_doc = new HtmlDocument();
|
||||||
_doc.Load(new StringReader(Details.ResponseText));
|
_doc.Load(new StringReader(Details.ResponseText));
|
||||||
@@ -221,7 +224,7 @@ namespace Orchard.Specs.Bindings {
|
|||||||
|
|
||||||
[Then(@"I should see ""(.*)""")]
|
[Then(@"I should see ""(.*)""")]
|
||||||
public void ThenIShouldSee(string text) {
|
public void ThenIShouldSee(string text) {
|
||||||
Assert.That(Details.ResponseText, Is.StringContaining(text));
|
Assert.That(Details.ResponseText, Is.StringMatching(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Then(@"I should not see ""(.*)""")]
|
[Then(@"I should not see ""(.*)""")]
|
||||||
|
Reference in New Issue
Block a user