// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJLReturnReadinessPacketContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJL.ReturnReadinessPackets",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJLReturnReadinessPacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationReturnReadinessPacketContract Contract;
	TestTrue(
		TEXT("The validation return-readiness packet contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationReturnReadinessPacketContract(
			TEXT("validation-return-readiness-packet-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation return-readiness packet contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-return-readiness-packet-contract")
	);
	TestTrue(
		TEXT("The validation return-readiness packet contract must preserve benchmark-drift readiness packets."),
		Contract.ReturnReadinessPacketIds.Contains(TEXT("return-readiness-packet/benchmark-drift-ready"))
	);
	TestTrue(
		TEXT("The validation return-readiness packet contract must preserve the bounded return-readiness packet surface."),
		Contract.PacketSurfaceTags.Contains(TEXT("bounded return-readiness packet"))
	);
	TestTrue(
		TEXT("The validation return-readiness packet contract must preserve the no-release-readiness-authority guard."),
		Contract.ReturnGuardTags.Contains(TEXT("no-release-readiness-authority guard"))
	);
	TestTrue(
		TEXT("The validation return-readiness packet contract must keep release readiness authority ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("release readiness authority ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJLWakeStateConfirmationBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJL.WakeStateConfirmations",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJLWakeStateConfirmationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationWakeStateConfirmationBoundary Boundary;
	TestTrue(
		TEXT("The validation wake-state confirmation boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationWakeStateConfirmationBoundary(
			TEXT("validation-wake-state-confirmation-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation wake-state confirmation boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-wake-state-confirmation-boundary")
	);
	TestTrue(
		TEXT("The validation wake-state confirmation boundary must preserve manual-waiver wake confirmations."),
		Boundary.WakeConfirmationIds.Contains(TEXT("wake-confirmation/manual-waiver-ready-confirmed"))
	);
	TestTrue(
		TEXT("The validation wake-state confirmation boundary must preserve the bounded wake-state confirmation surface."),
		Boundary.ConfirmationSurfaceTags.Contains(TEXT("bounded wake-state confirmation"))
	);
	TestTrue(
		TEXT("The validation wake-state confirmation boundary must preserve the no-resume-platform-ownership guard."),
		Boundary.WakeGuardTags.Contains(TEXT("no-resume-platform-ownership guard"))
	);
	TestTrue(
		TEXT("The validation wake-state confirmation boundary must keep generic resume platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic resume platform ownership"))
	);
	return true;
}

#endif
