Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

test(glossary): watch the dialog and the open forms for N+1 queries

Guido Boyke2c9acf822788
diff --git a/spec/requests/organisations/glossary_spec.rb b/spec/requests/organisations/glossary_spec.rb
index 2407f12..2fdeab1 100644
--- a/spec/requests/organisations/glossary_spec.rb
+++ b/spec/requests/organisations/glossary_spec.rb
@@ -1003,7 +1003,8 @@ RSpec.describe 'Organisations::Glossary', :ci_guard, type: :request do
create(:term_correction, organisation: organisation, glossary_term: found, heard: "vor schlag #{index}",
project: create(:project, organisation: organisation), user: member_with(role_with))
create(:term_correction, organisation: organisation, glossary_term: found, heard: "vorschlak #{index}",
- person: create(:person, organisation: organisation), project: open_project)
+ person: create(:person, organisation: organisation), project: open_project,
+ status: 'proposed')
end
end
end
@@ -1014,7 +1015,9 @@ RSpec.describe 'Organisations::Glossary', :ci_guard, type: :request do
get organisation_glossary_terms_path(organisation)
expect(response).to have_http_status(:ok)
- expect(Nokogiri::HTML(response.body).css('[data-glossary-row]').size).to eq(5)
+ page = Nokogiri::HTML(response.body)
+ expect(page.css('[data-glossary-row]').size).to eq(5)
+ expect(page.text.scan(I18n.t('views.organisations.glossary.index.open_forms', count: 1)).size).to eq(3)
end
it 'renders a lane with many heard forms without an N+1' do
@@ -1026,7 +1029,9 @@ RSpec.describe 'Organisations::Glossary', :ci_guard, type: :request do
get organisation_glossary_term_path(organisation, target), headers: frame_headers
expect(response).to have_http_status(:ok)
- expect(Nokogiri::HTML(response.body).css('.glossary-heard__row').size).to eq(3)
+ page = Nokogiri::HTML(response.body)
+ expect(page.css('.glossary-heard__row').size).to eq(3)
+ expect(page.css('.glossary-heard__decide form').size).to eq(2)
end
end
diff --git a/spec/requests/organisations/meeting_term_corrections_spec.rb b/spec/requests/organisations/meeting_term_corrections_spec.rb
index c4a6f4c..d3ee917 100644
--- a/spec/requests/organisations/meeting_term_corrections_spec.rb
+++ b/spec/requests/organisations/meeting_term_corrections_spec.rb
@@ -186,6 +186,37 @@ RSpec.describe 'Organisations::MeetingTermCorrections', :ci_guard, type: :reques
end
end
+ # Prosopite watches every example: the dialog reads the participants, the
+ # glossary suggestions and the glossary rights once, however many there are.
+ describe 'queries' do
+ before do
+ Prosopite.pause do
+ 4.times do |index|
+ create(:meeting_participant, meeting: meeting, display_name: "Gast Nummer#{index}",
+ person: create(:person, organisation: organisation))
+ create(:glossary_term, organisation: organisation, term: "Begriff #{index}")
+ end
+ end
+ end
+
+ it 'opens the dialog with many participants and terms without an N+1' do
+ sign_in writer('manage_glossary')
+ get new_path, headers: frame
+
+ expect(response).to have_http_status(:ok)
+ expect(page_markup).to have_css('select[name="term_correction[speaker_id]"] option', count: 7)
+ expect(page_markup).to have_css('datalist option', count: 4, visible: :all)
+ end
+
+ it 'corrects in a meeting with many participants and terms without an N+1' do
+ sign_in writer('manage_glossary')
+ post_correction
+
+ expect(response).to have_http_status(:ok)
+ expect(TermCorrection.count).to eq(1)
+ end
+ end
+
describe 'the count' do
it 'counts the heard form as typed, in its own frame' do
sign_in writer