Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PropTrackr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mdmuradalahi
PropTrackr
Commits
a7f1f039
Commit
a7f1f039
authored
4 months ago
by
mdmuradalahi
Browse files
Options
Downloads
Patches
Plain Diff
5.3_TDD
parent
0972414f
No related branches found
No related tags found
No related merge requests found
Pipeline
#47147
failed
4 months ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/test.exs
+2
-2
2 additions, 2 deletions
config/test.exs
test/proptracker_web/controllers/5.3_session_test.exs
+52
-0
52 additions, 0 deletions
test/proptracker_web/controllers/5.3_session_test.exs
with
54 additions
and
2 deletions
config/test.exs
+
2
−
2
View file @
a7f1f039
...
...
@@ -16,7 +16,7 @@ config :proptracker, Proptracker.Repo,
# We don't run a server during test. If one is required,
# you can enable the server option below.
config
:proptracker
,
ProptrackerWeb
.
Endpoint
,
http:
[
ip:
{
127
,
0
,
0
,
1
},
port:
400
0
],
http:
[
ip:
{
127
,
0
,
0
,
1
},
port:
400
1
],
secret_key_base:
"iHDmR++9wq05btCX44LZWV6tfBprf9xTg5mr+vNSW0mM8G5Y2lH2RTHrWVisVwHL"
,
server:
true
...
...
@@ -37,5 +37,5 @@ config :phoenix_live_view,
enable_expensive_runtime_checks:
true
# Hound Configuration
config
:hound
,
driver:
"chrome_driver"
,
port:
58968
# update the port according to your local chrome_drive message
config
:hound
,
driver:
"chrome_driver"
,
port:
62493
# update the port according to your local chrome_drive message
config
:proptracker
,
sql_sandbox:
true
This diff is collapsed.
Click to expand it.
test/proptracker_web/controllers/5.3_session_test.exs
0 → 100644
+
52
−
0
View file @
a7f1f039
defmodule
ProptrackerWeb
.
SessionControllerTest
do
use
ProptrackerWeb
.
ConnCase
alias
Proptracker
.
Accounts
.
User
alias
Proptracker
.
Repo
@valid_user_attrs
%{
name:
"Test User"
,
username:
"test_user"
,
password:
"password123"
,
date_of_birth:
~D[1995-01-01]
,
phone_number:
"123456789"
}
# Helper to create a user in the database
defp
create_user
(
_
)
do
{
:ok
,
user
}
=
Repo
.
insert
(%
User
{}
|>
User
.
changeset
(
@valid_user_attrs
))
%{
user:
user
}
end
describe
"User login"
do
setup
[
:create_user
]
test
"successful login redirects to advertisements page"
,
%{
conn:
conn
,
user:
user
}
do
# Simulate a POST request to the login endpoint
conn
=
post
(
conn
,
"/login"
,
user:
%{
username:
user
.
username
,
password:
user
.
password
})
# Assert the user is redirected to the advertisements page
assert
redirected_to
(
conn
)
==
"/advertisements"
# Assert a flash message is set
assert
get_flash
(
conn
,
:info
)
==
"Logged in successfully."
# Assert the session contains the user ID
assert
get_session
(
conn
,
:user_id
)
==
user
.
id
end
test
"failed login due to invalid credentials"
,
%{
conn:
conn
}
do
# Simulate a POST request to the login endpoint with incorrect credentials
conn
=
post
(
conn
,
"/login"
,
user:
%{
username:
"wrong_username"
,
password:
"wrong_password"
})
# Assert the response renders the login page
assert
html_response
(
conn
,
200
)
=~
"Invalid username or password."
# Assert a flash error message is set
assert
get_flash
(
conn
,
:error
)
==
"Invalid username or password."
# Assert the session does not contain a user ID
refute
get_session
(
conn
,
:user_id
)
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment