# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Query.project(fullPath).vulnerabilitySeveritiesCount' do
  let_it_be(:project) { create(:project) }
  let_it_be(:user) { create(:user) }
  let_it_be(:vulnerability) { create(:vulnerability, :high, project: project) }

  let_it_be(:query) do
    %(
      query {
        project(fullPath: "#{project.full_path}") {
          vulnerabilitySeveritiesCount {
            high
          }
        }
      }
    )
  end

  before do
    stub_licensed_features(security_dashboard: true)

    project.add_developer(user)
  end

  subject { GitlabSchema.execute(query, context: { current_user: user }).as_json }

  it "returns counts for each severity of the project's detected or confirmed vulnerabilities" do
    high_count = subject.dig('data', 'project', 'vulnerabilitySeveritiesCount', 'high')

    expect(high_count).to eq(1)
  end
end
