Make the seven sidebar section groups (Admin, Design, Deployment, Notifications, Site Calls, Monitoring, Audit) collapsible. New NavSection component renders a header toggle button (chevron) and reveals its items only while expanded; NavMenu owns the expanded-section set. Behaviour: sections are collapsed by default; state persists in the `scadabridge_nav` cookie (written/read via the new nav-state.js JS interop, mirroring treeview-storage.js) so it survives reloads and reconnects; navigating into a section auto-expands it and remembers it. The Dashboard item stays sectionless and always visible. Tests: NavMenu bUnit tests expand sections before asserting items and add collapsed-by-default / toggle / cookie-persistence cases; Playwright nav tests expand sections before clicking links; new NavCollapseTests covers the feature E2E. Build 0 warnings; bUnit 545 passed; Playwright nav suite green (the unrelated AuditGridColumnTests resize-reload case remains pre-existing flaky — an un-awaited save race in that test).
90 lines
3.5 KiB
C#
90 lines
3.5 KiB
C#
using Microsoft.Playwright;
|
|
|
|
namespace ScadaLink.CentralUI.PlaywrightTests;
|
|
|
|
[Collection("Playwright")]
|
|
public class NavigationTests
|
|
{
|
|
private readonly PlaywrightFixture _fixture;
|
|
|
|
public NavigationTests(PlaywrightFixture fixture)
|
|
{
|
|
_fixture = fixture;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Dashboard_IsVisibleAfterLogin()
|
|
{
|
|
var page = await _fixture.NewAuthenticatedPageAsync();
|
|
|
|
// The nav sidebar should be visible with the brand. ToContainText, not
|
|
// ToHaveText: the brand also carries the accent mark glyph (▮).
|
|
await Expect(page.Locator(".brand")).ToContainTextAsync("ScadaBridge");
|
|
// The nav should contain "Dashboard" link (exact match to avoid "Health Dashboard")
|
|
await Expect(page.GetByRole(AriaRole.Link, new() { Name = "Dashboard", Exact = true })).ToBeVisibleAsync();
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("Sites", "/admin/sites")]
|
|
[InlineData("API Keys", "/admin/api-keys")]
|
|
[InlineData("LDAP Mappings", "/admin/ldap-mappings")]
|
|
public async Task AdminNavLinks_NavigateCorrectly(string linkText, string expectedPath)
|
|
{
|
|
var page = await _fixture.NewAuthenticatedPageAsync();
|
|
await ClickNavAndWait(page, linkText, expectedPath);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("SMTP Configuration", "/notifications/smtp")]
|
|
[InlineData("Notification Lists", "/notifications/lists")]
|
|
[InlineData("Notification Report", "/notifications/report")]
|
|
[InlineData("Notification KPIs", "/notifications/kpis")]
|
|
public async Task NotificationsNavLinks_NavigateCorrectly(string linkText, string expectedPath)
|
|
{
|
|
var page = await _fixture.NewAuthenticatedPageAsync();
|
|
await ClickNavAndWait(page, linkText, expectedPath);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("Templates", "/design/templates")]
|
|
[InlineData("Shared Scripts", "/design/shared-scripts")]
|
|
[InlineData("Connections", "/design/connections")]
|
|
[InlineData("External Systems", "/design/external-systems")]
|
|
public async Task DesignNavLinks_NavigateCorrectly(string linkText, string expectedPath)
|
|
{
|
|
var page = await _fixture.NewAuthenticatedPageAsync();
|
|
await ClickNavAndWait(page, linkText, expectedPath);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("Topology", "/deployment/topology")]
|
|
[InlineData("Deployments", "/deployment/deployments")]
|
|
public async Task DeploymentNavLinks_NavigateCorrectly(string linkText, string expectedPath)
|
|
{
|
|
var page = await _fixture.NewAuthenticatedPageAsync();
|
|
await ClickNavAndWait(page, linkText, expectedPath);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("Health Dashboard", "/monitoring/health")]
|
|
[InlineData("Event Logs", "/monitoring/event-logs")]
|
|
[InlineData("Parked Messages", "/monitoring/parked-messages")]
|
|
public async Task MonitoringNavLinks_NavigateCorrectly(string linkText, string expectedPath)
|
|
{
|
|
var page = await _fixture.NewAuthenticatedPageAsync();
|
|
await ClickNavAndWait(page, linkText, expectedPath);
|
|
}
|
|
|
|
private static async Task ClickNavAndWait(IPage page, string linkText, string expectedPath)
|
|
{
|
|
// Sections are collapsed by default — open them so the link is in the DOM.
|
|
await PlaywrightFixture.ExpandAllNavSectionsAsync(page);
|
|
await page.Locator($"nav a:has-text('{linkText}')").ClickAsync();
|
|
await PlaywrightFixture.WaitForPathAsync(page, expectedPath);
|
|
Assert.Contains(expectedPath, page.Url);
|
|
}
|
|
|
|
private static ILocatorAssertions Expect(ILocator locator) =>
|
|
Assertions.Expect(locator);
|
|
}
|