1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
6 use Pleroma.Web.ConnCase, async: true
8 alias Pleroma.Web.CommonAPI
10 describe "POST /api/v1/pleroma/scrobble" do
11 test "works correctly" do
12 %{conn: conn} = oauth_access(["write"])
16 |> put_req_header("content-type", "application/json")
17 |> post("/api/v1/pleroma/scrobble", %{
18 "title" => "lain radio episode 1",
20 "album" => "lain radio",
22 "externalLink" => "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+1"
25 assert %{"title" => "lain radio episode 1"} = json_response_and_validate_schema(conn, 200)
29 describe "GET /api/v1/pleroma/accounts/:id/scrobbles" do
30 test "works correctly" do
31 %{user: user, conn: conn} = oauth_access(["read"])
34 CommonAPI.listen(user, %{
35 title: "lain radio episode 1",
38 externalLink: "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+1"
42 CommonAPI.listen(user, %{
43 title: "lain radio episode 2",
46 externalLink: "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+2"
50 CommonAPI.listen(user, %{
51 title: "lain radio episode 3",
54 externalLink: "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+3"
57 conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/scrobbles")
59 result = json_response_and_validate_schema(conn, 200)
61 assert length(result) == 3