Skip to content
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

Fixes #628 #635

Merged
merged 2 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/UniversalDashboard.UITest/Integration/Select.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,30 @@ Get-UDDashboard | Stop-UDDashboard
Describe "Select" {
Context "onSelect" {
$dashboard = New-UDDashboard -Title "Test" -Content {

New-UDButton -Text "Button" -Id 'btn' -OnClick {
$Value = (Get-UDElement -Id 'test').Attributes['value']
Add-UDElement -ParentId 'output' -Content {
New-UDElement -Tag 'div' -Id 'innerOutput2' -Content { $value }
}
}

New-UDSelect -Label "Test" -Id 'test' -Option {
New-UDSelectOption -Nam "Test 1" -Value "1"
New-UDSelectOption -Nam "Test 2" -Value "2"
New-UDSelectOption -Nam "Test 3" -Value "3"
} -OnChange {
Set-UDElement -Id "output" -Content { $EventData }
Add-UDElement -ParentId 'output' -Content {
New-UDElement -Tag 'div' -Id 'innerOutput' -Content { $EventData }
}
}

New-UDElement -Id "output" -Tag "div" -Content { }


}

$Server = Start-UDDashboard -Port 10001 -Dashboard $dashboard
$Server = Start-UDDashboard -Port 10001 -Dashboard $dashboard -Design
$Driver = Start-SeFirefox
Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort"

Expand All @@ -33,7 +45,20 @@ Describe "Select" {
$Element = Find-SeElement -XPath "//ul/li" -Element $Element | Select-Object -Skip 0 -First 1
Invoke-SeClick -Element $Element

(Find-SeElement -Driver $Driver -Id 'output').Text | should be "1"
(Find-SeElement -Driver $Driver -Id 'innerOutput').Text | should be "1"
}

It "should select item and get it with Get-UDElement" {
$Element = Find-SeElement -ClassName "select-wrapper" -Driver $Driver | Select-Object -First 1
Invoke-SeClick -Element $Element

$Element = Find-SeElement -XPath "//ul/li" -Element $Element | Select-Object -Skip 0 -First 1
Invoke-SeClick -Element $Element

$Button = Find-SeElement -Driver $Driver -Id 'btn'
Invoke-SeClick -Element $Button

(Find-SeElement -Driver $Driver -Id 'innerOutput2').Text | should be "1"
}

Stop-SeDriver $Driver
Expand Down
4 changes: 3 additions & 1 deletion src/UniversalDashboard/Controllers/ComponentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,10 @@ public async Task<IActionResult> PutEndpoint()
[HttpPost]
[Route("element/sessionState/{requestId}")]
[Authorize]
public IActionResult SetElementSessionState([FromRoute]string requestId, [FromBody]Element element)
public IActionResult SetElementSessionState([FromRoute]string requestId, [FromBody]JObject jobject)
{
var element = (Element)jobject.ToObject(typeof(Element));

_stateRequestService.Set(requestId, element);
return Ok();
}
Expand Down