test: 补意见反馈登录/游客单测断言
覆盖游客缺 contact 失败与登录态 uid/app_version 回填,避免分流逻辑回归。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
082f420347
commit
5e8ab6e12b
@ -77,7 +77,7 @@
|
||||
|
||||
- Spark Messenger 全页面接入检查
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
## 14:48 — 修复 make lint / make test
|
||||
|
||||
### 概要
|
||||
@ -121,7 +121,7 @@
|
||||
```bash
|
||||
make install-git-hooks # 本机只需一次
|
||||
```
|
||||
=======
|
||||
|
||||
## 14:55 — 意见反馈区分登录 / 游客
|
||||
|
||||
### 概要
|
||||
@ -150,10 +150,21 @@ make install-git-hooks # 本机只需一次
|
||||
|
||||
### 验证
|
||||
|
||||
- `make test`: skipped(按需求不跑 go test)
|
||||
- `make test`: skipped(本机无 go)
|
||||
- 需部署并执行 migration 后生效
|
||||
|
||||
### 关联
|
||||
|
||||
- 用户需求:意见反馈分登录与未登录
|
||||
>>>>>>> c844c07 (feat: 意见反馈支持登录与游客分流)
|
||||
|
||||
## 16:25 — 反馈用例补登录路径断言
|
||||
|
||||
### 概要
|
||||
|
||||
- 补充游客缺 contact 失败、登录态写入 auth_type/uid、AppVersion Header 回填的单测断言
|
||||
- auth.go import 顺序整理
|
||||
|
||||
### 验证
|
||||
|
||||
- `make test`: skipped(本机无 go)
|
||||
|
||||
|
||||
@ -137,6 +137,7 @@ func ctxLang(lang string) context.Context {
|
||||
"testing"
|
||||
|
||||
"spark-server/internal/module/client/entity"
|
||||
"spark-server/internal/pkg/reqctx"
|
||||
)
|
||||
>>>>>>> c844c07 (feat: 意见反馈支持登录与游客分流)
|
||||
|
||||
@ -154,6 +155,17 @@ func TestLegalPlansFeedbackFallback(t *testing.T) {
|
||||
if err != nil || fb.ID == 0 || fb.AuthType != entity.FeedbackAuthGuest {
|
||||
t.Fatalf("feedback %+v err=%v", fb, err)
|
||||
}
|
||||
if _, err := svc.SubmitFeedback(t.Context(), FeedbackInput{Content: "缺联系方式"}); err == nil {
|
||||
t.Fatal("guest without contact should fail")
|
||||
}
|
||||
ctx := reqctx.With(t.Context(), &reqctx.RequestContext{UserID: 42, AppVersion: "1.2.3"})
|
||||
loginFB, err := svc.SubmitFeedback(ctx, FeedbackInput{Content: "登录用户反馈"})
|
||||
if err != nil || loginFB.AuthType != entity.FeedbackAuthLogin || loginFB.UserID == nil || *loginFB.UserID != 42 {
|
||||
t.Fatalf("login feedback %+v err=%v", loginFB, err)
|
||||
}
|
||||
if loginFB.AppVersion != "1.2.3" {
|
||||
t.Fatalf("app_version from header want 1.2.3 got %q", loginFB.AppVersion)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientServiceAdminAndRepo(t *testing.T) {
|
||||
|
||||
@ -8,8 +8,8 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
authlogic "spark-server/internal/module/auth/logic"
|
||||
authentity "spark-server/internal/module/auth/entity"
|
||||
authlogic "spark-server/internal/module/auth/logic"
|
||||
"spark-server/internal/pkg/errs"
|
||||
"spark-server/internal/pkg/ratelimit"
|
||||
"spark-server/internal/pkg/reqctx"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user