Files
story/internal/elderagent/legacy_sync_integration_test.go
T

38 lines
1.5 KiB
Go
Raw Normal View History

package elderagent
import (
"context"
"strings"
"testing"
"github.com/google/uuid"
)
func TestPersonaSyncDefersLegacyUnresolvedMedia(t *testing.T) {
f := personaTestFixture(t)
f.sync(t)
sid := uuid.NewString()
f.exec(t, `INSERT INTO call_session(id,device_id,tenant_id,subject_id,boot_id,hook_event_id,call_generation,binding_generation,manifest_status,local_audio_off,sdk_stopped,remote_state) VALUES($1::uuid,$2::uuid,'10000000-0000-0000-0000-000000000001',$3::uuid,$1::uuid,$1,0,0,'ISSUED',true,true,'UNKNOWN')`, sid, f.device, f.id)
f.exec(t, `UPDATE subject_profile SET preferred_name='旧链路新称呼' WHERE id=$1::uuid`, f.id)
if i := f.sync(t); i.PersonaSyncStatus != "DEFERRED" {
t.Fatal("legacy NULL budget bypassed active guard", i)
}
f.exec(t, `UPDATE call_session SET remote_state='STOPPED_OBSERVED' WHERE id=$1::uuid`, sid)
if i := f.sync(t); i.PersonaSyncStatus != "SYNCED" {
t.Fatal("completed legacy media blocked sync", i)
}
}
func TestPersonaSyncClearsVoicePermissionWithoutProfileEdit(t *testing.T) {
f := personaTestFixture(t)
f.sync(t)
f.exec(t, `UPDATE consent_snapshot SET effective_consents='{"voice_chat":false}' WHERE subject_id=$1::uuid`, f.id)
if err := f.s.SyncPending(context.Background()); err != nil {
t.Fatal(err)
}
i, err := f.s.Get(context.Background(), f.public)
if err != nil || i.PersonaSyncStatus != "SYNCED" || i.PersonalizationIncluded || strings.Contains(f.p.role(), "旧称呼") || strings.Contains(f.p.role(), "京剧") {
t.Fatal("voice withdrawal kept profile on Bot", i, err)
}
}