diff --git a/test/dummy/log/test.log b/test/dummy/log/test.log index bd553e2..1908eda 100644 --- a/test/dummy/log/test.log +++ b/test/dummy/log/test.log @@ -29368,3 +29368,259 @@ Processing by BreakEscape::GamesController#unlock as HTML TRANSACTION (0.1ms) RELEASE SAVEPOINT active_record_1 Completed 200 OK in 4ms (Views: 0.1ms | ActiveRecord: 0.6ms (5 queries, 0 cached) | GC: 0.0ms) TRANSACTION (0.1ms) rollback transaction + ActiveRecord::InternalMetadata Load (0.3ms) SELECT * FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? ORDER BY "ar_internal_metadata"."key" ASC LIMIT 1 [[nil, "schema_sha1"]] + ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC + TRANSACTION (0.0ms) begin transaction +  (0.1ms) PRAGMA foreign_keys +  (0.0ms) PRAGMA defer_foreign_keys +  (0.0ms) PRAGMA defer_foreign_keys = ON +  (0.0ms) PRAGMA foreign_keys = OFF + Fixtures Load (0.1ms) DELETE FROM "break_escape_demo_users"; +DELETE FROM "break_escape_missions"; +INSERT INTO "break_escape_demo_users" ("id", "handle", "created_at", "updated_at") VALUES (149617800, 'test_user', '2025-11-24 11:19:17', '2025-11-24 11:19:17'); +INSERT INTO "break_escape_demo_users" ("id", "handle", "created_at", "updated_at") VALUES (618102942, 'other_user', '2025-11-24 11:19:17', '2025-11-24 11:19:17'); +INSERT INTO "break_escape_missions" ("id", "name", "display_name", "description", "published", "difficulty_level", "created_at", "updated_at") VALUES (418560898, 'ceo_exfil', 'CEO Exfiltration', 'Test scenario', 1, 3, '2025-11-24 11:19:17', '2025-11-24 11:19:17'); +INSERT INTO "break_escape_missions" ("id", "name", "display_name", "description", "published", "difficulty_level", "created_at", "updated_at") VALUES (636030761, 'test_unpublished', 'Unpublished Test', 'Not visible', 0, 1, '2025-11-24 11:19:17', '2025-11-24 11:19:17') +  (0.0ms) PRAGMA defer_foreign_keys = 0 +  (0.0ms) PRAGMA foreign_keys = 1 + TRANSACTION (0.7ms) commit transaction +  (0.0ms) PRAGMA foreign_key_check + TRANSACTION (0.0ms) begin transaction +------------------------------------------------------------------------------- +BreakEscape::GameTest: test_should_reject_locked_door_without_any_unlock_method +------------------------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.2ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.593710"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.593611"], ["updated_at", "2025-11-24 11:19:17.593611"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] validate_unlock: type=door, id=office1, attempt=, method= +[BreakEscape] Room data: locked=true, lockType=key, requires=office1_key +[BreakEscape] Room is LOCKED, method must be valid: +[BreakEscape] SECURITY VIOLATION: No valid unlock method for LOCKED door: office1, method= +[BreakEscape] validate_unlock returning: false + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +--------------------------------------------------------------------------------------- +BreakEscape::GameTest: test_should_reject_lockpick_unlock_without_lockpick_in_inventory +--------------------------------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.595519"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.595480"], ["updated_at", "2025-11-24 11:19:17.595480"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] validate_unlock: type=door, id=office1, attempt=, method=lockpick +[BreakEscape] Room data: locked=true, lockType=key, requires=office1_key +[BreakEscape] Room is LOCKED, method must be valid: lockpick +[BreakEscape] Checking for lockpick in inventory (1 items) +[BreakEscape] Inventory item: type=key, scenarioData.type=, is_lockpick=false +[BreakEscape] Lockpick found in inventory: false +[BreakEscape] Lockpick validation result: false +[BreakEscape] validate_unlock returning: false + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +---------------------------------------------- +BreakEscape::GameTest: test_should_unlock_room +---------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.596663"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.596631"], ["updated_at", "2025-11-24 11:19:17.596631"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Update (0.1ms) UPDATE "break_escape_games" SET "player_state" = ?, "updated_at" = ? WHERE "break_escape_games"."id" = ? [["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\",\"office\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["updated_at", "2025-11-24 11:19:17.597131"], ["id", 1]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +-------------------------------------------------------------------------------------- +BreakEscape::GameTest: test_should_allow_access_to_unlocked_doors_regardless_of_method +-------------------------------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.598076"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.598045"], ["updated_at", "2025-11-24 11:19:17.598045"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] validate_unlock: type=door, id=reception, attempt=, method=unlocked +[BreakEscape] Door already unlocked in player state, granting access + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +--------------------------------------------------------------------------- +BreakEscape::GameTest: test_has_key_in_inventory_should_find_keys_by_key_id +--------------------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.599062"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.599031"], ["updated_at", "2025-11-24 11:19:17.599031"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] Checking for key office1_key in inventory (1 items) +[BreakEscape] Inventory item: name=Office Key, key_id=office1_key, is_match=true +[BreakEscape] Key office1_key found in inventory: true +[BreakEscape] Checking for key wrong_key in inventory (1 items) +[BreakEscape] Inventory item: name=Office Key, key_id=office1_key, is_match=false +[BreakEscape] Key wrong_key found in inventory: false + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +------------------------------------------------------------------ +BreakEscape::GameTest: test_lockpick_should_bypass_key_requirement +------------------------------------------------------------------ + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.600076"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.600045"], ["updated_at", "2025-11-24 11:19:17.600045"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] validate_unlock: type=door, id=secure_vault, attempt=, method=lockpick +[BreakEscape] Room data: locked=true, lockType=key, requires=vault_master_key +[BreakEscape] Room is LOCKED, method must be valid: lockpick +[BreakEscape] Checking for lockpick in inventory (1 items) +[BreakEscape] Inventory item: type=lockpick, scenarioData.type=, is_lockpick=true +[BreakEscape] Lockpick found in inventory: true +[BreakEscape] Lockpick validation result: true +[BreakEscape] validate_unlock returning: true + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +---------------------------------------------------------------------- +BreakEscape::GameTest: test_key_takes_precedence_over_lockpick_attempt +---------------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.601139"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.601099"], ["updated_at", "2025-11-24 11:19:17.601099"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] validate_unlock: type=door, id=office1, attempt=, method=key +[BreakEscape] Room data: locked=true, lockType=key, requires=office1_key +[BreakEscape] Room is LOCKED, method must be valid: key +[BreakEscape] Checking for key office1_key in inventory (2 items) +[BreakEscape] Inventory item: name=Office Key, key_id=office1_key, is_match=true +[BreakEscape] Key office1_key found in inventory: true +[BreakEscape] Key validation result: true +[BreakEscape] validate_unlock returning: true + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +------------------------------------------------------------------- +BreakEscape::GameTest: test_should_validate_unlock_with_correct_key +------------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.602347"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.602315"], ["updated_at", "2025-11-24 11:19:17.602315"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] validate_unlock: type=door, id=office1, attempt=, method=key +[BreakEscape] Room data: locked=true, lockType=key, requires=office1_key +[BreakEscape] Room is LOCKED, method must be valid: key +[BreakEscape] Checking for key office1_key in inventory (1 items) +[BreakEscape] Inventory item: name=Office Key, key_id=office1_key, is_match=true +[BreakEscape] Key office1_key found in inventory: true +[BreakEscape] Key validation result: true +[BreakEscape] validate_unlock returning: true + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +---------------------------------------------------------------------------------------- +BreakEscape::GameTest: test_has_lockpick_in_inventory_should_not_find_non-lockpick_items +---------------------------------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.603385"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.603354"], ["updated_at", "2025-11-24 11:19:17.603354"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] Checking for lockpick in inventory (1 items) +[BreakEscape] Inventory item: type=key, scenarioData.type=, is_lockpick=false +[BreakEscape] Lockpick found in inventory: false + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +--------------------------------------------------------------- +BreakEscape::GameTest: test_should_belong_to_player_and_mission +--------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.604390"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.604359"], ["updated_at", "2025-11-24 11:19:17.604359"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +--------------------------------------------------------------------- +BreakEscape::GameTest: test_should_reject_unlock_without_required_key +--------------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.605370"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.605338"], ["updated_at", "2025-11-24 11:19:17.605338"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] validate_unlock: type=door, id=office1, attempt=, method=key +[BreakEscape] Room data: locked=true, lockType=key, requires=office1_key +[BreakEscape] Room is LOCKED, method must be valid: key +[BreakEscape] Checking for key office1_key in inventory (1 items) +[BreakEscape] Inventory item: name=Wrong Key, key_id=wrong_key, is_match=false +[BreakEscape] Key office1_key found in inventory: false +[BreakEscape] Key validation result: false +[BreakEscape] validate_unlock returning: false + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +------------------------------------------------ +BreakEscape::GameTest: test_should_update_health +------------------------------------------------ + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.608786"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.608745"], ["updated_at", "2025-11-24 11:19:17.608745"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Update (0.1ms) UPDATE "break_escape_games" SET "player_state" = ?, "updated_at" = ? WHERE "break_escape_games"."id" = ? [["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":50}"], ["updated_at", "2025-11-24 11:19:17.609338"], ["id", 1]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +--------------------------------------------------------------------------- +BreakEscape::GameTest: test_has_lockpick_in_inventory_should_find_lockpicks +--------------------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.2ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.610587"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.610357"], ["updated_at", "2025-11-24 11:19:17.610357"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] Checking for lockpick in inventory (1 items) +[BreakEscape] Inventory item: type=lockpick, scenarioData.type=, is_lockpick=true +[BreakEscape] Lockpick found in inventory: true + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +---------------------------------------------------------------- +BreakEscape::GameTest: test_should_validate_unlock_with_lockpick +---------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.611717"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.611684"], ["updated_at", "2025-11-24 11:19:17.611684"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 +[BreakEscape] validate_unlock: type=door, id=office1, attempt=, method=lockpick +[BreakEscape] Room data: locked=true, lockType=key, requires=office1_key +[BreakEscape] Room is LOCKED, method must be valid: lockpick +[BreakEscape] Checking for lockpick in inventory (1 items) +[BreakEscape] Inventory item: type=lockpick, scenarioData.type=, is_lockpick=true +[BreakEscape] Lockpick found in inventory: true +[BreakEscape] Lockpick validation result: true +[BreakEscape] validate_unlock returning: true + TRANSACTION (0.2ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +----------------------------------------------------------------- +BreakEscape::GameTest: test_should_clamp_health_between_0_and_100 +----------------------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.612925"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.612893"], ["updated_at", "2025-11-24 11:19:17.612893"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Update (0.1ms) UPDATE "break_escape_games" SET "player_state" = ?, "updated_at" = ? WHERE "break_escape_games"."id" = ? [["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":0}"], ["updated_at", "2025-11-24 11:19:17.613474"], ["id", 1]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 + TRANSACTION (0.0ms) rollback transaction + TRANSACTION (0.0ms) begin transaction +-------------------------------------------------- +BreakEscape::GameTest: test_should_track_inventory +-------------------------------------------------- + BreakEscape::Mission Load (0.0ms) SELECT "break_escape_missions".* FROM "break_escape_missions" WHERE "break_escape_missions"."id" = ? LIMIT ? [["id", 418560898], ["LIMIT", 1]] + BreakEscape::DemoUser Load (0.0ms) SELECT "break_escape_demo_users".* FROM "break_escape_demo_users" WHERE "break_escape_demo_users"."id" = ? LIMIT ? [["id", 149617800], ["LIMIT", 1]] + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Create (0.1ms) INSERT INTO "break_escape_games" ("player_type", "player_id", "mission_id", "scenario_data", "player_state", "status", "started_at", "completed_at", "score", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["player_type", "BreakEscape::DemoUser"], ["player_id", 149617800], ["mission_id", 418560898], ["scenario_data", "{\"startRoom\":\"reception\",\"rooms\":{}}"], ["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["status", "in_progress"], ["started_at", "2025-11-24 11:19:17.614478"], ["completed_at", nil], ["score", 0], ["created_at", "2025-11-24 11:19:17.614427"], ["updated_at", "2025-11-24 11:19:17.614427"]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 + TRANSACTION (0.0ms) SAVEPOINT active_record_1 + BreakEscape::Game Update (0.1ms) UPDATE "break_escape_games" SET "player_state" = ?, "updated_at" = ? WHERE "break_escape_games"."id" = ? [["player_state", "{\"currentRoom\":\"reception\",\"unlockedRooms\":[\"reception\"],\"unlockedObjects\":[],\"inventory\":[{\"type\":\"key\",\"name\":\"Test Key\"}],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}"], ["updated_at", "2025-11-24 11:19:17.614926"], ["id", 1]] + TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1 + TRANSACTION (0.0ms) rollback transaction diff --git a/test/dummy/storage/test.sqlite3 b/test/dummy/storage/test.sqlite3 index bcdfde3..4b0c3e6 100644 Binary files a/test/dummy/storage/test.sqlite3 and b/test/dummy/storage/test.sqlite3 differ diff --git a/test/models/break_escape/game_test.rb b/test/models/break_escape/game_test.rb index e2eedda..9aa6204 100644 --- a/test/models/break_escape/game_test.rb +++ b/test/models/break_escape/game_test.rb @@ -53,5 +53,174 @@ module BreakEscape @game.update_health!(-10) assert_equal 0, @game.player_state['health'] end + + # Tests for key-based door unlock + test "should validate unlock with correct key" do + @game.scenario_data = { + "rooms" => { + "office1" => { + "locked" => true, + "lockType" => "key", + "requires" => "office1_key" + } + } + } + @game.player_state['inventory'] = [ + { 'type' => 'key', 'key_id' => 'office1_key', 'name' => 'Office Key' } + ] + + result = @game.validate_unlock('door', 'office1', '', 'key') + assert result, "Should unlock door with correct key in inventory" + end + + test "should reject unlock without required key" do + @game.scenario_data = { + "rooms" => { + "office1" => { + "locked" => true, + "lockType" => "key", + "requires" => "office1_key" + } + } + } + @game.player_state['inventory'] = [ + { 'type' => 'key', 'key_id' => 'wrong_key', 'name' => 'Wrong Key' } + ] + + result = @game.validate_unlock('door', 'office1', '', 'key') + assert_not result, "Should reject unlock without required key" + end + + test "should reject locked door without any unlock method" do + @game.scenario_data = { + "rooms" => { + "office1" => { + "locked" => true, + "lockType" => "key", + "requires" => "office1_key" + } + } + } + @game.player_state['inventory'] = [] + + result = @game.validate_unlock('door', 'office1', '', nil) + assert_not result, "Should reject locked door without unlock method" + end + + # Tests for lockpick-based door unlock + test "should validate unlock with lockpick" do + @game.scenario_data = { + "rooms" => { + "office1" => { + "locked" => true, + "lockType" => "key", + "requires" => "office1_key" + } + } + } + @game.player_state['inventory'] = [ + { 'type' => 'lockpick', 'name' => 'Lock Pick Kit' } + ] + + result = @game.validate_unlock('door', 'office1', '', 'lockpick') + assert result, "Should unlock door with lockpick" + end + + test "should reject lockpick unlock without lockpick in inventory" do + @game.scenario_data = { + "rooms" => { + "office1" => { + "locked" => true, + "lockType" => "key", + "requires" => "office1_key" + } + } + } + @game.player_state['inventory'] = [ + { 'type' => 'key', 'key_id' => 'office1_key', 'name' => 'Office Key' } + ] + + result = @game.validate_unlock('door', 'office1', '', 'lockpick') + assert_not result, "Should reject lockpick unlock without lockpick in inventory" + end + + # Tests for combined scenarios + test "lockpick should bypass key requirement" do + @game.scenario_data = { + "rooms" => { + "secure_vault" => { + "locked" => true, + "lockType" => "key", + "requires" => "vault_master_key" + } + } + } + @game.player_state['inventory'] = [ + { 'type' => 'lockpick', 'name' => 'Lock Pick Kit' } + ] + + # Should succeed with lockpick even without the master key + result = @game.validate_unlock('door', 'secure_vault', '', 'lockpick') + assert result, "Lockpick should bypass specific key requirement" + end + + test "key takes precedence over lockpick attempt" do + @game.scenario_data = { + "rooms" => { + "office1" => { + "locked" => true, + "lockType" => "key", + "requires" => "office1_key" + } + } + } + @game.player_state['inventory'] = [ + { 'type' => 'key', 'key_id' => 'office1_key', 'name' => 'Office Key' }, + { 'type' => 'lockpick', 'name' => 'Lock Pick Kit' } + ] + + # Key unlock should succeed + result = @game.validate_unlock('door', 'office1', '', 'key') + assert result, "Key unlock should succeed" + end + + test "should allow access to unlocked doors regardless of method" do + @game.scenario_data = { + "rooms" => { + "reception" => { + "locked" => false + } + } + } + @game.player_state['inventory'] = [] + + result = @game.validate_unlock('door', 'reception', '', 'unlocked') + assert result, "Should allow access to unlocked doors" + end + + test "has_key_in_inventory should find keys by key_id" do + @game.player_state['inventory'] = [ + { 'type' => 'key', 'key_id' => 'office1_key', 'name' => 'Office Key' } + ] + + assert @game.has_key_in_inventory?('office1_key'), "Should find key by key_id" + assert_not @game.has_key_in_inventory?('wrong_key'), "Should not find missing key" + end + + test "has_lockpick_in_inventory should find lockpicks" do + @game.player_state['inventory'] = [ + { 'type' => 'lockpick', 'name' => 'Lock Pick Kit' } + ] + + assert @game.has_lockpick_in_inventory?, "Should find lockpick in inventory" + end + + test "has_lockpick_in_inventory should not find non-lockpick items" do + @game.player_state['inventory'] = [ + { 'type' => 'key', 'key_id' => 'office1_key', 'name' => 'Office Key' } + ] + + assert_not @game.has_lockpick_in_inventory?, "Should not find non-lockpick items as lockpick" + end end end