Client link: read and sign the agreements first, then the details
While an active agreement is unsigned in its current version, the link's other parts are locked: the overview shows them dashed with "After signing" and no Send button, and every other page of the link (About you, Contact, Passport, Address, Documents, Send) redirects to the agreement and takes nothing posted to it. A new version locks them again until it is signed. Checks: fmt, clippy, 105 unit and 56 integration tests (tests/agreements.rs asserts the redirects, that nothing posted before signing is saved, and that the parts open after signing and close at a new version); the locked overview checked on a phone in light and dark.
This commit is contained in:
1 parent
d0e13dffd2
commit
506221ecd0
6 files changed
+120
-17
No files matched your search
@@ -187,6 +187,39 @@ async fn the_client_signs_and_signs_again_after_a_change(pool: PgPool) {
|
||||
assert!(t.contains("value=\"Hans Becker\""), "{t}");
|
||||
assert!(t.contains("/static/signature.js"));
|
||||
|
||||
// nothing else opens before the agreement is signed, and nothing is
|
||||
// taken: every part leads to it, Send included
|
||||
assert!(o.contains("First read and sign"), "{o}");
|
||||
assert!(
|
||||
o.contains("After signing") && !o.contains("send-btn"),
|
||||
"{o}"
|
||||
);
|
||||
for part in ["about", "contact", "passport", "address", "documents"] {
|
||||
let r = app.get(&format!("{base}/{part}")).await;
|
||||
assert_eq!(r.status, StatusCode::SEE_OTHER, "{part}");
|
||||
assert_eq!(r.location(), uri, "{part}");
|
||||
}
|
||||
let r = client_post(
|
||||
&app,
|
||||
&format!("{base}/contact"),
|
||||
&csrf,
|
||||
&[("phone", "123")],
|
||||
&[],
|
||||
)
|
||||
.await;
|
||||
assert_eq!(r.location(), uri);
|
||||
let r = client_post(&app, &format!("{base}/send"), &csrf, &[], &[]).await;
|
||||
assert_eq!(r.location(), uri);
|
||||
let (phone, open): (String, bool) = sqlx::query_as(
|
||||
"SELECT p.phone, l.closed_at IS NULL FROM people p JOIN client_links l ON l.person_id = p.id \
|
||||
WHERE p.id = $1",
|
||||
)
|
||||
.bind(person)
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!((phone.as_str(), open), ("", true));
|
||||
|
||||
// without the box ticked, or with a broken drawing
|
||||
let r = client_post(
|
||||
&app,
|
||||
@@ -270,6 +303,13 @@ async fn the_client_signs_and_signs_again_after_a_change(pool: PgPool) {
|
||||
assert_eq!(file.status, StatusCode::OK);
|
||||
assert!(file.bytes.starts_with(b"%PDF-"));
|
||||
|
||||
// signed: the other parts open
|
||||
assert_eq!(
|
||||
app.get(&format!("{base}/about")).await.status,
|
||||
StatusCode::OK
|
||||
);
|
||||
assert!(app.get(&base).await.text().contains("send-btn"));
|
||||
|
||||
// signed: the page says so, a second post changes nothing
|
||||
assert!(
|
||||
app.get(&uri)
|
||||
@@ -347,6 +387,8 @@ async fn the_client_signs_and_signs_again_after_a_change(pool: PgPool) {
|
||||
.await;
|
||||
assert_eq!(r.status, StatusCode::UNPROCESSABLE_ENTITY);
|
||||
assert!(r.text().contains("changed the text while you read it"));
|
||||
// and the parts close again until it is signed
|
||||
assert_eq!(app.get(&format!("{base}/about")).await.location(), uri);
|
||||
|
||||
// switched off: no longer asked for
|
||||
app.post(
|
||||
|
||||
Reference in new issue
Block a user