Skip to content

Commit d8bd25d

Browse files
net0wellclaude
andcommitted
fix(painel): saídas somem ao organizar, canvas no tema escuro e foco do login (spec 008)
- Editor de trilha: o Vue Flow também roda o is-valid-connection nas arestas recebidas por props; as ligações já existentes com as saídas da trilha eram recusadas e sumiam do canvas depois de "Organizar" (o modelo não perdia nada). Arestas do modelo (com id) passam direto; a validação vale só para conexões novas. - Tema escuro: controles de zoom e minimapa usam as cores do tema (o CSS do Vue Flow tem cores claras fixas). - Login fixo: na página, o usuário recebe o foco ao montar. O autofocus do Vuetify espera ~50 ms e tirava o foco de quem já digitava a senha. No diálogo de sessão expirada continua o autofocus na senha. - Testes: E2E de "Organizar" mantendo as 4 ligações das saídas, cores do canvas no tema escuro (AC-12) e Vitest do foco do login (AC-17/AC-19). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b2e1856 commit d8bd25d

6 files changed

Lines changed: 104 additions & 5 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { mount } from '@vue/test-utils'
2+
import { createPinia, setActivePinia } from 'pinia'
3+
import { beforeEach, describe, expect, it } from 'vitest'
4+
import LoginForm from './LoginForm.vue'
5+
6+
describe('Formulário de login fixo', () => {
7+
beforeEach(() => setActivePinia(createPinia()))
8+
9+
it('Spec008_AC17 na página o usuário já recebe o foco ao montar (quem digita logo não perde a senha)', () => {
10+
const wrapper = mount(LoginForm, { attachTo: document.body })
11+
12+
expect(document.activeElement).toBe(wrapper.find('input[name=name]').element)
13+
wrapper.unmount()
14+
})
15+
16+
it('Spec008_AC19 com o usuário travado (sessão expirada) o campo de usuário não toma o foco', () => {
17+
const wrapper = mount(LoginForm, { attachTo: document.body, props: { lockedName: 'ana' } })
18+
19+
expect(document.activeElement).not.toBe(wrapper.find('input[name=name]').element)
20+
expect(wrapper.find('input[name=name]').attributes('readonly')).toBeDefined()
21+
wrapper.unmount()
22+
})
23+
})

‎panel/src/components/auth/LoginForm.vue‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
2-
import { computed, onBeforeUnmount, ref } from 'vue'
2+
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
33
import { useI18n } from 'vue-i18n'
4+
import type { VTextField } from 'vuetify/components'
45
import { useSession } from '@/stores/session'
56
67
/** Login fixo (D-129): nome + senha; erro genérico (D-135) e contagem regressiva no 429 (D-146). */
@@ -14,6 +15,7 @@ const password = ref('')
1415
const busy = ref(false)
1516
const invalid = ref(false)
1617
const wait = ref(0)
18+
const nameField = ref<VTextField | null>(null)
1719
let timer: ReturnType<typeof setInterval> | null = null
1820
1921
const canSubmit = computed(() => !busy.value && wait.value === 0 && name.value.trim() !== '' && password.value !== '')
@@ -56,6 +58,14 @@ async function submit() {
5658
}
5759
}
5860
61+
// Na página o foco vai ao usuário já ao montar: o autofocus do Vuetify espera ~50 ms e tiraria o foco de quem já começou a
62+
// digitar. No diálogo de sessão expirada (usuário travado) fica o autofocus da senha, que espera a transição do diálogo.
63+
onMounted(() => {
64+
if (!props.lockedName) {
65+
nameField.value?.focus()
66+
}
67+
})
68+
5969
onBeforeUnmount(() => timer && clearInterval(timer))
6070
</script>
6171

@@ -76,13 +86,13 @@ onBeforeUnmount(() => timer && clearInterval(timer))
7686
{{ t('auth.login.throttled', { seconds: wait }) }}
7787
</v-alert>
7888
<v-text-field
89+
ref="nameField"
7990
v-model="name"
8091
:label="t('auth.login.name')"
8192
autocomplete="username"
8293
:readonly="Boolean(lockedName)"
8394
prepend-inner-icon="mdi-account"
8495
name="name"
85-
autofocus
8696
/>
8797
<v-text-field
8898
v-model="password"

