105 lines
4.0 KiB
GDScript
105 lines
4.0 KiB
GDScript
extends SceneTree
|
|
|
|
const FeatureFlags := preload("res://scripts/config/feature_flags.gd")
|
|
|
|
var failures := 0
|
|
|
|
|
|
class ScreenHost extends Control:
|
|
var shown_screen := ""
|
|
|
|
func show_screen(screen_name: String, _payload: Variant = null) -> void:
|
|
shown_screen = screen_name
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("_run")
|
|
|
|
|
|
func _run() -> void:
|
|
var prior_environment: String = ProjectSettings.get_setting("step3/deployment_environment", "development")
|
|
ProjectSettings.set_setting("step3/deployment_environment", "uat")
|
|
_assert(FeatureFlags.progression_enabled(), "UAT should enable progression")
|
|
|
|
for environment in ["prd", "production", "development", "unknown"]:
|
|
ProjectSettings.set_setting("step3/deployment_environment", environment)
|
|
_assert(not FeatureFlags.progression_enabled(), "%s should not enable progression" % environment)
|
|
|
|
ProjectSettings.set_setting("step3/deployment_environment", "prd")
|
|
var received: Array = []
|
|
var credits = root.get_node("CreditsService")
|
|
var prior_credits: int = credits.credits
|
|
var prior_loaded: bool = credits.loaded
|
|
var capture := func(amount: int, reason: String): received.append([amount, reason])
|
|
credits.award_received.connect(capture)
|
|
credits.apply_award_response({"credits": {"credits": 123}, "creditAwards": [{
|
|
"amount": 10, "reasonCode": "rank_promotion", "description": "Advanced rank"
|
|
}]})
|
|
_assert(received.is_empty(), "production should suppress progression award notifications")
|
|
_assert(credits.credits == 123, "production should still apply balances containing progression awards")
|
|
credits.apply_award_response({"creditAwards": [{
|
|
"amount": 2, "reasonCode": "qbank_difficult_correct", "description": "Difficult question correct"
|
|
}]})
|
|
_assert(received.size() == 1, "production should retain ordinary learning reward notifications")
|
|
credits.award_received.disconnect(capture)
|
|
credits.credits = prior_credits
|
|
credits.loaded = prior_loaded
|
|
|
|
var production_setup = load("res://scripts/ui/block_setup.gd").new()
|
|
var screen_host := ScreenHost.new()
|
|
root.add_child(screen_host)
|
|
production_setup.main = screen_host
|
|
root.add_child(production_setup)
|
|
await process_frame
|
|
_assert(not production_setup.goal_row.visible, "production block setup should hide progression finish lines")
|
|
var question_bank = root.get_node("QuestionBankService")
|
|
var prior_questions: Array = question_bank.questions.duplicate(true)
|
|
question_bank.questions = [_sample_question()]
|
|
production_setup.selected_system = "All Systems"
|
|
production_setup.size_spin.value = 5
|
|
production_setup._start_block()
|
|
_assert(screen_host.shown_screen == "player", "production should launch a classic block directly")
|
|
_assert(root.get_node("StudySessionService").active_session_id.is_empty(), "production classic blocks should not create progression sessions")
|
|
root.get_node("BlockSessionService").finish_block()
|
|
question_bank.questions = prior_questions
|
|
production_setup.queue_free()
|
|
screen_host.queue_free()
|
|
|
|
var production_profile = load("res://scripts/ui/progress_profile.gd").new()
|
|
root.add_child(production_profile)
|
|
await process_frame
|
|
_assert(production_profile.progression_content == null, "production profile should omit clinical progression")
|
|
production_profile.queue_free()
|
|
|
|
ProjectSettings.set_setting("step3/deployment_environment", "uat")
|
|
var uat_setup = load("res://scripts/ui/block_setup.gd").new()
|
|
root.add_child(uat_setup)
|
|
await process_frame
|
|
_assert(uat_setup.goal_row.visible, "UAT block setup should retain progression finish lines")
|
|
uat_setup.queue_free()
|
|
|
|
ProjectSettings.set_setting("step3/deployment_environment", prior_environment)
|
|
await process_frame
|
|
quit(1 if failures > 0 else 0)
|
|
|
|
|
|
func _sample_question() -> Dictionary:
|
|
var choices: Array = []
|
|
for index in 5:
|
|
choices.append({"id": String.chr(65 + index), "text": "Choice %d" % index})
|
|
return {
|
|
"external_id": "progression-flag-test",
|
|
"system": "Cardiovascular",
|
|
"stem": "Test stem",
|
|
"lead_in": "Choose an answer.",
|
|
"choices": choices,
|
|
"correct_choice_id": "A",
|
|
}
|
|
|
|
|
|
func _assert(condition: bool, message: String) -> void:
|
|
if condition:
|
|
return
|
|
failures += 1
|
|
push_error(message)
|