Skip to content

refactor(audience): test fixtures and sample-app polish (SDK-277)#728

Open
ImmutableJeffrey wants to merge 13 commits intochore/sdk-272-pr-3-test-pinning-and-sample-eventsfrom
chore/sdk-272-pr-4-fixtures-and-sample-polish
Open

refactor(audience): test fixtures and sample-app polish (SDK-277)#728
ImmutableJeffrey wants to merge 13 commits intochore/sdk-272-pr-3-test-pinning-and-sample-eventsfrom
chore/sdk-272-pr-4-fixtures-and-sample-polish

Conversation

@ImmutableJeffrey
Copy link
Copy Markdown
Collaborator

Summary

  • Adds TestFixtures for per-test fixture data values (anonymous IDs, user IDs, alias endpoints, identity values, payload values for Track / Identify / Alias / Resource / Purchase / MilestoneReached scenarios).
  • Adds the missing meta file for TestEventNames.
  • Extends TestEventNames with transport / queue scenario names, placeholder event names, and the OfflineResilienceTests blocked_{i} prefix.
  • Extends TestFixtures with Track properties scenario data, distribution-platform fixture, identity-persistence fixture, ConsentStore corruption fixture, ThreadSafetyStressTests userId, GzipTests anon-{i} prefix, and minimal MessageBuilder placeholders.
  • Adds SampleAppLiveFireFixtures for the sample-app live-fire test inputs.
  • Adds SampleAppUi.LogPayloadKeys and routes the sample-app log-payload dictionary keys through it.
  • Adds SampleAppUi.Messages for status messages emitted by RunAndLog handlers.
  • Adds HTTP test response body and exception-message fixtures in HttpTransportTests.
  • Migrates inline CSS classes in AudienceSample.cs to SampleAppUi.Css references.
  • Centralises the "Copied!" flash label in SampleAppUi.ButtonText.CopiedFlash.
  • Adds JsonRoundTripFixtures for paired JSON serialise / deserialise fixtures shared between JsonTests and JsonReaderTests.
  • Extends TestFixtures with ISO 4217 currency codes, Progression.World, ContextProvider sabotage exception text, disk-block sentinel body, mixed-case DistributionPlatform, Unity Application.platform string, and longer alias endpoint fixtures.
  • Centralises ConstantsTests BaseUrl publishable-key fixtures and package.json resolution path components as file-local consts.
  • No behaviour change. Wire format and OnError callback contract unchanged.

Linear: SDK-277

@ImmutableJeffrey ImmutableJeffrey requested review from a team as code owners May 3, 2026 07:18
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-3-test-pinning-and-sample-events branch from b3398d3 to 7ccd158 Compare May 3, 2026 07:40
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-4-fixtures-and-sample-polish branch from 3044693 to a5e7bd1 Compare May 3, 2026 07:40
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-3-test-pinning-and-sample-events branch from 7ccd158 to 9c4da2e Compare May 3, 2026 07:43
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-4-fixtures-and-sample-polish branch from a5e7bd1 to 76424cd Compare May 3, 2026 07:43
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-3-test-pinning-and-sample-events branch from 9c4da2e to ba0bcf4 Compare May 3, 2026 07:54
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-4-fixtures-and-sample-polish branch from 76424cd to 08f5caf Compare May 3, 2026 07:54
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-3-test-pinning-and-sample-events branch from ba0bcf4 to de145e3 Compare May 3, 2026 07:58
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-4-fixtures-and-sample-polish branch from 08f5caf to 8245c1c Compare May 3, 2026 07:58
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-3-test-pinning-and-sample-events branch from de145e3 to daf1246 Compare May 3, 2026 12:39
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-4-fixtures-and-sample-polish branch from 8245c1c to e0114c0 Compare May 3, 2026 12:39
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-3-test-pinning-and-sample-events branch from daf1246 to cf5c443 Compare May 3, 2026 14:14
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-4-fixtures-and-sample-polish branch from e0114c0 to 7d06189 Compare May 3, 2026 14:14
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-3-test-pinning-and-sample-events branch from cf5c443 to ea260bf Compare May 3, 2026 19:06
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-4-fixtures-and-sample-polish branch from 7d06189 to 4c052b9 Compare May 3, 2026 19:06
…xtures

The SDK test suite repeated the same identifier and payload literals
across MessageBuilderTests, TypedEventTests, JsonTests,
ImmutableAudienceTests, and DeleteDataTests. The pairs that appeared
both as inputs and as assertion targets were the worst offenders
(anon-42, user-42, user-99, from-id, to-id) since a typo flipping
one side would silently pass on the other.

Add TestFixtures alongside TestDefaults (which already centralises
config defaults) and reference TestFixtures.X across the five files.

Constants cover anonymous IDs (1, 42, 123), user IDs (42, 99), alias
endpoints (from / to), identity values keyed to IdentityType.Custom /
Steam / Passport (player-42 / player_steam / player_passport),
Resource event payload values (gold currency, quest_reward itemType,
main_quest_01 itemId), Purchase event payload values (gem_pack_01
itemId, Starter Gem Pack itemName, txn_abc123 transactionId), and
the MilestoneReached name (first_boss_defeated).

