Skip to content

Commit

Permalink
test(rna): add test against RNA type
Browse files Browse the repository at this point in the history
  • Loading branch information
colinux committed Feb 12, 2024
1 parent f09ab62 commit 5e859bd
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions spec/graphql/dossier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
end

describe 'dossier with champs' do
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :communes }, { type: :address }, { type: :siret }]) }
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :communes }, { type: :address }, { type: :siret }, { type: :rna }]) }
let(:dossier) { create(:dossier, :accepte, :with_populated_champs, procedure: procedure) }
let(:query) { DOSSIER_WITH_CHAMPS_QUERY }
let(:variables) { { number: dossier.id } }
Expand All @@ -48,7 +48,30 @@
}
end

before { dossier.champs_public.second.update(data: address) }
let(:rna) do
{
"adresse" => {
"commune" => "Paris 14e",
"type_voie" => "RUE",
"code_insee" => "75114",
"complement" => nil,
"code_postal" => "75512",
"numero_voie" => "12",
"distribution" => nil,
"libelle_voie" => "xyz"
},
"association_rna" => "W173847273",
"association_objet" => "prévenir",
"association_titre" => "CROIX ROUGE",
"association_date_creation" => "1964-12-30",
"association_date_declaration" => "2022-08-10"
}
end

before do
dossier.champs_public.find { _1.type_champ == TypeDeChamp.type_champs.fetch(:address) }.update(data: address)
dossier.champs_public.find { _1.type_champ == TypeDeChamp.type_champs.fetch(:rna) }.update(data: rna)
end

it do
expect(data[:dossier][:champs][0][:__typename]).to eq "CommuneChamp"
Expand All @@ -59,6 +82,11 @@
expect(data[:dossier][:champs][1][:departement][:code]).to eq('75')
expect(data[:dossier][:champs][2][:etablissement][:siret]).to eq dossier.champs_public[2].etablissement.siret
expect(data[:dossier][:champs][0][:id]).to eq(data[:dossier][:revision][:champDescriptors][0][:id])

expect(data[:dossier][:champs][3][:rna][:id]).to eq('W173847273')
expect(data[:dossier][:champs][3][:rna][:title]).to eq('CROIX ROUGE')
expect(data[:dossier][:champs][3][:rna][:address][:label]).to eq('12 RUE xyz 75512 Paris 14e')
expect(data[:dossier][:champs][3][:rna][:address][:streetNumber]).to eq('12')
end

context 'when etablissement is in degraded mode' do
Expand Down Expand Up @@ -398,6 +426,8 @@
entreprise { capitalSocial }
}
}
...RNAChampFragment
}
}
}
Expand All @@ -423,6 +453,17 @@
streetName
streetNumber
}
fragment RNAChampFragment on RNAChamp {
stringValue
rna {
id
title
address {
...AddressFragment
}
}
}
GRAPHQL

DOSSIER_WITH_LINKED_DOSIER_QUERY = <<-GRAPHQL
Expand Down

0 comments on commit 5e859bd

Please sign in to comment.