This commit is contained in:
@@ -10333,3 +10333,8 @@ Destino confirmado pelo executor existente: https://teste-investidor.tempo.co.mz
|
||||
Pré-instalação: backup fresco em /var/backups/investmoz-guide-20261117/backup, restauro isolado integral de 195 tabelas e 417 ficheiros conferido; fontes do executor e configuração preservadas. Verificação global npm run check detecta formatação em 65 ficheiros anteriores não alterados por este lote; lint focado e tipos aprovados. Não foram reformulados ficheiros não relacionados para corrigir essa dívida. O executor mantém os seus testes normais sem dispensa.
|
||||
|
||||
Regressão final do candidato: 1 977 testes frontend aprovados após compilação QA; tipos e lint dos ficheiros afectados aprovados. Actualizados exclusivamente os mocks de importação/autenticação dos ensaios existentes para manter as verificações anteriores com o novo componente. O registo demográfico anterior conserva a referência e4735424 e um manifesto que já não coincide com b60c231d; é uma condição anterior a este incremento, preservada sem activação/revalidação por este lote.
|
||||
|
||||
|
||||
## 17/11/2026 — GUIA-PASSO-20261117: correcção da abertura automática
|
||||
|
||||
Verificação autenticada online no dossier sintético db85f087-0737-4164-892a-4fa4fe1313df: os 19 botões de ajuda abriram/fecharam e o percurso Seguinte mostrou as 19 explicações completas. Identificado conflito entre focus/click do summary e o toggle nativo: uma etapa podia fechar-se depois da selecção automática da ajuda. Correcção limitada ao componente: ignorar summary em focus/click e observar o toggle nativo em captura depois da abertura. Fecho deliberado continua possível; o guia fechado permanece pausado. Regressão executa os handlers reais e confirma a sequência; ensaio do componente real no navegador confirmou fecho, reabertura e selecção de outra etapa. Tipos/lint focado aprovados. Sem alterações nos dados, estados, formulários ou permissões. Instalação pelo mesmo executor, com backup/restauro fresco; conferir recibo posterior e repetir as 19 etapas online antes da aceitação.
|
||||
|
||||
@@ -115,12 +115,13 @@ export function InvestmentHelpGuide({
|
||||
}
|
||||
}
|
||||
|
||||
function orient(target: EventTarget) {
|
||||
function orient(target: EventTarget, disclosure = false) {
|
||||
if (
|
||||
!automatic ||
|
||||
paused.current ||
|
||||
!(target instanceof Element) ||
|
||||
target.closest('[data-help-controls]')
|
||||
target.closest('[data-help-controls]') ||
|
||||
(!disclosure && target.closest('summary'))
|
||||
)
|
||||
return;
|
||||
const code = target.closest<HTMLElement>('[data-investment-step]')
|
||||
@@ -128,6 +129,21 @@ export function InvestmentHelpGuide({
|
||||
if (code && steps.some((step) => step.code === code)) setActive(code);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const node = root.current;
|
||||
if (!node) return;
|
||||
const onToggle = (event: Event) => {
|
||||
const target = event.target;
|
||||
// Native toggle follows the summary click. Observe the opened state
|
||||
// instead of changing it while focus/click is still being dispatched.
|
||||
if (target instanceof HTMLDetailsElement && target.open) {
|
||||
orient(target, true);
|
||||
}
|
||||
};
|
||||
node.addEventListener('toggle', onToggle, true);
|
||||
return () => node.removeEventListener('toggle', onToggle, true);
|
||||
}, [automatic, steps]);
|
||||
|
||||
return (
|
||||
<GuideContext.Provider
|
||||
value={{ steps, active: visibleActive, automatic, choose }}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import React from 'react';
|
||||
import ts from 'typescript';
|
||||
import { compileFunction } from 'node:vm';
|
||||
import { createRequire } from 'node:module';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
@@ -86,3 +90,139 @@ test('dossier help follows only the steps already permitted by the adaptive path
|
||||
assert.doesNotMatch(component, /router\.|fetch\(|\.submit\(|\.post\(/);
|
||||
assert.doesNotMatch(component, /location\.(assign|reload)|window\.history/);
|
||||
});
|
||||
|
||||
test('summary focus and click wait for the native open toggle; closing a stage does not reopen it', () => {
|
||||
const require = createRequire(import.meta.url);
|
||||
const memory = [];
|
||||
let cursor = 0;
|
||||
let refCursor = 0;
|
||||
const refs = [];
|
||||
const effects = [];
|
||||
const listeners = {};
|
||||
const rootNode = {
|
||||
querySelectorAll: () => [],
|
||||
addEventListener: (name, listener) => {
|
||||
listeners[name] = listener;
|
||||
},
|
||||
removeEventListener() {},
|
||||
};
|
||||
const hooks = {
|
||||
...React,
|
||||
useEffect(effect) {
|
||||
effects.push(effect);
|
||||
},
|
||||
useRef: (initial) => {
|
||||
const index = refCursor++;
|
||||
return (refs[index] ??= { current: initial });
|
||||
},
|
||||
useState(initial) {
|
||||
const index = cursor++;
|
||||
if (!(index in memory)) memory[index] = initial;
|
||||
return [
|
||||
memory[index],
|
||||
(value) => {
|
||||
memory[index] = value;
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
const source = readFileSync(
|
||||
new URL(
|
||||
'../../resources/js/components/investment-step-help.tsx',
|
||||
import.meta.url,
|
||||
),
|
||||
'utf8',
|
||||
);
|
||||
const code = ts.transpileModule(source, {
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
jsx: ts.JsxEmit.ReactJSX,
|
||||
},
|
||||
}).outputText;
|
||||
const module = { exports: {} };
|
||||
compileFunction(code, ['require', 'module', 'exports'])(
|
||||
(name) =>
|
||||
name === 'react'
|
||||
? hooks
|
||||
: name === 'lucide-react'
|
||||
? { CircleHelp: () => null }
|
||||
: name === '@/lib/investment-step-help'
|
||||
? { helpPreferenceKey, readHelpPreference }
|
||||
: require(name),
|
||||
module,
|
||||
module.exports,
|
||||
);
|
||||
class Target {
|
||||
constructor(summary, open) {
|
||||
this.summary = summary;
|
||||
this.open = open;
|
||||
this.dataset = { investmentStep: 'S02' };
|
||||
}
|
||||
closest(selector) {
|
||||
return selector === 'summary'
|
||||
? this.summary
|
||||
? this
|
||||
: null
|
||||
: selector === '[data-investment-step]'
|
||||
? this
|
||||
: null;
|
||||
}
|
||||
}
|
||||
class Disclosure extends Target {}
|
||||
const originalElement = globalThis.Element;
|
||||
const originalDetails = globalThis.HTMLDetailsElement;
|
||||
globalThis.Element = Target;
|
||||
globalThis.HTMLDetailsElement = Disclosure;
|
||||
const render = () => {
|
||||
cursor = 0;
|
||||
refCursor = 0;
|
||||
effects.length = 0;
|
||||
const tree = module.exports.InvestmentHelpGuide({
|
||||
user: 1,
|
||||
flow: 'regression',
|
||||
steps: [investmentStageHelp('S02', 'Análise')],
|
||||
});
|
||||
refs[0].current = rootNode;
|
||||
effects.at(-1)();
|
||||
return tree;
|
||||
};
|
||||
try {
|
||||
let tree = render();
|
||||
const summary = new Target(true);
|
||||
tree.props.children.props.onFocusCapture({ target: summary });
|
||||
tree.props.children.props.onClickCapture({ target: summary });
|
||||
assert.equal(
|
||||
render().props.value.active,
|
||||
null,
|
||||
'summary events must not open details before their native click',
|
||||
);
|
||||
listeners.toggle({
|
||||
target: new Disclosure(false, false),
|
||||
});
|
||||
assert.equal(render().props.value.active, null);
|
||||
listeners.toggle({
|
||||
target: new Disclosure(false, true),
|
||||
});
|
||||
tree = render();
|
||||
assert.equal(
|
||||
tree.props.value.active,
|
||||
'S02',
|
||||
'opening a stage selects its automatic help',
|
||||
);
|
||||
tree.props.value.choose(null);
|
||||
tree = render();
|
||||
listeners.toggle({
|
||||
target: new Disclosure(false, true),
|
||||
});
|
||||
assert.equal(
|
||||
render().props.value.active,
|
||||
null,
|
||||
'closing the guide keeps automatic help paused',
|
||||
);
|
||||
} finally {
|
||||
if (originalElement === undefined) delete globalThis.Element;
|
||||
else globalThis.Element = originalElement;
|
||||
if (originalDetails === undefined) delete globalThis.HTMLDetailsElement;
|
||||
else globalThis.HTMLDetailsElement = originalDetails;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user