Skip to content

Commit

Permalink
Remove deprecated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Oct 27, 2023
1 parent 1796a8a commit e4ef4db
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 200 deletions.
93 changes: 1 addition & 92 deletions test/ret_web/channels/entity_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ defmodule RetWeb.EntityTest do
import RetWeb.EntityTestUtils, only: [read_json: 1]

alias RetWeb.SessionSocket
alias Ret.{Repo, HubRoleMembership, Storage}
alias Ret.{Repo, HubRoleMembership}

@payload_save_entity_state read_json("save_entity_state_payload.json")
@payload_save_entity_state_2 read_json("save_entity_state_payload_2.json")
@payload_save_entity_state_promotable read_json("save_entity_state_payload_promotable.json")
@payload_save_entity_state_unpromotable read_json("save_entity_state_payload_unpromotable.json")
@payload_update_entity_state read_json("update_entity_state_payload.json")
@payload_delete_entity_state read_json("delete_entity_state_payload.json")
@default_join_params %{"profile" => %{}, "context" => %{}}
Expand Down Expand Up @@ -72,52 +70,6 @@ defmodule RetWeb.EntityTest do
reason: :unauthorized
}
end

test "save_entity_state succeeds if provided correct promotion keys", %{
socket: socket,
hub: hub,
account: account
} do
%HubRoleMembership{hub: hub, account: account} |> Repo.insert!()
temp_file = generate_temp_file("test")

{:ok, _, socket} =
subscribe_and_join(socket, "hub:#{hub.hub_sid}", join_params_for_account(account))

{:ok, uuid} = Storage.store(%Plug.Upload{path: temp_file}, "text/plain", "secret")

updated_map =
@payload_save_entity_state_promotable
|> Map.put("file_id", uuid)
|> Map.put("file_access_token", "secret")

assert_reply push(socket, "save_entity_state", updated_map), :ok
end

test "save_entity_state fails if provided incorrect promotion parameters", %{
socket: socket,
hub: hub,
account: account
} do
%HubRoleMembership{hub: hub, account: account} |> Repo.insert!()
temp_file = generate_temp_file("test2")

{:ok, _, socket} =
subscribe_and_join(socket, "hub:#{hub.hub_sid}", join_params_for_account(account))

{:ok, uuid} = Storage.store(%Plug.Upload{path: temp_file}, "text/plain", "secret")

updated_map =
@payload_save_entity_state_unpromotable
|> Map.put("file_id", uuid)
|> Map.put("file_access_token", " not_secret")

assert_reply push(socket, "save_entity_state", updated_map),
:error,
%{
reason: :not_allowed
}
end
end

test "update_entity_state overwrites previous entity state", %{
Expand Down Expand Up @@ -159,26 +111,6 @@ defmodule RetWeb.EntityTest do
}
end

test "delete_entity_state replies with error if owned file does not exist", %{
socket: socket,
hub: hub,
account: account
} do
%HubRoleMembership{hub: hub, account: account} |> Repo.insert!()

{:ok, _, socket} =
subscribe_and_join(socket, "hub:#{hub.hub_sid}", join_params_for_account(account))

push(socket, "save_entity_state", @payload_save_entity_state)

non_existent_file_payload =
Map.put(@payload_delete_entity_state, "file_id", "non_existent_file_id")

assert_reply push(socket, "delete_entity_state", non_existent_file_payload), :error, %{
reason: :file_not_found
}
end

test "delete_entity_state replies with error if not authorized", %{
socket: socket,
hub: hub
Expand All @@ -190,29 +122,6 @@ defmodule RetWeb.EntityTest do
}
end

test "delete_entity_state deletes the entity and deactivates the owned file if file_id is present",
%{
socket: socket,
hub: hub,
account: account,
owned_file: owned_file
} do
%HubRoleMembership{hub: hub, account: account} |> Repo.insert!()

{:ok, _, socket} =
subscribe_and_join(socket, "hub:#{hub.hub_sid}", join_params_for_account(account))

push(socket, "save_entity_state", @payload_save_entity_state)

payload_with_file_id =
Map.put(@payload_delete_entity_state, "file_id", owned_file.owned_file_uuid)

assert_reply push(socket, "delete_entity_state", payload_with_file_id), :ok

updated_file = owned_file |> Repo.reload()
assert updated_file.state == :inactive
end

test "delete_entity_state deletes the entity with the matching nid", %{
socket: socket,
hub: hub,
Expand Down
54 changes: 0 additions & 54 deletions test/support/utils/save_entity_state_payload_promotable.json

This file was deleted.

54 changes: 0 additions & 54 deletions test/support/utils/save_entity_state_payload_unpromotable.json

This file was deleted.

0 comments on commit e4ef4db

Please sign in to comment.