GHERKIN TEST CASES

# =====================================================================
# Feature: CPDS with VSS Signal Hooks
#
# Custom VSS signals (placeholders for step bindings):
# - Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified (Bool)
# - Vehicle.Cabin.Infotainment.CarerNotification.IsCarerNotified (Bool)
# - Vehicle.Cabin.Infotainment.HVAC.AutoOverrideActive (Bool)
# - Vehicle.Cabin.Infotainment.EmergencyCall.IsEmergencyCallActive (Bool)
# - Vehicle.Cabin.ChildPresenceDetection.IsChildDetected (Bool)
# - Vehicle.Cabin.Security.AllowsEmergencyEntry (Bool)
# - Vehicle.Cabin.Infotainment.EmergencyCall.IsAcknowledged (Bool)
# - Vehicle.Cabin.Infotainment.DriverAppNotification.IsAcknowledged (Bool)
# - Vehicle.Cabin.Infotainment.CarerNotification.IsAcknowledged (Bool)
# - Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeRequested (Bool)
# - Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeActive (Bool)
# - Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeDenied (Bool)
#
# States: S0, S1, S2, S3, S4, S5, S6, S7, S8, S9, S_Fault
# Timers: T_DETECT=10s, T_ACK_1=5m, T_ACK_2=5m, T_ACK_3=5m, T_ACK_4=10m, SOC_CRIT=15%
# =====================================================================

Feature: Arm and finalize the CPDS cycle with signal visibility

  Background:
    Given the vehicle ignition is switched off
    And all doors are closed
    And the key is out of proximity range
    And all CPDS sensors are functional and calibrated
    And CPDS state is "S0 Off"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false
    And Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified is false
    And Vehicle.Cabin.Infotainment.CarerNotification.IsCarerNotified is false
    And Vehicle.Cabin.Infotainment.HVAC.AutoOverrideActive is false
    And Vehicle.Cabin.Infotainment.EmergencyCall.IsEmergencyCallActive is false
    And Vehicle.Cabin.Security.AllowsEmergencyEntry is false

  @Req_CPDS_00_1
  Scenario: CPDS arms after ignition off
    When 5 seconds elapse after ignition-off
    Then CPDS state is "S1 Armed/Scanning"

  @Req_CPDS_00_2
  Scenario: Return to Standby after verified child absence
    Given CPDS state is "S4 Exterior Alert"
    And no child is detected for 30 seconds continuously
    When 5 seconds elapse
    Then all alerts are inactive
    And CPDS state is "S9 Standby"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false
    And Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified is false
    And Vehicle.Cabin.Infotainment.HVAC.AutoOverrideActive is false

  @Req_CPDS_00_3
  Scenario: Adult intervention pauses escalation and re-verifies
    Given CPDS state is "S4 Exterior Alert"
    When any door is opened or the ignition turns on
    Then escalation is paused
    And CPDS performs unattended-child re-verification
    And CPDS remains out of "S4 Exterior Alert" until detection finishes


# =====================================================================
# Detection and Fusion with signals
# =====================================================================

Feature: Confirm unattended child using sensor fusion and set IsChildDetected

  Background:
    Given CPDS state is "S1 Armed/Scanning"

  @Req_CPDS_01_1
  Scenario: Sensors activate on S1 entry
    When CPDS enters "S1 Armed/Scanning"
    Then direct and indirect sensors are active within 5 seconds

  @Req_CPDS_01_2
  Scenario Outline: Fusion confirms child and sets IsChildDetected = true
    Given the following direct sensors are positive: <direct_positive_list>
    And the following indirect indicators are positive: <indirect_positive_list>
    And there is no adult-presence contradiction
    When T_DETECT elapses
    Then CPDS state is "S2 Child Confirmed"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is true

    Examples:
      | direct_positive_list     | indirect_positive_list                     |
      | camera, radar            | seat_pressure, rear_belt_latched, windows  |
      | microphone               | seat_pressure, rear_belt_latched, windows, doors_closed |

  @Req_CPDS_01_2 @Edge
  Scenario: Threshold not met keeps IsChildDetected = false
    Given the following direct sensors are positive: camera
    And the following indirect indicators are positive: rear_belt_latched, windows
    And there is no adult-presence contradiction
    When T_DETECT elapses
    Then CPDS remains in "S1 Armed/Scanning"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false

  @Req_CPDS_01_3
  Scenario: Adult presence blocks confirmation and signals remain false
    Given front-seat adult presence is detected
    When T_DETECT elapses
    Then CPDS remains in "S1 Armed/Scanning"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false


