// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseIAEnvironmentProfileTest,
	"HyperTwist.FirstParty.Immersive.PhaseIA.EnvironmentProfile",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseIAEnvironmentProfileTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveEnvironmentProfileContract Contract;
	TestTrue(
		TEXT("The immersive environment profile contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveEnvironmentProfileContract(
			TEXT("immersive-training-environment-profile"),
			Contract
		)
	);
	TestEqual(
		TEXT("The immersive environment profile id must stay stable."),
		Contract.ContractId,
		TEXT("immersive-training-environment-profile")
	);
	TestTrue(
		TEXT("The immersive environment profile must preserve an alpine ridge family."),
		Contract.EnvironmentFamilyIds.Contains(TEXT("environment/alpine-ridge"))
	);
	TestTrue(
		TEXT("The immersive environment profile must preserve an observatory family."),
		Contract.EnvironmentFamilyIds.Contains(TEXT("environment/observatory"))
	);
	TestTrue(
		TEXT("The immersive environment profile must remain a scenic training shell."),
		Contract.PresenceSurfaceTags.Contains(TEXT("scenic training shell"))
	);
	TestTrue(
		TEXT("The immersive environment profile must keep the generic virtual desktop excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic virtual desktop shell"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseIALightingAudioTest,
	"HyperTwist.FirstParty.Immersive.PhaseIA.LightingAndAudio",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseIALightingAudioTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveLightingPresetBoundary LightingBoundary;
	TestTrue(
		TEXT("The immersive lighting boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveLightingPresetBoundary(
			TEXT("immersive-training-lighting-preset-boundary"),
			LightingBoundary
		)
	);
	TestTrue(
		TEXT("The immersive lighting boundary must preserve dawn-focus lighting."),
		LightingBoundary.LightingPresetIds.Contains(TEXT("preset/dawn-focus"))
	);
	TestTrue(
		TEXT("The immersive lighting boundary must preserve puzzle-face legibility bias."),
		LightingBoundary.LegibilitySurfaceTags.Contains(TEXT("puzzle-face legibility bias"))
	);
	TestTrue(
		TEXT("The immersive lighting boundary must keep full weather simulation excluded."),
		LightingBoundary.ExplicitExclusions.Contains(TEXT("full weather simulation ownership"))
	);

	FHyperTwistTrainingImmersiveAmbientAudioBoundary AudioBoundary;
	TestTrue(
		TEXT("The immersive ambient audio boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveAmbientAudioBoundary(
			TEXT("immersive-training-ambient-audio-boundary"),
			AudioBoundary
		)
	);
	TestTrue(
		TEXT("The immersive ambient audio boundary must preserve the alpine wind bed."),
		AudioBoundary.AudioFamilyIds.Contains(TEXT("audio/alpine-wind-bed"))
	);
	TestTrue(
		TEXT("The immersive ambient audio boundary must preserve replay-safe ducking."),
		AudioBoundary.ComfortSurfaceTags.Contains(TEXT("replay-safe ducking"))
	);
	TestTrue(
		TEXT("The immersive ambient audio boundary must keep voice-assistant playback excluded."),
		AudioBoundary.ExplicitExclusions.Contains(TEXT("voice-assistant playback ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistImmersivePhaseIAWorldAnchorsTest,
	"HyperTwist.FirstParty.Immersive.PhaseIA.WorldAnchors",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistImmersivePhaseIAWorldAnchorsTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingImmersiveWorldAnchorContract Contract;
	TestTrue(
		TEXT("The immersive world-anchor contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledImmersiveWorldAnchorContract(
			TEXT("immersive-training-world-anchor-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The immersive world-anchor id must stay stable."),
		Contract.ContractId,
		TEXT("immersive-training-world-anchor-contract")
	);
	TestTrue(
		TEXT("The immersive world-anchor contract must preserve the puzzle dais anchor."),
		Contract.AnchorIds.Contains(TEXT("anchor/puzzle-dais"))
	);
	TestTrue(
		TEXT("The immersive world-anchor contract must preserve replay path staging."),
		Contract.TargetSurfaceTags.Contains(TEXT("replay path staging"))
	);
	TestTrue(
		TEXT("The immersive world-anchor contract must preserve a comfort-safe forward anchor."),
		Contract.StabilitySurfaceTags.Contains(TEXT("comfort-safe forward anchor"))
	);
	TestTrue(
		TEXT("The immersive world-anchor contract must keep productivity dashboard anchors excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic productivity dashboard anchors"))
	);
	return true;
}

#endif
