test: overview
This commit is contained in:
parent
46669d206f
commit
fc63464210
@ -0,0 +1,46 @@
|
||||
---
|
||||
source: web/src/endpoints/availability/get_overview.rs
|
||||
expression: body
|
||||
snapshot_kind: text
|
||||
---
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h1 class="title is-1">Übersicht</h1>
|
||||
<h3 class="title is-3">geplante Veranstaltungen</h3>
|
||||
<p class="subtitle is-5">in den nächsten 31 Tagen</p>
|
||||
|
||||
<div class="panel p-2">
|
||||
|
||||
<div class="panel-block is-justify-content-space-between">
|
||||
<span>
|
||||
<b>WGT</b> Sonntag, 06.07.2025 10:00 - 20:00
|
||||
</span>
|
||||
<a class="button is-small is-link is-light" href="/calendar?date=2025-07-06">
|
||||
<svg class="icon">
|
||||
<use href="/static/feather-sprite.svg#calendar" />
|
||||
</svg>
|
||||
<span>im Kalender anzeigen</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<h3 class="title is-3">Deine Verfügbarkeiten</h3>
|
||||
<p class="subtitle is-5">in den nächsten 31 Tagen</p>
|
||||
|
||||
<div class="notification">
|
||||
Keine Verfügbarkeiten für diesen Zeitraum hinterlegt.
|
||||
</div>
|
||||
|
||||
|
||||
<h3 class="title is-3">Deine Einteilungen</h3>
|
||||
<p class="subtitle is-5">in den nächsten 31 Tagen</p>
|
||||
|
||||
<div class="notification">
|
||||
Keine Einteilungen für diesen Zeitraum vorhanden.
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</section>
|
@ -14,7 +14,8 @@ use crate::{
|
||||
use brass_db::models::{Assignment, Availability, Event, Role, User};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "overview.html")]
|
||||
#[cfg_attr(not(test), template(path = "overview.html"))]
|
||||
#[cfg_attr(test, template(path = "overview.html", block = "content"), allow(dead_code))]
|
||||
struct OverviewTemplate {
|
||||
user: User,
|
||||
events: Vec<Event>,
|
||||
@ -63,3 +64,52 @@ async fn get(
|
||||
|
||||
Ok(template.to_response()?)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_http::StatusCode;
|
||||
use brass_db::models::{Clothing, Event, EventChangeset, Location};
|
||||
use brass_macros::db_test;
|
||||
use chrono::Utc;
|
||||
|
||||
use crate::utils::test_helper::{
|
||||
assert_snapshot, test_get, DbTestContext, RequestConfig, ServiceResponseExt,
|
||||
};
|
||||
|
||||
#[db_test]
|
||||
fn endpoint_produces_template(context: &DbTestContext) {
|
||||
let app = context.app().await;
|
||||
Location::create(&context.db_pool, "Arena Abc", 1)
|
||||
.await
|
||||
.unwrap();
|
||||
Clothing::create(&context.db_pool, "Anzugsordnung")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let event_changeset = EventChangeset {
|
||||
time: (
|
||||
Utc::now().date_naive().and_hms_opt(10, 0, 0).unwrap(),
|
||||
Utc::now().date_naive().and_hms_opt(20, 0, 0).unwrap(),
|
||||
),
|
||||
name: "WGT".to_string(),
|
||||
location_id: 1,
|
||||
voluntary_wachhabender: false,
|
||||
voluntary_fuehrungsassistent: false,
|
||||
amount_of_posten: 1,
|
||||
clothing: 1,
|
||||
note: None,
|
||||
};
|
||||
|
||||
Event::create(&context.db_pool, event_changeset)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let config = RequestConfig::new("/");
|
||||
let response = test_get(&context.db_pool, app, &config).await;
|
||||
|
||||
let (status, body) = response.into_status_and_body().await;
|
||||
|
||||
assert_eq!(StatusCode::OK, status);
|
||||
assert_snapshot!(body);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user