Welcome to mirror list, hosted at ThFree Co, Russian Federation.

saved_replies.rb « fixtures « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 613e4a1b447faedc81935b9fd8f335c9d61d2f5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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 saved replies' do
    base_input_path = 'saved_replies/queries/'
    base_output_path = 'graphql/saved_replies/'
    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 saved replies' do
    base_input_path = 'saved_replies/queries/'
    base_output_path = 'graphql/saved_replies/'
    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 saved reply' do
    base_input_path = 'saved_replies/queries/'
    base_output_path = 'graphql/saved_replies/'
    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 saved reply and it errors' do
    base_input_path = 'saved_replies/queries/'
    base_output_path = 'graphql/saved_replies/'
    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