Migrate UI tests to Playwright dotta
This commit is contained in:
@@ -3,8 +3,26 @@ using JdeScoping.Ui.Tests.Support;
|
||||
|
||||
namespace JdeScoping.Ui.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Playwright UI smoke tests for the Data Sync Requests page.
|
||||
/// Validates that the page loads and shows action buttons or redirects to search.
|
||||
/// Requires a running Docker host (Category: RequiresDockerHost).
|
||||
/// </summary>
|
||||
public sealed class DataSyncPageTests(PlaywrightFixture fixture) : UiTestBase(fixture)
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies the Data Sync page loads at /data-sync/requests and displays action buttons.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Steps:
|
||||
/// <list type="number">
|
||||
/// <item>Navigate to the Data Sync Requests page.</item>
|
||||
/// <item>Assert the URL ends with /data-sync/requests or /search (redirect).</item>
|
||||
/// <item>If on the data sync page, assert "Data Sync Requests" heading is visible.</item>
|
||||
/// <item>Assert "New Request" or "Reload Pipelines" button is visible.</item>
|
||||
/// <item>If redirected, assert "Search Details" is visible.</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
[Trait("Category", "RequiresDockerHost")]
|
||||
public async Task DataSync_Loads()
|
||||
@@ -12,23 +30,27 @@ public sealed class DataSyncPageTests(PlaywrightFixture fixture) : UiTestBase(fi
|
||||
await RunAsync(async page =>
|
||||
{
|
||||
await UiNavigationHelper.NavigateToDataSyncAsync(page);
|
||||
var url = page.Url;
|
||||
var onDataSync = url.EndsWith("/data-sync/requests", StringComparison.OrdinalIgnoreCase);
|
||||
var redirectedToSearch = url.EndsWith("/search", StringComparison.OrdinalIgnoreCase);
|
||||
string url = page.Url;
|
||||
bool onDataSync = url.EndsWith("/data-sync/requests", StringComparison.OrdinalIgnoreCase);
|
||||
bool redirectedToSearch = url.EndsWith("/search", StringComparison.OrdinalIgnoreCase);
|
||||
Assert.True(onDataSync || redirectedToSearch, $"Unexpected URL: {url}");
|
||||
|
||||
if (onDataSync)
|
||||
{
|
||||
await Assertions.Expect(page.GetByText("Data Sync Requests")).ToBeVisibleAsync(new() { Timeout = 15_000 });
|
||||
var newRequestButton = page.GetByRole(Microsoft.Playwright.AriaRole.Button, new() { Name = "New Request" });
|
||||
var reloadButton = page.GetByRole(Microsoft.Playwright.AriaRole.Button, new() { Name = "Reload Pipelines" });
|
||||
var hasAnyControl = await newRequestButton.IsVisibleAsync() || await reloadButton.IsVisibleAsync();
|
||||
await Assertions.Expect(page.GetByText("Data Sync Requests"))
|
||||
.ToBeVisibleAsync(new LocatorAssertionsToBeVisibleOptions { Timeout = 15_000 });
|
||||
var newRequestButton =
|
||||
page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "New Request" });
|
||||
var reloadButton =
|
||||
page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "Reload Pipelines" });
|
||||
bool hasAnyControl = await newRequestButton.IsVisibleAsync() || await reloadButton.IsVisibleAsync();
|
||||
Assert.True(hasAnyControl, "Expected Data Sync action buttons to be visible.");
|
||||
}
|
||||
else
|
||||
{
|
||||
await Assertions.Expect(page.GetByText("Search Details")).ToBeVisibleAsync(new() { Timeout = 15_000 });
|
||||
await Assertions.Expect(page.GetByText("Search Details"))
|
||||
.ToBeVisibleAsync(new LocatorAssertionsToBeVisibleOptions { Timeout = 15_000 });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user