‎panel/src/components/flow/FlowCanvas.vue‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ function connectStart(params: { event?: MouseEvent | TouchEvent } & OnConnectSta
6666
}
6767
}
6868
69-
function isValidConnection(connection: Connection): boolean {
69+
function isValidConnection(connection: Connection | Edge): boolean {
70+
// O Vue Flow também valida as arestas recebidas por props (elas têm id); essas vêm do modelo, que já é válido, e
71+
// "ligar numa saída existente" só é proibido para uma conexão nova (sem isso, Organizar sumia com as saídas).
72+
if ('id' in connection) {
73+
return true
74+
}
75+
7076
return (
7177
props.editable &&
7278
Boolean(connection.sourceHandle && connection.targetHandle) &&

‎panel/src/components/flow/flow.css‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,34 @@ button.step-node__port-label {
120120
cursor: not-allowed;
121121
}
122122

123+
/* Controles e minimapa seguem o tema do painel: os estilos do Vue Flow têm cores claras fixas. */
124+
.flow-canvas .vue-flow__controls {
125+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
126+
}
127+
128+
.flow-canvas .vue-flow__controls-button {
129+
background: rgb(var(--v-theme-surface));
130+
color: rgb(var(--v-theme-on-surface));
131+
border-bottom: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
132+
}
133+
134+
.flow-canvas .vue-flow__controls-button:hover {
135+
background: rgba(var(--v-theme-on-surface), 0.08);
136+
}
137+
138+
.flow-canvas .vue-flow__minimap {
139+
background-color: rgb(var(--v-theme-surface));
140+
border: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
141+
}
142+
143+
.flow-canvas .vue-flow__minimap-mask {
144+
fill: rgba(var(--v-theme-on-surface), 0.08);
145+
}
146+
147+
.flow-canvas .vue-flow__minimap-node {
148+
fill: rgba(var(--v-theme-on-surface), 0.3);
149+
}
150+
123151
.flow-canvas .vue-flow__edge.edge--implicit .vue-flow__edge-path {
124152
stroke-dasharray: 6 4;
125153
opacity: 0.6;

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,23 @@ public async Task Spec008_AC10_Reader_SeesNoActionButtons_AndEditRoutesShowNoPer
131131
[Fact]
132132
public async Task Spec008_AC12_FollowsTheDarkSystemTheme_AndKeepsTheManualChoiceAfterReload()
133133
{
134-
await StartAsync();
134+
await StartAsync(s => s.Worker = false);
135+
await App.ImportFixtureAsync("calculo-progressao");
135136
var page = await OpenAsync(PanelUsers.Reader, o => o.ColorScheme = ColorScheme.Dark);
136-
await GoToAsync(page, string.Empty);
137+
await GoToAsync(page, "trilhas/calculo-progressao");
137138
var app = page.Locator(".v-application");
138139
await Expect(app).ToHaveClassAsync(new Regex(@"\bv-theme--dark\b"));
139140

141+
// The canvas controls and minimap follow the theme (Vue Flow styles them light by default).
142+
await Expect(page.Locator(".vue-flow__minimap")).ToBeVisibleAsync();
143+
var surface = await page.Locator(".flow-canvas").EvaluateAsync<string>("e => getComputedStyle(e).backgroundColor");
144+
foreach (var part in new[] { ".vue-flow__controls-button", ".vue-flow__minimap" })
145+
{
146+
(await page.Locator(part).First.EvaluateAsync<string>("e => getComputedStyle(e).backgroundColor")).ShouldBe(surface, part);
147+
}
148+
149+
await GoToAsync(page, string.Empty);
150+
140151
await page.GetByTestId("theme-menu").ClickAsync();
141152
await page.GetByTestId("theme-light").ClickAsync();
142153
await Expect(app).ToHaveClassAsync(new Regex(@"\bv-theme--light\b"));

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,27 @@ public async Task Spec008_AC16_TestingTheDraft_FollowsThePipelineTestLive_AndPub
144144
pipeline.Versions.Select(v => (v.Version, v.Status)).ShouldBe([(2, VersionStatus.Draft), (1, VersionStatus.Published)], ignoreOrder: true);
145145
}
146146

147+
[Fact]
148+
public async Task Spec008_AC03_Organize_KeepsEveryConnection_IncludingThePipelineOutputs()
149+
{
150+
await StartAsync(s => s.Worker = false);
151+
await App.ImportFixtureAsync("calculo-progressao");
152+
await App.Host.Admin.CreatePipelineDraftFromAsync("calculo-progressao", 1, PsrEnvironment.Author, Ct);
153+
var page = await OpenAsync(PanelUsers.Author);
154+
await GoToAsync(page, "trilhas/calculo-progressao/editar");
155+
var canvas = page.GetByTestId("pipeline-canvas");
156+
var edges = canvas.Locator(".vue-flow__edge");
157+
var outputs = canvas.Locator(".vue-flow__edge[data-id^='out:']");
158+
await Expect(outputs).ToHaveCountAsync(4);
159+
var before = await edges.CountAsync();
160+
161+
await page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "Organizar" }).ClickAsync();
162+
163+
await Expect(page.GetByTestId("dirty")).ToBeVisibleAsync();
164+
await Expect(outputs).ToHaveCountAsync(4);
165+
await Expect(edges).ToHaveCountAsync(before);
166+
}
167+
147168
private static ILocator Step(ILocator canvas, string key) => canvas.Locator($"[data-step={key}]");
148169

149170
private static ILocator In(ILocator node, string name) => node.Locator($"[data-handle='in:{name}']");

0 commit comments

Comments
 (0)