fix(robot): show the per-game name in REST game views, not the account name
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 50s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m18s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 50s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m18s
The seat display-name snapshot only reached the live-event path (seatNames);
the REST DTO layer still resolved seat names from the account store
(fillSeatNames), so the game screen and lobby list showed the robot's seeded
account name ("Женя") while the your_turn toast showed its per-game name
("Звёздный_Барс2"). Carry the snapshot into gameDTOFromGame and have
fillSeatNames fall back to the account only for a seat with no snapshot (a
pre-snapshot legacy row). Friends and invitations keep account names (the
persistent identity, not a per-game disguise).
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -111,3 +112,35 @@ func TestMoveRecordDTOFrom(t *testing.T) {
|
||||
t.Fatalf("move dto mismatch: %+v", dto)
|
||||
}
|
||||
}
|
||||
|
||||
// TestGameDTOCarriesSeatSnapshot checks the DTO carries each seat's display-name
|
||||
// snapshot (so a disguised robot's per-game name reaches the REST views, not just live
|
||||
// events) rather than leaving it for an account lookup.
|
||||
func TestGameDTOCarriesSeatSnapshot(t *testing.T) {
|
||||
g := game.Game{
|
||||
Variant: engine.VariantEnglish, Players: 2, TurnTimeout: time.Hour,
|
||||
Seats: []game.Seat{
|
||||
{Seat: 0, AccountID: uuid.New(), DisplayName: "Звёздный_Барс2"},
|
||||
{Seat: 1, AccountID: uuid.New(), DisplayName: "Тест"},
|
||||
},
|
||||
}
|
||||
dto := gameDTOFromGame(g)
|
||||
if dto.Seats[0].DisplayName != "Звёздный_Барс2" || dto.Seats[1].DisplayName != "Тест" {
|
||||
t.Fatalf("seat snapshot not carried into DTO: %+v", dto.Seats)
|
||||
}
|
||||
}
|
||||
|
||||
// TestFillSeatNamesKeepsSnapshot checks fillSeatNames leaves a seat whose snapshot is
|
||||
// already set untouched (no account lookup), so the per-game name is not overwritten by
|
||||
// the robot's seeded account name.
|
||||
func TestFillSeatNamesKeepsSnapshot(t *testing.T) {
|
||||
s := &Server{} // accounts is unused: a present snapshot must skip the lookup
|
||||
dto := &gameDTO{Seats: []seatDTO{
|
||||
{Seat: 0, AccountID: uuid.New().String(), DisplayName: "Звёздный_Барс2"},
|
||||
{Seat: 1, AccountID: uuid.New().String(), DisplayName: "Тест"},
|
||||
}}
|
||||
s.fillSeatNames(context.Background(), dto, map[string]string{})
|
||||
if dto.Seats[0].DisplayName != "Звёздный_Барс2" || dto.Seats[1].DisplayName != "Тест" {
|
||||
t.Fatalf("fillSeatNames overwrote a seat snapshot: %+v", dto.Seats)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user