debian-mirror-gitlab/spec/requests/api/graphql/crm/contacts_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
1.5 KiB
Ruby
Raw Permalink Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'getting CRM contacts', feature_category: :service_desk do
2022-08-13 15:12:31 +05:30
include GraphqlHelpers
let_it_be(:current_user) { create(:user) }
let_it_be(:group) { create(:group, :crm_enabled) }
let_it_be(:contact_a) do
create(
:contact,
group: group,
2022-08-27 11:52:29 +05:30
first_name: "PQR",
last_name: "STU",
email: "aaa@test.com",
description: "YZ",
state: "active"
2022-08-13 15:12:31 +05:30
)
end
let_it_be(:contact_b) do
create(
:contact,
group: group,
first_name: "ABC",
last_name: "DEF",
2022-08-27 11:52:29 +05:30
email: "ghi@test.com",
description: "LMNO",
state: "inactive"
2022-08-13 15:12:31 +05:30
)
end
let_it_be(:contact_c) do
create(
:contact,
group: group,
2022-08-27 11:52:29 +05:30
first_name: "JKL",
last_name: "MNO",
email: "vwx@test.com",
2022-08-13 15:12:31 +05:30
description: "YZ",
state: "active"
)
end
before do
group.add_reporter(current_user)
end
it_behaves_like 'sorted paginated query' do
let(:sort_argument) { {} }
let(:first_param) { 2 }
2022-08-27 11:52:29 +05:30
let(:all_records) { [contact_b, contact_c, contact_a] }
2022-08-13 15:12:31 +05:30
let(:data_path) { [:group, :contacts] }
def pagination_query(params)
graphql_query_for(
:group,
{ full_path: group.full_path },
query_graphql_field(:contacts, params, "#{page_info} nodes { id }")
)
end
def pagination_results_data(nodes)
nodes.map { |item| GlobalID::Locator.locate(item['id']) }
end
end
end