Feature: Project context set --execution-env-priority flag (Bug #1079)
  As a developer
  I want to set execution environment priority when using project context set
  So that I can control project-level execution environment precedence per spec §Execution Environment Routing

  # Bug #1079 is now fixed: the --execution-env-priority flag is implemented.
  # These tests serve as regression tests.

  Background:
    Given a bug 1079 in-memory database is initialized
    And a project "local/bug1079-app" exists for bug 1079

  @tdd_issue @tdd_issue_1079 @tdd_issue_4178
  Scenario: Bug #1079 - project context set accepts --execution-env-priority override
    When I run bug 1079 context set on "local/bug1079-app" with execution_environment "host" and execution_env_priority "override"
    Then the bug 1079 command should succeed
    And the stored bug 1079 execution_env_priority should be "override"

  @tdd_issue @tdd_issue_1079 @tdd_issue_4178
  Scenario: Bug #1079 - project context set accepts --execution-env-priority fallback
    When I run bug 1079 context set on "local/bug1079-app" with execution_environment "host" and execution_env_priority "fallback"
    Then the bug 1079 command should succeed
    And the stored bug 1079 execution_env_priority should be "fallback"

  @tdd_issue @tdd_issue_1079 @tdd_issue_4178
  Scenario: Bug #1079 - project context set rejects --execution-env-priority without --execution-environment
    When I run bug 1079 context set on "local/bug1079-app" with execution_env_priority "override" but no execution_environment
    Then the bug 1079 command should fail
    And the bug 1079 output should contain "--execution-env-priority requires --execution-environment"

  @tdd_issue @tdd_issue_1079 @tdd_issue_4178
  Scenario: Bug #1079 - project context set defaults execution-env-priority to fallback when not specified
    When I run bug 1079 context set on "local/bug1079-app" with execution_environment "host" but no execution_env_priority
    Then the bug 1079 command should succeed
    And the stored bug 1079 execution_env_priority should be "fallback"

  @tdd_issue @tdd_issue_1079 @tdd_issue_4178
  Scenario: Bug #1079 - project context set rejects invalid --execution-env-priority value
    When I run bug 1079 context set on "local/bug1079-app" with execution_environment "host" and execution_env_priority "invalid-value"
    Then the bug 1079 command should fail
    And the bug 1079 output should contain "Invalid execution env priority"
  @tdd_issue @tdd_issue_1079 @tdd_expected_fail @tdd_issue_4178
  Scenario: Bug #1079 - project context show reflects persisted execution-env-priority
    When I run bug 1079 context set on "local/bug1079-app" with execution_environment "host" and execution_env_priority "override"
    Then the bug 1079 command should succeed
    When I run bug 1079 context show on "local/bug1079-app" with format "json"
    Then the bug 1079 command should succeed
    And the bug 1079 json output should include "execution_env_priority" as "override"
