mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-07 02:33:39 +02:00
Move navigation to interceptor
Squashed commit of the following:
commit c8bf5e0cb4fd95935e06dc46dda38256f5bb970f
Author: Arne Schlüter <arne@schlueter.is>
Date: Wed Aug 1 11:37:43 2018 +0200
Start credential verification only if there are previous credentials
commit 61e6f2e7f2fb4d01e59c71c5980b1b761fa0bf83
Author: Arne Schlüter <arne@schlueter.is>
Date: Wed Aug 1 10:22:31 2018 +0200
Make `dispatches?` helper return a boolean
commit 4dc10acd5f1eae616d62c24e3cb9685e4e595f04
Author: Arne Schlüter <arne@schlueter.is>
Date: Wed Aug 1 09:19:49 2018 +0200
Add joker for linting
commit 7069febff0ed49be5c60e6787bfc9dc5b758917b
Author: Arne Schlüter <arne@schlueter.is>
Date: Tue Jul 31 14:17:41 2018 +0200
Implement navigation as interceptor
FIXME: Unauthorized access doesn't redirect to `#/login?redirect=...`
commit 60f9f03dd86f48234133e76dd57c067afb7a74d4
Author: Arne Schlüter <arne@schlueter.is>
Date: Wed Jul 18 19:35:47 2018 +0200
Make booting explicit and prepare for :navigate interceptor
This commit is contained in:
parent
852a3193ab
commit
727d454871
14 changed files with 257 additions and 221 deletions
|
|
@ -1,41 +1,27 @@
|
|||
(ns airsonic-ui.subs-test
|
||||
(:require [cljs.test :refer [deftest testing is]]
|
||||
[airsonic-ui.db :as db]
|
||||
[airsonic-ui.fixtures :refer [song] :as fixtures]
|
||||
[airsonic-ui.fixtures :as fixtures]
|
||||
[airsonic-ui.utils.api :as api]
|
||||
[airsonic-ui.events :as ev]
|
||||
[airsonic-ui.subs :as subs]))
|
||||
|
||||
(def creds {:credentials {:u "test"
|
||||
:p "test"
|
||||
:server "https://demo.airsonic.io/"}})
|
||||
|
||||
(deftest is-booting
|
||||
(testing "Should be true when provided the initial state"
|
||||
(is (true? (subs/is-booting? db/default-db [:_]))))
|
||||
(testing "Should be true when we have credentials but no response yet"
|
||||
(is (true? (-> (ev/restore-previous-session {:store creds} [:_])
|
||||
(ev/credentials-found [:_])
|
||||
:db
|
||||
(subs/is-booting? [:_])))))
|
||||
(testing "Should be false when the login screen is shown"
|
||||
(is (false? (-> (ev/restore-previous-session {} [:_])
|
||||
(ev/credentials-not-found [:_])
|
||||
:db
|
||||
(subs/is-booting? [:_])))))
|
||||
(let [{:keys [u p server]} (:credentials creds)]
|
||||
(testing "Should be false after we verified our credentials with the server"
|
||||
(is (false? (-> (ev/credentials-verified {:db {}} [:_ u p server])
|
||||
:db
|
||||
(subs/is-booting? [:_])))))
|
||||
(testing "Should be false after the server rejected our credentials"
|
||||
(is (false? (-> (ev/credentials-verification-failure {} [:_ (:auth-failure fixtures/responses)])
|
||||
:db
|
||||
(subs/is-booting? [:_]))))))
|
||||
(testing "Should be false when a user logged out voluntarily"
|
||||
(is (false? (-> (ev/logout {} [:_])
|
||||
:db
|
||||
(subs/is-booting? [:_]))))))
|
||||
(deftest booting
|
||||
(let [route [:some-route nil nil]
|
||||
verified-credentials (assoc fixtures/credentials :verified? true)
|
||||
is-booting? (fn is-booting? [db]
|
||||
(subs/is-booting? db [:subs/is-booting?]))]
|
||||
(testing "Should be false when we don't have previous credentials"
|
||||
(is (not (is-booting? {:current-route route})))
|
||||
(is (not (is-booting? {:current-route route
|
||||
:credentials {}}))) )
|
||||
(testing "Should be true when we have unverified credentials"
|
||||
(is (true? (is-booting? {:current-route route
|
||||
:credentials fixtures/credentials}))))
|
||||
(testing "Should be false when we have verified credentials"
|
||||
(is (not (is-booting? {:current-route route
|
||||
:credentials verified-credentials}))))
|
||||
(testing "Should be true when routing is not yet set up"
|
||||
(is (true? (is-booting? {:current-route nil
|
||||
:credentials verified-credentials}))))))
|
||||
|
||||
(deftest cover-images
|
||||
(let [credentials {:server "https://foo.bar"
|
||||
|
|
@ -44,6 +30,6 @@
|
|||
(testing "Should give the correct path once the credentials are set"
|
||||
(is (= (api/cover-url (:server credentials)
|
||||
(select-keys credentials [:u :p])
|
||||
song
|
||||
fixtures/song
|
||||
48)
|
||||
(subs/cover-url [credentials] [:_ song 48]))))))
|
||||
(subs/cover-url [credentials] [:subs/cover-image fixtures/song 48]))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue