diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-03 06:08:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-03 06:08:30 +0300 |
commit | 00c0098252ac7b303061175ff4c3e002c07407d2 (patch) | |
tree | d3882967cb0737c15ed2916f8bcc3ee9a7920fef /spec/frontend/fixtures/comment_templates.rb | |
parent | c8f8f2a4966ab5ccbee8477544987ef9bdbcd55f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/fixtures/comment_templates.rb')
-rw-r--r-- | spec/frontend/fixtures/comment_templates.rb | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/spec/frontend/fixtures/comment_templates.rb b/spec/frontend/fixtures/comment_templates.rb new file mode 100644 index 00000000000..32f425d7ebd --- /dev/null +++ b/spec/frontend/fixtures/comment_templates.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GraphQL::Query, type: :request, feature_category: :user_profile do + include JavaScriptFixturesHelpers + include ApiHelpers + include GraphqlHelpers + + let_it_be(:current_user) { create(:user) } + + before do + sign_in(current_user) + end + + context 'when user has no comment templates' do + base_input_path = 'comment_templates/queries/' + base_output_path = 'graphql/comment_templates/' + query_name = 'saved_replies.query.graphql' + + it "#{base_output_path}saved_replies_empty.query.graphql.json" do + query = get_graphql_query_as_string("#{base_input_path}#{query_name}") + + post_graphql(query, current_user: current_user) + + expect_graphql_errors_to_be_empty + end + end + + context 'when user has comment templates' do + base_input_path = 'comment_templates/queries/' + base_output_path = 'graphql/comment_templates/' + query_name = 'saved_replies.query.graphql' + + it "#{base_output_path}saved_replies.query.graphql.json" do + create(:saved_reply, user: current_user) + create(:saved_reply, user: current_user) + + query = get_graphql_query_as_string("#{base_input_path}#{query_name}") + + post_graphql(query, current_user: current_user) + + expect_graphql_errors_to_be_empty + end + end + + context 'when user creates comment template' do + base_input_path = 'comment_templates/queries/' + base_output_path = 'graphql/comment_templates/' + query_name = 'create_saved_reply.mutation.graphql' + + it "#{base_output_path}#{query_name}.json" do + query = get_graphql_query_as_string("#{base_input_path}#{query_name}") + + post_graphql(query, current_user: current_user, variables: { name: "Test", content: "Test content" }) + + expect_graphql_errors_to_be_empty + end + end + + context 'when user creates comment template and it errors' do + base_input_path = 'comment_templates/queries/' + base_output_path = 'graphql/comment_templates/' + query_name = 'create_saved_reply.mutation.graphql' + + it "#{base_output_path}create_saved_reply_with_errors.mutation.graphql.json" do + query = get_graphql_query_as_string("#{base_input_path}#{query_name}") + + post_graphql(query, current_user: current_user, variables: { name: nil, content: nil }) + + expect(flattened_errors).not_to be_empty + end + end +end |