// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "Blueprint/WidgetTree.h"
#include "Components/TextBlock.h"
#include "HyperTwistTraining/HyperTwistCoachDashboardWidget.h"
#include "HyperTwistTraining/HyperTwistTrainingControlSurfaceFormatting.h"
#include "HyperTwistTraining/HyperTwistTrainingPanelWidget.h"
#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

namespace HyperTwistControlProfileContinuityParityTestInternal
{
	UTextBlock* FindDashboardTextBlock(
		const UHyperTwistCoachDashboardWidget* CoachDashboard,
		const TCHAR* WidgetName
	)
	{
		if (CoachDashboard == nullptr)
		{
			return nullptr;
		}

		UWidgetTree* WidgetTree = CoachDashboard->WidgetTree;
		if (WidgetTree == nullptr)
		{
			return nullptr;
		}

		return Cast<UTextBlock>(WidgetTree->FindWidget(FName(WidgetName)));
	}
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistControlInputContinuityStateFormattingTest,
	"HyperTwist.Browser.ControlInputContinuityStateFormatting",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistControlInputContinuityStateFormattingTest::RunTest(
	const FString& Parameters
)
{
	const FString MissingLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlInputPreferencesStatusLine(
			false,
			FString(),
			false,
			FString(),
			7,
			9
		);
	TestTrue(
		TEXT("The control/input continuity formatter must render a fully absent continuity lane as missing with explicit fallback ids and zero recall counts."),
		MissingLine.Contains(TEXT("Preferences continuity: missing"))
			&& MissingLine.Contains(TEXT("camera export n/a"))
			&& MissingLine.Contains(TEXT("immersive recall n/a"))
			&& MissingLine.Contains(TEXT("recall scopes 0"))
			&& MissingLine.Contains(TEXT("preference fields 0"))
	);

	const FString PartialLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlInputPreferencesStatusLine(
			true,
			TEXT("artifact/camera-export-json"),
			false,
			FString(),
			7,
			9
		);
	TestTrue(
		TEXT("The control/input continuity formatter must render a one-sided continuity lane as partial while preserving the ready id and withholding the missing one."),
		PartialLine.Contains(TEXT("Preferences continuity: partial"))
			&& PartialLine.Contains(TEXT("camera export artifact/camera-export-json"))
			&& PartialLine.Contains(TEXT("immersive recall n/a"))
			&& PartialLine.Contains(TEXT("recall scopes 0"))
			&& PartialLine.Contains(TEXT("preference fields 0"))
	);

	const FString ReadyLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlInputPreferencesStatusLine(
			true,
			TEXT("artifact/camera-export-json"),
			true,
			TEXT("immersive-training-session-recall-boundary"),
			3,
			5
		);
	TestTrue(
		TEXT("The control/input continuity formatter must render a fully ready continuity lane with the shipped ids and live recall counts."),
		ReadyLine.Contains(TEXT("Preferences continuity: ready"))
			&& ReadyLine.Contains(TEXT("camera export artifact/camera-export-json"))
			&& ReadyLine.Contains(TEXT("immersive recall immersive-training-session-recall-boundary"))
			&& ReadyLine.Contains(TEXT("recall scopes 3"))
			&& ReadyLine.Contains(TEXT("preference fields 5"))
	);

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistControlSettingsContinuityStateFormattingTest,
	"HyperTwist.Browser.ControlSettingsContinuityStateFormatting",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistControlSettingsContinuityStateFormattingTest::RunTest(
	const FString& Parameters
)
{
	const FString MissingCameraLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsCameraSettingsLine(
			false,
			false,
			TEXT("tool/camera-settings"),
			TEXT("artifact/camera-export-json"),
			3,
			2,
			1
		);
	TestTrue(
		TEXT("The control/settings camera continuity formatter must render a fully absent camera lane as missing with fallback ids and zero out stale tool counts."),
		MissingCameraLine.Contains(TEXT("Viewer camera settings: missing"))
			&& MissingCameraLine.Contains(TEXT("tool n/a"))
			&& MissingCameraLine.Contains(TEXT("camera export n/a"))
			&& MissingCameraLine.Contains(TEXT("workflow tags 0"))
			&& MissingCameraLine.Contains(TEXT("preview states 0"))
			&& MissingCameraLine.Contains(TEXT("export artifacts 0"))
	);

	const FString PartialCameraLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsCameraSettingsLine(
			true,
			false,
			TEXT("tool/camera-settings"),
			FString(),
			3,
			2,
			1
		);
	TestTrue(
		TEXT("The control/settings camera continuity formatter must render owned-but-not-continuous camera state as partial."),
		PartialCameraLine.Contains(TEXT("Viewer camera settings: partial"))
			&& PartialCameraLine.Contains(TEXT("tool tool/camera-settings"))
			&& PartialCameraLine.Contains(TEXT("camera export n/a"))
	);

	const FString ReadyCameraLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsCameraSettingsLine(
			true,
			true,
			TEXT("tool/camera-settings"),
			TEXT("artifact/camera-export-json"),
			3,
			2,
			1
		);
	TestTrue(
		TEXT("The control/settings camera continuity formatter must render a fully ready camera lane with the shipped export id."),
		ReadyCameraLine.Contains(TEXT("Viewer camera settings: ready"))
			&& ReadyCameraLine.Contains(TEXT("tool tool/camera-settings"))
			&& ReadyCameraLine.Contains(TEXT("camera export artifact/camera-export-json"))
	);

	const FString MissingImmersiveLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsImmersiveSettingsLine(
			false,
			false,
			TEXT("immersive-training-presence-control-contract"),
			TEXT("immersive-training-session-recall-boundary"),
			3,
			3,
			4,
			7,
			9,
			11
		);
	TestTrue(
		TEXT("The control/settings immersive continuity formatter must render a fully absent immersive lane as missing with fallback ids and zero out stale presence and recall counts."),
		MissingImmersiveLine.Contains(TEXT("Immersive presence settings: missing"))
			&& MissingImmersiveLine.Contains(TEXT("contract n/a"))
			&& MissingImmersiveLine.Contains(TEXT("session recall n/a"))
			&& MissingImmersiveLine.Contains(TEXT("intensity presets 0"))
			&& MissingImmersiveLine.Contains(TEXT("reduced-distraction presets 0"))
			&& MissingImmersiveLine.Contains(TEXT("presence tags 0"))
			&& MissingImmersiveLine.Contains(TEXT("recall scopes 0"))
			&& MissingImmersiveLine.Contains(TEXT("preference fields 0"))
			&& MissingImmersiveLine.Contains(TEXT("reset surfaces 0"))
	);

	const FString PartialImmersiveLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsImmersiveSettingsLine(
			true,
			false,
			TEXT("immersive-training-presence-control-contract"),
			FString(),
			3,
			3,
			4,
			7,
			9,
			11
		);
	TestTrue(
		TEXT("The control/settings immersive continuity formatter must render owned-but-not-recalled immersive state as partial while masking stale recall counts."),
		PartialImmersiveLine.Contains(TEXT("Immersive presence settings: partial"))
			&& PartialImmersiveLine.Contains(TEXT("contract immersive-training-presence-control-contract"))
			&& PartialImmersiveLine.Contains(TEXT("session recall n/a"))
			&& PartialImmersiveLine.Contains(TEXT("recall scopes 0"))
			&& PartialImmersiveLine.Contains(TEXT("preference fields 0"))
			&& PartialImmersiveLine.Contains(TEXT("reset surfaces 0"))
	);

	const FString ReadyImmersiveLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsImmersiveSettingsLine(
			true,
			true,
			TEXT("immersive-training-presence-control-contract"),
			TEXT("immersive-training-session-recall-boundary"),
			3,
			3,
			4,
			3,
			5,
			3
		);
	TestTrue(
		TEXT("The control/settings immersive continuity formatter must render a fully ready immersive lane with the shipped recall id and counts."),
		ReadyImmersiveLine.Contains(TEXT("Immersive presence settings: ready"))
			&& ReadyImmersiveLine.Contains(TEXT("contract immersive-training-presence-control-contract"))
			&& ReadyImmersiveLine.Contains(TEXT("session recall immersive-training-session-recall-boundary"))
			&& ReadyImmersiveLine.Contains(TEXT("recall scopes 3"))
			&& ReadyImmersiveLine.Contains(TEXT("preference fields 5"))
	);

	const FString MissingFamilyOwnedLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsFamilyOwnedLine(
			TEXT("Magic120Cell"),
			false,
			false,
			TEXT("magic120cell-focus-view-profile"),
			TEXT("phase6c/magic120cell/dedicated-training-session-surface"),
			TEXT("phase6c/magic120cell/interactive-scene-surface"),
			TEXT("magic120cell-persistence-boundary"),
			TEXT("phase6c/magic120cell/family-owned-scene-state"),
			4,
			TEXT("symmetry presets"),
			5,
			5,
			TEXT("visibility presets"),
			5,
			TEXT("focus surfaces"),
			5
		);
	TestTrue(
		TEXT("The control/settings family-owned formatter must render a fully absent higher-dimensional ownership lane as missing and mask stale ids and counts."),
		MissingFamilyOwnedLine.Contains(TEXT("Magic120Cell owned settings: missing"))
			&& MissingFamilyOwnedLine.Contains(TEXT("profile n/a"))
			&& MissingFamilyOwnedLine.Contains(TEXT("session n/a"))
			&& MissingFamilyOwnedLine.Contains(TEXT("scene n/a"))
			&& MissingFamilyOwnedLine.Contains(TEXT("persistence n/a"))
			&& MissingFamilyOwnedLine.Contains(TEXT("semantics n/a"))
			&& MissingFamilyOwnedLine.Contains(TEXT("selectors 0"))
			&& MissingFamilyOwnedLine.Contains(TEXT("projection tags 0"))
			&& MissingFamilyOwnedLine.Contains(TEXT("symmetry presets 0"))
			&& MissingFamilyOwnedLine.Contains(TEXT("visibility presets 0"))
			&& MissingFamilyOwnedLine.Contains(TEXT("focus surfaces 0"))
	);

	const FString PartialFamilyOwnedLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsFamilyOwnedLine(
			TEXT("MagicCube5D"),
			true,
			false,
			TEXT("magiccube5d-projection-view-profile"),
			TEXT("phase6c/magiccube5d/dedicated-training-session-surface"),
			TEXT("phase6c/magiccube5d/interactive-scene-surface"),
			TEXT("magiccube5d-persistence-boundary"),
			TEXT("phase6c/magiccube5d/family-owned-scene-state"),
			4,
			TEXT("stereo tags"),
			5,
			5,
			TEXT("visibility tags"),
			5,
			TEXT("focus surfaces"),
			5
		);
	TestTrue(
		TEXT("The control/settings family-owned formatter must render one-sided higher-dimensional ownership as partial while preserving the ready-side view ids and counts."),
		PartialFamilyOwnedLine.Contains(TEXT("MagicCube5D owned settings: partial"))
			&& PartialFamilyOwnedLine.Contains(TEXT("profile magiccube5d-projection-view-profile"))
			&& PartialFamilyOwnedLine.Contains(TEXT("session n/a"))
			&& PartialFamilyOwnedLine.Contains(TEXT("scene n/a"))
			&& PartialFamilyOwnedLine.Contains(TEXT("persistence n/a"))
			&& PartialFamilyOwnedLine.Contains(TEXT("semantics n/a"))
			&& PartialFamilyOwnedLine.Contains(TEXT("selectors 4"))
			&& PartialFamilyOwnedLine.Contains(TEXT("projection tags 5"))
			&& PartialFamilyOwnedLine.Contains(TEXT("stereo tags 5"))
			&& PartialFamilyOwnedLine.Contains(TEXT("visibility tags 5"))
			&& PartialFamilyOwnedLine.Contains(TEXT("focus surfaces 5"))
	);

	const FString MissingSelectorOwnershipLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsSelectorOwnershipLine(
			false,
			false,
			false,
			TEXT("phase6c/magic120cell/runtime-view-context-surface"),
			TEXT("phase6c/magic120cell/dedicated-training-session-surface"),
			TEXT("phase6c/magic120cell/interactive-scene-surface"),
			4
		);
	TestTrue(
		TEXT("The control/settings selector formatter must render a fully absent selector lane as missing and mask stale active-surface ids."),
		MissingSelectorOwnershipLine.Contains(TEXT("Higher-dimensional selector ownership: missing"))
			&& MissingSelectorOwnershipLine.Contains(TEXT("active context n/a"))
			&& MissingSelectorOwnershipLine.Contains(TEXT("active session n/a"))
			&& MissingSelectorOwnershipLine.Contains(TEXT("active scene n/a"))
			&& MissingSelectorOwnershipLine.Contains(TEXT("active selectors 0"))
	);

		const FString MissingStatusLine =
			HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsStatusLine(
				false,
				false,
				false,
				false,
				false,
				false,
				false,
				false,
				false,
				false,
				false,
				false,
				false
			);
	TestTrue(
		TEXT("The control/settings status formatter must render fully absent dedicated-family ownership as missing instead of overstating it as partial."),
			MissingStatusLine.Contains(TEXT("camera missing"))
				&& MissingStatusLine.Contains(TEXT("immersive missing"))
				&& MissingStatusLine.Contains(TEXT("120-cell owned settings missing"))
				&& MissingStatusLine.Contains(TEXT("5D owned settings missing"))
				&& MissingStatusLine.Contains(TEXT("selectors missing"))
				&& MissingStatusLine.Contains(TEXT("selector recall unavailable"))
				&& MissingStatusLine.Contains(TEXT("XR rebinding missing"))
				&& MissingStatusLine.Contains(TEXT("packaged proof not yet shipped"))
		);

		const FString MixedStatusLine =
			HyperTwistTrainingControlSurfaceFormatting::BuildControlSettingsStatusLine(
				false,
				false,
				true,
			false,
			true,
			true,
				true,
				false,
				true,
				false,
				false,
				true,
				false
			);
	TestTrue(
		TEXT("The control/settings status formatter must keep mixed missing-versus-partial continuity truth explicit instead of collapsing it into one generic degraded label."),
			MixedStatusLine.Contains(TEXT("camera missing"))
				&& MixedStatusLine.Contains(TEXT("immersive partial"))
				&& MixedStatusLine.Contains(TEXT("120-cell owned settings ready"))
				&& MixedStatusLine.Contains(TEXT("5D owned settings partial"))
				&& MixedStatusLine.Contains(TEXT("selectors partial"))
				&& MixedStatusLine.Contains(TEXT("selector recall unavailable"))
				&& MixedStatusLine.Contains(TEXT("XR rebinding owned"))
				&& MixedStatusLine.Contains(TEXT("packaged proof not yet shipped"))
		);

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistControlProfileContinuityStateFormattingTest,
	"HyperTwist.Browser.ControlProfileContinuityStateFormatting",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistControlProfileContinuityStateFormattingTest::RunTest(
	const FString& Parameters
)
{
	const FString MissingContinuityLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlProfilePreferencesContinuityLine(
			false,
			FString(),
			false,
			FString(),
			0,
			0
		);
	TestTrue(
		TEXT("The control/profile continuity formatter must render a fully absent continuity lane as missing with fallback ids."),
		MissingContinuityLine.Contains(TEXT("Profile continuity: missing"))
			&& MissingContinuityLine.Contains(TEXT("camera export n/a"))
			&& MissingContinuityLine.Contains(TEXT("immersive recall n/a"))
	);

	const FString PartialContinuityLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlProfilePreferencesContinuityLine(
			true,
			TEXT("artifact/camera-export-json"),
			false,
			FString(),
			7,
			9
		);
	TestTrue(
		TEXT("The control/profile continuity formatter must render a one-sided continuity lane as partial while preserving the ready id and masking stale recall counts."),
		PartialContinuityLine.Contains(TEXT("Profile continuity: partial"))
			&& PartialContinuityLine.Contains(TEXT("camera export artifact/camera-export-json"))
			&& PartialContinuityLine.Contains(TEXT("immersive recall n/a"))
			&& PartialContinuityLine.Contains(TEXT("recall scopes 0"))
			&& PartialContinuityLine.Contains(TEXT("preference fields 0"))
	);

	const FString ReadyContinuityLine =
		HyperTwistTrainingControlSurfaceFormatting::BuildControlProfilePreferencesContinuityLine(
			true,
			TEXT("artifact/camera-export-json"),
			true,
			TEXT("immersive-training-session-recall-boundary"),
			3,
			5
		);
	TestTrue(
		TEXT("The control/profile continuity formatter must render a fully ready continuity lane with the shipped ids and counts."),
		ReadyContinuityLine.Contains(TEXT("Profile continuity: ready"))
			&& ReadyContinuityLine.Contains(TEXT("camera export artifact/camera-export-json"))
			&& ReadyContinuityLine.Contains(TEXT("immersive recall immersive-training-session-recall-boundary"))
			&& ReadyContinuityLine.Contains(TEXT("recall scopes 3"))
			&& ReadyContinuityLine.Contains(TEXT("preference fields 5"))
	);

		const FString MixedStatusLine =
			HyperTwistTrainingControlSurfaceFormatting::BuildControlProfileStatusLine(
				true,
				true,
			true,
			true,
				false,
				false,
				true,
				false,
				true,
				false
			);
	TestTrue(
		TEXT("The control/profile status formatter must keep partial continuity truth explicit alongside unloaded active-selection and unavailable selector-recall posture."),
			MixedStatusLine.Contains(TEXT("classic keyboard ready"))
				&& MixedStatusLine.Contains(TEXT("active selection not loaded"))
				&& MixedStatusLine.Contains(TEXT("selector recall unavailable"))
				&& MixedStatusLine.Contains(TEXT("profile continuity partial"))
				&& MixedStatusLine.Contains(TEXT("controller rebinding owned"))
				&& MixedStatusLine.Contains(TEXT("packaged proof not yet shipped"))
		);

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistTrainingPanelControlProfileContinuityParityTest,
	"HyperTwist.Browser.TrainingPanel.ControlProfileContinuityParity",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistTrainingPanelControlProfileContinuityParityTest::RunTest(
	const FString& Parameters
)
{
	UHyperTwistTrainingPanelWidget* TrainingPanel = NewObject<UHyperTwistTrainingPanelWidget>();
	TestNotNull(TEXT("The training panel widget must be constructible."), TrainingPanel);
	if (TrainingPanel == nullptr)
	{
		return false;
	}

	const FHyperTwistTrainingControlProfileRosterInspectSurface Surface =
		TrainingPanel->GetDisplayedControlProfileRosterInspectSurface();
	TestTrue(
		TEXT("The control/profile roster surface must keep bounded camera and immersive continuity explicit in structured form."),
		Surface.bCameraSettingsContinuityReady
			&& Surface.CameraSettingsExportArtifactId
				== TEXT("artifact/camera-export-json")
			&& Surface.bImmersiveSessionRecallReady
			&& Surface.ImmersiveSessionRecallBoundaryId
				== TEXT("immersive-training-session-recall-boundary")
			&& Surface.ImmersiveSessionRecallScopeCount == 3
			&& Surface.ImmersiveSessionRecallPreferenceFieldTagCount == 5
	);
	TestTrue(
		TEXT("The control/profile roster surface must keep the bounded continuity ids visible in the rendered detail line."),
		Surface.PreferencesContinuityLine.Contains(TEXT("artifact/camera-export-json"))
			&& Surface.PreferencesContinuityLine.Contains(
				TEXT("immersive-training-session-recall-boundary"))
			&& Surface.DetailLine.Contains(TEXT("artifact/camera-export-json"))
			&& Surface.DetailLine.Contains(
				TEXT("immersive-training-session-recall-boundary"))
	);

	FHyperTwistTrainingHigherDimensionalRuntimeActivationProfile ActiveActivationProfile;
	FHyperTwistTrainingHigherDimensionalRuntimeViewContextSurface ActiveViewContextSurface;
	FHyperTwistTrainingHigherDimensionalRuntimeSessionSurface ActiveSessionSurface;
	FHyperTwistTrainingHigherDimensionalInteractiveSceneSurface ActiveSceneSurface;
	const bool bLoadedActiveSelection =
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledHigherDimensionalRuntimeActivationProfileById(
			TEXT("magic120cell-cleanroom-runtime-activation"),
			ActiveActivationProfile
		) && UHyperTwistTrainingRuntimeLibrary::TryGetBundledHigherDimensionalRuntimeViewContextSurfaceByActivationProfileId(
			TEXT("magic120cell-cleanroom-runtime-activation"),
			ActiveViewContextSurface
		) && UHyperTwistTrainingRuntimeLibrary::TryGetBundledHigherDimensionalRuntimeSessionSurfaceByActivationProfileId(
			TEXT("magic120cell-cleanroom-runtime-activation"),
			ActiveSessionSurface
		) && UHyperTwistTrainingRuntimeLibrary::TryGetBundledHigherDimensionalInteractiveSceneSurfaceByActivationProfileId(
			TEXT("magic120cell-cleanroom-runtime-activation"),
			ActiveSceneSurface
		);
	TestTrue(
		TEXT("The control/profile roster active-selection proof must be able to load the bundled dedicated-family activation, session, and scene surfaces."),
		bLoadedActiveSelection
	);
	if (bLoadedActiveSelection)
	{
		TrainingPanel->CachedHigherDimensionalRuntimeActivationProfile =
			ActiveActivationProfile;
		TrainingPanel->CachedHigherDimensionalRuntimeViewContextSurface =
			ActiveViewContextSurface;
		TrainingPanel->CachedHigherDimensionalRuntimeSessionSurface =
			ActiveSessionSurface;
		TrainingPanel->CachedHigherDimensionalInteractiveSceneSurface =
			ActiveSceneSurface;
		const FHyperTwistTrainingControlProfileRosterInspectSurface ActiveSurface =
			TrainingPanel->GetDisplayedControlProfileRosterInspectSurface();
		TestEqual(
			TEXT("The control/profile roster surface must keep the active higher-dimensional scene surface id in structured form."),
			ActiveSurface.ActiveHigherDimensionalInteractiveSceneSurfaceId,
			TEXT("phase6c/magic120cell/interactive-scene-surface")
		);
		TestTrue(
			TEXT("The control/profile roster surface must keep the active higher-dimensional scene surface visible in the rendered detail line."),
			ActiveSurface.ActiveHigherDimensionalProfileLine.Contains(
				TEXT("phase6c/magic120cell/interactive-scene-surface"))
		);
	}

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistCoachDashboardControlProfileContinuityArtifactsTest,
	"HyperTwist.Browser.CoachDashboard.ControlProfileContinuityArtifacts",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistCoachDashboardControlProfileContinuityArtifactsTest::RunTest(
	const FString& Parameters
)
{
	UHyperTwistCoachDashboardWidget* CoachDashboard = NewObject<UHyperTwistCoachDashboardWidget>();
	TestNotNull(TEXT("The coach dashboard widget must be constructible."), CoachDashboard);
	if (CoachDashboard == nullptr)
	{
		return false;
	}

	CoachDashboard->TakeWidget();
	CoachDashboard->RefreshCoachDashboardView();

	const FHyperTwistTrainingControlProfileRosterInspectSurface Surface =
		CoachDashboard->GetDisplayedControlProfileRosterInspectSurface();
	TestTrue(
		TEXT("The coach dashboard control/profile roster surface must retain the bounded continuity ids in its detail line."),
		Surface.DetailLine.Contains(TEXT("artifact/camera-export-json"))
			&& Surface.DetailLine.Contains(
				TEXT("immersive-training-session-recall-boundary"))
	);

	UTextBlock* PreferencesContinuityTextBlock =
		HyperTwistControlProfileContinuityParityTestInternal::FindDashboardTextBlock(
			CoachDashboard,
			TEXT("CoachControlProfileRosterPreferencesContinuity")
		);
	TestNotNull(
		TEXT("The coach dashboard must build the structured preferences-continuity roster row."),
		PreferencesContinuityTextBlock
	);
	if (PreferencesContinuityTextBlock != nullptr)
	{
		TestEqual(
			TEXT("The structured preferences-continuity roster row must mirror the inspect surface."),
			PreferencesContinuityTextBlock->GetText().ToString(),
			Surface.PreferencesContinuityLine
		);
		TestTrue(
			TEXT("The structured preferences-continuity roster row must expose the shipped camera-export and immersive recall ids."),
			PreferencesContinuityTextBlock->GetText().ToString().Contains(
				TEXT("artifact/camera-export-json"))
				&& PreferencesContinuityTextBlock->GetText().ToString().Contains(
					TEXT("immersive-training-session-recall-boundary"))
		);
	}

	return true;
}

#endif
