diff --git a/spec/graphql/dossier_spec.rb b/spec/graphql/dossier_spec.rb index b2fc60c4d..fe919867f 100644 --- a/spec/graphql/dossier_spec.rb +++ b/spec/graphql/dossier_spec.rb @@ -158,6 +158,30 @@ RSpec.describe Types::DossierType, type: :graphql do } end + describe 'dossier with titre identite filled' do + let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :titre_identite }]) } + let(:dossier) { create(:dossier, :accepte, :with_populated_champs, procedure: procedure) } + + let(:query) { DOSSIER_WITH_TITRE_IDENTITE_QUERY } + let(:variables) { { number: dossier.id } } + + it { + expect(data[:dossier][:champs][0][:filled]).to eq(true) + } + end + + describe 'dossier with titre identite not filled' do + let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :titre_identite }]) } + let(:dossier) { create(:dossier, :accepte, procedure: procedure) } + + let(:query) { DOSSIER_WITH_TITRE_IDENTITE_QUERY } + let(:variables) { { number: dossier.id } } + + it { + expect(data[:dossier][:champs][0][:filled]).to eq(false) + } + end + DOSSIER_QUERY = <<-GRAPHQL query($number: Int!) { dossier(number: $number) { @@ -260,4 +284,21 @@ RSpec.describe Types::DossierType, type: :graphql do } } GRAPHQL + + DOSSIER_WITH_TITRE_IDENTITE_QUERY = <<-GRAPHQL + query($number: Int!) { + dossier(number: $number) { + id + number + champs { + id + label + __typename + ... on TitreIdentiteChamp { + filled + } + } + } + } + GRAPHQL end