Includes main_quest_01, player_passport, anon-123, and
first_boss_defeated beyond the user's listed values: same per-fixture
data category, same migration treatment. tutorial_complete from the
user's list does not appear in the test suite (the milestone fixture
uses first_boss_defeated); skipped on that basis.

Per the user's "everything random goes in a constant" stance,
applied against the previous session's recommendation that scenario
descriptors read better inline. Recording the override on the user's
explicit request.

Follow-up to SDK-272 (centralisation of duplicated literals).
TestEventNames.cs (SHA 6d237a3a) was committed without its .meta file.
Unity generates one on project open, but the convention across the
test folder is to commit them so the GUID is stable across machines
(mirrors TestDefaults.cs.meta and TestFixtures.cs.meta).

Follow-up to SDK-272 (centralisation of duplicated literals).
…enarios

Adds named event-name constants for the EventQueue scenario tests
(IntervalFlush, DisposeTest), placeholder constants for transport /
queue scaffolding where the event name is just filler (PlaceholderA,
PlaceholderB, PlaceholderTest, PlaceholderTrack, PlaceholderIgnored,
PlaceholderEvt), and BlockedPrefix for the OfflineResilienceTests
$"blocked_{i}" templated string.

Migrates inline references in:
- MessageBuilderTests ("evt" placeholders, six sites)
- EventQueueTests (Msg() helper calls, six sites)
- HttpTransportTests (WireFixture.Track event-name args, eight sites)
- OfflineResilienceTests ($"blocked_{i}" templated literal, three sites)

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
Adds:
- Track properties: CustomPropKeyRecipeId, CraftingRecipeIronSword
- Distribution platform fixture: ProviderValue
- IdentityType fallback fixture: UnknownProvider
- Identity persistence fixtures: PreExistingId, PreExistingIdFromLastLaunch
- ConsentStore corruption fixture: NotAnInt
- Stress test userId: UserRaceStress
- DeleteData generic userId: SomeUser
- Templated prefix for GzipTests $"anon-{i}": AnonIdPrefix
- Minimal placeholders for MessageBuilder Identify / Alias arg slots
  (GenericUserId, GenericFromId, GenericToId, GenericFromType,
  GenericToType)

Migrates inline references in:
- DeleteDataTests
- ImmutableAudienceTests (Track props, race-stress userId, provider value)
- Core/IdentityTests (pre-existing-id fixtures)
- IdentityTypeTests (TestCase attribute now references the const)
- Core/ConsentStoreTests (corrupt-file fixture)
- Utility/GzipTests (anon-{i} templated prefix)
- Events/MessageBuilderTests (Identify / Alias placeholder slots)

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
Adds SampleAppLiveFireFixtures alongside SampleAppLiveFireTests with
three constants (MilestoneSmokeName, GameId, LinkUrl) shared across
five inline call sites in the live-fire batch. Retargeting the smoke
suite (e.g. switching the game id slug) is now a one-line change
instead of a five-line touch.

Migrates inline references in SampleAppLiveFireTests for the
typed-event Resource / Purchase / MilestoneReached fills and the
sample-app custom catalogue fills (WishlistAdd, WishlistRemove,
GamePageViewed, LinkClicked).

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
…AppUi.LogPayloadKeys

The sample-app builds Dictionary<string, object> echo payloads for
each RunAndLog "Ok" row (Track outcomes, Identify / Alias outcomes,
OnError rows, Init config echo). Each key was inline at the
construction site, so a rename (e.g. "publishableKey" to "key")
would touch six call sites today and grow as the demo expands.

Adds a LogPayloadKeys sub-class to SampleAppUi with eighteen
constants covering the existing payload schema (Event, Overload,
Effects, Id, Accepted, From, To, Code, Message, Consent, Debug,
FlushIntervalSeconds, FlushSize, PackageVersion,
ShutdownFlushTimeoutMs, PublishableKey, PersistentDataPath) plus a
nested OverloadValues for the "typed" / "string" enum-like values
written under LogPayloadKeys.Overload.

Migrates AudienceSample.cs to reference the constants. UXML element
names (in the existing SampleAppUi sub-classes) are unchanged.

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
…Messages

AudienceSample.cs had inline status strings at every RunAndLog "Ok"
return and AppendLog call (SDK stopped, anonymous ID regenerated
queue cleared, queue flushed, erasure request dispatched, backend
acknowledged, plus two interpolated messages for track-dropped and
flushInterval-clamped warnings).

Adds five plain-string constants and two format-string constants
(suffixed Fmt, used with string.Format) to the existing
SampleAppUi.Messages catalogue alongside the consent-flow messages
already centralised there. Migrates seven inline references in
AudienceSample.cs.

The two interpolated status strings used em-dashes; replaced with
commas in the centralised form to match the project glyph rule.
NoActiveIdentity (already in Messages) had the same em-dash
artefact and gets the same comma replacement.

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
…fixtures

