2021-06-08 01:23:25 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'nuget package details', feature_category: :package_registry do
|
2021-06-08 01:23:25 +05:30
|
|
|
include GraphqlHelpers
|
2021-09-04 01:27:46 +05:30
|
|
|
include_context 'package details setup'
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
let_it_be(:package) { create(:nuget_package, :last_downloaded_at, :with_metadatum, project: project) }
|
2021-10-27 15:23:28 +05:30
|
|
|
let_it_be(:dependency_link) { create(:packages_dependency_link, :with_nuget_metadatum, package: package) }
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
let(:metadata) { query_graphql_fragment('NugetMetadata') }
|
2021-10-27 15:23:28 +05:30
|
|
|
let(:dependency_link_response) { graphql_data_at(:package, :dependency_links, :nodes, 0) }
|
|
|
|
let(:dependency_response) { graphql_data_at(:package, :dependency_links, :nodes, 0, :dependency) }
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
subject { post_graphql(query, current_user: user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it_behaves_like 'a package detail'
|
|
|
|
it_behaves_like 'a package with files'
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
it 'has the correct metadata' do
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(metadata_response).to match a_graphql_entity_for(
|
|
|
|
package.nuget_metadatum, :license_url, :project_url, :icon_url
|
2021-06-08 01:23:25 +05:30
|
|
|
)
|
|
|
|
end
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
it 'has dependency links' do
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(dependency_link_response).to match a_graphql_entity_for(
|
|
|
|
dependency_link,
|
2021-10-27 15:23:28 +05:30
|
|
|
'dependencyType' => dependency_link.dependency_type.upcase
|
|
|
|
)
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(dependency_response).to match a_graphql_entity_for(
|
|
|
|
dependency_link.dependency, :name, :version_pattern
|
2021-10-27 15:23:28 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'avoids N+1 queries' do
|
|
|
|
first_user = create(:user)
|
|
|
|
second_user = create(:user)
|
|
|
|
|
|
|
|
control_count = ActiveRecord::QueryRecorder.new do
|
|
|
|
post_graphql(query, current_user: first_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
create_list(:packages_dependency_link, 10, :with_nuget_metadatum, package: package)
|
|
|
|
|
|
|
|
expect do
|
|
|
|
post_graphql(query, current_user: second_user)
|
|
|
|
end.not_to exceed_query_limit(control_count)
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|