# =====================================================================
# Initial driver notification with signal hooks
# =====================================================================

Feature: Notify driver and validate acknowledgment proximity

  Background:
    Given CPDS state is "S2 Child Confirmed"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is true

  @Req_CPDS_02_1
  Scenario: Notify driver on S2 entry sets IsDriverNotified = true
    When CPDS enters "S2 Child Confirmed"
    Then CPDS enters "S3 Notify Driver" within 10 seconds
    And a mobile push is sent with a countdown for T_ACK_1
    And Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified is true

  @Req_CPDS_02_2
  Scenario: Remote dismiss rejected without proximity or door open
    Given CPDS state is "S3 Notify Driver"
    And the driver device is not within 20 meters
    And no door is opened
    When the driver taps "Acknowledge" in the app
    Then the acknowledgment is rejected
    And Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified is true

@Req_CPDS_02_3
Scenario: Valid driver acknowledgment resolves and resets signals
  Given CPDS state is "S3 Notify Driver"
  And the driver device is within 20 meters
  And a door is opened
  And child absence is verified for 30 seconds
  When Vehicle.Cabin.Infotainment.DriverAppNotification.IsAcknowledged becomes true less than 5 minutes after driver notification activation
  Then CPDS state is "S9 Standby"
  And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false
  And Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified is false
  And Vehicle.Cabin.Infotainment.DriverAppNotification.IsAcknowledged is false

@Req_CPDS_02_4
Scenario: Driver can snooze once for 10 minutes when nearby
  Given CPDS state is "S3 Notify Driver"
  And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is true
  And the driver device is within 20 meters
  And no door is opened
  # request snooze within the original T_ACK_1 window (5 minutes)
  When Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeRequested becomes true less than 5 minutes after driver notification activation
  Then Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeActive is true
  # after the 10-minute snooze, system resumes the timeline
  When 10 minutes elapse
  Then Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeActive is false
  # total: T_ACK_1 (5m) + T_SNOOZE (10m) with no acknowledgment -> escalate
  When 5 minutes elapse
  Then CPDS state is "S4 Exterior Alert"

@Req_CPDS_02_4 @Edge
Scenario: Snooze is blocked when battery is critical
  Given CPDS state is "S3 Notify Driver"
  And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is true
  And the driver device is within 20 meters
  And battery SOC is below 15 percent
  When Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeRequested is set to true
  Then Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeActive is false
  And Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeDenied is true
  And Vehicle.Cabin.Infotainment.EmergencyCall.IsEmergencyCallActive is true
  And Vehicle.Cabin.Security.AllowsEmergencyEntry is true

@Req_CPDS_02_4 @Edge
Scenario: Snooze can be requested only once per incident
  Given CPDS state is "S3 Notify Driver"
  And the driver device is within 20 meters
  When Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeRequested is set to true
  Then Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeActive is true
  # second request during same incident should be denied
  When Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeRequested is set to true
  Then Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeDenied is true
  And Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeActive is true

@Req_CPDS_02_4
Scenario: Valid driver acknowledgment during snooze resolves to Standby
  Given CPDS state is "S3 Notify Driver"
  And the driver device is within 20 meters
  When Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeRequested is set to true
  Then Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeActive is true
  # driver returns during snooze and acknowledges
  And a door is opened
  And child absence is verified for 30 seconds
  When Vehicle.Cabin.Infotainment.DriverAppNotification.IsAcknowledged becomes true less than 10 minutes after driver notification activation
  Then CPDS state is "S9 Standby"
  And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false
  And Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeActive is false
  And Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified is false
  And Vehicle.Cabin.Infotainment.DriverAppNotification.IsAcknowledged is false

