Skip to content

Commit 74c0eaa

Browse files
net0wellclaude
andcommitted
test(painel): E2E sem corridas de tempo (spec 008)
- AC-06: o worker só sobe depois de a página mostrar a execução na fila. Numa máquina rápida o primeiro passo terminava antes de a página abrir e o nó só era visto como Succeeded. - AC-15: o axe roda depois que as animações terminam. Um diálogo ainda abrindo misturava os rótulos com o fundo e dava contraste 4,27. - ChooseAsync: espera entre as rolagens do menu virtual do Vuetify, com prazo de 15 s. Antes, as 20 tentativas se esgotavam enquanto o menu ainda abria. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d8bd25d commit 74c0eaa

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎tests/PythonScriptRunner.Panel.E2E.Tests/AccessibilityTests.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public async Task Spec008_AC15_LoginListFormAndRunDetail_HaveNoSeriousOrCritical
3838

3939
private static async Task ExpectAccessibleAsync(IPage page, string screen)
4040
{
41+
// axe reads the colors as rendered: a dialog still fading in blends its labels with the backdrop.
42+
await page.WaitForFunctionAsync(
43+
"() => document.getAnimations().every(a => a.playState !== 'running' || a.effect?.getComputedTiming().endTime === Infinity)");
4144
var result = await page.RunAxe();
4245
var violations = result.Violations
4346
.Where(v => v.Impact is "serious" or "critical")

‎tests/PythonScriptRunner.Panel.E2E.Tests/Infrastructure/PanelPage.cs‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Diagnostics;
2+
13
namespace PythonScriptRunner.Panel.E2E.Tests.Infrastructure;
24

35
/// <summary>Interactions with the panel widgets that need more than a click (Monaco, Vuetify selects, Vue Flow handles).</summary>
@@ -47,10 +49,18 @@ public static async Task ChooseAsync(this ILocator scope, string label, string o
4749
await Expect(menu).ToBeVisibleAsync();
4850

4951
// The menu renders only the items in view (virtual scroll): scroll until the option exists, then click it where it is
50-
// (scrolling it into view again would make the list render it anew).
51-
for (var i = 0; i < 20 && await item.CountAsync() == 0; i++)
52+
// (scrolling it into view again would make the list render it anew). The menu may still be opening, so give each
53+
// scroll time to render instead of spending all the attempts at once.
54+
var deadline = Stopwatch.StartNew();
55+
while (await item.CountAsync() == 0)
5256
{
57+
if (deadline.Elapsed > TimeSpan.FromSeconds(15))
58+
{
59+
throw new TimeoutException($"The option '{option}' did not appear in the '{label}' menu.");
60+
}
61+
5362
await menu.EvaluateAsync("menu => [menu, ...menu.querySelectorAll('*')].filter(e => e.scrollHeight > e.clientHeight + 1).forEach(e => e.scrollTop += 120)");
63+
await page.WaitForTimeoutAsync(100);
5464
}
5565

5666
await item.DispatchEventAsync("click");

‎tests/PythonScriptRunner.Panel.E2E.Tests/OperationTests.cs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public sealed partial class OperationTests(PostgresFixture postgres, BrokerFixtu
2323
[Fact]
2424
public async Task Spec008_AC06_Executor_RunsCalculoProgressao_AndSeesTheNodesChangeLiveUntilSucceeded()
2525
{
26-
await StartAsync();
26+
await StartAsync(s => s.Worker = false);
2727
await App.ImportFixtureAsync("calculo-progressao");
2828
var page = await OpenAsync(PanelUsers.Executor);
2929
await page.Context.AddInitScriptAsync(RecordStepStatuses);
@@ -36,6 +36,11 @@ public async Task Spec008_AC06_Executor_RunsCalculoProgressao_AndSeesTheNodesCha
3636
await Expect(page).ToHaveURLAsync(RunUrl());
3737
var flow = page.GetByTestId("run-flow");
3838
await Expect(flow.Locator("[data-step]")).ToHaveCountAsync(4);
39+
await Expect(flow.Locator("[data-step][data-status=Pending], [data-step][data-status=Queued]")).ToHaveCountAsync(4);
40+
41+
// The worker starts only once the page shows the run waiting: on a fast machine the first step could otherwise
42+
// finish before the page loads, and its node would only ever be seen as Succeeded.
43+
await App.Environment.StartHostAsync();
3944
await Expect(page.GetByTestId("run-status")).ToHaveAttributeAsync("data-status", "Succeeded", new LocatorAssertionsToHaveAttributeOptions { Timeout = 180_000 });
4045
await Expect(flow.Locator("[data-step][data-status=Succeeded]")).ToHaveCountAsync(4);
4146

0 commit comments

Comments
 (0)