Shared test helper to enroll a node in API integration tests

未关闭 适合新手
#295 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
backend, testing

调研方向

从 issue 中列出的六个集成测试文件开始,比较它们重复的 join token、CSR 和 enrollment 设置。阅读 apps/api/src/testing/ 下的 testing helper,以及 fleet 的 enrollment 入口点,以确定每个测试需要返回什么。添加共享 helper,只更新这六个测试,并运行 pnpm test:integration;当它以相同的测试数量通过,且这些测试都不 import fleet/infrastructure/ 时,任务即完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
2
派生
1
平均合并
7 小时 17 分钟
30 天内合并 PR
197

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

shipkeepdev/shipkeep 的其他 Issue

查看 shipkeepdev/shipkeep 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。