// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBRegressionSnapshotContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJB.RegressionSnapshots",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBRegressionSnapshotContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingRegressionSnapshotContract Contract;
	TestTrue(
		TEXT("The regression-snapshot contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledRegressionSnapshotContract(
			TEXT("validation-regression-snapshot-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The regression-snapshot contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-regression-snapshot-contract")
	);
	TestTrue(
		TEXT("The regression-snapshot contract must preserve the baseline snapshot kind."),
		Contract.SnapshotKindIds.Contains(TEXT("snapshot-kind/baseline"))
	);
	TestTrue(
		TEXT("The regression-snapshot contract must preserve validation outcome snapshots."),
		Contract.SnapshotSurfaceTags.Contains(TEXT("validation outcome snapshot"))
	);
	TestTrue(
		TEXT("The regression-snapshot contract must preserve same-input comparison guard."),
		Contract.StabilityGuardTags.Contains(TEXT("same-input comparison guard"))
	);
	TestTrue(
		TEXT("The regression-snapshot contract must keep generic experiment tracker ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic experiment tracker ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBCrossRunDeltaBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJB.CrossRunDeltas",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBCrossRunDeltaBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingCrossRunBenchmarkDeltaBoundary Boundary;
	TestTrue(
		TEXT("The cross-run benchmark delta boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledCrossRunBenchmarkDeltaBoundary(
			TEXT("validation-cross-run-benchmark-delta-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The cross-run benchmark delta boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-cross-run-benchmark-delta-boundary")
	);
	TestTrue(
		TEXT("The cross-run benchmark delta boundary must preserve anchor-coverage deltas."),
		Boundary.DeltaProfileIds.Contains(TEXT("delta-profile/anchor-coverage"))
	);
	TestTrue(
		TEXT("The cross-run benchmark delta boundary must preserve regression drift notes."),
		Boundary.DeltaSurfaceTags.Contains(TEXT("regression drift note"))
	);
	TestTrue(
		TEXT("The cross-run benchmark delta boundary must preserve same-benchmark-profile guard."),
		Boundary.InterpretationGuardTags.Contains(TEXT("same-benchmark-profile guard"))
	);
	TestTrue(
		TEXT("The cross-run benchmark delta boundary must keep public leaderboard ordering ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("public leaderboard ordering ownership"))
	);
	return true;
}

#endif
