// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDRunSummaryContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJD.RunSummaries",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDRunSummaryContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationRunSummaryContract Contract;
	TestTrue(
		TEXT("The validation run-summary contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationRunSummaryContract(
			TEXT("validation-run-summary-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation run-summary contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-run-summary-contract")
	);
	TestTrue(
		TEXT("The validation run-summary contract must preserve the validation-overview section."),
		Contract.SummarySectionIds.Contains(TEXT("run-summary/validation-overview"))
	);
	TestTrue(
		TEXT("The validation run-summary contract must preserve the runtime evidence handoff summary surface."),
		Contract.RunSurfaceTags.Contains(TEXT("runtime evidence handoff summary"))
	);
	TestTrue(
		TEXT("The validation run-summary contract must preserve the no-approval-automation guard."),
		Contract.TriageGuardTags.Contains(TEXT("no-approval-automation guard"))
	);
	TestTrue(
		TEXT("The validation run-summary contract must keep cross-product issue tracker ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("cross-product issue tracker ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDOperatorReviewPacketBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJD.OperatorReviewPackets",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDOperatorReviewPacketBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingOperatorReviewPacketBoundary Boundary;
	TestTrue(
		TEXT("The operator-review packet boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledOperatorReviewPacketBoundary(
			TEXT("validation-operator-review-packet-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The operator-review packet boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-operator-review-packet-boundary")
	);
	TestTrue(
		TEXT("The operator-review packet boundary must preserve regression-repro review packets."),
		Boundary.ReviewPacketIds.Contains(TEXT("review-packet/regression-repro-review"))
	);
	TestTrue(
		TEXT("The operator-review packet boundary must preserve manual triage handoff."),
		Boundary.ReviewSurfaceTags.Contains(TEXT("manual triage handoff"))
	);
	TestTrue(
		TEXT("The operator-review packet boundary must preserve the no-release-approval guard."),
		Boundary.DecisionGuardTags.Contains(TEXT("no-release-approval guard"))
	);
	TestTrue(
		TEXT("The operator-review packet boundary must keep generic approval workflow ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic approval workflow ownership"))
	);
	return true;
}

#endif