HttpTransportTests had inline literals for the malformed-body
diagnostic ("not-json"), the empty JSON object body ("{}"), and the
exception messages thrown by MockHandler factories ("connection
refused", "Request timed out", "simulated").

Adds five file-local consts (MalformedResponseBody, EmptyJsonObjectBody,
ConnectionRefusedMessage, RequestTimedOutMessage,
SimulatedCancellationMessage) at the top of the fixture and migrates
six call sites. The empty body "" is left inline since "the body is
truly empty" carries the meaning at the call site.

NUnit assertions never check the exception messages, but pinning the
"what failure was simulated" intent keeps the fixture's catalogue of
network failure modes visible in one place.

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
…CSS classes

AudienceSample.UI.cs RefreshStatusBar set status-cell classes via
inline strings ("state-warn", "state-ok", and "dim" five times) even
though SampleAppUi.Css.StateWarn / .StateOk / .Dim already exist for
exactly this purpose.

Migrates seven call sites to the constants. CSS-side renames now
need to touch one place (Css.Dim) instead of grep-and-replace across
the SetStatusCell call sites.

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
…AppUi.ButtonText.CopiedFlash

AudienceSample.UI.cs:368 set the click-to-copy flash via inline
"Copied!". Distinct from the existing SampleAppUi.ButtonText.Copied
("Copied", no exclamation) used as the persistent button label after
copying. Both strings can drift independently today.

Adds ButtonText.CopiedFlash with a comment noting the distinction
and migrates the inline reference. The two consts now sit next to
each other so a future translation pass would catch both.

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
JsonTests and JsonReaderTests both used the same literals to verify
round-trip behaviour: each input dictionary in JsonTests had a
matching encoded form in JsonReaderTests, and vice versa. The
single string pair (key / hello), the all-escapes string (val /
"say \"hi\"\nback\\slash\ttab"), and the nested object (outer /
inner / value) appeared duplicated in both files.

Adds JsonRoundTripFixtures with the raw key, raw value, and
exact-encoded form for each of the three pairs. Migrates six
references across the two files.

Renaming any fixture (e.g. swapping "hello" for "world") now needs
one edit and both tests stay coherent.

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
…enario values

Adds:
- Currency code fixtures: UsdCurrency ("USD"), EurCurrency ("EUR"),
  used across Purchase / Resource typed-event tests
- Progression world fixture: ProgressionWorldTutorial ("tutorial"),
  three uses across TypedEventTests and ImmutableAudienceTests
- Exception fixture: ContextProviderBoomMessage ("boom"),
  for the ContextProvider sabotage test
- Disk-block sentinel: DiskBlockerContent ("blocker"),
  written to the queue directory path so creation fails
- DistributionPlatform mixed-case fixtures:
  DistributionPlatformSteamCased ("Steam"),
  DistributionPlatformSteamUppercase ("STEAM"),
  for Init's lowercase-normalisation test
- Application.platform fixture: PlatformWindows ("WindowsPlayer"),
  for the GameLaunch.Platform test
- Generic alias endpoint fixtures: GenericAliasFromId ("fromId"),
  GenericAliasToId ("toId"), GenericAliasFromShort ("from"),
  for Alias argument-validation tests where the value is filler

Migrates inline references in:
- Events/TypedEventTests (seven Purchase / Resource currency and
  Progression world fills)
- ImmutableAudienceTests (boom, USD x2, fromId/toId, from, tutorial,
  Steam, STEAM, WindowsPlayer)
- OfflineResilienceTests (blocker)

IdentityTypeTests "Steam" / "STEAM" left inline; the wire-format
casing fixtures stay self-contained inside that test until the
IdentityType wire-format extraction lands. MessagesTests "USD" /
"usd" left inline; the literals there appear inside expected error
strings being verified, so centralising would defeat the test's
own pinning.

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
…s file-local consts

ConstantsTests had inline literals for the publishable-key fixtures
the BaseUrl resolution tests pass through Constants.BaseUrl
("pk_imapik-test-abc", "pk_imapik-prod-abc"), the custom override
URL ("https://api.dev.immutable.com"), and the package.json
discovery-walk components ("src", "Packages", "Audience",
"package.json", and the JSON field names "version" / "name").

Adds nine file-local consts at the top of the fixture (matching
the PublishableKeyPrefixTests TestPrefixKey / NonTestKey precedent)
and migrates eleven references across the BaseUrl tests, the
package.json LibraryVersion / LibraryName tests, and the
ReadPackageJson upward-walk helper.

Per the user's "everything random goes in a constant" stance.

Follow-up to SDK-272 (centralisation of duplicated literals).
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-3-test-pinning-and-sample-events branch from ea260bf to 4bacd74 Compare May 3, 2026 19:15
@ImmutableJeffrey ImmutableJeffrey force-pushed the chore/sdk-272-pr-4-fixtures-and-sample-polish branch from 4c052b9 to e2d1ce2 Compare May 3, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant