diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/graphql/types/project_type_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/graphql/types/project_type_spec.rb')
-rw-r--r-- | spec/graphql/types/project_type_spec.rb | 127 |
1 files changed, 122 insertions, 5 deletions
diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index b435f3ed5ff..30fabb8e9e2 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -36,7 +36,8 @@ RSpec.describe GitlabSchema.types['Project'] do cluster_agent cluster_agents agent_configurations ci_template timelogs merge_commit_template squash_commit_template work_item_types recent_issue_boards ci_config_path_or_default packages_cleanup_policy ci_variables - timelog_categories fork_targets branch_rules ci_config_variables pipeline_schedules + timelog_categories fork_targets branch_rules ci_config_variables pipeline_schedules languages + incident_management_timeline_event_tags ] expect(described_class).to include_graphql_fields(*expected_fields) @@ -212,8 +213,8 @@ RSpec.describe GitlabSchema.types['Project'] do it "returns the project's sast configuration for analyzer variables" do analyzer = subject.dig('data', 'project', 'sastCiConfiguration', 'analyzers', 'nodes').first - expect(analyzer['name']).to eq('bandit') - expect(analyzer['label']).to eq('Bandit') + expect(analyzer['name']).to eq('brakeman') + expect(analyzer['label']).to eq('Brakeman') expect(analyzer['enabled']).to eq(true) end @@ -290,14 +291,14 @@ RSpec.describe GitlabSchema.types['Project'] do subject { described_class.fields['issue'] } it { is_expected.to have_graphql_type(Types::IssueType) } - it { is_expected.to have_graphql_resolver(Resolvers::IssuesResolver.single) } + it { is_expected.to have_graphql_resolver(Resolvers::ProjectIssuesResolver.single) } end describe 'issues field' do subject { described_class.fields['issues'] } it { is_expected.to have_graphql_type(Types::IssueType.connection_type) } - it { is_expected.to have_graphql_resolver(Resolvers::IssuesResolver) } + it { is_expected.to have_graphql_resolver(Resolvers::ProjectIssuesResolver) } end describe 'merge_request field' do @@ -508,6 +509,12 @@ RSpec.describe GitlabSchema.types['Project'] do it { is_expected.to have_graphql_resolver(Resolvers::Ci::JobTokenScopeResolver) } end + describe 'incident_management_timeline_event_tags field' do + subject { described_class.fields['incidentManagementTimelineEventTags'] } + + it { is_expected.to have_graphql_type(Types::IncidentManagement::TimelineEventTagType) } + end + describe 'agent_configurations' do let_it_be(:project) { create(:project) } let_it_be(:user) { create(:user) } @@ -731,4 +738,114 @@ RSpec.describe GitlabSchema.types['Project'] do end end end + + describe 'timeline_event_tags' do + let_it_be(:user) { create(:user) } + let_it_be(:project) do + create(:project, + :private, + :repository, + creator_id: user.id, + namespace: user.namespace) + end + + let_it_be(:tag1) do + create(:incident_management_timeline_event_tag, + project: project, + name: 'Tag 1') + end + + let_it_be(:tag2) do + create(:incident_management_timeline_event_tag, + project: project, + name: 'Tag 2') + end + + let(:query) do + %( + query { + project(fullPath: "#{project.full_path}") { + incidentManagementTimelineEventTags { + name + id + } + } + } + ) + end + + let(:tags) do + subject.dig('data', 'project', 'incidentManagementTimelineEventTags') + end + + subject { GitlabSchema.execute(query, context: { current_user: user }).as_json } + + context 'when user has permissions to read project' do + before do + project.add_developer(user) + end + + it 'contains timeline event tags' do + expect(tags.count).to eq(2) + expect(tags.first['name']).to eq(tag1.name) + expect(tags.last['name']).to eq(tag2.name) + end + end + end + + describe 'languages' do + let_it_be(:user) { create(:user) } + let_it_be(:project) do + create(:project, + :private, + :repository, + creator_id: user.id, + namespace: user.namespace) + end + + let(:query) do + %( + query { + project(fullPath: "#{project.full_path}") { + languages { + name + share + color + } + } + } + ) + end + + let(:mock_languages) { [] } + + before do + allow_next_instance_of(::Projects::RepositoryLanguagesService) do |service| + allow(service).to receive(:execute).and_return(mock_languages) + end + end + + subject { GitlabSchema.execute(query, context: { current_user: user }).as_json } + + let(:languages) { subject.dig('data', 'project', 'languages') } + + context "when the languages haven't been detected yet" do + it 'returns an empty array' do + expect(languages).to eq([]) + end + end + + context 'when the languages were detected before' do + let(:mock_languages) do + [{ share: 66.69, name: "Ruby", color: "#701516" }, + { share: 22.98, name: "JavaScript", color: "#f1e05a" }, + { share: 7.91, name: "HTML", color: "#e34c26" }, + { share: 2.42, name: "CoffeeScript", color: "#244776" }] + end + + it 'returns the repository languages' do + expect(languages).to eq(mock_languages.map(&:stringify_keys)) + end + end + end end |