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
Open
Conversation
b3398d3 to
7ccd158
Compare
3044693 to
a5e7bd1
Compare
7ccd158 to
9c4da2e
Compare
a5e7bd1 to
76424cd
Compare
9c4da2e to
ba0bcf4
Compare
76424cd to
08f5caf
Compare
ba0bcf4 to
de145e3
Compare
08f5caf to
8245c1c
Compare
de145e3 to
daf1246
Compare
8245c1c to
e0114c0
Compare
daf1246 to
cf5c443
Compare
e0114c0 to
7d06189
Compare
cf5c443 to
ea260bf
Compare
7d06189 to
4c052b9
Compare
…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).
ea260bf to
4bacd74
Compare
4c052b9 to
e2d1ce2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestFixturesfor per-test fixture data values (anonymous IDs, user IDs, alias endpoints, identity values, payload values for Track / Identify / Alias / Resource / Purchase / MilestoneReached scenarios).TestEventNames.TestEventNameswith transport / queue scenario names, placeholder event names, and theOfflineResilienceTestsblocked_{i}prefix.TestFixtureswith Track properties scenario data, distribution-platform fixture, identity-persistence fixture, ConsentStore corruption fixture, ThreadSafetyStressTests userId, GzipTestsanon-{i}prefix, and minimalMessageBuilderplaceholders.SampleAppLiveFireFixturesfor the sample-app live-fire test inputs.SampleAppUi.LogPayloadKeysand routes the sample-app log-payload dictionary keys through it.SampleAppUi.Messagesfor status messages emitted byRunAndLoghandlers.HttpTransportTests.AudienceSample.cstoSampleAppUi.Cssreferences.SampleAppUi.ButtonText.CopiedFlash.JsonRoundTripFixturesfor paired JSON serialise / deserialise fixtures shared betweenJsonTestsandJsonReaderTests.TestFixtureswith ISO 4217 currency codes,Progression.World, ContextProvider sabotage exception text, disk-block sentinel body, mixed-caseDistributionPlatform, UnityApplication.platformstring, and longer alias endpoint fixtures.ConstantsTestsBaseUrlpublishable-key fixtures andpackage.jsonresolution path components as file-local consts.OnErrorcallback contract unchanged.Linear: SDK-277