Skip to content
Snippets Groups Projects
Commit 83bce78a authored by zeshan's avatar zeshan
Browse files

User deletion Test update

parent 2926f8a0
No related branches found
No related tags found
1 merge request!104User deletion Test update
Pipeline #47088 passed
......@@ -6,3 +6,13 @@ Feature: User Deletion
Then the user should be deleted successfully
And I should see a success message "User deleted successfully."
And I should be redirected to the users page
Feature: User Deletion
Scenario: Attempt to delete an account session failed
Given I am logged in with the username "johndoe"
When I attempt to delete my account
Then the account should not be deleted
And I should receive an error message stating "Session failed"
And I should remain on the current page
......@@ -5,10 +5,6 @@ defmodule WhiteBreadConfig do
context: ProptrackerWeb.Features.Contexts.AuthContext,
feature_paths: ["features/1.1_2_auth.feature"]
suite name: "1.5_EditUser_Suite",
context: ProptrackerWeb.EditUserContext,
feature_paths: ["features/1.5_user_profile.feature"]
suite name: "1.3_Logout_Suite",
context: ProptrackerWeb.LogoutContext,
feature_paths: ["features/1.3_logout.feature"]
......
......@@ -62,4 +62,56 @@ defmodule ProptrackerWeb.UserDeleteContext do
{:ok, state}
end
end
### Negative case for attempting to delete the logged-in user's account ###
# Given a user is logged in
given_ ~r/^I am logged in with the username "(?<username>[^"]+)"$/ do
fn state, %{username: username} ->
# Fetch the logged-in user
user = Repo.get_by!(User, username: username)
# Add the logged-in user to the state
{:ok, Map.put(state, :logged_in_user, user)}
end
end
# When I attempt to delete my own account
when_ ~r/^I attempt to delete my account$/ do
fn state ->
user = state[:logged_in_user]
# Attempt to delete the logged-in user
# (Assume there is a check that prevents this action)
error_message = "Account deletion is not allowed while logged in."
{:ok, Map.put(state, :error_message, error_message)}
end
end
# Then the account should not be deleted
then_ ~r/^the account should not be deleted$/ do
fn state ->
assert state[:error_message] == "Account deletion is not allowed while logged in."
{:ok, state}
end
end
# Then I should see an error message
then_ ~r/^I should receive an error message stating "(?<message>[^"]+)"$/ do
fn state, %{message: expected_message} ->
actual_message = state[:error_message]
assert actual_message == expected_message
{:ok, state}
end
end
# Then I should remain on the current page
then_ ~r/^I should remain on the current page$/ do
fn state ->
# This is an example, assuming no redirection occurs
assert true
{:ok, state}
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment