Repository navigation
test(providers/gitlab): add opt-in live smoke test against real GitLab - #321
Merged
Merged
Conversation
Adds src/__tests__/e2e/gitlab-provider-live.test.ts, mirroring the cnb-provider-live pattern: skipped unless GITLAB_TOKEN is set, runs a read-only whoami check via GET /user against the configured instance (defaults to gitlab.com, or self-hosted via GITLAB_URL). The mutating half (create -> clone -> push -> open-MR) was verified manually against git.guazi-corp.com with the teamai-cli GitLab provider shipping in 0.21.0-beta.0. Token auth + REST API + in-URL oauth2 clone + createPullRequest (with reviewer_ids resolution) all work end-to-end; the closed MR !2 with sha=e160899 and the successful real clone under /tmp/teamai-gl-clone-* are the artefacts. Refs Tencent#303 Co-Authored-By: Claude Fable 5 <[email protected]>
Walternater
commented
Aug 25, 2026
Walternater
left a comment
Collaborator
Author
There was a problem hiding this comment.
PR #321 审核结论:Approve 级,可合并。
22 行纯新增测试,无生产代码改动,风险极低。我拉取 Tencent/teamai-cli 源码逐项核对了 PR 描述中的声明,全部属实。
核对通过的声明
gitlabIsAuthenticated/gitlabWhoami确实存在于src/providers/gitlab/gitlab-api.ts,且签名(前者同步 boolean、后者 asyncPromise<string|null>)与测试用法一致。vitest.e2e.config.tsinclude 了src/__tests__/e2e/**/*.test.ts,新文件会被 e2e 配置收集。- 默认
vitest.config.ts明确 excludesrc/__tests__/e2e/**,"不会在无 secret 的 CI 误跑"的声明成立。 - 结构与
cnb-provider-live.test.ts完全同构(同断言形状、同 skipIf 模式、同注释骨架)。 GITLAB_URL自托管实例确实被gitlabBaseUrl()消费,注释描述与实现一致。- 失败路径正确:token 无效时
gitlabWhoami返回 null,length > 0断言会失败,而不是静默通过——live smoke test 该挂就挂,符合预期。
两个非阻塞 nit(不建议为此改动)
- 文件末尾缺换行(diff 里有
\ No newline at end of file),而 cnb 对应文件有。仓库无 prettier/eslint 强制,纯一致性问题。 HAS_GITLAB只判断GITLAB_TOKEN,而getGitLabToken()还接受GITLAB_PRIVATE_TOKEN/GITLAB_PAT两个别名。只设了别名的贡献者会看到测试被 skip 而非执行。cnb 侧无别名所以无此问题;若想对齐 provider 行为,可改成Boolean(getGitLabToken()),但当前写法作为 smoke test 也完全够用。
结论:按现状合并即可。
Walternater
added a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
Tencent#321) Adds src/__tests__/e2e/gitlab-provider-live.test.ts, mirroring the cnb-provider-live pattern: skipped unless GITLAB_TOKEN is set, runs a read-only whoami check via GET /user against the configured instance (defaults to gitlab.com, or self-hosted via GITLAB_URL). The mutating half (create -> clone -> push -> open-MR) was verified manually against git.guazi-corp.com with the teamai-cli GitLab provider shipping in 0.21.0-beta.0. Token auth + REST API + in-URL oauth2 clone + createPullRequest (with reviewer_ids resolution) all work end-to-end; the closed MR !2 with sha=e160899 and the successful real clone under /tmp/teamai-gl-clone-* are the artefacts. Refs Tencent#303 Co-authored-by: wangchongfei <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to the GitLab provider already shipping in 0.21.0-beta.0. Adds an opt-in live smoke test under
src/__tests__/e2e/, mirroring the existingcnb-provider-livepattern: skipped unlessGITLAB_TOKENis set, runs a read-onlyGET /useragainst the configured instance (gitlab.com by default, or self-hosted viaGITLAB_URL).The full mutating flow was verified manually against
git.guazi-corp.combefore opening this PR:git clonewith the in-URLoauth2:<token>@basic-auth formteamai pushMR creation (real!2created withsha=e160899, then closed)Why this PR
During the work for #303 we discovered the upstream provider already shipped (between our branch and the rebase), so the originally-planned PR became redundant. Rather than re-implement, this lands the only piece that wasn't already there — an automated live auth smoke test — so future contributors can opt-in to CI verification of their GitLab setup.
Type of Change
Test Plan
npx tsc --noEmitpassesnpx vitest runpasses (2185/2185)npx vitest run --config vitest.e2e.config.tspasses (64 pass, 24 skip including the new test)it.skipIf(!HAS_GITLAB)correctly skips withoutGITLAB_TOKEN; verified manually with a realGITLAB_TOKENagainst git.guazi-corp.comRelated Issues
Refs #303
Notes for Reviewers
cnb-provider-livepattern exactly — reviewers familiar with that test will recognise the shape.npx vitest run(matchescnb-provider-live) so it cannot accidentally run in a CI environment without the secret.