Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll committed Nov 14, 2018
1 parent e472343 commit 135c0e8
Showing 1 changed file with 16 additions and 52 deletions.
68 changes: 16 additions & 52 deletions src/UniversalDashboard.UITest/Integration/Input.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Import-Module $ModulePath -Force
Get-UDDashboard | Stop-UDDashboard

Describe "Input" {

Context "Validation" {
$dashboard = New-UDDashboard -Title "Validation" -Content {
New-UDRow -Columns {
Expand Down Expand Up @@ -110,13 +109,6 @@ Describe "Input" {
}

Context "Custom input" {
$tempDir = [System.IO.Path]::GetTempPath()
$tempFile = Join-Path $tempDir "output.txt"

if ((Test-path $tempFile)) {
Remove-Item $tempFile -Force
}

$dashboard = New-UDDashboard -Title "Test" -Content {
New-UDInput -Title "Simple Form" -Id "Form" -Content {
New-UDInputField -Type 'textbox' -Name 'test' -Placeholder 'Test testbox' -DefaultValue "Test"
Expand All @@ -133,14 +125,7 @@ Describe "Input" {
} -Endpoint {
param($Test, $Test2, $Test3, $Test4, $Test5, $Test6, $Test7, $Test8, $Test9, $Test10)

$tempDir = [System.IO.Path]::GetTempPath()
$tempFile = Join-Path $tempDir "output.txt"

if ((Test-path $tempFile)) {
Remove-Item $tempFile -Force
}

[PSCustomObject]@{
$Cache:Output = [PSCustomObject]@{
test = $test
test2 = $test2
test3 = $test3
Expand All @@ -151,7 +136,7 @@ Describe "Input" {
test8 = $test8
test9 = $test9
# test10 = $test10
} | ConvertTo-Json | Out-File -FilePath $tempFile
}
}
}

Expand All @@ -175,9 +160,7 @@ Describe "Input" {

Start-Sleep 1

$Output = Get-Content -Path $tempFile | ConvertFrom-Json

$Output.test9 | Should be ((Get-Date).ToString("20-MM-yyyy"))
$Cache:Output.test9 | Should be ((Get-Date).ToString("20-MM-yyyy"))
}

It "should submit textarea" {
Expand All @@ -190,9 +173,7 @@ Describe "Input" {

Start-Sleep 1

$Output = Get-Content -Path $tempFile | ConvertFrom-Json

$Output.test6 | Should be "Hello!!!!!!!!!!!!!!!!!!!!!!!!!"
$Cache:Output.test6 | Should be "Hello!!!!!!!!!!!!!!!!!!!!!!!!!"
}

It "should submit password" {
Expand All @@ -205,9 +186,7 @@ Describe "Input" {

Start-Sleep 1

$Output = Get-Content -Path $tempFile | ConvertFrom-Json

$Output.test5 | Should be "Hello"
$Cache:Output.test5 | Should be "Hello"
}

It "should submit text" {
Expand All @@ -220,9 +199,7 @@ Describe "Input" {

Start-Sleep 1

$Output = Get-Content -Path $tempFile | ConvertFrom-Json

$Output.test | Should be "TestHello"
$Cache:Output.test | Should be "TestHello"
}

It "should output bool" {
Expand All @@ -234,9 +211,7 @@ Describe "Input" {

Start-Sleep 1

$Output = Get-Content -Path $tempFile | ConvertFrom-Json

$Output.test2 | Should be "true"
$Cache:Output.test2 | Should be "true"
}

It "should selected default value" {
Expand All @@ -245,9 +220,7 @@ Describe "Input" {

Start-Sleep 1

$Output = Get-Content -Path $tempFile | ConvertFrom-Json

$Output.test3 | Should be "Test"
$Cache:Output.test3 | Should be "Test"
}


Expand All @@ -263,9 +236,7 @@ Describe "Input" {

Start-Sleep 1

$Output = Get-Content -Path $tempFile | ConvertFrom-Json

$Output.test3 | Should be "Test2"
$Cache:Output.test3 | Should be "Test2"
}


Expand All @@ -278,9 +249,7 @@ Describe "Input" {

Start-Sleep 1

$Output = Get-Content -Path $tempFile | ConvertFrom-Json

$Output.test4 | Should be "MyTestValue2"
$Cache:Output.test4 | Should be "MyTestValue2"
}

It "should switch the switch" {
Expand All @@ -292,16 +261,14 @@ Describe "Input" {

Start-Sleep 1

$Output = Get-Content -Path $tempFile | ConvertFrom-Json

$Output.test7 | Should be "true"
$Cache:Output.test7 | Should be "true"
}


Stop-SeDriver $Driver
Stop-UDDashboard -Server $Server
}

Context "input and monitor" {
$dashboard = New-UDDashboard -Title "Test" -Content {
New-UDInput -Title "Simple Form" -Id "Form" -Endpoint {
Expand Down Expand Up @@ -609,16 +576,16 @@ Describe "Input" {
$Driver = Start-SeFirefox
Enter-SeUrl -Driver $Driver -Url "http://localhost:$BrowserPort"

Start-Sleep 1

It "should have different content after click" {
$Element = Find-SeElement -Name "Test" -Driver $Driver
Send-SeKeys -Element $Element -Keys "16"

Start-Sleep 1

$Button = Find-SeElement -Id "btnForm" -Driver $Driver
Invoke-SeClick $Button

Sleep 2
Start-Sleep 2

$Target = Find-SeElement -Id "Sixteen" -Driver $Driver
$Target.Text | Should be "Sixteen`r`n16"
Expand All @@ -628,7 +595,4 @@ Describe "Input" {
Stop-UDDashboard -Server $Server
}




}

0 comments on commit 135c0e8

Please sign in to comment.