Skip to content

Commit

Permalink
Added Tests to Ensure An Image Is seen if approved
Browse files Browse the repository at this point in the history
  • Loading branch information
MICHAELMUNAVU83 committed Nov 13, 2024
1 parent 276b5e2 commit 9022562
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ defmodule AniminaWeb.BookmarksComponents do
<img
class="object-cover rounded-lg aspect-square h-24 w-24"
src={Photo.get_optimized_photo_to_use(@bookmark.user.profile_photo, :normal)}
id={"image-for-bookmarked-user-#{@bookmark.user.id}"}
/>
<p
:if={
Expand Down
1 change: 1 addition & 0 deletions lib/animina_web/components/profile/profile_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ defmodule AniminaWeb.ProfileComponents do
<img
class="object-cover w-8 h-8 rounded-full"
src={Photo.get_optimized_photo_to_use(@user.profile_photo, :normal)}
id={"profile-image-for-receiver-#{@user.id}"}
/>
<p
:if={
Expand Down
54 changes: 54 additions & 0 deletions test/animina_web/live/bookmark_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,59 @@ defmodule AniminaWeb.BookmarkTest do

assert html =~ Ash.CiString.value(private_user.username)
end

test "If a bookmarked profile has an approved profile image , they can see it",
%{
conn: conn,
public_user: public_user,
private_user: private_user
} do
# we visit the page of private_user , a bookmark and visit_log_entry is created
{:ok, _index_live, _html} =
conn
|> login_user(%{
"username_or_email" => public_user.username,
"password" => "MichaelTheEngineer"
})
|> live(~p"/#{private_user.username}")

{:ok, index_live, html} =
conn
|> login_user(%{
"username_or_email" => public_user.username,
"password" => "MichaelTheEngineer"
})
|> live(~p"/my/bookmarks")

assert html =~ "Bookmarks"

assert html =~ "Liked Profiles"

refute html =~ Ash.CiString.value(private_user.username)

{_, {:live_redirect, %{kind: :push, to: url}}} =
index_live
|> element("#visited_tab", "Visited")
|> render_click()

assert url == "/my/bookmarks/visited"

{:ok, index_live, html} =
conn
|> login_user(%{
"username_or_email" => public_user.username,
"password" => "MichaelTheEngineer"
})
|> live("#{url}")

assert html =~ "Visited Profiles"
refute html =~ "Liked Profiles"

assert html =~ Ash.CiString.value(private_user.username)

# We now ensure that the profile image of the bookmarked user is displayed as the image is approved
assert has_element?(index_live, "#image-for-bookmarked-user-#{private_user.id}")
end
end

defp create_public_user do
Expand Down Expand Up @@ -413,6 +466,7 @@ defmodule AniminaWeb.BookmarkTest do
original_filename: file_path_without_uploads,
size: 100,
ext: "jpg",
state: :approved,
mime: "image/jpeg"
})
end
Expand Down
22 changes: 22 additions & 0 deletions test/animina_web/live/chat_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ defmodule AniminaWeb.ChatTest do
assert html =~ "#{private_user.height}"
end

test "You see a user's Mini Profile with their image if you visit their chat live", %{
conn: conn,
public_user: public_user,
private_user: private_user
} do
# we visit the message box for public user and private user

{:ok, index_live, html} =
conn
|> login_user(%{
"username_or_email" => public_user.username,
"password" => "MichaelTheEngineer"
})
|> live(~p"/#{public_user.username}/messages/#{private_user.username}")

assert html =~ private_user.name
assert html =~ "#{private_user.height}"

# We now ensure that the profile image of the user you are texting is seen in the chat box
assert has_element?(index_live, "#profile-image-for-receiver-#{private_user.id}")
end

test "You can send a message through the message box", %{
conn: conn,
public_user: public_user,
Expand Down

0 comments on commit 9022562

Please sign in to comment.