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

graphql_known_operations_spec.rb « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 80214307be3072d147749b361fb8535c98e780f4 (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
# frozen_string_literal: true

require 'spec_helper'

# We need to distinguish between known and unknown GraphQL operations. This spec
# tests that we set up Gitlab::Graphql::KnownOperations.default which requires
# integration of FE queries, webpack plugin, and BE.
RSpec.describe 'Graphql known operations', :js do
  around do |example|
    # Let's make sure we aren't receiving or leaving behind any side-effects
    # https://gitlab.com/gitlab-org/gitlab/-/jobs/1743294100
    ::Gitlab::Graphql::KnownOperations.instance_variable_set(:@default, nil)
    ::Gitlab::Webpack::GraphqlKnownOperations.clear_memoization!

    example.run

    ::Gitlab::Graphql::KnownOperations.instance_variable_set(:@default, nil)
    ::Gitlab::Webpack::GraphqlKnownOperations.clear_memoization!
  end

  it 'collects known Graphql operations from the code', :aggregate_failures do
    # Check that we include some arbitrary operation name we expect
    known_operations = Gitlab::Graphql::KnownOperations.default.operations.map(&:name)

    expect(known_operations).to include("searchProjects")
    expect(known_operations.length).to be > 20
    expect(known_operations).to all(match(%r{^[a-z]+}i))
  end
end