feat(desktop): drop parked review flow, add publish management
SaaS 侧人工审核后才创建 publish job,desktop 不再做二次审核:移除 manual/waiting_user/parked/from_parked 状态机与 LeaseFromParked 查询, desktop client 只执行发布并新增"发布管理"页(待发布队列 / 历史 / 再次 发送)。同时抽离 @geo/publisher-platforms 共享适配器包、新增 Redis-based desktop_presence 与 publish_record_support,刷新 admin-web 发布弹窗与 媒体库;plan A / spec 文档同步口径。
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/geo-platform/tenant-api/internal/tenant/repository"
|
||||
)
|
||||
|
||||
func TestResolveDesktopClientOnline_PresenceHitWins(t *testing.T) {
|
||||
now := time.Date(2026, 4, 19, 21, 30, 0, 0, time.UTC)
|
||||
|
||||
online := resolveDesktopClientOnline(&repository.DesktopClient{
|
||||
ID: uuid.New(),
|
||||
LastSeenAt: nil,
|
||||
}, true, true, now)
|
||||
|
||||
assert.True(t, online)
|
||||
}
|
||||
|
||||
func TestResolveDesktopClientOnline_FallsBackToRecentHeartbeatWhenPresenceMisses(t *testing.T) {
|
||||
now := time.Date(2026, 4, 19, 21, 30, 0, 0, time.UTC)
|
||||
lastSeen := now.Add(-30 * time.Second)
|
||||
|
||||
online := resolveDesktopClientOnline(&repository.DesktopClient{
|
||||
ID: uuid.New(),
|
||||
LastSeenAt: &lastSeen,
|
||||
}, false, true, now)
|
||||
|
||||
assert.True(t, online)
|
||||
}
|
||||
|
||||
func TestResolveDesktopClientOnline_StaleHeartbeatIsOffline(t *testing.T) {
|
||||
now := time.Date(2026, 4, 19, 21, 30, 0, 0, time.UTC)
|
||||
lastSeen := now.Add(-(desktopClientPresenceTTL + time.Second))
|
||||
|
||||
online := resolveDesktopClientOnline(&repository.DesktopClient{
|
||||
ID: uuid.New(),
|
||||
LastSeenAt: &lastSeen,
|
||||
}, false, false, now)
|
||||
|
||||
assert.False(t, online)
|
||||
}
|
||||
|
||||
func TestBuildDesktopAccountView_PrefersAccountPresenceClient(t *testing.T) {
|
||||
service := &DesktopAccountService{}
|
||||
accountID := uuid.New()
|
||||
staleClientID := uuid.New()
|
||||
activeClientID := uuid.New()
|
||||
lastSeen := time.Date(2026, 4, 19, 21, 30, 0, 0, time.UTC)
|
||||
deviceName := "Desktop MacIntel"
|
||||
|
||||
view := service.buildDesktopAccountView(
|
||||
&repository.DesktopAccount{
|
||||
DesktopID: accountID,
|
||||
ClientID: &staleClientID,
|
||||
Platform: "toutiaohao",
|
||||
PlatformUID: "platform:4181862206",
|
||||
DisplayName: "ireader",
|
||||
Health: "live",
|
||||
},
|
||||
map[uuid.UUID]*repository.DesktopClient{
|
||||
activeClientID: {
|
||||
ID: activeClientID,
|
||||
LastSeenAt: &lastSeen,
|
||||
DeviceName: &deviceName,
|
||||
},
|
||||
},
|
||||
map[uuid.UUID]uuid.UUID{
|
||||
accountID: activeClientID,
|
||||
},
|
||||
)
|
||||
|
||||
if assert.NotNil(t, view.ClientID) {
|
||||
assert.Equal(t, activeClientID.String(), *view.ClientID)
|
||||
}
|
||||
if assert.NotNil(t, view.ClientOnline) {
|
||||
assert.True(t, *view.ClientOnline)
|
||||
}
|
||||
assert.Equal(t, "4181862206", view.PlatformUID)
|
||||
assert.Equal(t, &lastSeen, view.ClientLastSeenAt)
|
||||
assert.Equal(t, &deviceName, view.ClientDeviceName)
|
||||
}
|
||||
|
||||
func TestBuildDesktopAccountView_FallsBackToStoredClientWhenNoPresence(t *testing.T) {
|
||||
service := &DesktopAccountService{}
|
||||
accountID := uuid.New()
|
||||
storedClientID := uuid.New()
|
||||
lastSeen := time.Date(2026, 4, 19, 21, 30, 0, 0, time.UTC)
|
||||
|
||||
view := service.buildDesktopAccountView(
|
||||
&repository.DesktopAccount{
|
||||
DesktopID: accountID,
|
||||
ClientID: &storedClientID,
|
||||
Platform: "toutiaohao",
|
||||
PlatformUID: "4181862206",
|
||||
DisplayName: "ireader",
|
||||
Health: "live",
|
||||
},
|
||||
map[uuid.UUID]*repository.DesktopClient{
|
||||
storedClientID: {
|
||||
ID: storedClientID,
|
||||
LastSeenAt: &lastSeen,
|
||||
},
|
||||
},
|
||||
nil,
|
||||
)
|
||||
|
||||
if assert.NotNil(t, view.ClientID) {
|
||||
assert.Equal(t, storedClientID.String(), *view.ClientID)
|
||||
}
|
||||
if assert.NotNil(t, view.ClientOnline) {
|
||||
assert.False(t, *view.ClientOnline)
|
||||
}
|
||||
assert.Equal(t, &lastSeen, view.ClientLastSeenAt)
|
||||
}
|
||||
Reference in New Issue
Block a user