diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d5f8f67a..47554ed09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: - bin/rspec spec/controllers/*_spec.rb - bin/rspec spec/controllers/[a-l]**/*_spec.rb - bin/rspec spec/controllers/[m-z]**/*_spec.rb - - bin/rspec spec/features + - bin/rspec spec/system - bin/rspec spec/helpers spec/lib spec/middlewares - bin/rspec spec/mailers spec/jobs spec/policies - bin/rspec spec/models diff --git a/.rubocop.yml b/.rubocop.yml index d1e5ce5f6..7c7982b4b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -722,7 +722,7 @@ Rails/DelegateAllowBlank: Rails/DynamicFindBy: Enabled: true Exclude: - - "spec/features/**/*.rb" + - "spec/system/**/*.rb" Rails/EnumUniqueness: Enabled: true diff --git a/Gemfile b/Gemfile index 33cc8f5c0..5fbc1aa53 100644 --- a/Gemfile +++ b/Gemfile @@ -89,11 +89,10 @@ group :test do gem 'capybara' # Integration testing gem 'capybara-email' # Access emails during integration tests gem 'capybara-screenshot' # Save a dump of the page when an integration test fails - gem 'capybara-selenium' - gem 'database_cleaner' gem 'factory_bot' gem 'launchy' gem 'rails-controller-testing' + gem 'selenium-webdriver' gem 'shoulda-matchers', require: false gem 'timecop' gem 'vcr' diff --git a/Gemfile.lock b/Gemfile.lock index 867650789..c06ad62b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -162,9 +162,6 @@ GEM capybara-screenshot (1.0.25) capybara (>= 1.0, < 4) launchy - capybara-selenium (0.0.6) - capybara - selenium-webdriver case_transform (0.2) activesupport caxlsx (3.1.0) @@ -189,12 +186,6 @@ GEM css_parser (1.9.0) addressable daemons (1.3.1) - database_cleaner (2.0.1) - database_cleaner-active_record (~> 2.0.0) - database_cleaner-active_record (2.0.0) - activerecord (>= 5.a) - database_cleaner-core (~> 2.0.0) - database_cleaner-core (2.0.1) datetime_picker_rails (0.0.7) momentjs-rails (>= 2.8.1) deep_cloneable (3.0.0) @@ -798,13 +789,11 @@ DEPENDENCIES capybara capybara-email capybara-screenshot - capybara-selenium charlock_holmes chartkick chunky_png clamav-client daemons - database_cleaner deep_cloneable delayed_cron_job delayed_job_active_record @@ -874,6 +863,7 @@ DEPENDENCIES sanitize-url sassc-rails scss_lint + selenium-webdriver sentry-delayed_job sentry-rails sentry-ruby diff --git a/Guardfile b/Guardfile index 24a9eca3b..30cfad9f1 100644 --- a/Guardfile +++ b/Guardfile @@ -2,7 +2,7 @@ # More info at https://github.com/guard/guard#readme ## Uncomment and set this to only include directories you want to watch -# directories %w(app lib config test spec features) \ +# directories %w(app lib config test spec system) \ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")} ## Note: if you are using the `directories` clause above and you are not @@ -77,8 +77,8 @@ guard :rspec, cmd: 'spring rspec' do watch('app/controllers/application_controller.rb') { "spec/controllers" } watch('spec/rails_helper.rb') { "spec" } - # Capybara features specs - watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } + # Capybara system specs + watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/system/#{m[1]}_spec.rb" } # Turnip features and steps watch(%r{^spec/acceptance/(.+)\.feature$}) diff --git a/app/controllers/new_administrateur/types_de_champ_controller.rb b/app/controllers/new_administrateur/types_de_champ_controller.rb index 4d4e1685c..49cc93507 100644 --- a/app/controllers/new_administrateur/types_de_champ_controller.rb +++ b/app/controllers/new_administrateur/types_de_champ_controller.rb @@ -57,6 +57,9 @@ module NewAdministrateur ], methods: [ :drop_down_list_value, + :drop_down_other, + :drop_down_secondary_libelle, + :drop_down_secondary_description, :piece_justificative_template_filename, :piece_justificative_template_url, :editable_options @@ -73,6 +76,9 @@ module NewAdministrateur :parent_id, :private, :drop_down_list_value, + :drop_down_other, + :drop_down_secondary_libelle, + :drop_down_secondary_description, :piece_justificative_template, editable_options: [ :cadastres, @@ -94,6 +100,9 @@ module NewAdministrateur :description, :mandatory, :drop_down_list_value, + :drop_down_other, + :drop_down_secondary_libelle, + :drop_down_secondary_description, :piece_justificative_template, editable_options: [ :cadastres, diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 721ddf54b..6ba476c78 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -337,8 +337,8 @@ module Users def champs_params params.permit(dossier: { champs_attributes: [ - :id, :value, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :piece_justificative_file, value: [], - champs_attributes: [:id, :_destroy, :value, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :piece_justificative_file, value: []] + :id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :piece_justificative_file, value: [], + champs_attributes: [:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :piece_justificative_file, value: []] ] }) end diff --git a/app/controllers/users/transfers_controller.rb b/app/controllers/users/transfers_controller.rb index 3744dd1c7..285e0f7a3 100644 --- a/app/controllers/users/transfers_controller.rb +++ b/app/controllers/users/transfers_controller.rb @@ -16,7 +16,7 @@ module Users .joins(:dossiers) .find_by!(id: params[:id], dossiers: { user: current_user }) - transfer.destroy + transfer.destroy_and_nullify redirect_to dossiers_path end diff --git a/app/javascript/components/TypesDeChampEditor/components/TypeDeChamp.jsx b/app/javascript/components/TypesDeChampEditor/components/TypeDeChamp.jsx index 00ce93494..bce4e7103 100644 --- a/app/javascript/components/TypesDeChampEditor/components/TypeDeChamp.jsx +++ b/app/javascript/components/TypesDeChampEditor/components/TypeDeChamp.jsx @@ -11,9 +11,11 @@ import MoveButton from './MoveButton'; import TypeDeChampCarteOption from './TypeDeChampCarteOption'; import TypeDeChampCarteOptions from './TypeDeChampCarteOptions'; import TypeDeChampDropDownOptions from './TypeDeChampDropDownOptions'; +import TypeDeChampDropDownOther from './TypeDeChampDropDownOther'; import TypeDeChampPieceJustificative from './TypeDeChampPieceJustificative'; import TypeDeChampRepetitionOptions from './TypeDeChampRepetitionOptions'; import TypeDeChampTypesSelect from './TypeDeChampTypesSelect'; +import TypeDeChampDropDownSecondary from './TypeDeChampDropDownSecondary'; const TypeDeChamp = sortableElement( ({ typeDeChamp, dispatch, idx: index, isFirstItem, isLastItem, state }) => { @@ -22,6 +24,8 @@ const TypeDeChamp = sortableElement( 'multiple_drop_down_list', 'linked_drop_down_list' ].includes(typeDeChamp.type_champ); + const isLinkedDropDown = typeDeChamp.type_champ === 'linked_drop_down_list'; + const isSimpleDropDown = typeDeChamp.type_champ === 'drop_down_list'; const isFile = typeDeChamp.type_champ === 'piece_justificative'; const isCarte = typeDeChamp.type_champ === 'carte'; const isExplication = typeDeChamp.type_champ === 'explication'; @@ -130,6 +134,15 @@ const TypeDeChamp = sortableElement( isVisible={isDropDown} handler={updateHandlers.drop_down_list_value} /> + + + + + ); + } + return null; +} + +TypeDeChampDropDownOther.propTypes = { + isVisible: PropTypes.bool, + handler: PropTypes.object +}; + +export default TypeDeChampDropDownOther; diff --git a/app/javascript/components/TypesDeChampEditor/components/TypeDeChampDropDownSecondary.jsx b/app/javascript/components/TypesDeChampEditor/components/TypeDeChampDropDownSecondary.jsx new file mode 100644 index 000000000..6f1ee62f8 --- /dev/null +++ b/app/javascript/components/TypesDeChampEditor/components/TypeDeChampDropDownSecondary.jsx @@ -0,0 +1,41 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +export default function TypeDeChampDropDownSecondary({ + isVisible, + libelleHandler, + descriptionHandler +}) { + if (isVisible) { + return ( +
+ + + +