76 lines
3.6 KiB
GDScript
76 lines
3.6 KiB
GDScript
extends SceneTree
|
|
|
|
const Controller = preload("res://entry/recruit_review_page_controller.gd")
|
|
|
|
var failures: Array[String] = []
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run_test")
|
|
|
|
|
|
func run_test() -> void:
|
|
var controller := Controller.new()
|
|
var company := _fixture_company()
|
|
var content := controller._market_controller._content({})
|
|
var review: Dictionary = controller.snapshot(company, "offer-001", "zh_CN", content)
|
|
expect(review.ok and review.page_id == "recruit_review", "snapshot identifies Recruit Review")
|
|
expect(review.offer_id == "offer-001" and review.facts.name == "ari", "snapshot preserves stable offer and generated name")
|
|
expect(review.facts.profession_id == "PF-B01" and not review.facts.profession_job.is_empty(), "snapshot exposes profession facts")
|
|
expect(review.facts.trait_id == "TR-001" and not review.facts.trait_benefit.is_empty() and not review.facts.trait_cost.is_empty(), "snapshot exposes trait facts")
|
|
expect(review.facts.starting_item_id == "EQ-002" and review.facts.history.level == 1, "snapshot exposes item and history facts")
|
|
expect(review.hire.eligible and review.hire.reason == "eligible", "available offer exposes Hire boundary")
|
|
expect(review.impact.owned_before == 2 and review.impact.owned_after == 3 and review.impact.line_capacity == 4, "snapshot exposes Company impact separately from Line capacity")
|
|
|
|
var already := company.duplicate(true)
|
|
already.active_contract.available_recruit_offer_ids = []
|
|
var already_review: Dictionary = controller.snapshot(already, "offer-001", "en", content)
|
|
expect(already_review.ok and not already_review.hire.eligible and already_review.hire.reason == "already_hired", "already-hired offer is inspectable but not committable")
|
|
var complete := company.duplicate(true)
|
|
complete.active_contract.hire_receipts = [{"operation_id": "one"}, {"operation_id": "two"}]
|
|
var complete_review: Dictionary = controller.snapshot(complete, "offer-001", "en", content)
|
|
expect(not complete_review.hire.eligible and complete_review.hire.reason == "opening_hires_complete", "opening stop blocks a third Hire")
|
|
var missing: Dictionary = controller.snapshot(company, "missing", "zh_CN", content)
|
|
expect(not missing.ok and missing.code == "RECRUIT_OFFER_UNAVAILABLE", "unknown offer is rejected")
|
|
|
|
var copied: Dictionary = review.offer
|
|
copied.display_name_tokens[0] = "changed"
|
|
expect(company.active_contract.market_board.recruit_offers[0].display_name_tokens[0] == "name.ari", "view data is isolated from Company input")
|
|
if failures.is_empty():
|
|
print("ABG_M18_RECRUIT_REVIEW_CONTROLLER_OK stable_offer=true facts=profession,trait,attributes,item,history impact=company_2_to_3_line_4 hire=eligible,already_hired,opening_hires_complete missing=true copies=true")
|
|
quit(0)
|
|
else:
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
func _fixture_company() -> Dictionary:
|
|
return {
|
|
"company_id": "company-001",
|
|
"owned_recruits": [{"recruit_id": "owned-001"}, {"recruit_id": "owned-002"}],
|
|
"active_contract": {
|
|
"status": "market",
|
|
"coin": 52,
|
|
"line_capacity": 4,
|
|
"hire_receipts": [],
|
|
"available_recruit_offer_ids": ["offer-001"],
|
|
"market_board": {
|
|
"recruit_offers": [{
|
|
"source_offer_id": "offer-001",
|
|
"display_name_tokens": ["name.ari"],
|
|
"profession_id": "PF-B01",
|
|
"trait_id": "TR-001",
|
|
"starting_equipment_id": "EQ-002",
|
|
"list_price": 14,
|
|
"attribute_rolls": {"vigor": 3, "force": 2, "finesse": 1, "resolve": 2, "focus": 1},
|
|
}],
|
|
},
|
|
},
|
|
}
|
|
|
|
|
|
func expect(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
failures.append("M18 Recruit Review Controller: %s" % message)
|