# Regression tests for bug #2943: agents project show must display resource
# names instead of raw ULIDs for linked resources.
Feature: Project show displays resource names for linked resources
  As a developer using the agents CLI
  I want "agents project show" to display human-readable resource names
  So that I can identify linked resources without looking up ULIDs manually

  Background:
    Given a fresh project-show-resource-name database is initialised

  @tdd_issue @tdd_issue_2943
  Scenario: Show displays resource name instead of ULID for a named resource
    Given a project "local/my-app" exists in the resource-name DB
    And a named resource "local/my-git-repo" is linked to project "local/my-app" in the resource-name DB
    When I show project "local/my-app" via the resource-name CLI
    Then the resource-name show output should contain "local/my-git-repo"
    And the resource-name show exit code should be 0

  @tdd_issue @tdd_issue_2943
  Scenario: Show falls back to ULID when resource has no name
    Given a project "local/unnamed-res-proj" exists in the resource-name DB
    And an unnamed resource is linked to project "local/unnamed-res-proj" in the resource-name DB
    When I show project "local/unnamed-res-proj" via the resource-name CLI
    Then the resource-name show output should contain the resource ULID
    And the resource-name show exit code should be 0

  @tdd_issue @tdd_issue_2943
  Scenario: Show displays resource name with read-only marker
    Given a project "local/ro-proj" exists in the resource-name DB
    And a named read-only resource "local/ro-resource" is linked to project "local/ro-proj" in the resource-name DB
    When I show project "local/ro-proj" via the resource-name CLI
    Then the resource-name show output should contain "local/ro-resource"
    And the resource-name show output should contain "read-only"
    And the resource-name show exit code should be 0

  @tdd_issue @tdd_issue_2943
  Scenario: Show displays resource name with alias when set
    Given a project "local/alias-proj" exists in the resource-name DB
    And resource "local/aliased-resource" with alias "my-alias" is linked to project "local/alias-proj" in the resource-name DB
    When I show project "local/alias-proj" via the resource-name CLI
    Then the resource-name show output should contain "local/aliased-resource"
    And the resource-name show output should contain "my-alias"
    And the resource-name show exit code should be 0

  @tdd_issue @tdd_issue_2943
  Scenario: JSON output includes both resource_id and resource_name
    Given a project "local/json-proj" exists in the resource-name DB
    And a named resource "local/json-resource" is linked to project "local/json-proj" in the resource-name DB
    When I show project "local/json-proj" as JSON via the resource-name CLI
    Then the resource-name show output should contain "resource_id"
    And the resource-name show output should contain "resource_name"
    And the resource-name show output should contain "local/json-resource"
    And the resource-name show exit code should be 0

  @tdd_issue @tdd_issue_2943
  Scenario: YAML output includes both resource_id and resource_name
    Given a project "local/yaml-proj" exists in the resource-name DB
    And a named resource "local/yaml-resource" is linked to project "local/yaml-proj" in the resource-name DB
    When I show project "local/yaml-proj" as YAML via the resource-name CLI
    Then the resource-name show output should contain "resource_id"
    And the resource-name show output should contain "resource_name"
    And the resource-name show output should contain "local/yaml-resource"
    And the resource-name show exit code should be 0

  @tdd_issue @tdd_issue_2943
  Scenario: Show gracefully handles registry unavailable by falling back to ULID
    Given a project "local/fallback-proj" exists in the resource-name DB
    And a resource is linked to project "local/fallback-proj" in the resource-name DB
    When I show project "local/fallback-proj" with registry unavailable via the resource-name CLI
    Then the resource-name show output should contain the resource ULID
    And the resource-name show exit code should be 0
