Add an integration test for sign in
This commit is contained in:
parent
8c70f90234
commit
6b043620b8
1 changed files with 36 additions and 0 deletions
|
|
@ -137,3 +137,39 @@ async fn sign_up() -> Result<(), Box<dyn Error>> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct SignInFormData {
|
||||
email: String,
|
||||
password: String,
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn sign_in() -> Result<(), Box<dyn Error>> {
|
||||
// Arrange.
|
||||
let state = utils::common_state().await?;
|
||||
let _user_id = utils::create_user(
|
||||
&state.db_connection,
|
||||
"president@spaceball.planet",
|
||||
"12345678",
|
||||
)
|
||||
.await?;
|
||||
let server = TestServer::new(app::make_service(state))?;
|
||||
|
||||
// Act.
|
||||
let response = server
|
||||
.post("/signin")
|
||||
.form(&SignInFormData {
|
||||
email: "president@spaceball.planet".into(),
|
||||
password: "12345678".into(),
|
||||
})
|
||||
.await;
|
||||
|
||||
// Assert.
|
||||
response.assert_status_see_other(); // Redirection after successful sign in.
|
||||
response.assert_text("");
|
||||
response.assert_header("location", "/en/"); // English is the default language.
|
||||
dbg!(&response);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue