-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: loosen application duo schema and hide duos when disabled by config
:application/duo :duo/codes is now always added to application base view (when provided by draft-saved event), but schema expected :duo/matches to exist if :application/duo was present. The specific scenario for this regression happened when :enable-duo config was off, and duo codes were previously recorded in draft-saved event(s). All :application/duo keys are now optional. Application duos are hidden during enrichment if disabled by :enable-duo configuration, so that pdf rendering and other parts do not display them. Previously application base view used config, but this was unintentionally against how application-view documented itself as pure function.
- Loading branch information
Showing
3 changed files
with
45 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2564,6 +2564,7 @@ | |
cat1 (test-helpers/create-catalogue-item! {:workflow-id wfid :resource-id res1}) | ||
cat2 (test-helpers/create-catalogue-item! {:workflow-id wfid :resource-id res2}) | ||
app-id (test-helpers/create-application! {:actor applicant-id :catalogue-item-ids [cat1 cat2]})] | ||
|
||
(testing "save partially valid duo codes" | ||
(is (= {:success true} | ||
(send-command applicant-id | ||
|
@@ -2620,6 +2621,7 @@ | |
:validity "duo/not-compatible"}}]} | ||
(-> (get-application-for-user app-id applicant-id) | ||
:application/duo)))) | ||
|
||
(testing "save fully valid duo codes" | ||
(is (= {:success true} | ||
(send-command applicant-id | ||
|
@@ -2676,7 +2678,13 @@ | |
:duo/shorthand "DS" | ||
:duo/validation {:errors [] :validity "duo/compatible"}}]} | ||
(-> (get-application-for-user app-id applicant-id) | ||
:application/duo)))))))) | ||
:application/duo)))) | ||
|
||
(testing "duo codes are not enriched when config :enable-duo is false" | ||
(with-redefs [rems.config/env (assoc rems.config/env :enable-duo false)] | ||
(let [application (get-application-for-user app-id applicant-id)] | ||
(is (nil? (:application/duo application))) | ||
(is (empty? (keep :resource/duo (:application/resources application))))))))))) | ||
|
||
(deftest test-application-raw | ||
(let [api-key "42" | ||
|
@@ -2816,8 +2824,7 @@ | |
:event/actor-attributes {:userid "alice" :name "Alice Applicant" :nickname "In Wonderland" :email "[email protected]" :organizations [{:organization/id "default"}] :researcher-status-by "so"} | ||
:application/field-values [{:form form-id :field "field-1" :value "raw test"} | ||
{:form form-id :field "att" :value (str att-id)}] | ||
:event/visibility "visibility/public"}] | ||
:application/duo {:duo/matches []}} | ||
:event/visibility "visibility/public"}]} | ||
(-> (api-call :get (str "/api/applications/" app-id "/raw") nil | ||
api-key reporter) | ||
;; event ids are unpredictable | ||
|