diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afabb98..c4978e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,13 @@ jobs: # Testcontainers (Docker); GitHub's Windows runners cannot run Linux containers, so Windows runs the Core tests only. - name: Test if: runner.os == 'Linux' - run: dotnet test --no-build --configuration Release + run: dotnet test --no-build --configuration Release --solution tests/PythonScriptRunner.SemE2E.slnf + + # The panel E2E tests run alone: containers starting or stopping in the other test projects change the host's network + # interfaces, and Chromium then aborts requests in flight with ERR_NETWORK_CHANGED. + - name: Test (panel E2E) + if: runner.os == 'Linux' + run: dotnet test --no-build --configuration Release --project tests/PythonScriptRunner.Panel.E2E.Tests - name: Upload Playwright traces if: failure() && runner.os == 'Linux' diff --git a/README.md b/README.md index f811c8c..44436e0 100644 --- a/README.md +++ b/README.md @@ -283,7 +283,13 @@ dotnet test --project tests/PythonScriptRunner.Panel.E2E.Tests --no-build # PS ``` Quando um teste falha, o *trace* do Playwright fica em `TestResults/traces` ao lado do assembly de testes -(`npx playwright show-trace .zip`). +(`npx playwright show-trace .zip`). Rode o E2E sozinho: contêineres subindo ou parando em outros projetos de +teste mudam as interfaces de rede e o Chromium aborta requisições com `ERR_NETWORK_CHANGED`. Para todo o resto de uma vez, +use o filtro de solução sem o E2E (é o que o CI faz): + +```bash +dotnet test --solution tests/PythonScriptRunner.SemE2E.slnf +``` O teste de desempenho do painel usa ~200 mil execuções; `PSR_PERF_RUNS_PER_DAY=50000` roda o volume médio completo (90 dias). O documento OpenAPI do painel é comparado com `tests/PythonScriptRunner.Dashboard.Tests/Snapshots/openapi-v1.verified.json`; diff --git a/panel/scripts/check-bundle.mjs b/panel/scripts/check-bundle.mjs index 100fd00..5dd59e9 100644 --- a/panel/scripts/check-bundle.mjs +++ b/panel/scripts/check-bundle.mjs @@ -1,6 +1,6 @@ // Orçamento do bundle inicial (spec 008): ≤ 500 KB gzip para os arquivos que index.html carrega. // Monaco e Vue Flow ficam em chunks carregados sob demanda e não entram na conta. -import { readFile } from 'node:fs/promises' +import { readdir, readFile } from 'node:fs/promises' import { gzipSync } from 'node:zlib' import { fileURLToPath } from 'node:url' @@ -20,3 +20,12 @@ if (total > limit) { console.error('O bundle inicial passou do orçamento da spec 008.') process.exit(1) } + +// A CSP do painel só aceita `data:` em imagens: uma fonte embutida seria bloqueada pelo navegador. +const css = (await readdir(`${dist}assets`)).filter((f) => f.endsWith('.css')) +for (const file of css) { + if ((await readFile(`${dist}assets/${file}`, 'utf8')).includes('url(data:font/')) { + console.error(`assets/${file} embute uma fonte como data:, que a CSP do painel bloqueia.`) + process.exit(1) + } +} diff --git a/panel/src/components/auth/LoginForm.spec.ts b/panel/src/components/auth/LoginForm.spec.ts new file mode 100644 index 0000000..cc96b4c --- /dev/null +++ b/panel/src/components/auth/LoginForm.spec.ts @@ -0,0 +1,23 @@ +import { mount } from '@vue/test-utils' +import { createPinia, setActivePinia } from 'pinia' +import { beforeEach, describe, expect, it } from 'vitest' +import LoginForm from './LoginForm.vue' + +describe('Formulário de login fixo', () => { + beforeEach(() => setActivePinia(createPinia())) + + it('Spec008_AC17 na página o usuário já recebe o foco ao montar (quem digita logo não perde a senha)', () => { + const wrapper = mount(LoginForm, { attachTo: document.body }) + + expect(document.activeElement).toBe(wrapper.find('input[name=name]').element) + wrapper.unmount() + }) + + it('Spec008_AC19 com o usuário travado (sessão expirada) o campo de usuário não toma o foco', () => { + const wrapper = mount(LoginForm, { attachTo: document.body, props: { lockedName: 'ana' } }) + + expect(document.activeElement).not.toBe(wrapper.find('input[name=name]').element) + expect(wrapper.find('input[name=name]').attributes('readonly')).toBeDefined() + wrapper.unmount() + }) +}) diff --git a/panel/src/components/auth/LoginForm.vue b/panel/src/components/auth/LoginForm.vue index 7b9c54c..2247106 100644 --- a/panel/src/components/auth/LoginForm.vue +++ b/panel/src/components/auth/LoginForm.vue @@ -1,6 +1,7 @@ @@ -76,13 +86,13 @@ onBeforeUnmount(() => timer && clearInterval(timer)) {{ t('auth.login.throttled', { seconds: wait }) }} - + {{ t('common.refresh') }} - + diff --git a/panel/src/views/audit/AuditView.vue b/panel/src/views/audit/AuditView.vue index 113e490..a288fe6 100644 --- a/panel/src/views/audit/AuditView.vue +++ b/panel/src/views/audit/AuditView.vue @@ -64,7 +64,7 @@ onMounted(() => load(true)) - + diff --git a/panel/src/views/pipelines/PipelineDetailView.vue b/panel/src/views/pipelines/PipelineDetailView.vue index e53b098..06b1064 100644 --- a/panel/src/views/pipelines/PipelineDetailView.vue +++ b/panel/src/views/pipelines/PipelineDetailView.vue @@ -347,7 +347,7 @@ const exportUrl = (v: number) => `${apiBase}/pipelines/${encodeURIComponent(key. t('common.save') }}
{{ t('pipelines.settings.retention') }}
- + {{ publishError }} - + diff --git a/panel/src/views/pipelines/RunPipelineDialog.vue b/panel/src/views/pipelines/RunPipelineDialog.vue index 44b41b6..db0f496 100644 --- a/panel/src/views/pipelines/RunPipelineDialog.vue +++ b/panel/src/views/pipelines/RunPipelineDialog.vue @@ -69,7 +69,7 @@ async function submit() { {{ error }} - + - + diff --git a/panel/src/views/stages/StageEditorView.vue b/panel/src/views/stages/StageEditorView.vue index eab1835..5a874a9 100644 --- a/panel/src/views/stages/StageEditorView.vue +++ b/panel/src/views/stages/StageEditorView.vue @@ -381,7 +381,7 @@ function retry(): Schemas['RetryPolicy'] { @update:model-value="(v: string) => form && (form.memoryLimitMb = v === '' ? null : Number(v))" />
{{ t('stages.editor.retry') }}
- + (/\.(woff2?|ttf|otf|eot)$/i.test(file) ? false : undefined), }, worker: { format: 'es', diff --git a/tests/PythonScriptRunner.Panel.E2E.Tests/AccessTests.cs b/tests/PythonScriptRunner.Panel.E2E.Tests/AccessTests.cs index f84c998..6cfe41f 100644 --- a/tests/PythonScriptRunner.Panel.E2E.Tests/AccessTests.cs +++ b/tests/PythonScriptRunner.Panel.E2E.Tests/AccessTests.cs @@ -131,12 +131,23 @@ public async Task Spec008_AC10_Reader_SeesNoActionButtons_AndEditRoutesShowNoPer [Fact] public async Task Spec008_AC12_FollowsTheDarkSystemTheme_AndKeepsTheManualChoiceAfterReload() { - await StartAsync(); + await StartAsync(s => s.Worker = false); + await App.ImportFixtureAsync("calculo-progressao"); var page = await OpenAsync(PanelUsers.Reader, o => o.ColorScheme = ColorScheme.Dark); - await GoToAsync(page, string.Empty); + await GoToAsync(page, "trilhas/calculo-progressao"); var app = page.Locator(".v-application"); await Expect(app).ToHaveClassAsync(new Regex(@"\bv-theme--dark\b")); + // The canvas controls and minimap follow the theme (Vue Flow styles them light by default). + await Expect(page.Locator(".vue-flow__minimap")).ToBeVisibleAsync(); + var surface = await page.Locator(".flow-canvas").EvaluateAsync("e => getComputedStyle(e).backgroundColor"); + foreach (var part in new[] { ".vue-flow__controls-button", ".vue-flow__minimap" }) + { + (await page.Locator(part).First.EvaluateAsync("e => getComputedStyle(e).backgroundColor")).ShouldBe(surface, part); + } + + await GoToAsync(page, string.Empty); + await page.GetByTestId("theme-menu").ClickAsync(); await page.GetByTestId("theme-light").ClickAsync(); await Expect(app).ToHaveClassAsync(new Regex(@"\bv-theme--light\b")); diff --git a/tests/PythonScriptRunner.Panel.E2E.Tests/AccessibilityTests.cs b/tests/PythonScriptRunner.Panel.E2E.Tests/AccessibilityTests.cs index 93b9a94..4079e5d 100644 --- a/tests/PythonScriptRunner.Panel.E2E.Tests/AccessibilityTests.cs +++ b/tests/PythonScriptRunner.Panel.E2E.Tests/AccessibilityTests.cs @@ -38,6 +38,9 @@ public async Task Spec008_AC15_LoginListFormAndRunDetail_HaveNoSeriousOrCritical private static async Task ExpectAccessibleAsync(IPage page, string screen) { + // axe reads the colors as rendered: a dialog still fading in blends its labels with the backdrop. + await page.WaitForFunctionAsync( + "() => document.getAnimations().every(a => a.playState !== 'running' || a.effect?.getComputedTiming().endTime === Infinity)"); var result = await page.RunAxe(); var violations = result.Violations .Where(v => v.Impact is "serious" or "critical") diff --git a/tests/PythonScriptRunner.Panel.E2E.Tests/Infrastructure/PanelPage.cs b/tests/PythonScriptRunner.Panel.E2E.Tests/Infrastructure/PanelPage.cs index 8041786..062357b 100644 --- a/tests/PythonScriptRunner.Panel.E2E.Tests/Infrastructure/PanelPage.cs +++ b/tests/PythonScriptRunner.Panel.E2E.Tests/Infrastructure/PanelPage.cs @@ -1,3 +1,5 @@ +using System.Diagnostics; + namespace PythonScriptRunner.Panel.E2E.Tests.Infrastructure; /// Interactions with the panel widgets that need more than a click (Monaco, Vuetify selects, Vue Flow handles). @@ -47,10 +49,18 @@ public static async Task ChooseAsync(this ILocator scope, string label, string o await Expect(menu).ToBeVisibleAsync(); // The menu renders only the items in view (virtual scroll): scroll until the option exists, then click it where it is - // (scrolling it into view again would make the list render it anew). - for (var i = 0; i < 20 && await item.CountAsync() == 0; i++) + // (scrolling it into view again would make the list render it anew). The menu may still be opening, so give each + // scroll time to render instead of spending all the attempts at once. + var deadline = Stopwatch.StartNew(); + while (await item.CountAsync() == 0) { + if (deadline.Elapsed > TimeSpan.FromSeconds(15)) + { + throw new TimeoutException($"The option '{option}' did not appear in the '{label}' menu."); + } + await menu.EvaluateAsync("menu => [menu, ...menu.querySelectorAll('*')].filter(e => e.scrollHeight > e.clientHeight + 1).forEach(e => e.scrollTop += 120)"); + await page.WaitForTimeoutAsync(100); } await item.DispatchEventAsync("click"); diff --git a/tests/PythonScriptRunner.Panel.E2E.Tests/OperationTests.cs b/tests/PythonScriptRunner.Panel.E2E.Tests/OperationTests.cs index 8c32df2..7964396 100644 --- a/tests/PythonScriptRunner.Panel.E2E.Tests/OperationTests.cs +++ b/tests/PythonScriptRunner.Panel.E2E.Tests/OperationTests.cs @@ -23,7 +23,7 @@ public sealed partial class OperationTests(PostgresFixture postgres, BrokerFixtu [Fact] public async Task Spec008_AC06_Executor_RunsCalculoProgressao_AndSeesTheNodesChangeLiveUntilSucceeded() { - await StartAsync(); + await StartAsync(s => s.Worker = false); await App.ImportFixtureAsync("calculo-progressao"); var page = await OpenAsync(PanelUsers.Executor); await page.Context.AddInitScriptAsync(RecordStepStatuses); @@ -36,6 +36,11 @@ public async Task Spec008_AC06_Executor_RunsCalculoProgressao_AndSeesTheNodesCha await Expect(page).ToHaveURLAsync(RunUrl()); var flow = page.GetByTestId("run-flow"); await Expect(flow.Locator("[data-step]")).ToHaveCountAsync(4); + await Expect(flow.Locator("[data-step][data-status=Pending], [data-step][data-status=Queued]")).ToHaveCountAsync(4); + + // The worker starts only once the page shows the run waiting: on a fast machine the first step could otherwise + // finish before the page loads, and its node would only ever be seen as Succeeded. + await App.Environment.StartHostAsync(); await Expect(page.GetByTestId("run-status")).ToHaveAttributeAsync("data-status", "Succeeded", new LocatorAssertionsToHaveAttributeOptions { Timeout = 180_000 }); await Expect(flow.Locator("[data-step][data-status=Succeeded]")).ToHaveCountAsync(4); diff --git a/tests/PythonScriptRunner.Panel.E2E.Tests/PipelineEditorTests.cs b/tests/PythonScriptRunner.Panel.E2E.Tests/PipelineEditorTests.cs index 5400910..5198fe8 100644 --- a/tests/PythonScriptRunner.Panel.E2E.Tests/PipelineEditorTests.cs +++ b/tests/PythonScriptRunner.Panel.E2E.Tests/PipelineEditorTests.cs @@ -144,6 +144,27 @@ public async Task Spec008_AC16_TestingTheDraft_FollowsThePipelineTestLive_AndPub pipeline.Versions.Select(v => (v.Version, v.Status)).ShouldBe([(2, VersionStatus.Draft), (1, VersionStatus.Published)], ignoreOrder: true); } + [Fact] + public async Task Spec008_AC03_Organize_KeepsEveryConnection_IncludingThePipelineOutputs() + { + await StartAsync(s => s.Worker = false); + await App.ImportFixtureAsync("calculo-progressao"); + await App.Host.Admin.CreatePipelineDraftFromAsync("calculo-progressao", 1, PsrEnvironment.Author, Ct); + var page = await OpenAsync(PanelUsers.Author); + await GoToAsync(page, "trilhas/calculo-progressao/editar"); + var canvas = page.GetByTestId("pipeline-canvas"); + var edges = canvas.Locator(".vue-flow__edge"); + var outputs = canvas.Locator(".vue-flow__edge[data-id^='out:']"); + await Expect(outputs).ToHaveCountAsync(4); + var before = await edges.CountAsync(); + + await page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "Organizar" }).ClickAsync(); + + await Expect(page.GetByTestId("dirty")).ToBeVisibleAsync(); + await Expect(outputs).ToHaveCountAsync(4); + await Expect(edges).ToHaveCountAsync(before); + } + private static ILocator Step(ILocator canvas, string key) => canvas.Locator($"[data-step={key}]"); private static ILocator In(ILocator node, string name) => node.Locator($"[data-handle='in:{name}']"); diff --git a/tests/PythonScriptRunner.SemE2E.slnf b/tests/PythonScriptRunner.SemE2E.slnf new file mode 100644 index 0000000..cce70b4 --- /dev/null +++ b/tests/PythonScriptRunner.SemE2E.slnf @@ -0,0 +1,12 @@ +{ + "solution": { + "path": "../PythonScriptRunner.slnx", + "projects": [ + "tests/PythonScriptRunner.Core.Tests/PythonScriptRunner.Core.Tests.csproj", + "tests/PythonScriptRunner.Dashboard.Tests/PythonScriptRunner.Dashboard.Tests.csproj", + "tests/PythonScriptRunner.EntityFrameworkCore.Tests/PythonScriptRunner.EntityFrameworkCore.Tests.csproj", + "tests/PythonScriptRunner.RabbitMQ.Tests/PythonScriptRunner.RabbitMQ.Tests.csproj", + "tests/PythonScriptRunner.Worker.Tests/PythonScriptRunner.Worker.Tests.csproj" + ] + } +}