Files
Ymir/core/tests/world/TestJsonSmoke.cpp
vinihcrosaandClaude Sonnet 4.6 53ce4a91f6 feat: environmental conditions, vessel instanceId, panel stability, regression tests
Environmental Conditions feature:
- C++ EnvironmentTimeline: time-series current/wind data, JSON serialization
- WASM bindings: loadEnvironment(), World integration
- TypeScript types: CurrentSeries, WindSeries, EnvironmentPayload
- Zustand environmentStore with React panel (EnvironmentConditionPanel)
- Mock WASM current drift physics: nautical→body-frame velocity applied in step()

Bug fixes:
- Vessel instanceId: unique auto-increment ID per scenario instance prevents duplicate
  vesselId crash when adding two vessels of same type
- vesselPanelStore: separate vesselTypeId field so config fetch uses correct type ID
  (not instanceId) after the instanceId/vesselId split
- VesselMarker stable eventHandlers: useMemo + useRef pattern prevents react-leaflet
  from re-registering Leaflet listeners every 50ms tick, fixing panel clicks during
  active simulation

Tests:
- Playwright regression suite (e2e/regression.spec.ts): 8 tests covering panel open
  during simulation, multi-click consistency, two VLCC no error, dual marker render,
  individual panel open, remove-one behavior, current drift, no-drift baseline

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 11:29:16 -03:00

31 lines
1.0 KiB
C++

#include <catch2/catch_test_macros.hpp>
#include <nlohmann/json.hpp>
#include <stdexcept>
TEST_CASE("nlohmann/json smoke — parse valid JSON", "[world][json]") {
auto j = nlohmann::json::parse(R"({"ok": true})");
REQUIRE(j.at("ok").get<bool>() == true);
}
TEST_CASE("nlohmann/json smoke — parse integer field", "[world][json]") {
auto j = nlohmann::json::parse(R"({"value": 42})");
REQUIRE(j.at("value").get<int>() == 42);
}
TEST_CASE("nlohmann/json smoke — parse string field", "[world][json]") {
auto j = nlohmann::json::parse(R"({"name": "ymir"})");
REQUIRE(j.at("name").get<std::string>() == "ymir");
}
TEST_CASE("nlohmann/json smoke — malformed JSON throws", "[world][json]") {
REQUIRE_THROWS_AS(
nlohmann::json::parse("{broken"),
nlohmann::json::parse_error
);
}
TEST_CASE("nlohmann/json smoke — missing key throws", "[world][json]") {
auto j = nlohmann::json::parse(R"({"ok": true})");
REQUIRE_THROWS_AS(j.at("missing"), nlohmann::json::out_of_range);
}