Logo: a Lanna gable whose crossed kalae horns stand over a desk, gold on navy, with "Lanna Desk" and "Visas · stays · contracts" in Sarabun drawn as outlines. static/brand/ has the mark, the logo for light and for dark backgrounds and a one-color version; scripts/gen_logo.py makes them, the favicon and the header's mark from forms/fonts/Sarabun-Bold/SemiBold (SIL Open Font License, next to the Regular already there). `/` is now lannadesk.com's public page (templates/landing.html, static/landing.css): what Lanna Desk takes care of, how a client starts (write, open the link, sign first, we keep the dates), how the data is kept, contact@lannadesk.com and "Staff sign-in". It needs no session and shows no records. The back office's first page, the deadlines, moves to `/desk` (web::HOME): the header, the nav, the filter, the login's default target and the messages' links follow. Signing out now ends the session at id.cnx.network too. Kanidm names no end_session_endpoint, but its GET /ui/logout ends the session and clears its cookies (SameSite=Lax, so they come along on a top-level navigation). The logout form may only lead to this site (CSP form-action 'self'), so /signed-out sends the browser on with a refresh and offers the link as well; providers that are not Kanidm keep the old page. Checks: fmt, clippy, 109 unit and 57 integration tests (the public page open and free of records, /desk behind the sign-in, the sign-out page leading to the provider); the page at 1280 and 390 px; the header's mark in both themes; the style check on the README, PLAN and the page.
113 lines
4.0 KiB
Rust
113 lines
4.0 KiB
Rust
//! The deadlines of the demo people, on the Deadlines page, the people list
|
|
//! and the person's pages.
|
|
|
|
use axum::http::StatusCode;
|
|
use sqlx::PgPool;
|
|
|
|
use crate::common::local;
|
|
|
|
async fn person(pool: &PgPool, surname: &str) -> i64 {
|
|
sqlx::query_scalar("SELECT id FROM people WHERE surname = $1")
|
|
.bind(surname)
|
|
.fetch_one(pool)
|
|
.await
|
|
.unwrap()
|
|
}
|
|
|
|
#[sqlx::test(migrator = "visa::db::MIGRATOR")]
|
|
async fn the_demo_people_show_every_kind_of_deadline(pool: PgPool) {
|
|
visa::seed::demo(&pool, visa::dates::today()).await.unwrap();
|
|
let app = local(pool.clone());
|
|
|
|
let r = app.get("/desk").await;
|
|
assert_eq!(r.status, StatusCode::OK);
|
|
let page = r.text();
|
|
for expect in [
|
|
// Tomas: the report was due 11 days ago, a week of grace is over
|
|
"Late",
|
|
// Jane: 60 days of visa exemption, 20 left
|
|
"Extension of stay",
|
|
"Under 6 months",
|
|
"TM.30 for the address",
|
|
// Erika: back from a trip 79 days ago
|
|
"Window open",
|
|
"Work permit expiry",
|
|
// Sofia: still abroad with her visa
|
|
"Visa valid for entry",
|
|
] {
|
|
assert!(page.contains(expect), "the dashboard lacks {expect:?}");
|
|
}
|
|
assert!(
|
|
!page.contains("SAMPLE"),
|
|
"archived people have no deadlines"
|
|
);
|
|
// the most urgent first: Tomas's late report
|
|
let late = page.find("Late").unwrap();
|
|
let open = page.find("Window open").unwrap();
|
|
assert!(late < open);
|
|
|
|
let tomas = person(&pool, "Novak").await;
|
|
let p = app.get(&format!("/people/{tomas}")).await.text();
|
|
assert!(
|
|
p.contains("Basis: extension of stay for marriage to a Thai national."),
|
|
"{p}"
|
|
);
|
|
assert!(p.contains("Report in person and pay the 2,000 THB fine"));
|
|
let erika = person(&pool, "Mustermann").await;
|
|
let s = app.get(&format!("/people/{erika}/stay")).await.text();
|
|
assert!(
|
|
s.contains("Basis: extension of stay for work, kept by a re-entry permit."),
|
|
"{s}"
|
|
);
|
|
assert!(s.contains("Online until"), "Erika may still report online");
|
|
assert!(
|
|
s.contains("Demo Engineering Co., Ltd."),
|
|
"the work permit names the employer"
|
|
);
|
|
|
|
// the people list shows each person's next deadline
|
|
let list = app.get("/people").await.text();
|
|
assert!(list.contains("90-day report,"));
|
|
// the company filter on the dashboard
|
|
let company: i64 =
|
|
sqlx::query_scalar("SELECT id FROM companies WHERE name = 'Demo Accounting Partnership'")
|
|
.fetch_one(&pool)
|
|
.await
|
|
.unwrap();
|
|
let only = app.get(&format!("/desk?company={company}")).await.text();
|
|
assert!(only.contains("NOVAK, Tomas") && !only.contains("MUSTERMANN"));
|
|
}
|
|
|
|
#[sqlx::test(migrator = "visa::db::MIGRATOR")]
|
|
async fn a_new_arrival_brings_its_deadlines(pool: PgPool) {
|
|
let app = local(pool.clone());
|
|
let r = app
|
|
.post("/people", &[("surname", "Doe"), ("first_name", "Jane")])
|
|
.await;
|
|
let id = crate::common::id_from(r.location());
|
|
let page = app.get(&format!("/people/{id}")).await.text();
|
|
assert!(page.contains("No arrival is recorded yet."));
|
|
|
|
let today = visa::dates::today();
|
|
let arrived = (today - chrono::TimeDelta::days(30)).to_string();
|
|
let until = (today + chrono::TimeDelta::days(150)).to_string();
|
|
let r = app
|
|
.post(
|
|
&format!("/people/{id}/arrivals"),
|
|
&[
|
|
("arrived_on", arrived.as_str()),
|
|
("admission", "visa"),
|
|
("permitted_until", until.as_str()),
|
|
],
|
|
)
|
|
.await;
|
|
assert_eq!(r.status, StatusCode::SEE_OTHER, "{}", r.text());
|
|
let page = app.get(&format!("/people/{id}")).await.text();
|
|
assert!(page.contains("In Thailand since"));
|
|
assert!(page.contains("90-day report"));
|
|
assert!(page.contains("Calculated as the arrival plus 89 days"));
|
|
assert!(page.contains("No current address is recorded."));
|
|
let due = visa::dates::fmt_date(today + chrono::TimeDelta::days(59));
|
|
assert!(page.contains(&due), "the report is due on day 90: {due}");
|
|
}
|