Skip to content

Commit a66a388

Browse files
test(audience-sample): centralise live-fire test fixture values
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).
1 parent e8dd0c9 commit a66a388

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Immutable.Audience.Samples.SampleApp.Tests
2+
{
3+
// Values used by SampleAppLiveFireTests when filling the demo input fields.
4+
internal static class SampleAppLiveFireFixtures
5+
{
6+
internal const string MilestoneSmokeName = "il2cpp_smoke";
7+
internal const string GameId = "il2cpp_game_1";
8+
internal const string LinkUrl = "https://example.com/il2cpp";
9+
}
10+
}

examples/audience/Assets/SampleApp/Tests/Runtime/SampleAppLiveFireFixtures.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/audience/Assets/SampleApp/Tests/Runtime/SampleAppLiveFireTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public IEnumerator TypedEvent_MilestoneReached_FlushReportsOk()
172172
{
173173
yield return DriveTypedEventAndFlush(SampleAppUi.Buttons.TypedEvent(EventNames.MilestoneReached), root =>
174174
{
175-
root.Q<TextField>(SampleAppUi.TypedEventField(EventNames.MilestoneReached, EventPropertyKeys.Name)).value = "il2cpp_smoke";
175+
root.Q<TextField>(SampleAppUi.TypedEventField(EventNames.MilestoneReached, EventPropertyKeys.Name)).value = SampleAppLiveFireFixtures.MilestoneSmokeName;
176176
});
177177
}
178178

@@ -262,7 +262,7 @@ public IEnumerator CustomTrack_WithDictionaryProps_FlushReportsOk()
262262

263263
// Custom event name + JSON props (the sample app parses props as JSON
264264
// and forwards them as Dictionary<string, object> to ImmutableAudience.Track).
265-
_root!.Q<TextField>(SampleAppUi.CustomEvent.Name).value = "il2cpp_smoke";
265+
_root!.Q<TextField>(SampleAppUi.CustomEvent.Name).value = SampleAppLiveFireFixtures.MilestoneSmokeName;
266266
_root.Q<TextField>(SampleAppUi.CustomEvent.Props).value =
267267
"{\"int_field\":42,\"str_field\":\"hello\",\"bool_field\":true,\"nested\":{\"a\":1}}";
268268
_root.Q<Button>(SampleAppUi.Buttons.CustomEvent).Click();
@@ -423,7 +423,7 @@ public IEnumerator TypedEvent_WishlistAdd_FlushReportsOk()
423423
{
424424
yield return DriveTypedEventAndFlush(SampleAppUi.Buttons.TypedEvent(SampleAppCustomEvents.WishlistAdd), root =>
425425
{
426-
root.Q<TextField>(SampleAppUi.TypedEventField(SampleAppCustomEvents.WishlistAdd, SampleAppCustomEventPropertyKeys.GameId)).value = "il2cpp_game_1";
426+
root.Q<TextField>(SampleAppUi.TypedEventField(SampleAppCustomEvents.WishlistAdd, SampleAppCustomEventPropertyKeys.GameId)).value = SampleAppLiveFireFixtures.GameId;
427427
});
428428
}
429429

@@ -432,7 +432,7 @@ public IEnumerator TypedEvent_WishlistRemove_FlushReportsOk()
432432
{
433433
yield return DriveTypedEventAndFlush(SampleAppUi.Buttons.TypedEvent(SampleAppCustomEvents.WishlistRemove), root =>
434434
{
435-
root.Q<TextField>(SampleAppUi.TypedEventField(SampleAppCustomEvents.WishlistRemove, SampleAppCustomEventPropertyKeys.GameId)).value = "il2cpp_game_1";
435+
root.Q<TextField>(SampleAppUi.TypedEventField(SampleAppCustomEvents.WishlistRemove, SampleAppCustomEventPropertyKeys.GameId)).value = SampleAppLiveFireFixtures.GameId;
436436
});
437437
}
438438

@@ -441,7 +441,7 @@ public IEnumerator TypedEvent_GamePageViewed_FlushReportsOk()
441441
{
442442
yield return DriveTypedEventAndFlush(SampleAppUi.Buttons.TypedEvent(SampleAppCustomEvents.GamePageViewed), root =>
443443
{
444-
root.Q<TextField>(SampleAppUi.TypedEventField(SampleAppCustomEvents.GamePageViewed, SampleAppCustomEventPropertyKeys.GameId)).value = "il2cpp_game_1";
444+
root.Q<TextField>(SampleAppUi.TypedEventField(SampleAppCustomEvents.GamePageViewed, SampleAppCustomEventPropertyKeys.GameId)).value = SampleAppLiveFireFixtures.GameId;
445445
});
446446
}
447447

@@ -450,7 +450,7 @@ public IEnumerator TypedEvent_LinkClicked_FlushReportsOk()
450450
{
451451
yield return DriveTypedEventAndFlush(SampleAppUi.Buttons.TypedEvent(SampleAppCustomEvents.LinkClicked), root =>
452452
{
453-
root.Q<TextField>(SampleAppUi.TypedEventField(SampleAppCustomEvents.LinkClicked, SampleAppCustomEventPropertyKeys.Url)).value = "https://example.com/il2cpp";
453+
root.Q<TextField>(SampleAppUi.TypedEventField(SampleAppCustomEvents.LinkClicked, SampleAppCustomEventPropertyKeys.Url)).value = SampleAppLiveFireFixtures.LinkUrl;
454454
});
455455
}
456456

0 commit comments

Comments
 (0)