test(ui): align rejected-submit e2e specs with per-command sync semantics
Tests · UI / test (push) Has been cancelled
Tests · Integration / integration (pull_request) Successful in 1m46s
Tests · Go / test (pull_request) Successful in 1m59s
Tests · UI / test (pull_request) Successful in 3m8s

The `rename-planet` and `ship-classes` rejected-submit specs broke on
the previous commit because:

1. `tests/e2e/fixtures/order-fbs.ts` builds the FBS response without
   `forceDefaults(true)`, and flatbuffers@25's TS codegen now elides
   `cmd_applied=false` against its int8 default of 0. The encoded
   payload no longer carried the rejection, so the UI decoded the row
   as `applied` and the assertions on the `rejected` status text
   failed first. The production Go transcoder already force-slots
   the field; mirror that behaviour in the e2e fixture.
2. The specs themselves still asserted the old blanket
   `data-sync-status="error"` on per-command rejection. After the
   previous commit's behaviour change the bar stays `synced` for
   per-command rejection (only genuine transport failures keep the
   red banner + Retry), so the assertions now read the row's inline
   reason text instead.

`tests/e2e/fixtures/order-fbs.ts` also gains the `cmdErrorMessage`
field so future fixtures can mirror the engine's rejection reason
through the round trip.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilia Denisov
2026-05-29 12:11:50 +02:00
parent 723885e74e
commit 2ffd7527a6
3 changed files with 40 additions and 4 deletions
@@ -34,6 +34,10 @@ interface CommandResultFixtureBase {
cmdId: string;
applied: boolean | null;
errorCode: number | null;
// Optional engine-formatted rejection reason; mirrors the
// `cmd_error_message` field added in the same patch as
// `cmdErrorCode`'s shelf renumber. Omit on applied commands.
errorMessage?: string | null;
}
export interface PlanetRenameResultFixture extends CommandResultFixtureBase {
@@ -132,6 +136,14 @@ export function buildOrderResponsePayload(
updatedAt: number,
): Uint8Array {
const builder = new Builder(256);
// flatbuffers@25 elides any field equal to its generated default;
// for `cmd_applied: bool = null` the default is int8 0, so the
// false case (per-command rejection) would silently disappear from
// the encoded payload. The production Go transcoder uses explicit
// `Slot()` calls that force the write, and the unit-test helpers
// in `tests/helpers/fake-order-client.ts` flip `forceDefaults`;
// these e2e fixtures need the same toggle.
builder.forceDefaults(true);
const itemOffsets = commands.map((c) => encodeItem(builder, c));
const commandsVec = UserGamesOrderResponse.createCommandsVector(
builder,
@@ -155,6 +167,11 @@ export function buildOrderGetResponsePayload(
found = true,
): Uint8Array {
const builder = new Builder(256);
// See `buildOrderResponsePayload` — the GET response path needs
// the same `forceDefaults` toggle so a stored per-command rejection
// (cmd_applied=false / cmd_error_code=0) survives the round trip
// to the UI's `hydrateFromServer`.
builder.forceDefaults(true);
let orderOffset = 0;
if (found) {
@@ -290,6 +307,10 @@ function encodeItem(builder: Builder, c: CommandResultFixture): number {
break;
}
}
const errMsgOffset =
c.errorMessage !== undefined && c.errorMessage !== null
? builder.createString(c.errorMessage)
: 0;
CommandItem.startCommandItem(builder);
CommandItem.addCmdId(builder, cmdIdOffset);
if (c.applied !== null) CommandItem.addCmdApplied(builder, c.applied);
@@ -298,6 +319,9 @@ function encodeItem(builder: Builder, c: CommandResultFixture): number {
}
CommandItem.addPayloadType(builder, payloadType);
CommandItem.addPayload(builder, inner);
if (errMsgOffset !== 0) {
CommandItem.addCmdErrorMessage(builder, errMsgOffset);
}
return CommandItem.endCommandItem(builder);
}