Files
scadalink-design/tests/ScadaLink.CentralUI.Tests/ComponentRenderingTests.cs
Joseph Doherty b07f43a308 feat(centralui): rebrand web UI to ScadaBridge + technical-light theme
Rename the user-facing product name from ScadaLink to ScadaBridge across
the six display strings (browser title, sidebar brand, login + not-authorized
headings, dashboard welcome/subtitle). Namespaces, assemblies, config keys,
and _content/ScadaLink.CentralUI asset routes are unchanged.

Apply the technical-light design system: vendor theme.css + IBM Plex fonts
into the CentralUI RCL, include theme.css globally (after Bootstrap so its
--bs-* token overrides win), and restyle the layout chrome to a light
sidebar — white surface, hairline rules, ink text, accent-blue active item,
the brand accent mark. Page markup stays Bootstrap and inherits the warm
paper background, Plex type, accent, and hairline borders via the tokens.

Tests: build 0 warnings; bUnit 542 passed; Playwright 64 passed.
2026-05-22 07:03:46 -04:00

84 lines
2.5 KiB
C#

using System.Security.Claims;
using Bunit;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.DependencyInjection;
using ScadaLink.CentralUI.Components.Pages;
namespace ScadaLink.CentralUI.Tests;
/// <summary>
/// bUnit rendering tests for CentralUI Blazor components.
/// Verifies that pages render their expected markup structure.
/// </summary>
public class ComponentRenderingTests : BunitContext
{
[Fact]
public void LoginPage_RendersForm_WithUsernameAndPasswordFields()
{
var cut = Render<Login>();
// Verify the form action
var form = cut.Find("form");
Assert.Equal("/auth/login", form.GetAttribute("action"));
// Verify username field
var usernameInput = cut.Find("input#username");
Assert.Equal("text", usernameInput.GetAttribute("type"));
Assert.Equal("username", usernameInput.GetAttribute("name"));
// Verify password field
var passwordInput = cut.Find("input#password");
Assert.Equal("password", passwordInput.GetAttribute("type"));
Assert.Equal("password", passwordInput.GetAttribute("name"));
// Verify submit button
var submitButton = cut.Find("button[type='submit']");
Assert.Contains("Sign In", submitButton.TextContent);
}
[Fact]
public void LoginPage_WithoutError_DoesNotRenderAlert()
{
var cut = Render<Login>();
Assert.Throws<Bunit.ElementNotFoundException>(() => cut.Find("div.alert.alert-danger"));
}
[Fact]
public void Dashboard_RequiresAuthorizeAttribute()
{
var authorizeAttrs = typeof(Dashboard)
.GetCustomAttributes(typeof(AuthorizeAttribute), true);
Assert.NotEmpty(authorizeAttrs);
}
[Fact]
public void TemplateEditor_RequiresDesignPolicy()
{
var authorizeAttrs = typeof(ScadaLink.CentralUI.Components.Pages.Design.Templates)
.GetCustomAttributes(typeof(AuthorizeAttribute), true);
Assert.NotEmpty(authorizeAttrs);
var attr = (AuthorizeAttribute)authorizeAttrs[0];
Assert.Equal("RequireDesign", attr.Policy);
}
[Fact]
public void LoginPage_RendersLdapCredentialHint()
{
var cut = Render<Login>();
Assert.Contains("LDAP credentials", cut.Markup);
}
[Fact]
public void LoginPage_RendersScadaBridgeTitle()
{
var cut = Render<Login>();
var title = cut.Find("h4.card-title");
Assert.Equal("ScadaBridge", title.TextContent);
}
}