@Req_CPDS_02_2 @Req_CPDS_02_4
Scenario: Remote ack is still rejected; snooze does not override proximity guard
  Given CPDS state is "S3 Notify Driver"
  And the driver device is not within 20 meters
  And no door is opened
  When Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeRequested is set to true
  Then Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeActive is false
  And Vehicle.Cabin.Infotainment.DriverAppNotification.IsSnoozeDenied is true
  # and remote ack is still rejected
  When Vehicle.Cabin.Infotainment.DriverAppNotification.IsAcknowledged is set to true
  Then the acknowledgment is rejected
  And Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified is true


# =====================================================================
# Exterior alert and HVAC intervention with signals
# =====================================================================

Feature: Escalation after exterior alert

  Background:
    Given CPDS state is "S3 Notify Driver"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is true

  @Req_CPDS_03_1
  Scenario: No valid acknowledgment by T_ACK_1 starts exterior alert
    When T_ACK_1 elapses without a valid acknowledgment
    Then CPDS state is "S4 Exterior Alert"

  @Req_CPDS_03_2
  Scenario: Valid acknowledgment during exterior alert returns to Standby
    Given CPDS state is "S4 Exterior Alert"
    And the driver device is within 20 meters or a door opens
    And child absence is verified for 30 seconds
    When an acknowledgment is received within T_ACK_2
    Then CPDS state is "S9 Standby"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false

  @Req_CPDS_04_1
  Scenario: No valid acknowledgment by T_ACK_2 starts HVAC intervention
    Given CPDS state is "S4 Exterior Alert"
    When T_ACK_2 elapses without a valid acknowledgment
    Then CPDS state is "S5 HVAC Intervention"
    And Vehicle.Cabin.Infotainment.HVAC.AutoOverrideActive is true

  @Req_CPDS_04_2
  Scenario: Battery guard uses minimal-energy HVAC but keeps override active
    Given CPDS state is "S5 HVAC Intervention"
    And battery SOC is below the low-energy threshold but not critical
    When temperature is outside the safe range
    Then CPDS applies minimal-energy cooling or ventilation
    And Vehicle.Cabin.Infotainment.HVAC.AutoOverrideActive is true

  @Req_CPDS_04_3
  Scenario: Acknowledgment during HVAC returns to Standby and clears override
    Given CPDS state is "S5 HVAC Intervention"
    And child absence is verified for 30 seconds
    When an acknowledgment is received within T_ACK_3
    Then CPDS state is "S9 Standby"
    And Vehicle.Cabin.Infotainment.HVAC.AutoOverrideActive is false
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false


# =====================================================================
# Carers notification and emergency path with signals
# =====================================================================

Feature: Notify carers and, if needed, unlock and call emergency services

  Background:
    Given CPDS state is "S5 HVAC Intervention"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is true

  @Req_CPDS_05_1
  Scenario: No acknowledgment by T_ACK_3 notifies carers
    When T_ACK_3 elapses without a valid acknowledgment
    Then CPDS state is "S6 Notify Carers"
    And carers are notified by at least two channels within 60 seconds
    And Vehicle.Cabin.Infotainment.CarerNotification.IsCarerNotified is true

@Req_CPDS_05_2
Scenario: Carer acknowledgment resolves and resets signals
  Given CPDS state is "S6 Notify Carers"
  And a carer arrives within BLE range or opens a door
  And child absence is verified for 30 seconds
  When Vehicle.Cabin.Infotainment.CarerNotification.IsAcknowledged becomes true less than 10 minutes after carer notification activation
  Then CPDS state is "S9 Standby"
  And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false
  And Vehicle.Cabin.Infotainment.CarerNotification.IsCarerNotified is false
  And Vehicle.Cabin.Infotainment.CarerNotification.IsAcknowledged is false

@Req_CPDS_06_1 @Req_CPDS_06_2
Scenario: No response after carers leads to unlock and emergency call
  Given CPDS state is "S6 Notify Carers"
  When T_ACK_4 elapses without a valid acknowledgment
  Then CPDS state is "S7 Allow Access"
  And Vehicle.Cabin.Security.AllowsEmergencyEntry is true
  And CPDS state is "S8 Emergency Services"
  And Vehicle.Cabin.Infotainment.EmergencyCall.IsEmergencyCallActive is true
  And an emergency call is placed within 10 seconds including required payload

