From e4ef4db31c83088adf66ac676d9b993a23637384 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Fri, 27 Oct 2023 11:40:48 +0200 Subject: [PATCH] Remove deprecated tests --- test/ret_web/channels/entity_test.exs | 93 +------------------ .../save_entity_state_payload_promotable.json | 54 ----------- ...ave_entity_state_payload_unpromotable.json | 54 ----------- 3 files changed, 1 insertion(+), 200 deletions(-) delete mode 100644 test/support/utils/save_entity_state_payload_promotable.json delete mode 100644 test/support/utils/save_entity_state_payload_unpromotable.json diff --git a/test/ret_web/channels/entity_test.exs b/test/ret_web/channels/entity_test.exs index 3c734683d..c58300c01 100644 --- a/test/ret_web/channels/entity_test.exs +++ b/test/ret_web/channels/entity_test.exs @@ -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" => %{}} @@ -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", %{ @@ -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 @@ -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, diff --git a/test/support/utils/save_entity_state_payload_promotable.json b/test/support/utils/save_entity_state_payload_promotable.json deleted file mode 100644 index 06f7bd550..000000000 --- a/test/support/utils/save_entity_state_payload_promotable.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "nid": "hvpg97x", - "create_message": { - "version": 1, - "networkId": "hvpg97x", - "prefabName": "media", - "initialData": { - "src": "https://hubs.local:4000/files/101ac987-61f4-4645-b512-def3f0336fdf.jpg?token=2bbfa5ff552a159cff50b8bc212a477c", - "recenter": true, - "resize": true, - "animateLoad": true, - "fileId": "101ac987-61f4-4645-b512-def3f0336fdf", - "isObjectMenuTarget": true - } - }, - "updates": [ - { - "root_nid": "hvpg97x", - "nid": "hvpg97x", - "update_message": { - "nid": "hvpg97x", - "lastOwnerTime": 1157850816, - "timestamp": 1157852116, - "owner": "9eac3551-20d7-4b04-80fc-2009b5e8fe10", - "data": { - "networked-transform": { - "version": 1, - "data": { - "position": [ - 44.335304260253906, - 1.4967195987701416, - -6.183996677398682 - ], - "rotation": [ - -0.03446304053068161, - 0.6161360144615173, - 0.026999054476618767, - 0.7864221334457397 - ], - "scale": [ - 1, - 1, - 1 - ] - } - } - } - } - } - ], - "file_id": "101ac987-61f4-4645-b512-def3f0336fdf", - "file_access_token": "2bbfa5ff552a159cff50b8bc212a477c", - "promotion_token": "1701f2fc68081168c7b19ebfabc76dc6" -} diff --git a/test/support/utils/save_entity_state_payload_unpromotable.json b/test/support/utils/save_entity_state_payload_unpromotable.json deleted file mode 100644 index d28bf44b3..000000000 --- a/test/support/utils/save_entity_state_payload_unpromotable.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "nid": "hvpg97x", - "create_message": { - "version": 1, - "networkId": "hvpg97x", - "prefabName": "media", - "initialData": { - "src": "https://hubs.local:4000/files/101ac987-61f4-4645-b512-def3f0336fdf.jpg?token=2bbfa5ff552a159cff50b8bc212a477c", - "recenter": true, - "resize": true, - "animateLoad": true, - "fileId": "101ac987-61f4-4645-b512-def3f0336fdf", - "isObjectMenuTarget": true - } - }, - "updates": [ - { - "root_nid": "hvpg97x", - "nid": "hvpg97x", - "update_message": { - "nid": "hvpg97x", - "lastOwnerTime": 1157792473, - "timestamp": 1157845450, - "owner": "9eac3551-20d7-4b04-80fc-2009b5e8fe10", - "data": { - "networked-transform": { - "version": 1, - "data": { - "position": [ - 44.30113220214844, - 1.4787851572036743, - -5.9799041748046875 - ], - "rotation": [ - -0.032501693814992905, - 0.6693336963653564, - 0.029331713914871216, - 0.7416709065437317 - ], - "scale": [ - 1, - 1, - 1 - ] - } - } - } - } - } - ], - "file_id": "101ac987-61f4-4645-b512-def3f0336fdf", - "promotion_token": "1701f2fc68081168c7b19ebfabc76dc6", - "file_access_token": "dasfaisodfjoein0ewoINCORRECT" -}