|
336 | 336 |
|
337 | 337 | (deftest application-api-third-party-review-test
|
338 | 338 | (let [api-key "42"
|
339 |
| - user "developer" |
340 |
| - reviewer "alice" |
| 339 | + applicant "alice" |
| 340 | + approver "developer" |
| 341 | + reviewer "bob" |
341 | 342 | catid 2
|
342 | 343 | app-id (-> (request :put (str "/api/application/save"))
|
343 |
| - (authenticate api-key user) |
| 344 | + (authenticate api-key applicant) |
344 | 345 | (json-body {:command "submit"
|
345 | 346 | :catalogue-items [catid]
|
346 | 347 | :items {1 "x" 2 "y" 3 "z"}
|
|
351 | 352 | (testing "send review request"
|
352 | 353 | (is (= 200
|
353 | 354 | (-> (request :put (str "/api/application/review_request"))
|
354 |
| - (authenticate api-key user) |
| 355 | + (authenticate api-key approver) |
355 | 356 | (json-body {:application-id app-id
|
356 | 357 | :round 0
|
357 | 358 | :comment "pls revu"
|
|
360 | 361 | :status))))
|
361 | 362 | (testing "check review event"
|
362 | 363 | (let [events (-> (request :get (str "/api/application/" app-id))
|
363 |
| - (authenticate api-key user) |
| 364 | + (authenticate api-key reviewer) |
364 | 365 | app
|
365 | 366 | read-body
|
366 | 367 | :application
|
367 | 368 | :events)]
|
368 |
| - (is (= [{:userid "developer" :comment nil :event "apply"} |
369 |
| - {:userid "alice" :comment "pls revu" :event "review-request"}] |
| 369 | + (is (= [{:userid applicant :comment nil :event "apply"} |
| 370 | + {:userid reviewer :comment "pls revu" :event "review-request"}] |
370 | 371 | (map #(select-keys % [:userid :comment :event]) events)))))
|
371 | 372 | (testing "send review"
|
372 | 373 | (is (= 200
|
|
378 | 379 | :comment "is ok"})
|
379 | 380 | app
|
380 | 381 | :status))))
|
381 |
| - (testing "check events" |
| 382 | + (testing "events of approver" |
382 | 383 | (let [events (-> (request :get (str "/api/application/" app-id))
|
383 |
| - (authenticate api-key user) |
| 384 | + (authenticate api-key approver) |
| 385 | + app |
| 386 | + read-body |
| 387 | + :application |
| 388 | + :events)] |
| 389 | + (is (= [{:userid applicant :comment nil :event "apply"} |
| 390 | + {:userid reviewer :comment "pls revu" :event "review-request"} |
| 391 | + {:userid reviewer :comment "is ok" :event "third-party-review"}] |
| 392 | + (map #(select-keys % [:userid :comment :event]) events))))) |
| 393 | + (testing "events of reviewer" |
| 394 | + (let [events (-> (request :get (str "/api/application/" app-id)) |
| 395 | + (authenticate api-key reviewer) |
| 396 | + app |
| 397 | + read-body |
| 398 | + :application |
| 399 | + :events)] |
| 400 | + (is (= [{:userid applicant :comment nil :event "apply"} |
| 401 | + {:userid reviewer :comment "pls revu" :event "review-request"} |
| 402 | + {:userid reviewer :comment "is ok" :event "third-party-review"}] |
| 403 | + (map #(select-keys % [:userid :comment :event]) events))))) |
| 404 | + (testing "events of applicant" |
| 405 | + (let [events (-> (request :get (str "/api/application/" app-id)) |
| 406 | + (authenticate api-key applicant) |
384 | 407 | app
|
385 | 408 | read-body
|
386 | 409 | :application
|
387 | 410 | :events)]
|
388 |
| - (is (= [{:userid "developer" :comment nil :event "apply"} |
389 |
| - {:userid "alice" :comment "pls revu" :event "review-request"} |
390 |
| - {:userid "alice" :comment "is ok" :event "third-party-review"}] |
391 |
| - (map #(select-keys % [:userid :comment :event]) events))))))) |
| 411 | + (is (= [{:userid applicant :comment nil :event "apply"} |
| 412 | + {:userid reviewer :comment nil :event "review-request"} |
| 413 | + {:userid reviewer :comment nil :event "third-party-review"}] |
| 414 | + (map #(select-keys % [:userid :comment :event]) events)) |
| 415 | + "does not see review event comments"))))) |
392 | 416 | ;; TODO non-happy path tests for review?
|
393 | 417 |
|
394 | 418 | ;; TODO test for event filtering when it gets implemented
|
|
0 commit comments