Skip to content

Commit

Permalink
Tabs tests (#671)
Browse files Browse the repository at this point in the history
* Introduce faster component testing feature. Tabs tests.

* Fix import.
  • Loading branch information
adamdriscoll authored Mar 1, 2019
1 parent e1e6213 commit 4c4ecf0
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 10 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions src/UniversalDashboard.Materialize/Tests/driver.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
param(
[Switch]$NoClose
)

Import-Module (Join-Path $PSScriptRoot "../../Selenium/Selenium.psm1") -Force
#Don't auto-load the materialize from UD
$Global:UDNoMaterialize = $true
Import-Module (Join-Path $PSScriptRoot "../../output/UniversalDashboard.Community.psd1") -Force
Import-Module (Join-Path $PSScriptRoot "../output/UniversalDashboard.Materialize/UniversalDashboard.Materialize.psd1") -Force

$Tests = Get-ChildItem $PSScriptRoot -Filter "*.tests.ps1"

$Dashboard = New-UDDashboard -Title "Test" -Content {}
$Server = Start-UDDashboard -Port 10000 -Dashboard $Dashboard
$Driver = Start-SeFirefox
Enter-SeUrl -Url "http://localhost:10000" -Driver $Driver
function Set-TestDashboard {
param(
[ScriptBlock]$Content
)

$Global:StateDictionary = @{}

$Dashboard = New-UDDashboard -Content $Content -Title "TEST" -EndpointInitialization (New-UDEndpointInitialization -Variable "StateDictionary")
$Server.DashboardService.SetDashboard($Dashboard)
Enter-SeUrl -Url "http://localhost:10000" -Driver $Driver
}

$Tests | ForEach-Object {
. $_.FullName
}

if (-not $NoClose)
{
Stop-UDDashboard -Port 10000
Stop-SeDriver $Driver
}
14 changes: 14 additions & 0 deletions src/UniversalDashboard.Materialize/Tests/tabs.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Describe "New-UDTabContainer" {
Context "Tabs" {
Set-TestDashboard {
New-UDTabContainer -Tabs {
New-UDTab -Text "Tab1" -Content { New-UDCard -Title "Hi" -Content {} }
New-UDTab -Text "Tab2" -Content { New-UDCard -Title "Hi2" -Content {} }
}
}

It "has tabs" {
Find-SeElement -Driver $Driver -ClassName "tabs" | should not be $null
}
}
}
2 changes: 1 addition & 1 deletion src/UniversalDashboard.UITest/TestFramework.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-Module "$PSScriptRoot\Integration\Selenium\Selenium.psm1" -Force
Import-Module "$PSScriptRoot\..\Selenium\Selenium.psm1" -Force

function Get-ModulePath {
param([Switch]$Release)
Expand Down
6 changes: 4 additions & 2 deletions src/UniversalDashboard/Server/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public Server(string name, string fileName, bool autoReload, PSHost host, int po
public bool Running { get; private set; }

internal bool IsRestApi { get; private set; }

public IDashboardService DashboardService { get; private set; }

private string _reloadKey;

Expand All @@ -88,8 +90,8 @@ public void Start(DashboardOptions dashboardOptions)
var builder = new WebHostBuilder()
.ConfigureServices((y) =>
{
var dashboardService = new DashboardService(dashboardOptions, _reloadKey);
y.Add(new ServiceDescriptor(typeof(IDashboardService), dashboardService));
DashboardService = new DashboardService(dashboardOptions, _reloadKey);
y.Add(new ServiceDescriptor(typeof(IDashboardService), DashboardService));

if (_reloader != null)
y.Add(new ServiceDescriptor(typeof(AutoReloader), _reloader));
Expand Down
6 changes: 5 additions & 1 deletion src/UniversalDashboard/UniversalDashboard.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ if ($PSEdition -eq "Core") {

Import-Module (Join-Path $PSScriptRoot "UniversalDashboardServer.psm1")
Import-Module (Join-Path $PSScriptRoot "UniversalDashboard.Controls.psm1")
Import-Module (Join-Path $PSScriptRoot "Modules\UniversalDashboard.Materialize\UniversalDashboard.Materialize.psd1")

if (-not $Global:UDNoMaterialize)
{
Import-Module (Join-Path $PSScriptRoot "Modules\UniversalDashboard.Materialize\UniversalDashboard.Materialize.psd1")
}
1 change: 1 addition & 0 deletions src/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ if (-not $NoHelp) {

if ($Test) {
. "$PSScriptRoot\UniversalDashboard.UITest\shebang.tests.ps1" -Release
. "$PSScriptRoot\UniversalDashboard.Materialize\driver.ps1"
}

12 changes: 6 additions & 6 deletions src/client/package-lock.json

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

0 comments on commit 4c4ecf0

Please sign in to comment.