Skip to content

Commit

Permalink
Update wafer map tests to wait for render/ setData. Remove extra dela…
Browse files Browse the repository at this point in the history
…y in AcceptanceTestsBase.
  • Loading branch information
msmithNI committed Oct 29, 2024
1 parent 59959ca commit b5be96f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ private async Task NavigateToPageAsync(IPage page, string route)
private async Task WaitForComponentsInitializationAsync(IPage page)
{
await page.WaitForFunctionAsync(ComponentLibraryInitializationTestJavaScript);
// Have encountered some test intermittency when interacting with the components immediately
// after the JS scripts report ready. Added an extra wait here to mitigate.
await Task.Delay(150);
}

protected sealed class AsyncDisposablePage : IAsyncDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
@bind-ColorScale="ColorScale"
@bind-HighlightedTags="HighlightedTags">
</NimbleWaferMap>
<br/>
<NimbleButton @onclick="GetValidityAsync">Get Validity Async</NimbleButton>
<NimbleTextField @bind-Value="TextFieldText"></NimbleTextField>
<NimbleTextField class="test-text-field" @bind-Value="TextFieldText"></NimbleTextField>
<br/>
<NimbleTextField class="render-text-field" @bind-Value="RenderTextField"></NimbleTextField>
@code {
public NimbleWaferMap? _waferMap;
private string? TextFieldText { get; set; }
private string? RenderTextField { get; set; }
[NotNull]
public IEnumerable<WaferMapDie> Dies { get; set; } = Enumerable.Empty<WaferMapDie>();
[NotNull]
Expand Down Expand Up @@ -85,6 +89,11 @@
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await _waferMap!.SetDataAsync(Dies);
if (firstRender)
{
RenderTextField = "RenderComplete";
StateHasChanged();
}
await base.OnAfterRenderAsync(firstRender);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
@bind-ColorScale="ColorScale"
@bind-HighlightedTags="HighlightedTags">
</NimbleWaferMap>
<br/>
<NimbleButton @onclick="GetValidityAsync">Get Validity Async</NimbleButton>
<NimbleTextField class="test-text-field" @bind-Value="TextFieldText"></NimbleTextField>
<br/>
<NimbleTextField class="render-text-field" @bind-Value="RenderTextField"></NimbleTextField>
@code {
public NimbleWaferMap? _waferMap;
Expand Down Expand Up @@ -108,6 +110,11 @@
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await _waferMap!.SetDataAsync(DiesTable);
if (firstRender)
{
RenderTextField = "RenderComplete";
StateHasChanged();
}
await base.OnAfterRenderAsync(firstRender);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public WaferMapTests(PlaywrightFixture playwrightFixture, NimbleBlazorWebHostSer
: base(playwrightFixture, blazorServerClassFixture)
{ }

private async Task WaitForWaferMapRenderCompleteAsync(IPage page)
{
await Assertions.Expect(page.Locator(".render-text-field")).ToHaveAttributeAsync("current-value", "RenderComplete");
}

[Fact]
public async Task WaferMap_WithDiesAndColorScale_RendersColorsAsync()
{
Expand All @@ -18,6 +23,7 @@ public async Task WaferMap_WithDiesAndColorScale_RendersColorsAsync()
var wafer = page.Locator("nimble-wafer-map");
var canvas = page.Locator(".main-wafer");

await WaitForWaferMapRenderCompleteAsync(page);
await Assertions.Expect(wafer).ToBeVisibleAsync();
await Assertions.Expect(canvas).ToBeVisibleAsync();
var color = await page.EvaluateAsync<string>(
Expand All @@ -33,8 +39,9 @@ public async Task WaferMap_WithGridDimensions_IsValidAsync()
var page = pageWrapper.Page;
var wafer = page.Locator("nimble-wafer-map");
var validButton = page.Locator("nimble-button");
var textField = page.Locator("nimble-text-field");
var textField = page.Locator(".test-text-field");

await WaitForWaferMapRenderCompleteAsync(page);
await Assertions.Expect(wafer).ToBeVisibleAsync();
await validButton.ClickAsync();

Expand All @@ -47,8 +54,9 @@ public async Task WaferMap_WithHoverEvent_TriggersDieChangeEventAsync()
await using var pageWrapper = await NewPageForRouteAsync("InteractiveServer/WaferMapRenderTest");
var page = pageWrapper.Page;
var wafer = page.Locator("nimble-wafer-map");
var textField = page.Locator("nimble-text-field");
var textField = page.Locator(".test-text-field");

await WaitForWaferMapRenderCompleteAsync(page);
await Assertions.Expect(wafer).ToBeVisibleAsync();
await wafer.HoverAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ public WaferMapTestsExperimental(PlaywrightFixture playwrightFixture, NimbleBlaz
: base(playwrightFixture, blazorServerClassFixture)
{ }

private async Task WaitForWaferMapRenderCompleteAsync(IPage page)
{
await Assertions.Expect(page.Locator(".render-text-field")).ToHaveAttributeAsync("current-value", "RenderComplete");
}

[Fact]
public async Task WaferMap_WithGridDimensions_IsValidAsync()
{
await using var pageWrapper = await NewPageForRouteAsync("InteractiveServer/WaferMapRenderTestExperimental");
var page = pageWrapper.Page;
var wafer = page.Locator("nimble-wafer-map");
var validButton = page.Locator("nimble-button");
var renderTextField = page.Locator(".render-text-field");
var textField = page.Locator(".test-text-field");

await WaitForWaferMapRenderCompleteAsync(page);
await Assertions.Expect(wafer).ToBeVisibleAsync();
await validButton.ClickAsync();

Expand All @@ -32,9 +37,9 @@ public async Task WaferMap_WithHoverEvent_TriggersDieChangeEventAsync()
await using var pageWrapper = await NewPageForRouteAsync("InteractiveServer/WaferMapRenderTestExperimental");
var page = pageWrapper.Page;
var wafer = page.Locator("nimble-wafer-map");
var renderTextField = page.Locator(".render-text-field");
var textField = page.Locator(".test-text-field");

await WaitForWaferMapRenderCompleteAsync(page);
await Assertions.Expect(wafer).ToBeVisibleAsync();
await wafer.HoverAsync();

Expand Down

0 comments on commit b5be96f

Please sign in to comment.