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",
24 assert %{"title" => "lain radio episode 1"} = json_response_and_validate_schema(conn, 200)
28 describe "GET /api/v1/pleroma/accounts/:id/scrobbles" do
29 test "works correctly" do
30 %{user: user, conn: conn} = oauth_access(["read"])
33 CommonAPI.listen(user, %{
34 title: "lain radio episode 1",
40 CommonAPI.listen(user, %{
41 title: "lain radio episode 2",
47 CommonAPI.listen(user, %{
48 title: "lain radio episode 3",
53 conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/scrobbles")
55 result = json_response_and_validate_schema(conn, 200)
57 assert length(result) == 3