Skip to content

Commit

Permalink
feature: add brouillon.spec test
Browse files Browse the repository at this point in the history
  • Loading branch information
yhru committed Oct 22, 2024
1 parent 3766b3d commit 7709cc7
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
describe 'deployment:20241021111111:feature_flag_referentiel_de_polynesie' do
let(:rake_task) { Rake::Task['after_party:feature_flag_referentiel_de_polynesie'] }
let!(:procedure_with_admin_featured) { create(:procedure) }
let!(:types_de_champ_private) { [{ type: :referentiel_de_polynesie }] }
let!(:procedure_with_referentiel_de_polynesie_with_admin_featured) { create(:procedure, types_de_champ_private:, administrateurs: [procedure_with_admin_featured.administrateurs.first]) }
let!(:procedure_without_admin_featured) { create(:procedure) }
let!(:procedure_with_referentiel_de_polynesie_without_admin_featured) { create(:procedure, types_de_champ_private:, administrateurs: [procedure_without_admin_featured.administrateurs.first]) }

subject(:run_task) do
rake_task.invoke
end

before { Flipper.enable(:referentiel_de_polynesie, procedure_with_admin_featured.administrateurs.first.user) }

after { rake_task.reenable }

describe 'feature_flag_referentiel_de_polynesie' do
it "with bad champs" do
expect(Flipper.enabled?(:referentiel_de_polynesie, procedure_with_admin_featured.administrateurs.first.user)).to eq(true)
expect(Flipper.enabled?(:referentiel_de_polynesie, procedure_with_admin_featured)).to eq(false)
expect(Flipper.enabled?(:referentiel_de_polynesie, procedure_with_referentiel_de_polynesie_with_admin_featured)).to eq(false)
expect(Flipper.enabled?(:referentiel_de_polynesie, procedure_without_admin_featured)).to eq(false)
expect(Flipper.enabled?(:referentiel_de_polynesie, procedure_with_referentiel_de_polynesie_without_admin_featured)).to eq(false)

run_task

procedure_with_admin_featured.reload
procedure_with_referentiel_de_polynesie_with_admin_featured.reload
procedure_without_admin_featured.reload
procedure_with_referentiel_de_polynesie_without_admin_featured.reload

expect(Flipper.enabled?(:referentiel_de_polynesie, procedure_with_admin_featured.administrateurs.first.user)).to eq(false)
expect(Flipper.enabled?(:referentiel_de_polynesie, procedure_with_admin_featured)).to eq(false)
expect(Flipper.enabled?(:referentiel_de_polynesie, procedure_with_referentiel_de_polynesie_with_admin_featured)).to eq(true)
expect(Flipper.enabled?(:referentiel_de_polynesie, procedure_without_admin_featured)).to eq(false)
expect(Flipper.enabled?(:referentiel_de_polynesie, procedure_with_referentiel_de_polynesie_without_admin_featured)).to eq(false)
end
end
end
28 changes: 28 additions & 0 deletions spec/system/users/brouillon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,34 @@
])
}

let(:simple_procedure_with_referentiel_de_polynesie) {
create(:procedure, :published, :for_individual, types_de_champ_public: [
{ mandatory: false, libelle: 'referentiel de polynesie', type_champ: 'referentiel_de_polynesie', table_id: "1" }
])
}

scenario 'fill a dossier with referentiel_de_polynesie', js: true, vcr: true do
log_in(user, simple_procedure_with_referentiel_de_polynesie)
fill_individual

find_field('referentiel de polynesie').click
fill_in('referentiel de polynesie', with: 'Mahina')

using_wait_time 5 do
expect(page).to have_selector('input[aria-expanded="true"]', visible: true, wait: 10)
end

using_wait_time 5 do
expect(page).to have_selector('ul[role="listbox"]', visible: true, wait: 10)
expect(page).to have_selector('ul[role="listbox"] li', text: 'Mahina - Tahiti - 98709')
end

find('ul[role="listbox"] li', text: 'Mahina - Tahiti - 98709').click
click_on 'Déposer le dossier'

expect(page).to have_content('Vous avez désormais accès à votre dossier en ligne.')
end

scenario 'save an incomplete dossier as draft but cannot not submit it', js: true do
log_in(user, simple_procedure)
fill_individual
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7709cc7

Please sign in to comment.