Tests/systemsDashboard.tests.ps1

Describe "Testing JumpCloud Systems Dashboard" {
    BeforeAll {
        Get-UDDashboard | Stop-UDDashboard
        Start-JCDashboard -JumpCloudAPIKey $TestOrgAPIKey -NoUpdate
        $Driver = Start-SeFirefox -Headless
        Enter-SeUrl "http://127.0.0.1:8003/Systems" -Driver $Driver
    }
    Context "Verifying System Dashboard Components" {

        It "Verifies the OS component" {
            $Element = Find-SeElement -Driver $Driver -TagName "system_os"
            $Element.Displayed | Should Be $true
        }
        It "Verifies the SystemsMFA component" {
            $Element = Find-SeElement -Driver $Driver -TagName "system_mfaStatus"
            $Element.Displayed | Should Be $true
        }
        It "Verifies the NewSystems component" {
            $Element = Find-SeElement -Driver $Driver -TagName "system_newSystems"
            $Element.Displayed | Should Be $true
        }
        It "Verifies the AgentVersion component" {
            $Element = Find-SeElement -Driver $Driver -TagName "system_agentVersion"
            $Element.Displayed | Should Be $true
        }
        It "Verifies the OSVersion component" {
            $Element = Find-SeElement -Driver $Driver -TagName "system_version"
            $Element.Displayed | Should Be $true
        }
        It "Verifies the LastContact component" {
            $Element = Find-SeElement -Driver $Driver -TagName "system_lastContact"
            $Element.Displayed | Should Be $true
        }

    }
    #TODO:add mock or attach to org returning no results
    Context "Testing the cases where no systems are to be displayed" {
        # It "No MFA Systems"{
        # $MFASystems = Get-SystemsWithLastContactWithinXDays -days 7
        # If ($MFASystems.Length -eq 0) {
        # $Element = Find-SeElement -Driver $Driver -TagName "SystemsMFA"
        # $Element.Text | Should BeLike "*None of your systems have MFA enabled."
        # }
        # }
        # It "No New Systems" {
        # $MFASystems = Get-SystemsWithLastContactWithinXDays -days 7
        # If ($MFASystems.Length -eq 0) {
        # $Element = Find-SeElement -Driver $Driver -TagName "NewSystems"
        # $Element.Text | Should BeLike "*No new systems have been added to your JumpCloud Organization*"
        # }
        # }
    }
    AfterAll {
        Stop-SeDriver $Driver
        Get-UDDashboard | Stop-UDDashboard
    }
}