Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dbretty committed Sep 30, 2024
1 parent 4e32852 commit 5c61e20
Show file tree
Hide file tree
Showing 26 changed files with 1,712 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ jobs:
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Run automated unit and integration tests
run: dotnet test /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov
- name: Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
path-to-lcov: PROFiLiX.Web.Shared.Tests/TestResults/coverage.info
24 changes: 24 additions & 0 deletions PROFiLiX.Server.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "PROFiLiX.Web.Installer", "P
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PROFiLiX.Web.Shared", "PROFiLiX.Web.Shared\PROFiLiX.Web.Shared.csproj", "{54AC9E09-0E8A-438B-9E82-B635858CB984}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{B512AAFE-E476-4B9D-BA7C-9FD3A97C5DAC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PROFiLiX.Web.Shared.Tests", "PROFiLiX.Web.Shared.Tests\PROFiLiX.Web.Shared.Tests.csproj", "{891B0AB0-0968-4DA0-8C29-B8EAF290765C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -87,10 +91,30 @@ Global
{54AC9E09-0E8A-438B-9E82-B635858CB984}.Release|x64.Build.0 = Release|Any CPU
{54AC9E09-0E8A-438B-9E82-B635858CB984}.Release|x86.ActiveCfg = Release|Any CPU
{54AC9E09-0E8A-438B-9E82-B635858CB984}.Release|x86.Build.0 = Release|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Debug|ARM64.Build.0 = Debug|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Debug|x64.ActiveCfg = Debug|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Debug|x64.Build.0 = Debug|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Debug|x86.ActiveCfg = Debug|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Debug|x86.Build.0 = Debug|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Release|Any CPU.Build.0 = Release|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Release|ARM64.ActiveCfg = Release|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Release|ARM64.Build.0 = Release|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Release|x64.ActiveCfg = Release|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Release|x64.Build.0 = Release|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Release|x86.ActiveCfg = Release|Any CPU
{891B0AB0-0968-4DA0-8C29-B8EAF290765C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{54AC9E09-0E8A-438B-9E82-B635858CB984} = {B512AAFE-E476-4B9D-BA7C-9FD3A97C5DAC}
{891B0AB0-0968-4DA0-8C29-B8EAF290765C} = {B512AAFE-E476-4B9D-BA7C-9FD3A97C5DAC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A99BFEE6-8238-40CF-814C-975AE619ACB1}
EndGlobalSection
Expand Down
5 changes: 4 additions & 1 deletion PROFiLiX.Web.Client/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
<MudDivider Class="my-2" />
<MudText Typo="Typo.body2" Class="px-4 mud-text-secondary">Helpdesk</MudText>

<MudNavLink Icon="@Icons.Material.Filled.HelpOutline" Href="/Helpdesk">
<MudNavLink Icon="@Icons.Material.Outlined.HelpOutline" Href="/Helpdesk">
Profile Actions
</MudNavLink>
<MudNavLink Icon="@Icons.Material.Outlined.DashboardCustomize" Href="/CustomActions">
Custom Actions
</MudNavLink>
</Authorized>
</AuthorizeView>

Expand Down
150 changes: 150 additions & 0 deletions PROFiLiX.Web.Client/Pages/Helpdesk/CustomActions.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
@page "/CustomActions"

@using PROFiLiX.Web.Shared.Common
@using Microsoft.AspNetCore.Authorization

@attribute [Authorize]

<PageTitle>Custom Actions</PageTitle>

<MudPaper Class="pa-2 ma-2" Elevation="25">

<MudText Typo="Typo.h5" Align="Align.Left" Class="px-4">
Custom Actions
</MudText>

<br />

@if (pageLoaded == true)
{
<MudTable Items="@CustomActionList" Hover="true" Breakpoint="Breakpoint.Sm">

<HeaderContent>

<MudTh>
<MudTooltip Text="Action Name" Placement="Placement.Right">
Action Name
</MudTooltip>
</MudTh>

<MudTh>
<MudTooltip Text="Action Type" Placement="Placement.Right">
Action Type
</MudTooltip>
</MudTh>

<MudTh>
<MudTooltip Text="Action Description" Placement="Placement.Right">
Action Description
</MudTooltip>
</MudTh>

<MudTh>
<MudTooltip Text="Actions" Placement="Placement.Right">

</MudTooltip>
</MudTh>

</HeaderContent>

<RowTemplate>

<MudTd DataLabel="ActionName">
@context.ActionName
</MudTd>

<MudTd DataLabel="ActionType">
@context.ActionType
</MudTd>

<MudTd DataLabel="ActionDescription">
<MudTooltip Text="@context.ActionContent" Placement="Placement.Start">
@context.ActionDescription
</MudTooltip>
</MudTd>

<MudTd DataLabel="Actions">
<MudIconButton Icon="@Icons.Material.Outlined.Edit" @onclick="() => Edit(context)"></MudIconButton>
<MudIconButton Icon="@Icons.Material.Outlined.DeleteForever" @onclick="() => Delete(context.Id)"></MudIconButton>
</MudTd>

</RowTemplate>

<PagerContent>
<MudBreakpointProvider>
<MudHidden Breakpoint="Breakpoint.Xs" Invert="true">
<MudTablePager PageSizeOptions="new int[]{10,20,30,40,50}" HideRowsPerPage="true" />
</MudHidden>
<MudHidden Breakpoint="Breakpoint.Sm" Invert="true">
<MudTablePager PageSizeOptions="new int[]{10,20,30,40,50}" HideRowsPerPage="true" />
</MudHidden>
<MudHidden Breakpoint="Breakpoint.Md" Invert="true">
<MudTablePager PageSizeOptions="new int[]{10,20,30,40,50}" HideRowsPerPage="true" />
</MudHidden>
<MudHidden Breakpoint="Breakpoint.Lg" Invert="true">
<MudTablePager PageSizeOptions="new int[]{10,20,30,40,50}" />
</MudHidden>
<MudHidden Breakpoint="Breakpoint.Xl" Invert="true">
<MudTablePager PageSizeOptions="new int[]{10,20,30,40,50}" />
</MudHidden>
<MudHidden Breakpoint="Breakpoint.Xxl" Invert="true">
<MudTablePager PageSizeOptions="new int[]{10,20,30,40,50}" />
</MudHidden>
</MudBreakpointProvider>
</PagerContent>

</MudTable>
}
else
{
<PageLoading />
}

<br />

<MudButton Variant="Variant.Outlined" Color="Color.Primary" @onclick="() => NavigateToAddCustomActionPage()">Add Custom Action</MudButton>

</MudPaper>

@code {
private List<ProfilixCustomAction> CustomActionList { get; set; } = new();
public bool pageLoaded = false;

private async Task LoadCustomActions()
{
var customActions = await ProfilixCustomActionService.GetAllProfilixCustomActionsAsync();
CustomActionList.Clear();
if (customActions is null)
{
return;
}
else
{
foreach (var customAction in customActions)
CustomActionList.Add(customAction);
}
}

protected override async Task OnInitializedAsync()
{
pageLoaded = false;
await LoadCustomActions();
pageLoaded = true;
}

private void NavigateToAddCustomActionPage()
{
NavigationManager.NavigateTo("/ManageCustomAction");
}

private void Edit(ProfilixCustomAction model)
{
NavigationManager.NavigateTo($"/ManageCustomAction/{model.Id}");
}

private async void Delete(int id)
{
var customAction = await ProfilixCustomActionService.DeleteProfilixCustomActionAsync(id);
NavigationManager.NavigateTo(NavigationManager.Uri, true);
}
}
37 changes: 31 additions & 6 deletions PROFiLiX.Web.Client/Pages/Helpdesk/Helpdesk.razor
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
<MudSelectItem Value="@(new ClientAction() { Name="Reset Mozilla Firefox"})" />
<MudSelectItem Value="@(new ClientAction() { Name="Reset Teams Classic"})" />
<MudSelectItem Value="@(new ClientAction() { Name="Reset Teams"})" />
@foreach (var customAction in CustomActionList)
{
<MudSelectItem Value="@(new ClientAction() { Name=customAction.ActionName, ActionType=customAction.ActionType, ActionContent=customAction.ActionContent })" />
}
</MudSelect>
</MudTd>

Expand Down Expand Up @@ -143,12 +147,28 @@
public IProfilixUserProfile userProfile = new ProfilixUserProfile();
private List<UserProfile> UserProfiles { get; set; } = new();
ClientAction clientAction = new ClientAction { Name = "Select Action" };
private List<ProfilixCustomAction> CustomActionList { get; set; } = new();

private string adminUserName = string.Empty;
private HubConnection? hubConnection;
public bool pageLoaded = false;
private string searchString1 = "";

private async Task LoadCustomActions()
{
var customActions = await ProfilixCustomActionService.GetAllProfilixCustomActionsAsync();
CustomActionList.Clear();
if (customActions is null)
{
return;
}
else
{
foreach (var customAction in customActions)
CustomActionList.Add(customAction);
}
}

private async void GetUserName()
{
var authenticationState = await GetAuthenticationStateAsync.GetAuthenticationStateAsync();
Expand Down Expand Up @@ -199,12 +219,15 @@

GetUserName();
await LoadUserProfiles();
await LoadCustomActions();
pageLoaded = true;
}

public class ClientAction
{
public string Name { get; set; } = string.Empty;
public ActionType ActionType { get; set; } = ActionType.Unknown;
public string ActionContent { get; set; } = string.Empty;
}

Func<ClientAction,string> converter = p => p.Name;
Expand All @@ -227,30 +250,32 @@
switch (clientAction.Name)
{
case "Clear Temp Files":
await hubConnection.SendAsync("SendMessageToClient", "ClearTempFiles", adminUserName, destinationUserProfile.HubConnectionId, result.Id);
await hubConnection.SendAsync("SendMessageToClient", "ClearTempFiles", adminUserName, destinationUserProfile.HubConnectionId, result.Id, "none", ActionType.Unknown, "none");

Check warning on line 253 in PROFiLiX.Web.Client/Pages/Helpdesk/Helpdesk.razor

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 253 in PROFiLiX.Web.Client/Pages/Helpdesk/Helpdesk.razor

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
executedAction = true;
break;
case "Reset Microsoft Edge":
await hubConnection.SendAsync("SendMessageToClient", "ResetEdge", adminUserName, destinationUserProfile.HubConnectionId, result.Id);
await hubConnection.SendAsync("SendMessageToClient", "ResetEdge", adminUserName, destinationUserProfile.HubConnectionId, result.Id, string.Empty, ActionType.Unknown, string.Empty);

Check warning on line 257 in PROFiLiX.Web.Client/Pages/Helpdesk/Helpdesk.razor

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 257 in PROFiLiX.Web.Client/Pages/Helpdesk/Helpdesk.razor

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
executedAction = true;
break;
case "Reset Google Chrome":
await hubConnection.SendAsync("SendMessageToClient", "ResetChrome", adminUserName, destinationUserProfile.HubConnectionId, result.Id);
await hubConnection.SendAsync("SendMessageToClient", "ResetChrome", adminUserName, destinationUserProfile.HubConnectionId, result.Id, string.Empty, ActionType.Unknown, string.Empty);

Check warning on line 261 in PROFiLiX.Web.Client/Pages/Helpdesk/Helpdesk.razor

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 261 in PROFiLiX.Web.Client/Pages/Helpdesk/Helpdesk.razor

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
executedAction = true;
break;
case "Reset Mozilla Firefox":
await hubConnection.SendAsync("SendMessageToClient", "ResetFirefox", adminUserName, destinationUserProfile.HubConnectionId, result.Id);
await hubConnection.SendAsync("SendMessageToClient", "ResetFirefox", adminUserName, destinationUserProfile.HubConnectionId, result.Id, string.Empty, ActionType.Unknown, string.Empty);

Check warning on line 265 in PROFiLiX.Web.Client/Pages/Helpdesk/Helpdesk.razor

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
executedAction = true;
break;
case "Reset Teams Classic":
await hubConnection.SendAsync("SendMessageToClient", "ResetTeamsClassic", adminUserName, destinationUserProfile.HubConnectionId, result.Id);
await hubConnection.SendAsync("SendMessageToClient", "ResetTeamsClassic", adminUserName, destinationUserProfile.HubConnectionId, result.Id, string.Empty, ActionType.Unknown, string.Empty);
executedAction = true;
break;
case "Reset Teams":
await hubConnection.SendAsync("SendMessageToClient", "ResetTeams", adminUserName, destinationUserProfile.HubConnectionId, result.Id);
await hubConnection.SendAsync("SendMessageToClient", "ResetTeams", adminUserName, destinationUserProfile.HubConnectionId, result.Id, string.Empty, ActionType.Unknown, string.Empty);
executedAction = true;
break;
default:
await hubConnection.SendAsync("SendMessageToClient", "Custom", adminUserName, destinationUserProfile.HubConnectionId, result.Id, clientAction.Name, clientAction.ActionType, clientAction.ActionContent);
executedAction = true;
break;
}
}
Expand Down
Loading

0 comments on commit 5c61e20

Please sign in to comment.