From b7743bed126d0c5f68ad77e804c35a7dbf10fc37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20Schl=C3=BCter?= Date: Mon, 20 Aug 2018 15:47:53 +0200 Subject: [PATCH] Use namespaced keywords only when modifying external data E.g. songs in the queue --- src/cljs/airsonic_ui/audio/playlist.cljs | 109 +++++++++--------- .../cljs/airsonic_ui/audio/playlist_test.cljs | 100 ++++++++-------- 2 files changed, 105 insertions(+), 104 deletions(-) diff --git a/src/cljs/airsonic_ui/audio/playlist.cljs b/src/cljs/airsonic_ui/audio/playlist.cljs index 0afc648..04ce733 100644 --- a/src/cljs/airsonic_ui/audio/playlist.cljs +++ b/src/cljs/airsonic_ui/audio/playlist.cljs @@ -13,51 +13,52 @@ (defmulti ->playlist "Creates a new playlist that behaves according to the given playback- and repeat-mode parameters." - (fn [queue playback-mode repeat-mode] playback-mode)) + (fn [queue & {:keys [playback-mode #_repeat-mode]}] + playback-mode)) (defn- mark-first-song [queue] - (let [[first-idx _] (find-where #(= 0 (:order %)) queue)] - (assoc-in queue [first-idx :currently-playing?] true))) + (let [[first-idx _] (find-where #(= 0 (:playlist/order %)) queue)] + (assoc-in queue [first-idx :playlist/currently-playing??] true))) -(defmethod ->playlist :playback-mode/linear - [queue playback-mode repeat-mode] - (let [queue (-> (mapv (fn [order song] (assoc song :order order)) (range) queue) +(defmethod ->playlist :linear + [queue & {:keys [playback-mode repeat-mode]}] + (let [queue (-> (mapv (fn [order song] (assoc song :playlist/order order)) (range) queue) (mark-first-song))] (->Playlist queue playback-mode repeat-mode))) (defn- -shuffle-songs [queue] (->> (shuffle (range (count queue))) - (mapv (fn [song order] (assoc song :order order)) queue))) + (mapv (fn [song order] (assoc song :playlist/order order)) queue))) -(defmethod ->playlist :playback-mode/shuffled - [queue playback-mode repeat-mode] - (let [queue (conj (mapv #(update % :order inc) (-shuffle-songs (rest queue))) - (assoc (first queue) :order 0 :currently-playing? true))] +(defmethod ->playlist :shuffled + [queue & {:keys [playback-mode repeat-mode]}] + (let [queue (conj (mapv #(update % :playlist/order inc) (-shuffle-songs (rest queue))) + (assoc (first queue) :playlist/order 0 :playlist/currently-playing?? true))] (->Playlist queue playback-mode repeat-mode))) (defn set-current-song "Marks a song in the queue as currently playing, given its ID" [playlist next-idx] - (let [[current-idx _] (find-where :currently-playing? (:queue playlist))] + (let [[current-idx _] (find-where :playlist/currently-playing?? (:queue playlist))] (-> (if current-idx - (update-in playlist [:queue current-idx] dissoc :currently-playing?) + (update-in playlist [:queue current-idx] dissoc :playlist/currently-playing??) playlist) - (assoc-in [:queue next-idx :currently-playing?] true)))) + (assoc-in [:queue next-idx :playlist/currently-playing??] true)))) (defn set-playback-mode "Changes the playback mode of a playlist and re-shuffles it if necessary" [playlist playback-mode] - (if (= playback-mode :playback-mode/shuffled) + (if (= playback-mode :shuffled) ;; for shuffled playlists we reorder the songs make sure that the currently ;; playing song has order 0 - (let [playlist (->playlist (:queue playlist) playback-mode (:repeat-mode playlist)) - [current-idx current-song] (find-where :currently-playing? (:queue playlist)) - [swap-idx _] (find-where #(= 0 (:order %)) (:queue playlist))] - (-> (assoc-in playlist [:queue current-idx :order] 0) - (assoc-in [:queue swap-idx :order] (:order current-song)))) + (let [playlist (->playlist (:queue playlist) :playback-mode playback-mode :repeat-mode (:repeat-mode playlist)) + [current-idx current-song] (find-where :playlist/currently-playing?? (:queue playlist)) + [swap-idx _] (find-where #(= 0 (:playlist/order %)) (:queue playlist))] + (-> (assoc-in playlist [:queue current-idx :playlist/order] 0) + (assoc-in [:queue swap-idx :playlist/order] (:playlist/order current-song)))) ;; for linear songs we just make sure that the current does not change - (let [[current-idx _] (find-where :currently-playing? (:queue playlist))] - (-> (->playlist (:queue playlist) playback-mode (:repeat-mode playlist)) + (let [[current-idx _] (find-where :playlist/currently-playing?? (:queue playlist))] + (-> (->playlist (:queue playlist) :playback-mode playback-mode :repeat-mode (:repeat-mode playlist)) (set-current-song current-idx))))) (defn set-repeat-mode @@ -69,71 +70,71 @@ "Returns the song in a playlist that is currently playing" [playlist] (->> (:queue playlist) - (filter :currently-playing?) + (filter :playlist/currently-playing??) (first))) (defmulti next-song "Advances the currently playing song" :repeat-mode) -(defmethod next-song :repeat-mode/none +(defmethod next-song :repeat-none [playlist] ;; this is pretty easy; get the next song and stop playing at the at - (let [[current-idx current-song] (find-where :currently-playing? (:queue playlist)) - [next-idx _] (find-where #(= (:order %) (inc (:order current-song))) (:queue playlist))] + (let [[current-idx current-song] (find-where :playlist/currently-playing?? (:queue playlist)) + [next-idx _] (find-where #(= (:playlist/order %) (inc (:playlist/order current-song))) (:queue playlist))] (update playlist :queue (fn [queue] (cond-> queue - current-idx (update current-idx dissoc :currently-playing?) - next-idx (assoc-in [next-idx :currently-playing?] true)))))) + current-idx (update current-idx dissoc :playlist/currently-playing??) + next-idx (assoc-in [next-idx :playlist/currently-playing??] true)))))) -(defmethod next-song :repeat-mode/single [playlist] playlist) +(defmethod next-song :repeat-single [playlist] playlist) -(defmethod next-song :repeat-mode/all +(defmethod next-song :repeat-all [playlist] - (let [[current-idx current-song] (find-where :currently-playing? (:queue playlist)) - [next-idx _] (find-where #(= (:order %) (inc (:order current-song))) (:queue playlist))] - (-> (update-in playlist [:queue current-idx] dissoc :currently-playing?) + (let [[current-idx current-song] (find-where :playlist/currently-playing?? (:queue playlist)) + [next-idx _] (find-where #(= (:playlist/order %) (inc (:playlist/order current-song))) (:queue playlist))] + (-> (update-in playlist [:queue current-idx] dissoc :playlist/currently-playing??) (update :queue (fn [queue] ;; we need special treatment here if we're playing the last song and ;; have a shuffled playlist because we need to re-shuffle (if next-idx - (assoc-in queue [next-idx :currently-playing?] true) + (assoc-in queue [next-idx :playlist/currently-playing??] true) (case (:playback-mode playlist) - :playback-mode/linear (assoc-in queue [0 :currently-playing?] true) - :playback-mode/shuffled (let [queue' (-shuffle-songs queue) - [next-idx _] (find-where #(= (:order %) 0) queue')] - (assoc-in queue' [next-idx :currently-playing?] true))))))))) + :linear (assoc-in queue [0 :playlist/currently-playing??] true) + :shuffled (let [queue' (-shuffle-songs queue) + [next-idx _] (find-where #(= (:playlist/order %) 0) queue')] + (assoc-in queue' [next-idx :playlist/currently-playing??] true))))))))) (defmulti previous-song "Goes back along the playback queue" :repeat-mode) -(defmethod previous-song :repeat-mode/single [playlist] playlist) +(defmethod previous-song :repeat-single [playlist] playlist) -(defmethod previous-song :repeat-mode/none [playlist] - (let [[current-idx current-song] (find-where :currently-playing? (:queue playlist)) - [next-idx _] (find-where #(= (:order %) (dec (:order current-song))) (:queue playlist))] +(defmethod previous-song :repeat-none [playlist] + (let [[current-idx current-song] (find-where :playlist/currently-playing?? (:queue playlist)) + [next-idx _] (find-where #(= (:playlist/order %) (dec (:playlist/order current-song))) (:queue playlist))] (set-current-song playlist (or next-idx current-idx)))) -(defmethod previous-song :repeat-mode/all [playlist] - (let [[_ current-song] (find-where :currently-playing? (:queue playlist)) - [next-idx _] (find-where #(= (:order %) - (rem (dec (:order current-song)) (count playlist))) +(defmethod previous-song :repeat-all [playlist] + (let [[_ current-song] (find-where :playlist/currently-playing?? (:queue playlist)) + [next-idx _] (find-where #(= (:playlist/order %) + (rem (dec (:playlist/order current-song)) (count playlist))) (:queue playlist))] (if next-idx (set-current-song playlist next-idx) - (if (= :playback-mode/shuffled (:playback-mode playlist)) + (if (= :shuffled (:playback-mode playlist)) (let [highest-order (dec (count playlist)) playlist (update playlist :queue -shuffle-songs) - [last-idx _] (find-where #(= (:order %) highest-order) (:queue playlist))] + [last-idx _] (find-where #(= (:playlist/order %) highest-order) (:queue playlist))] (set-current-song playlist last-idx)) - (set-current-song playlist (mod (dec (:order current-song)) (count playlist))))))) + (set-current-song playlist (mod (dec (:playlist/order current-song)) (count playlist))))))) (defn enqueue-last [playlist song] - (let [highest-order (last (sort (map :order (:queue playlist))))] - (update playlist :queue conj (assoc song :order (inc highest-order))))) + (let [highest-order (last (sort (map :playlist/order (:queue playlist))))] + (update playlist :queue conj (assoc song :playlist/order (inc highest-order))))) (defn enqueue-next [playlist song] - (let [[_ current-song] (find-where :currently-playing? (:queue playlist))] + (let [[_ current-song] (find-where :playlist/currently-playing?? (:queue playlist))] (update playlist :queue (fn [queue] - (-> (mapv #(if (> (:order %) (:order current-song)) (update % :order inc) %) queue) - (conj (assoc song :order (inc (:order current-song))))))))) + (-> (mapv #(if (> (:playlist/order %) (:playlist/order current-song)) (update % :playlist/order inc) %) queue) + (conj (assoc song :playlist/order (inc (:playlist/order current-song))))))))) diff --git a/test/cljs/airsonic_ui/audio/playlist_test.cljs b/test/cljs/airsonic_ui/audio/playlist_test.cljs index 15cb87d..37a1546 100644 --- a/test/cljs/airsonic_ui/audio/playlist_test.cljs +++ b/test/cljs/airsonic_ui/audio/playlist_test.cljs @@ -35,51 +35,51 @@ (testing "Playlist creation" (testing "should give us the correct current song" (let [queue (song-queue 10)] - (doseq [playback-mode [:playback-mode/linear, :playback-mode/shuffled] - repeat-mode [:repeat-mode/none, :repeat-mode/single, :repeat-mode/all]] + (doseq [playback-mode [:linear :shuffled] + repeat-mode [:repeat-none :repeat-single :repeat-all]] (is (same-song? (first queue) - (-> (playlist/->playlist queue playback-mode repeat-mode) + (-> (playlist/->playlist queue :playback-mode playback-mode :repeat-mode repeat-mode) (playlist/peek))) (str playback-mode ", " repeat-mode))))) (testing "should give us a playlist with the correct number of tracks" (let [queue (song-queue 100)] - (doseq [playback-mode [:playback-mode/linear, :playback-mode/shuffled] - repeat-mode [:repeat-mode/none, :repeat-mode/single, :repeat-mode/all]] + (doseq [playback-mode [:linear :shuffled] + repeat-mode [:repeat-none :repeat-single :repeat-all]] (is (= (count queue) - (count (playlist/->playlist queue playback-mode repeat-mode))) + (count (playlist/->playlist queue :playback-mode playback-mode :repeat-mode repeat-mode))) (str playback-mode ", " repeat-mode))))))) (deftest changing-playback-mode (testing "Changing playback mode" (testing "from linear to shuffled" (let [queue (song-queue 10) - linear (playlist/->playlist queue :playback-mode/linear :repeat-mode/none) - shuffled (playlist/set-playback-mode linear :playback-mode/shuffled)] + linear (playlist/->playlist queue :playback-mode :linear :repeat-mode :repeat-none) + shuffled (playlist/set-playback-mode linear :shuffled)] (testing "should re-order the tracks" - (is (not= (map :order (:queue shuffled)) (map :order (:queue linear))))) + (is (not= (map :playlist/order (:queue shuffled)) (map :playlist/order (:queue linear))))) (testing "should not change the currently playing track" (is (same-song? (playlist/peek linear) (playlist/peek shuffled)))) (testing "should not change the repeat mode" (is (= (:repeat-mode shuffled) (:repeat-mode linear)))))) (testing "from shuffled to linear" (let [queue (song-queue 10) - shuffled (playlist/->playlist queue :playback-mode/shuffled :repeat-mode/none) - linear (playlist/set-playback-mode shuffled :playback-mode/linear)] + shuffled (playlist/->playlist queue :playback-mode :shuffled :repeat-mode :repeat-none) + linear (playlist/set-playback-mode shuffled :linear)] (testing "should set the correct order for tracks" (is (every? #(apply same-song? %) (interleave queue (:queue linear)))) - (is (< (:order (first (:queue linear))) (:order (last (:queue linear)))))) + (is (< (:playlist/order (first (:queue linear))) (:playlist/order (last (:queue linear)))))) (testing "should not change the currently playing track" (is (same-song? (playlist/peek linear) (playlist/peek shuffled)))) (testing "should not change the repeat mode" (is (= (:repeat-mode shuffled) (:repeat-mode linear)))))))) -(deftest chaging-repeat-mode +(deftest changing-repeat-mode (testing "Changing the repeat mode" (testing "should not change the playback mode" - (doseq [playback-mode [:playback-mode/linear, :playback-mode/shuffled] - repeat-mode [:repeat-mode/none, :repeat-mode/single, :repeat-mode/all] - next-repeat-mode [:repeat-mode/none, :repeat-mode/single, :repeat-mode/all]] - (let [playlist (-> (playlist/->playlist (song-queue 1) playback-mode repeat-mode) + (doseq [playback-mode '(:linear :shuffled) + repeat-mode '(:repeat-none :repeat-single :repeat-all) + next-repeat-mode '(:repeat-none :repeat-single :repeat-all)] + (let [playlist (-> (playlist/->playlist (song-queue 1) :playback-mode playback-mode :repeat-mode repeat-mode) (playlist/set-repeat-mode next-repeat-mode))] (is (= playback-mode (:playback-mode playlist))) (is (= next-repeat-mode (:repeat-mode playlist)) @@ -87,9 +87,9 @@ (deftest linear-next-song (testing "Should follow the same order as the queue used for creation" - (doseq [repeat-mode [:repeat-mode/none :repeat-mode/all]] + (doseq [repeat-mode [:repeat-none :repeat-all]] (let [queue (song-queue 5) - playlist (playlist/->playlist queue :playback-mode/linear repeat-mode)] + playlist (playlist/->playlist queue :playback-mode :linear :repeat-mode repeat-mode)] (is (same-song? (nth queue 1) (-> (playlist/next-song playlist) (playlist/peek))) (str repeat-mode ", skipped once")) @@ -100,7 +100,7 @@ (testing "Should go back to the first song when repeat-mode is all and we played the last song") (testing "Should always give the same track when repeat-mode is single" (let [queue (song-queue 3) - playlist (playlist/->playlist queue :playback-mode/linear :repeat-mode/single) + playlist (playlist/->playlist queue :playback-mode :linear :repeat-mode :repeat-single) played-back (map playlist/peek (iterate playlist/next-song playlist))] (is (same-song? (first queue) (nth played-back 0))) (is (same-song? (first queue) (nth played-back 1))) @@ -108,29 +108,29 @@ (is (same-song? (first queue) (nth played-back 3)) "wrapping around"))) (testing "Should stop playing at the end of the queue when repeat-mode is none" (is (nil? (-> (song-queue 1) - (playlist/->playlist :playback-mode/linear :repeat-mode/none) + (playlist/->playlist :playback-mode :linear :repeat-mode :repeat-none) (playlist/next-song) (playlist/peek)))))) (deftest shuffled-next-song (testing "Should play every track once when called for the entire queue" - (doseq [repeat-mode '(:repeat-mode/none :repeat-mode/all)] + (doseq [repeat-mode '(:repeat-none :repeat-all)] (let [length 10 - playlist (playlist/->playlist (song-queue length) :playback-mode/shuffled repeat-mode) + playlist (playlist/->playlist (song-queue length) :playback-mode :shuffled :repeat-mode repeat-mode) played-tracks (->> (iterate playlist/next-song playlist) (map playlist/peek) (take length))] (is (= (count played-tracks) (count (set played-tracks))) (str repeat-mode))))) (testing "Should re-shuffle the playlist when wrapping around and repeat-mode is all" - (let [playlist (playlist/->playlist (song-queue 100) :playback-mode/shuffled :repeat-mode/all) - [last-idx _] (find-where #(= (:order %) 99) (:queue playlist))] - (is (not= (map :order (:queue playlist)) - (map :order (:queue (-> (playlist/set-current-song playlist last-idx) + (let [playlist (playlist/->playlist (song-queue 100) :playback-mode :shuffled :repeat-mode :repeat-all) + [last-idx _] (find-where #(= (:playlist/order %) 99) (:queue playlist))] + (is (not= (map :playlist/order (:queue playlist)) + (map :playlist/order (:queue (-> (playlist/set-current-song playlist last-idx) (playlist/next-song)))))))) (testing "Should always give the same track when repeat-mode is single" (let [queue (song-queue 3) - playlist (playlist/->playlist queue :playback-mode/shuffled :repeat-mode/single) + playlist (playlist/->playlist queue :playback-mode :shuffled :repeat-mode :repeat-single) played-back (map playlist/peek (iterate playlist/next-song playlist))] (is (same-song? (first queue) (nth played-back 0))) (is (same-song? (first queue) (nth played-back 1))) @@ -138,35 +138,35 @@ (is (same-song? (first queue) (nth played-back 3)) "wrapping around"))) (testing "Should stop playing at the end of the queue when repeat-mode is none" (is (nil? (-> (song-queue 1) - (playlist/->playlist :playback-mode/linear :repeat-mode/none) + (playlist/->playlist :playback-mode :linear :repeat-mode :repeat-none) (playlist/next-song) (playlist/peek)))))) (deftest linear-previous-song (testing "Should always give the same track when repeat-mode is single" (let [queue (song-queue 3) - playlist (playlist/->playlist queue :playback-mode/linear :repeat-mode/single) + playlist (playlist/->playlist queue :playback-mode :linear :repeat-mode :repeat-single) played-back (map playlist/peek (iterate playlist/next-song playlist))] (is (same-song? (first queue) (nth played-back 0))) (is (same-song? (first queue) (nth played-back 1))) (is (same-song? (first queue) (nth played-back 2))) (is (same-song? (first queue) (nth played-back 3)) "wrapping around"))) (testing "Should keep the linear order when repeat-mode is not single" - (doseq [repeat-mode '(:repeat-mode/none :repeat-mode/all)] + (doseq [repeat-mode '(:repeat-none :repeat-all)] (let [queue (song-queue 3) - playlist (playlist/->playlist queue :playback-mode/linear repeat-mode)] + playlist (playlist/->playlist queue :playback-mode :linear :repeat-mode repeat-mode)] (is (same-song? (nth queue 1) (-> (playlist/next-song playlist) (playlist/next-song) (playlist/previous-song) (playlist/peek))))))) (testing "Should repeatedly give the first song when repeat-mode is none" (let [queue (song-queue 3) - playlist (playlist/->playlist queue :playback-mode/linear :repeat-mode/none)] + playlist (playlist/->playlist queue :playback-mode :linear :repeat-mode :repeat-none)] (is (same-song? (first queue) (-> (playlist/previous-song playlist) (playlist/peek)))))) (testing "Should wrap around to last song when repeat-mode is all" (let [queue (song-queue 3) - playlist (playlist/->playlist queue :playback-mode/linear :repeat-mode/all)] + playlist (playlist/->playlist queue :playback-mode :linear :repeat-mode :repeat-all)] (is (same-song? (last queue) (-> (playlist/previous-song playlist) (playlist/peek))))))) @@ -174,16 +174,16 @@ (with-redefs [shuffle reverse] (testing "Should always give the same track when repeat-mode is single" (let [queue (song-queue 3) - playlist (playlist/->playlist queue :playback-mode/shuffled :repeat-mode/single) + playlist (playlist/->playlist queue :playback-mode :shuffled :repeat-mode :repeat-single) played-back (map playlist/peek (iterate playlist/next-song playlist))] (is (same-song? (first queue) (nth played-back 0))) (is (same-song? (first queue) (nth played-back 1))) (is (same-song? (first queue) (nth played-back 2))) (is (same-song? (first queue) (nth played-back 3)) "wrapping around"))) (testing "Should keep the playing order when repeat-mode is not single" - (doseq [repeat-mode '(:repeat-mode/none :repeat-mode/all)] + (doseq [repeat-mode '(:repeat-none :repeat-all)] (let [queue (song-queue 3) - playlist (playlist/->playlist queue :playback-mode/shuffled repeat-mode)] + playlist (playlist/->playlist queue :playback-mode :shuffled :repeat-mode repeat-mode)] (is (same-song? (playlist/peek playlist) (-> playlist (playlist/next-song) @@ -199,15 +199,15 @@ (str "for repeat mode " repeat-mode))))) (testing "Should re-shuffle when repeat-mode is all and we go back to before the first track" (let [playlist (with-redefs [shuffle identity] - (playlist/->playlist (song-queue 10) :playback-mode/shuffled :repeat-mode/all)) + (playlist/->playlist (song-queue 10) :playback-mode :shuffled :repeat-mode :repeat-all)) playlist' (with-redefs [shuffle reverse] (playlist/previous-song playlist))] - (is (not= (map :order (:queue playlist)) (map :order (:queue playlist')))))))) + (is (not= (map :playlist/order (:queue playlist)) (map :playlist/order (:queue playlist')))))))) (deftest set-current-song (testing "Should correctly set the new song" (let [queue (song-queue 3) - playlist (playlist/->playlist queue :playback-mode/shuffled :repeat-mode/single) + playlist (playlist/->playlist queue :playback-mode :shuffled :repeat-mode :repeat-single) current-track (first queue) next-track (-> (playlist/set-current-song playlist 1) (playlist/peek))] @@ -216,11 +216,11 @@ (deftest enqueue-last (testing "Should make sure the song is played last" - (doseq [playback-mode '(:playback-mode/linear :playback-mode/shuffled) - repeat-mode '(:repeat-mode/none :repeat-mode/all)] + (doseq [playback-mode '(:linear :shuffled) + repeat-mode '(:repeat-none :repeat-all)] (let [length 5, queue (song-queue length) playlist (with-redefs [shuffle identity] - (playlist/->playlist queue playback-mode repeat-mode)) + (playlist/->playlist queue :playback-mode playback-mode :repeat-mode repeat-mode)) played-back (->> (iterate playlist/next-song playlist) (take (dec length)) (map #(:id (playlist/peek %))) @@ -233,15 +233,15 @@ (:id)))) (str "for " playback-mode ", " repeat-mode))))) (testing "Should not change the order of the songs already in queue" - (doseq [playback-mode '(:playback-mode/linear :playback-mode/shuffled) - repeat-mode '(:repeat-mode/none :repeat-mode/all)] + (doseq [playback-mode '(:linear :shuffled) + repeat-mode '(:repeat-none :repeat-all)] (let [length 5, queue (song-queue length) - playlist (playlist/->playlist queue playback-mode repeat-mode) + playlist (playlist/->playlist queue :playback-mode playback-mode :repeat-mode repeat-mode) played-back-songs (fn played-back-songs [playlist] (->> (iterate playlist/next-song playlist) (take length) (map playlist/peek) - (map :order))) + (map :playlist/order))) played-back (played-back-songs playlist) played-back' (played-back-songs (playlist/enqueue-last playlist (song)))] (is (= played-back played-back') @@ -249,10 +249,10 @@ (deftest enqueue-next (testing "Should play the song after the currently playing song" - (doseq [playback-mode '(:playback-mode/linear :playback-mode/shuffled) - repeat-mode '(:repeat-mode/none :repeat-mode/all)] + (doseq [playback-mode '(:linear :shuffled) + repeat-mode '(:repeat-none :repeat-all)] (let [length 5, queue (song-queue length) - playlist (playlist/->playlist queue playback-mode repeat-mode) + playlist (playlist/->playlist queue :playback-mode playback-mode :repeat-mode repeat-mode) next-song (song)] (is (same-song? next-song (-> (playlist/enqueue-next playlist next-song) (playlist/next-song)