@Req_CPDS_06_3_1
Scenario: Post-event relock and Standby after emergency services acknowledgment
  Given CPDS state is "S7 Allow Access"
  And Vehicle.Cabin.Infotainment.EmergencyCall.IsEmergencyCallActive is true
  When Vehicle.Cabin.Infotainment.EmergencyCall.IsAcknowledged is set to true
  And 10 seconds elapse
  Then Vehicle.Cabin.Security.AllowsEmergencyEntry is false
  And Vehicle.Cabin.Infotainment.EmergencyCall.IsEmergencyCallActive is false
  And CPDS state is "S9 Standby"

@Req_CPDS_06_3_2
Scenario: Post-event relock and Standby after safe removal and door closure
  Given CPDS state is "S7 Allow Access"
  And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false
  When 10 seconds elapse
  Then Vehicle.Cabin.Security.AllowsEmergencyEntry is false
  And CPDS state is "S9 Standby"
  And Vehicle.Cabin.Infotainment.EmergencyCall.IsEmergencyCallActive is false


# =====================================================================
# No-child path and power saving with signals
# =====================================================================

Feature: Remain passive when no child is detected

  Background:
    Given CPDS state is "S1 Armed/Scanning"

  @Req_CPDS_07_1
  Scenario: No child within T_DETECT keeps system quiet
    When T_DETECT elapses without confirmation
    Then CPDS remains in "S1 Armed/Scanning"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false
    And Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified is false
    And Vehicle.Cabin.Infotainment.CarerNotification.IsCarerNotified is false

  @Req_CPDS_07_2
  Scenario: Idle timeout moves system to Standby
    Given 30 minutes elapse in "S1 Armed/Scanning" without positive indications
    When no door event occurs
    Then CPDS state is "S9 Standby"


# =====================================================================
# Overrides, connectivity, horn restriction, supervised stay, and critical SOC
# =====================================================================

Feature: Fallbacks and policy constraints with signal visibility

  @Req_CPDS_04_4
  Scenario: Immediate emergency call on critical battery
    Given CPDS state is "S3 Notify Driver"            # also valid for S2, S4, S5, S6
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is true
    And battery SOC is below 15 percent
    When SOC is reported
    Then CPDS enters "S8 Emergency Services" within 10 seconds
    And Vehicle.Cabin.Infotainment.EmergencyCall.IsEmergencyCallActive is true
    And CPDS enters "S7 Allow Access"
    And Vehicle.Cabin.Security.AllowsEmergencyEntry is true
    And Vehicle.Cabin.Infotainment.HVAC.AutoOverrideActive is true   # minimal ventilation

  @Req_CPDS_08_3
  Scenario: Connectivity loss triggers fallback and retries
    Given CPDS needs to send driver or carer notifications
    And mobile connectivity is unavailable
    When a notification attempt is made
    Then on-vehicle alerts and HVAC proceed
    And notification attempts are retried every 60 seconds
    And Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified is unchanged
    And Vehicle.Cabin.Infotainment.CarerNotification.IsCarerNotified is unchanged

  @Req_CPDS_08_4
  Scenario: Horn restriction substitutes with visual and HMI alerts
    Given regional settings disable horn use
    And CPDS state is "S4 Exterior Alert"
    When CPDS would activate horn
    Then CPDS uses repeated hazard light patterns and HMI messages
    And no VSS emergency-call or unlock signals are set

  @Req_CPDS_08_1
  Scenario: Supervised Stay keeps signals quiet unless distress cues
    Given the driver sets "Supervised Stay" at ignition-off
    And CPDS would normally enter "S1 Armed/Scanning"
    When distress cues are not detected for 30 minutes
    Then CPDS remains in "S9 Standby"
    And Vehicle.Cabin.ChildPresenceDetection.IsChildDetected is false
    And Vehicle.Cabin.Infotainment.DriverAppNotification.IsDriverNotified is false
