From 71741c5f98f426718b67db7c109f3babf0a58c24 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 8 Jul 2021 17:29:40 +0200 Subject: [PATCH 1/4] views: fix checkbox wrongly selected in multiple_drop_down_list The check for whether the checkbox should be checked or not was made by matching the whole string. Thus, given two options 'valid' and 'invalid', the check for the presence of 'valid' would succeed even when only 'invalid' was present in the values (because `'valid'.includes?('invalid')`. The code now checks against the list of items in the selected_options. --- .../_multiple_drop_down_list.html.haml | 3 +-- spec/views/shared/dossiers/_edit.html.haml_spec.rb | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/views/shared/dossiers/editable_champs/_multiple_drop_down_list.html.haml b/app/views/shared/dossiers/editable_champs/_multiple_drop_down_list.html.haml index 4911753ee..d4f5c6788 100644 --- a/app/views/shared/dossiers/editable_champs/_multiple_drop_down_list.html.haml +++ b/app/views/shared/dossiers/editable_champs/_multiple_drop_down_list.html.haml @@ -3,11 +3,10 @@ = form.collection_check_boxes(:value, champ.enabled_non_empty_options, :to_s, :to_s) do |b| .editable-champ.editable-champ-checkbox = b.label do - = b.check_box({ multiple: true, checked: champ&.value&.include?(b.value) }) + = b.check_box({ multiple: true, checked: champ&.selected_options&.include?(b.value) }) = b.text - else - hidden_field_id = SecureRandom.uuid = form.hidden_field :value, { data: { uuid: hidden_field_id } } = react_component("ComboMultipleDropdownList", options: champ.options, selected: champ.selected_options, disabled: champ.disabled_options, hiddenFieldId: hidden_field_id, label: champ.libelle) - diff --git a/spec/views/shared/dossiers/_edit.html.haml_spec.rb b/spec/views/shared/dossiers/_edit.html.haml_spec.rb index 4935c3024..2a3b072ad 100644 --- a/spec/views/shared/dossiers/_edit.html.haml_spec.rb +++ b/spec/views/shared/dossiers/_edit.html.haml_spec.rb @@ -61,16 +61,20 @@ describe 'shared/dossiers/edit.html.haml', type: :view do context 'with a multiple-values list' do let(:dossier) { create(:dossier) } - let(:type_de_champ) { create(:type_de_champ_multiple_drop_down_list, procedure: dossier.procedure) } - let(:champ) { create(:champ_multiple_drop_down_list, dossier: dossier, type_de_champ: type_de_champ) } + let(:type_de_champ) { create(:type_de_champ_multiple_drop_down_list, procedure: dossier.procedure, drop_down_list_value: drop_down_list_value) } + let(:champ) { create(:champ_multiple_drop_down_list, dossier: dossier, type_de_champ: type_de_champ, value: champ_value) } let(:options) { type_de_champ.drop_down_list_options } let(:enabled_options) { type_de_champ.drop_down_list_enabled_non_empty_options } before { dossier.champs << champ } context 'when the list is short' do + let(:drop_down_list_value) { ['valid', 'invalid', 'not sure yet'].join("\r\n") } + let(:champ_value) { ['invalid'].to_json } + it 'renders the list as checkboxes' do expect(subject).to have_selector('input[type=checkbox]', count: enabled_options.count) + expect(subject).to have_selector('input[type=checkbox][checked=checked]', count: 1) end it 'adds an extra hidden input, to send a blank value even when all checkboxes are unchecked' do @@ -79,7 +83,8 @@ describe 'shared/dossiers/edit.html.haml', type: :view do end context 'when the list is long' do - let(:type_de_champ) { create(:type_de_champ_multiple_drop_down_list, :long, procedure: dossier.procedure) } + let(:drop_down_list_value) { ['peach', 'banana', 'pear', 'apricot', 'apple', 'grapefruit'].join("\r\n") } + let(:champ_value) { ['banana', 'grapefruit'].to_json } it 'renders the list as a multiple-selection dropdown' do expect(subject).to have_selector('[data-react-class="ComboMultipleDropdownList"]') From 73935c23e43a988d2bc1ab8c32e95c46e579dd8a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Jul 2021 07:13:05 +0000 Subject: [PATCH 2/4] build(deps): bump addressable from 2.7.0 to 2.8.0 Bumps [addressable](https://github.com/sporkmonger/addressable) from 2.7.0 to 2.8.0. - [Release notes](https://github.com/sporkmonger/addressable/releases) - [Changelog](https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md) - [Commits](https://github.com/sporkmonger/addressable/compare/addressable-2.7.0...addressable-2.8.0) --- updated-dependencies: - dependency-name: addressable dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5a1f455c1..5958fdbd4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -84,7 +84,7 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) administrate (0.16.0) actionpack (>= 5.0) From 0dfe4fc89944d0cc9b101019fe80b26b63be599e Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 13 Jul 2021 14:38:38 +0200 Subject: [PATCH 3/4] js: update to @sentry/browser v6.9.0 Helps with de-duplicating issues being trigerred in a loop. See https://github.com/getsentry/sentry-javascript/pull/3730 --- package.json | 2 +- yarn.lock | 79 ++++++++++++++++++++++++++++------------------------ 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index 6aef882ce..d8365369a 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "@reach/combobox": "^0.13.0", "@reach/slider": "^0.15.0", "@reach/visually-hidden": "^0.15.2", - "@sentry/browser": "^5.15.5", + "@sentry/browser": "6.9.0", "@tmcw/togeojson": "^4.3.0", "babel-plugin-macros": "^2.8.0", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", diff --git a/yarn.lock b/yarn.lock index e7e578b61..a66bddc3f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1748,56 +1748,56 @@ prop-types "^15.7.2" tslib "^2.3.0" -"@sentry/browser@^5.15.5": - version "5.15.5" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.15.5.tgz#d9a51f1388581067b50d30ed9b1aed2cbb333a36" - integrity sha512-rqDvjk/EvogfdbZ4TiEpxM/lwpPKmq23z9YKEO4q81+1SwJNua53H60dOk9HpRU8nOJ1g84TMKT2Ov8H7sqDWA== +"@sentry/browser@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.9.0.tgz#b75ac1a6ff8fe60d451b14aea94d66f9dcd5570f" + integrity sha512-4JnEPcwoNs6JqeEd4wscBq+hxpotEJ0DJ4eOIsaNZIMyqEHXBHTXCk/gfrSsiZFrkHM4PgvUHOxaC0HcZ92oBA== dependencies: - "@sentry/core" "5.15.5" - "@sentry/types" "5.15.5" - "@sentry/utils" "5.15.5" + "@sentry/core" "6.9.0" + "@sentry/types" "6.9.0" + "@sentry/utils" "6.9.0" tslib "^1.9.3" -"@sentry/core@5.15.5": - version "5.15.5" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.15.5.tgz#40ea79bff5272d3fbbeeb4a98cdc59e1adbd2c92" - integrity sha512-enxBLv5eibBMqcWyr+vApqeix8uqkfn0iGsD3piKvoMXCgKsrfMwlb/qo9Ox0lKr71qIlZVt+9/A2vZohdgnlg== +"@sentry/core@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.9.0.tgz#43b25290f3b1eb2c23f665e1c0fcbadd06d06012" + integrity sha512-oFX2qQcMLujCeIuCQGlhpTUIOXiU5n6V2lqDnvMXUV8gKpplBPalwdlR9bgbSi+VO8u7LjHR1IKM0RAPWgNHWw== dependencies: - "@sentry/hub" "5.15.5" - "@sentry/minimal" "5.15.5" - "@sentry/types" "5.15.5" - "@sentry/utils" "5.15.5" + "@sentry/hub" "6.9.0" + "@sentry/minimal" "6.9.0" + "@sentry/types" "6.9.0" + "@sentry/utils" "6.9.0" tslib "^1.9.3" -"@sentry/hub@5.15.5": - version "5.15.5" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.15.5.tgz#f5abbcdbe656a70e2ff02c02a5a4cffa0f125935" - integrity sha512-zX9o49PcNIVMA4BZHe//GkbQ4Jx+nVofqU/Il32/IbwKhcpPlhGX3c1sOVQo4uag3cqd/JuQsk+DML9TKkN0Lw== +"@sentry/hub@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.9.0.tgz#21068e12769cc745825e8d122c7e81858f609708" + integrity sha512-5mors7ojbo7G85ZmoVPQBgFBMONAJwyZfV0LNLy14GenoaVNuxTPyvAQiJb1FYq+x6YZ3CvqGX6r74KRKQU87w== dependencies: - "@sentry/types" "5.15.5" - "@sentry/utils" "5.15.5" + "@sentry/types" "6.9.0" + "@sentry/utils" "6.9.0" tslib "^1.9.3" -"@sentry/minimal@5.15.5": - version "5.15.5" - resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.15.5.tgz#a0e4e071f01d9c4d808094ae7203f6c4cca9348a" - integrity sha512-zQkkJ1l9AjmU/Us5IrOTzu7bic4sTPKCatptXvLSTfyKW7N6K9MPIIFeSpZf9o1yM2sRYdK7GV08wS2eCT3JYw== +"@sentry/minimal@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.9.0.tgz#e6201eb237753994be83ec33866e3fdae9a79bf3" + integrity sha512-GBZ6wG2Rc1wInYEl2BZTZc/t57O1Da876ifLsSPpEQAEnGWbqZWb8RLjZskH09ZIL/K4XCIDDi5ySzN8kFUWJw== dependencies: - "@sentry/hub" "5.15.5" - "@sentry/types" "5.15.5" + "@sentry/hub" "6.9.0" + "@sentry/types" "6.9.0" tslib "^1.9.3" -"@sentry/types@5.15.5": - version "5.15.5" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.15.5.tgz#16c97e464cf09bbd1d2e8ce90d130e781709076e" - integrity sha512-F9A5W7ucgQLJUG4LXw1ZIy4iLevrYZzbeZ7GJ09aMlmXH9PqGThm1t5LSZlVpZvUfQ2rYA8NU6BdKJSt7B5LPw== +"@sentry/types@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.9.0.tgz#ef1a541c4240df6a7c6f5f31d7cdddd7d92c15f1" + integrity sha512-v52HJqLoLapEnqS2NdVtUXPvT+aezQgNXQkp8hiQ3RUdTm5cffwBVG7wlbpE6OsOOIZxd6p1zKylFkwCypiIIA== -"@sentry/utils@5.15.5": - version "5.15.5" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.15.5.tgz#dec1d4c79037c4da08b386f5d34409234dcbfb15" - integrity sha512-Nl9gl/MGnzSkuKeo3QaefoD/OJrFLB8HmwQ7HUbTXb6E7yyEzNKAQMHXGkwNAjbdYyYbd42iABP6Y5F/h39NtA== +"@sentry/utils@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.9.0.tgz#6bf0bf290a6d37a27078b7c1331a06d8a7e313c5" + integrity sha512-PimDr6KAi4cCp5hQZ8Az2/pDcdfhTu7WAU30Dd9MZwknpHSTmD4G6QvkdrB5er6kMMnNQOC7rMo6w/Do3m6X3w== dependencies: - "@sentry/types" "5.15.5" + "@sentry/types" "6.9.0" tslib "^1.9.3" "@sindresorhus/is@^0.14.0": @@ -12273,11 +12273,16 @@ tslib@^1, tslib@^1.8.1: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== -tslib@^1.9.0, tslib@^1.9.3: +tslib@^1.9.0: version "1.12.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.12.0.tgz#d1fc9cacd06a1456c62f2902b361573e83d66473" integrity sha512-5rxCQkP0kytf4H1T4xz1imjxaUUPMvc5aWp0rJ/VMIN7ClRiH1FwFvBt8wOeMasp/epeUnmSW6CixSIePtiLqA== +tslib@^1.9.3: + version "1.14.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" + integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== + tslib@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e" From 63cde95fc90185b9c7ca6573ff3a4104c36bf4bc Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 13 Jul 2021 12:57:42 +0000 Subject: [PATCH 4/4] js: ignore errors generated by a Microsoft crawler Sentry has a lot of Javacript errors stating: > UnhandledRejection: Non-Error promise rejection captured with value: Object Not Found Matching Id:2 This is apparently caused by a Microsoft crawler (maybe for scanning targets of email links), and can be safely ignored. See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062/12 --- app/javascript/shared/track/sentry.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/javascript/shared/track/sentry.js b/app/javascript/shared/track/sentry.js index faa02741a..67e82886a 100644 --- a/app/javascript/shared/track/sentry.js +++ b/app/javascript/shared/track/sentry.js @@ -4,7 +4,15 @@ const { key, enabled, user, environment, browser } = gon.sentry || {}; // We need to check for key presence here as we do not have a dsn for browser yet if (enabled && key) { - Sentry.init({ dsn: key, environment }); + Sentry.init({ + dsn: key, + environment, + ignoreErrors: [ + // Ignore errors generated by a Microsoft crawler. + // See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062 + 'Non-error promise rejection captured with keys' + ] + }); Sentry.configureScope((scope) => { scope.setUser(user);