Testar componente SmartForm
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- react, typescript
- Domain
- accessibility, frontend, testing
Research direction
Read src/components/form/SmartForm/index.tsx and compare the test structure in TextInput.test.tsx. Create src/components/form/SmartForm/index.test.tsx with a manually constructed formState and cover field rendering, submit handling, loading, disabled state, and axe accessibility checks. Run npm run test and confirm the component meets the 85% coverage threshold.
Written by the indexing model from the issue text.
Description
O que fazer
Criar testes unitários e de acessibilidade para o componente orquestrador SmartForm.
Arquivos a modificar
src/components/form/SmartForm/index.test.tsx— criação
Abordagem técnica
Seguir padrão de TextInput.test.tsx. formState é recebido via prop (UseSmartFormReturn), então não é necessário mockar useSmartForm — basta construir um objeto formState manualmente com os campos necessários (data, errors, loading, handleChangeValue, handleSubmit, serializedFields, disabled), todos como vi.fn()/valores simples.
Casos a cobrir (ver src/components/form/SmartForm/index.tsx):
- Renderiza um
SmartFieldpor item deformState.serializedFields, passandoerror,value,disabledeoptionscorretos. - Submit do
<form>(ex: clicar no botão de submit) chamaformState.handleSubmit. formState.loading: truerenderiza o indicador deLoadingdentro do botão de submit.formState.disabled: truedesabilita o botão de submit.- Teste de acessibilidade: renderizar com um
formStatemínimo (1-2 campos simples) e rodarexpect(await axe(container)).toHaveNoViolations().
Testes esperados
- Renderiza um campo por item de
serializedFields - Submete o formulário chamando
formState.handleSubmit - Exibe indicador de loading quando
formState.loadingétrue - Desabilita botão de submit quando
formState.disabledétrue - Sem violações de acessibilidade (
toHaveNoViolations)
Critérios de Aceite
-
SmartForm/index.tsxatinge cobertura consistente com o threshold de 85% -
npm run testpassa sem falhas, incluindo o teste de a11y
Referências
- Issue de origem: https://github.com/zjefersound/react-essentials/issues/33
- TechSpec:
issues/33-add_tests_important_components/techspec.md - Depende funcionalmente (não bloqueante de merge) da Issue de testes de
SmartFielde da Issue de infraestrutura de coverage/a11y
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 0
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from zjefersound/react-essentials
-
size:XS status:needs-refinement type:tech
Difficulty 1/5 Under an hour Newbie friendliness 82/100
zjefersound/react-essentials#42 · 1 comment ·
-
Agentic Coding tests Open
Difficulty 5/5 Over a week Newbie friendliness 35/100
zjefersound/react-essentials#47 · 1 comment ·
-
size:M status:backlog type:tech
Difficulty 3/5 1-2 days Newbie friendliness 74/100
-
size:M status:backlog type:tech
Difficulty 3/5 1-2 days Newbie friendliness 76/100
-
zjefersound/react-essentials#33 · 1 assignee ·
All issues in zjefersound/react-essentials
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100