Сценарии E2E#

Scenario M-001: machine + drip + rain => field water balance#

Цель: проверить, что события полива машиной, капельным контуром и осадки собираются в корректный агрегат field_water_balance.

Шаги:

  1. Установить модули melioration-irrigation-machine, melioration-irrigation-drip, melioration-weather, melioration-field.

  2. Отправить ingest:

    • POST /api/v1/melioration-irrigation-machine/commands/ingest;

    • POST /api/v1/melioration-irrigation-drip/commands/ingest;

    • POST /api/v1/melioration-weather/commands/ingest.

  3. Открыть карточку Field Water Balance.

  4. Проверить в строке поля:

    • заполнены machine_mm, drip_mm, rain_mm;

    • volume_mm = machine_mm + drip_mm + rain_mm.

Покрытие:

  • frontend e2e: frontend-vue/src/modules/melioration-field/e2e/water-balance.spec.js.

  • backend integration: backend-go/internal/api/plugins/melioration/plugin_test.go (агрегация и reconciliation).

Scenario M-002: station gap => service fallback (D-008)#

Цель: проверить, что при telemetry healthy=false модуль weather использует внешний сервис как primary для расчета осадков.

Шаги:

  1. Установить модуль melioration-weather.

  2. Отправить POST /api/v1/melioration-weather/commands/telemetry с healthy=false.

  3. Отправить POST /api/v1/melioration-weather/commands/ingest со значениями station_precip_mm и service_precip_mm.

  4. Открыть карточку Weather.

  5. Проверить:

    • source_mode=service_fallback;

    • used_precip_mm == service_precip_mm.

Покрытие:

  • frontend e2e: frontend-vue/src/modules/melioration-weather/e2e/weather-fallback.spec.js.

  • backend integration: backend-go/internal/api/plugins/melioration/plugin_test.go (TestWeatherTelemetryFallback).

Scenario M-003: A/B/C switch + auto-degrade from C#

Цель: проверить, что при потере критичной телеметрии режим C автоматически деградирует в B (или заданный fallback), и повторный переход в C блокируется до восстановления телеметрии.

Шаги:

  1. Последовательно установить режимы A, B, C для scope_type=field, scope_id=field-001 через:

    • POST /api/v1/melioration-control-mode/commands/set.

  2. Отправить событие потери телеметрии:

    • POST /api/v1/melioration-weather/commands/telemetry

    • тело: { "healthy": false, "fallback_mode": "B" }.

  3. Проверить ответ telemetry:

    • auto_degraded=true;

    • mode.mode="B";

    • присутствует audit событие telemetry_unhealthy_auto_degrade.

  4. Повторно попытаться включить C при healthy=false:

    • POST /api/v1/melioration-control-mode/commands/set с mode=C.

  5. Проверить отказ:

    • 409 policy_violation с причиной telemetry_unhealthy.

Покрытие:

  • backend e2e/integration: backend-go/internal/api/plugins/melioration/plugin_test.go (TestControlModeE2ESwitchAndAutoDegradeOnTelemetryFailure).