// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseICCoachCueGhostTargetTest,
	"HyperTwist.FirstParty.Immersive.PhaseIC.CoachCueAndGhostTarget",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseICCoachCueGhostTargetTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveCoachCueAnchorContract CoachContract;
	TestTrue(
		TEXT("The immersive coach-cue anchor contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveCoachCueAnchorContract(
			TEXT("immersive-training-coach-cue-anchor-contract"),
			CoachContract
		)
	);
	TestEqual(
		TEXT("The immersive coach-cue anchor id must stay stable."),
		CoachContract.ContractId,
		TEXT("immersive-training-coach-cue-anchor-contract")
	);
	TestTrue(
		TEXT("The immersive coach-cue anchor contract must preserve the coach callout arc."),
		CoachContract.CueAnchorIds.Contains(TEXT("anchor/coach-callout-arc"))
	);
	TestTrue(
		TEXT("The immersive coach-cue anchor contract must preserve guided lesson-step trigger posture."),
		CoachContract.TriggerSurfaceTags.Contains(TEXT("guided lesson-step trigger"))
	);
	TestTrue(
		TEXT("The immersive coach-cue anchor contract must keep generic tooltips excluded."),
		CoachContract.ExplicitExclusions.Contains(TEXT("generic UI tooltip ownership"))
	);

	FHyperTwistTrainingImmersiveGhostTargetBoundary GhostBoundary;
	TestTrue(
		TEXT("The immersive ghost-target boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveGhostTargetBoundary(
			TEXT("immersive-training-ghost-target-boundary"),
			GhostBoundary
		)
	);
	TestTrue(
		TEXT("The immersive ghost-target boundary must preserve drill end-state targeting."),
		GhostBoundary.TargetModeIds.Contains(TEXT("ghost-target/drill-end-state"))
	);
	TestTrue(
		TEXT("The immersive ghost-target boundary must preserve semi-transparent target pose visualization."),
		GhostBoundary.VisualizationSurfaceTags.Contains(TEXT("semi-transparent target pose"))
	);
	TestTrue(
		TEXT("The immersive ghost-target boundary must preserve puzzle-local alignment."),
		GhostBoundary.AlignmentSurfaceTags.Contains(TEXT("puzzle-local alignment"))
	);
	TestTrue(
		TEXT("The immersive ghost-target boundary must keep animation rig ownership excluded."),
		GhostBoundary.ExplicitExclusions.Contains(TEXT("full animation-rig ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseICReplayEmphasisTest,
	"HyperTwist.FirstParty.Immersive.PhaseIC.ReplayEmphasis",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseICReplayEmphasisTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveReplayEmphasisBoundary Boundary;
	TestTrue(
		TEXT("The immersive replay-emphasis boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveReplayEmphasisBoundary(
			TEXT("immersive-training-replay-emphasis-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The immersive replay-emphasis boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("immersive-training-replay-emphasis-boundary")
	);
	TestTrue(
		TEXT("The immersive replay-emphasis boundary must preserve path-ribbon mode."),
		Boundary.EmphasisModeIds.Contains(TEXT("replay-emphasis/path-ribbon"))
	);
	TestTrue(
		TEXT("The immersive replay-emphasis boundary must preserve error-turn highlight."),
		Boundary.ReplaySurfaceTags.Contains(TEXT("error-turn highlight"))
	);
	TestTrue(
		TEXT("The immersive replay-emphasis boundary must preserve coach-linked replay focus."),
		Boundary.AttentionSurfaceTags.Contains(TEXT("coach-linked replay focus"))
	);
	TestTrue(
		TEXT("The immersive replay-emphasis boundary must keep cinematic replay ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("full cinematic replay ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseICLessonStateTest,
	"HyperTwist.FirstParty.Immersive.PhaseIC.LessonState",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseICLessonStateTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveLessonStateContract Contract;
	TestTrue(
		TEXT("The immersive lesson-state contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveLessonStateContract(
			TEXT("immersive-training-lesson-state-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The immersive lesson-state id must stay stable."),
		Contract.ContractId,
		TEXT("immersive-training-lesson-state-contract")
	);
	TestTrue(
		TEXT("The immersive lesson-state contract must preserve drill-focus state."),
		Contract.LessonStateIds.Contains(TEXT("lesson-state/drill-focus"))
	);
	TestTrue(
		TEXT("The immersive lesson-state contract must preserve drill-target spotlighting."),
		Contract.SpotlightSurfaceTags.Contains(TEXT("drill-target spotlight"))
	);
	TestTrue(
		TEXT("The immersive lesson-state contract must preserve lesson-specific environment tone."),
		Contract.StateSurfaceTags.Contains(TEXT("lesson-specific environment tone"))
	);
	TestTrue(
		TEXT("The immersive lesson-state contract must keep mission scripting ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic mission scripting ownership"))
	);
	return true;
}

#endif
