Shared test helper to enroll a node in API integration tests

Aberta Para iniciantes
#295 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
84/100
Tipo de issue
Refatoração
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
backend, testing

Direção de pesquisa

Comece pelos seis arquivos de testes de integração listados na issue e compare a configuração repetida de join token, CSR e enrollment. Leia os helpers de testing em apps/api/src/testing/ e os pontos de entrada de enrollment de fleet para identificar o que cada teste precisa receber como retorno. Adicione o helper compartilhado, atualize somente esses seis testes e execute pnpm test:integration; o trabalho está concluído quando passar com a mesma quantidade de testes e nenhum desses testes importar fleet/infrastructure/.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

good first issue

What

Six integration tests outside the fleet module enroll a test node by importing fleet/infrastructure/ca/x509 directly to build a certificate signing request:

  • apps/api/src/modules/apps/application-domains-http.integration.spec.ts
  • apps/api/src/modules/confirmations/confirmation-http.integration.spec.ts
  • apps/api/src/modules/deployments/agent-actions-http.integration.spec.ts
  • apps/api/src/modules/deployments/allocation-observations.integration.spec.ts
  • apps/api/src/modules/deployments/deployment-pipeline.integration.spec.ts
  • apps/api/src/modules/deployments/pipeline-store.integration.spec.ts

CLAUDE.md says modules never import each other's infrastructure/. Tests are not production code, but the repeated setup also duplicates the same steps: issue a join token, build a CSR, enroll.

Proposed change

Add a shared helper in apps/api/src/testing/ (for example enroll-test-node.ts) that issues a join token, builds the CSR, enrolls a node and returns what the tests need. Use it in the six tests above and remove their direct fleet/infrastructure imports. The tests inside fleet itself can keep theirs.

Done when

  • None of the files listed above imports ../fleet/infrastructure/.
  • pnpm test:integration passes with the same number of tests.
  • Nothing changes outside src/testing/ and the six tests.

Raised in the review of #290.

Linguagem predominante
TypeScript
Estrelas
2
Forks
1
Merge médio
7h 17min
PRs com merge (30d)
197

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de shipkeepdev/shipkeep

Todas as issues de shipkeepdev/shipkeep

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.