# Simulate form submission to update the advertisement
conn=
Phoenix.ConnTest.put(
conn,
"/advertisements/#{advertisement.id}",
%{"advertisement"=>updated_ad_data}
)
{:ok,state|>Map.put(:conn,conn)}
end
end
# Then the advertisement should be updated in the advertisements list
then_~r/^the advertisement should be updated in the advertisements list with the new title "(?<argument_one>[^"]+)" and price "(?<argument_two>[^"]+)" $/do
# Then the advertisement should retain the original title and price
then_~r/^the advertisement should retain the original title "(?<original_title>[^"]+)" and price "(?<original_price>[^"]+)" in the advertisements list$/do
# When the user tries to edit the advertisement and leaves the title and price empty
when_~r/^the user tries to edit the advertisement and leaves the title and price empty $/do
fnstate->
conn=state[:conn]
advertisement=state[:advertisement]
# Prepare invalid advertisement data
invalid_ad_data=%{"title"=>"","price"=>""}
# Simulate form submission with invalid data
conn=
Phoenix.ConnTest.put(
conn,
"/advertisements/#{advertisement.id}",
%{"advertisement"=>invalid_ad_data}
)
{:ok,state|>Map.put(:conn,conn)}
end
end
# Then the advertisement should retain the original title and price
then_~r/^the advertisement should retain the original title "(?<argument_one>[^"]+)" and price "(?<argument_two>[^"]+)" in the advertisements list $/do