From 1e8813a74f321c27e7b442ed956e27c3e43ae92c Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 13 Feb 2025 10:46:27 +0100 Subject: [PATCH] fix(graphql): fix flaky n+1 test --- spec/controllers/api/v2/graphql_controller_n+1_spec.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/controllers/api/v2/graphql_controller_n+1_spec.rb b/spec/controllers/api/v2/graphql_controller_n+1_spec.rb index e4605abf18f..07aef069f52 100644 --- a/spec/controllers/api/v2/graphql_controller_n+1_spec.rb +++ b/spec/controllers/api/v2/graphql_controller_n+1_spec.rb @@ -23,6 +23,9 @@ request.env['HTTP_AUTHORIZATION'] = authorization_header end + MIN_QUERY_COUNT = 57 + MAX_QUERY_COUNT = 61 + describe 'demarche.dossiers' do let(:operation_name) { 'getDemarche' } let(:variables) { { demarcheNumber: procedure.id, includeDossiers: true, includeTraitements: true } } @@ -39,7 +42,7 @@ expect(gql_errors).to be_nil expect(gql_data[:demarche][:dossiers][:nodes].count).to eq(1) - expect(query_count).to be_between(56, 60) + expect(query_count).to be_between(MIN_QUERY_COUNT, MAX_QUERY_COUNT) end context "with 1 dossier per state" do @@ -56,7 +59,7 @@ expect(gql_errors).to be_nil expect(gql_data[:demarche][:dossiers][:nodes].count).to eq(dossiers_count + 1) - expect(query_count).to be_between(56, 60) + expect(query_count).to be_between(MIN_QUERY_COUNT, MAX_QUERY_COUNT) end end @@ -74,7 +77,7 @@ expect(gql_errors).to be_nil expect(gql_data[:demarche][:dossiers][:nodes].count).to eq(dossiers_count + 1) - expect(query_count).to be_between(56, 60) + expect(query_count).to be_between(MIN_QUERY_COUNT, MAX_QUERY_COUNT) end end end