| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
use makeover_layout::{Family, FieldKind}; |
| 41 |
use quasi_router::{Accepted, Action, Field, Node, Repeat}; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
fn version_suffixes() -> Vec<Accepted> { |
| 50 |
[ |
| 51 |
".zip", |
| 52 |
".dmg", |
| 53 |
".exe", |
| 54 |
".appimage", |
| 55 |
".deb", |
| 56 |
".tar.gz", |
| 57 |
".clap", |
| 58 |
".vst3", |
| 59 |
] |
| 60 |
.into_iter() |
| 61 |
.map(Accepted::suffix) |
| 62 |
.collect() |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
fn area(prompt: &str, hint: &str, fallback: &str, field: Field) -> String { |
| 81 |
use quasi_axum::Serves as _; |
| 82 |
|
| 83 |
|
| 84 |
let inner = quasi_webview::Webview::new().fragment(&Node::field(field)); |
| 85 |
format!( |
| 86 |
"<div class=\"file-upload-area\" data-upload-fallback=\"{}\">\ |
| 87 |
<div class=\"upload-text\">{}</div>\ |
| 88 |
<div class=\"upload-hint\">{}</div>{inner}</div>", |
| 89 |
crate::helpers::escape_html(fallback), |
| 90 |
crate::helpers::escape_html(prompt), |
| 91 |
crate::helpers::escape_html(hint), |
| 92 |
) |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
#[must_use] |
| 103 |
pub fn audio(item_id: &str) -> String { |
| 104 |
let field = Field::upload("audio", "Audio file", [Accepted::family(Family::Audio)]).writes( |
| 105 |
Action::post("/api/upload/presign") |
| 106 |
.with("item_id", item_id) |
| 107 |
.with("file_type", "audio") |
| 108 |
.awaiting() |
| 109 |
.by_host(), |
| 110 |
); |
| 111 |
|
| 112 |
area( |
| 113 |
"Drop audio file here or choose one to upload", |
| 114 |
"Supports MP3, WAV, FLAC, M4A up to 500 MB", |
| 115 |
"audio/mpeg", |
| 116 |
field, |
| 117 |
) |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
#[must_use] |
| 126 |
pub fn existing_version(version_id: &str) -> String { |
| 127 |
let field = Field::upload("version-file", "Version file", version_suffixes()).writes( |
| 128 |
Action::post(format!("/api/versions/{version_id}/upload/presign")) |
| 129 |
.awaiting() |
| 130 |
.by_host(), |
| 131 |
); |
| 132 |
|
| 133 |
area( |
| 134 |
"Drop file to upload for this version", |
| 135 |
"ZIP, DMG, EXE, AppImage, DEB, tar.gz, CLAP, VST3", |
| 136 |
"application/octet-stream", |
| 137 |
field, |
| 138 |
) |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
#[must_use] |
| 155 |
pub fn image(presign: &str, id_field: &str, id_value: &str) -> String { |
| 156 |
let field = Field::upload( |
| 157 |
"cover-image", |
| 158 |
"Cover image", |
| 159 |
[ |
| 160 |
Accepted::media_type("image/jpeg"), |
| 161 |
Accepted::media_type("image/png"), |
| 162 |
Accepted::media_type("image/webp"), |
| 163 |
], |
| 164 |
) |
| 165 |
.writes( |
| 166 |
Action::post(presign) |
| 167 |
.with(id_field, id_value) |
| 168 |
.awaiting() |
| 169 |
.by_host(), |
| 170 |
); |
| 171 |
|
| 172 |
area( |
| 173 |
"Drop an image here or choose one to upload", |
| 174 |
"JPG, PNG or WebP, square and at least 400x400px, up to 10 MB", |
| 175 |
"image/jpeg", |
| 176 |
field, |
| 177 |
) |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
#[must_use] |
| 193 |
pub fn version_queue() -> String { |
| 194 |
use quasi_axum::Serves as _; |
| 195 |
|
| 196 |
let field = Field::upload("version-files", "Files", version_suffixes()) |
| 197 |
.many() |
| 198 |
.hint( |
| 199 |
"Add one file per platform. Each gets its own label \ |
| 200 |
(e.g. \"macOS (arm)\", \"Linux (x86_64)\").", |
| 201 |
); |
| 202 |
quasi_webview::Webview::new().fragment(&Node::field(field)) |
| 203 |
} |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
#[must_use] |
| 216 |
pub fn version_details() -> String { |
| 217 |
use quasi_axum::Serves as _; |
| 218 |
|
| 219 |
let mut number = Field::new(FieldKind::Text, "new-version-number", "Version Number"); |
| 220 |
number.placeholder = Some("e.g., 1.0".to_owned()); |
| 221 |
|
| 222 |
let mut changelog = Field::new(FieldKind::Text, "version-changelog", "Notes (optional)"); |
| 223 |
changelog.placeholder = Some("What changed in this version...".to_owned()); |
| 224 |
|
| 225 |
let mut html = quasi_webview::Webview::new().fragment(&Node::field(number)); |
| 226 |
html.push_str(&quasi_webview::Webview::new().fragment(&Node::field(changelog))); |
| 227 |
html |
| 228 |
} |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
#[must_use] |
| 250 |
pub fn version_file_queue() -> String { |
| 251 |
use quasi_axum::Serves as _; |
| 252 |
|
| 253 |
let mut label = Field::new(FieldKind::Text, "version-file", "File"); |
| 254 |
label.placeholder = Some("e.g., macOS (arm)".to_owned()); |
| 255 |
let field = label.repeating(Repeat::new().added_by("version-files").removing("Remove")); |
| 256 |
quasi_webview::Webview::new().fragment(&Node::field(field)) |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
#[must_use] |
| 271 |
pub fn version_upload_all(item_id: &str) -> String { |
| 272 |
use quasi_axum::Serves as _; |
| 273 |
|
| 274 |
let action = Action::post(format!("/api/items/{item_id}/versions")) |
| 275 |
.awaiting() |
| 276 |
.by_host(); |
| 277 |
quasi_webview::Webview::new().fragment(&Node::act("Upload All", action)) |
| 278 |
} |
| 279 |
|
| 280 |
#[cfg(test)] |
| 281 |
mod tests { |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
#[test] |
| 287 |
fn the_picked_file_queue_says_where_its_slots_come_from_and_names_them_by_file() { |
| 288 |
let html = super::version_file_queue(); |
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
assert!( |
| 293 |
html.contains(r#"data-repeat-add-from="version-files""#), |
| 294 |
"{html}" |
| 295 |
); |
| 296 |
|
| 297 |
|
| 298 |
assert!(!html.contains("field-repeat-add"), "{html}"); |
| 299 |
|
| 300 |
assert!(html.contains(r#"data-repeat="version-file""#), "{html}"); |
| 301 |
assert!(html.contains("data-repeat-slots"), "{html}"); |
| 302 |
|
| 303 |
assert!(html.contains("<template"), "{html}"); |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
#[test] |
| 311 |
fn an_audio_upload_says_what_it_takes_where_it_goes_and_that_it_waits() { |
| 312 |
let html = super::audio("11111111-1111-1111-1111-111111111111"); |
| 313 |
|
| 314 |
assert!(html.contains(r#"type="file""#), "{html}"); |
| 315 |
assert!(html.contains(r#"accept="audio/*""#), "{html}"); |
| 316 |
assert!(!html.contains(" multiple"), "{html}"); |
| 317 |
assert!( |
| 318 |
html.contains(r#"data-sends="/api/upload/presign""#), |
| 319 |
"{html}" |
| 320 |
); |
| 321 |
assert!(html.contains("data-awaiting="), "{html}"); |
| 322 |
} |
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
#[test] |
| 328 |
fn no_transport_is_emitted_for_a_host_made_call() { |
| 329 |
let html = super::audio("11111111-1111-1111-1111-111111111111"); |
| 330 |
|
| 331 |
assert!(!html.contains("hx-post"), "{html}"); |
| 332 |
assert!(!html.contains("hx-trigger"), "{html}"); |
| 333 |
assert!(!html.contains("href="), "{html}"); |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
#[test] |
| 341 |
fn the_payload_rides_with_the_destination() { |
| 342 |
let html = super::audio("11111111-1111-1111-1111-111111111111"); |
| 343 |
|
| 344 |
assert!(html.contains("data-vals="), "{html}"); |
| 345 |
assert!(html.contains("item_id"), "{html}"); |
| 346 |
assert!( |
| 347 |
html.contains("11111111-1111-1111-1111-111111111111"), |
| 348 |
"{html}" |
| 349 |
); |
| 350 |
assert!(html.contains("file_type"), "{html}"); |
| 351 |
assert!(!html.contains("hx-vals"), "{html}"); |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
#[test] |
| 357 |
fn both_version_surfaces_take_the_same_files() { |
| 358 |
let single = super::existing_version("22222222-2222-2222-2222-222222222222"); |
| 359 |
let queue = super::version_queue(); |
| 360 |
let accept = r#"accept=".zip,.dmg,.exe,.appimage,.deb,.tar.gz,.clap,.vst3""#; |
| 361 |
|
| 362 |
assert!(single.contains(accept), "{single}"); |
| 363 |
assert!(queue.contains(accept), "{queue}"); |
| 364 |
} |
| 365 |
|
| 366 |
|
| 367 |
#[test] |
| 368 |
fn an_existing_version_is_addressed_by_id() { |
| 369 |
let html = super::existing_version("22222222-2222-2222-2222-222222222222"); |
| 370 |
|
| 371 |
assert!( |
| 372 |
html.contains( |
| 373 |
r#"data-sends="/api/versions/22222222-2222-2222-2222-222222222222/upload/presign""# |
| 374 |
), |
| 375 |
"{html}" |
| 376 |
); |
| 377 |
} |
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
#[test] |
| 383 |
fn the_queue_takes_many_files_and_sends_none_of_them() { |
| 384 |
let html = super::version_queue(); |
| 385 |
|
| 386 |
assert!(html.contains(" multiple"), "{html}"); |
| 387 |
assert!(!html.contains("data-sends"), "{html}"); |
| 388 |
assert!(!html.contains("data-awaiting"), "{html}"); |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
#[test] |
| 396 |
fn the_drop_area_is_there_for_the_binder() { |
| 397 |
let html = super::audio("11111111-1111-1111-1111-111111111111"); |
| 398 |
|
| 399 |
assert!(html.contains(r#"class="file-upload-area""#), "{html}"); |
| 400 |
assert!(html.contains("Drop audio file here"), "{html}"); |
| 401 |
} |
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
#[test] |
| 407 |
fn an_image_says_its_three_media_types_and_where_it_goes() { |
| 408 |
let html = super::image( |
| 409 |
"/api/items/image/presign", |
| 410 |
"item_id", |
| 411 |
"11111111-1111-1111-1111-111111111111", |
| 412 |
); |
| 413 |
|
| 414 |
assert!( |
| 415 |
html.contains(r#"accept="image/jpeg,image/png,image/webp""#), |
| 416 |
"{html}" |
| 417 |
); |
| 418 |
assert!(!html.contains(" multiple"), "{html}"); |
| 419 |
assert!( |
| 420 |
html.contains(r#"data-sends="/api/items/image/presign""#), |
| 421 |
"{html}" |
| 422 |
); |
| 423 |
assert!(html.contains("item_id"), "{html}"); |
| 424 |
assert!(html.contains("data-awaiting="), "{html}"); |
| 425 |
assert!(!html.contains("hx-post"), "{html}"); |
| 426 |
} |
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
#[test] |
| 433 |
fn both_wizard_images_take_the_same_files() { |
| 434 |
let item = super::image("/api/items/image/presign", "item_id", "i"); |
| 435 |
let project = super::image("/api/projects/image/presign", "project_id", "p"); |
| 436 |
let accept = r#"accept="image/jpeg,image/png,image/webp""#; |
| 437 |
|
| 438 |
assert!(item.contains(accept), "{item}"); |
| 439 |
assert!(project.contains(accept), "{project}"); |
| 440 |
assert!( |
| 441 |
project.contains(r#"data-sends="/api/projects/image/presign""#), |
| 442 |
"{project}" |
| 443 |
); |
| 444 |
assert!(project.contains("project_id"), "{project}"); |
| 445 |
} |
| 446 |
|
| 447 |
fn nav() -> Vec<crate::templates::StepNavItem> { |
| 448 |
vec![crate::templates::StepNavItem { |
| 449 |
name: "basics", |
| 450 |
label: "Basics", |
| 451 |
state: "active", |
| 452 |
}] |
| 453 |
} |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
#[test] |
| 460 |
fn the_item_wizard_step_is_wired_and_says_where_the_url_lands() { |
| 461 |
use askama::Template as _; |
| 462 |
|
| 463 |
let html = crate::templates::WizardItemBasicsTemplate { |
| 464 |
nav: nav(), |
| 465 |
project_slug: "a-project".into(), |
| 466 |
item_id: "11111111-1111-1111-1111-111111111111".into(), |
| 467 |
title: "A track".into(), |
| 468 |
description: String::new(), |
| 469 |
cover_image_url: None, |
| 470 |
} |
| 471 |
.render() |
| 472 |
.expect("render the item basics step"); |
| 473 |
|
| 474 |
assert!( |
| 475 |
html.contains(r#"data-sends="/api/items/image/presign""#), |
| 476 |
"{html}" |
| 477 |
); |
| 478 |
assert!( |
| 479 |
html.contains(r##"data-upload-fills="#cover-image-url""##), |
| 480 |
"{html}" |
| 481 |
); |
| 482 |
assert!(html.contains("data-upload-shows"), "{html}"); |
| 483 |
assert!(html.contains("data-upload-empty"), "{html}"); |
| 484 |
assert!(html.contains("data-upload-filled"), "{html}"); |
| 485 |
assert!(!html.contains("mnw-image-uploader"), "{html}"); |
| 486 |
} |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
#[test] |
| 492 |
fn the_project_wizard_step_shows_the_image_in_two_places() { |
| 493 |
use askama::Template as _; |
| 494 |
|
| 495 |
let html = crate::templates::WizardProjectAppearanceTemplate { |
| 496 |
nav: nav(), |
| 497 |
slug: "a-project".into(), |
| 498 |
project_id: "22222222-2222-2222-2222-222222222222".into(), |
| 499 |
cover_image_url: None, |
| 500 |
project_title: "A project".into(), |
| 501 |
} |
| 502 |
.render() |
| 503 |
.expect("render the project appearance step"); |
| 504 |
|
| 505 |
assert!( |
| 506 |
html.contains(r#"data-sends="/api/projects/image/presign""#), |
| 507 |
"{html}" |
| 508 |
); |
| 509 |
assert_eq!(html.matches("data-upload-shows").count(), 2, "{html}"); |
| 510 |
assert!( |
| 511 |
html.contains(r##"data-upload-fills="#cover-image-url""##), |
| 512 |
"{html}" |
| 513 |
); |
| 514 |
assert!(!html.contains("mnw-image-uploader"), "{html}"); |
| 515 |
} |
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
#[test] |
| 521 |
fn an_image_already_there_is_rendered_not_constructed() { |
| 522 |
use askama::Template as _; |
| 523 |
|
| 524 |
let html = crate::templates::WizardProjectAppearanceTemplate { |
| 525 |
nav: nav(), |
| 526 |
slug: "a-project".into(), |
| 527 |
project_id: "22222222-2222-2222-2222-222222222222".into(), |
| 528 |
cover_image_url: Some("https://cdn.example/cover.jpg".into()), |
| 529 |
project_title: "A project".into(), |
| 530 |
} |
| 531 |
.render() |
| 532 |
.expect("render the project appearance step"); |
| 533 |
|
| 534 |
assert!( |
| 535 |
html.contains(r#"src="https://cdn.example/cover.jpg""#), |
| 536 |
"{html}" |
| 537 |
); |
| 538 |
assert!(!html.contains(r#"src="""#), "{html}"); |
| 539 |
assert!(html.contains("data-upload-empty hidden"), "{html}"); |
| 540 |
} |
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
fn audio_item(audio_s3_key: Option<String>) -> crate::types::Item { |
| 545 |
crate::types::Item { |
| 546 |
id: "11111111-1111-1111-1111-111111111111".into(), |
| 547 |
title: "A recording".into(), |
| 548 |
price: "0".into(), |
| 549 |
price_cents: 0, |
| 550 |
item_type: "audio".into(), |
| 551 |
description: String::new(), |
| 552 |
thumbnail: String::new(), |
| 553 |
release_date: String::new(), |
| 554 |
sales_count: 0, |
| 555 |
tags: Vec::new(), |
| 556 |
content: crate::types::ItemContent::Audio { |
| 557 |
duration: None, |
| 558 |
duration_seconds: None, |
| 559 |
cover_url: None, |
| 560 |
episode_number: None, |
| 561 |
audio_s3_key, |
| 562 |
}, |
| 563 |
cover_image_url: None, |
| 564 |
is_free: true, |
| 565 |
can_access: true, |
| 566 |
enable_license_keys: false, |
| 567 |
default_max_activations: None, |
| 568 |
pwyw_enabled: false, |
| 569 |
pwyw_min_cents: None, |
| 570 |
publish_at: None, |
| 571 |
is_public: true, |
| 572 |
listed: true, |
| 573 |
bundle_item_count: 0, |
| 574 |
license_preset: None, |
| 575 |
custom_license_text: None, |
| 576 |
ai_tier: crate::db::AiTier::Handmade, |
| 577 |
ai_disclosure: None, |
| 578 |
} |
| 579 |
} |
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
#[test] |
| 586 |
fn the_audio_call_site_is_wired_and_carries_where_it_goes_after() { |
| 587 |
use askama::Template as _; |
| 588 |
|
| 589 |
let html = crate::templates::ItemDetailsTabTemplate { |
| 590 |
item: audio_item(None), |
| 591 |
bundle_items: Vec::new(), |
| 592 |
bundleable_items: Vec::new(), |
| 593 |
sections: Vec::new(), |
| 594 |
tag_suggestions: crate::templates::TagSuggestionsTemplate { |
| 595 |
suggestions: Vec::new(), |
| 596 |
}, |
| 597 |
} |
| 598 |
.render() |
| 599 |
.expect("render the details tab"); |
| 600 |
|
| 601 |
assert!( |
| 602 |
html.contains(r#"data-sends="/api/upload/presign""#), |
| 603 |
"{html}" |
| 604 |
); |
| 605 |
assert!( |
| 606 |
html.contains( |
| 607 |
r#"data-upload-goes="/dashboard/item/11111111-1111-1111-1111-111111111111?tab=files""# |
| 608 |
), |
| 609 |
"{html}" |
| 610 |
); |
| 611 |
} |
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
#[test] |
| 617 |
fn the_files_call_sites_keep_what_the_host_reads_them_by() { |
| 618 |
use askama::Template as _; |
| 619 |
|
| 620 |
let version = crate::types::Version { |
| 621 |
id: "22222222-2222-2222-2222-222222222222".into(), |
| 622 |
number: "1.0".into(), |
| 623 |
uploaded_date: "2026-08-20".into(), |
| 624 |
file_count: 0, |
| 625 |
size: "0 B".into(), |
| 626 |
downloads: 0, |
| 627 |
status: "draft".into(), |
| 628 |
is_current: true, |
| 629 |
has_file: false, |
| 630 |
file_name: None, |
| 631 |
label: None, |
| 632 |
}; |
| 633 |
|
| 634 |
let html = crate::templates::ItemVersionUploadTemplate { |
| 635 |
item: audio_item(None), |
| 636 |
versions: vec![version], |
| 637 |
} |
| 638 |
.render() |
| 639 |
.expect("render the uploader"); |
| 640 |
|
| 641 |
assert!(html.contains(r#"id="version-files""#), "{html}"); |
| 642 |
assert!( |
| 643 |
html.contains(r#"id="existing-version-upload-22222222-2222-2222-2222-222222222222""#), |
| 644 |
"{html}" |
| 645 |
); |
| 646 |
assert!( |
| 647 |
html.contains( |
| 648 |
r#"data-sends="/api/versions/22222222-2222-2222-2222-222222222222/upload/presign""# |
| 649 |
), |
| 650 |
"{html}" |
| 651 |
); |
| 652 |
} |
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
#[test] |
| 659 |
fn the_new_version_questions_keep_the_names_the_host_reads() { |
| 660 |
let html = super::version_details(); |
| 661 |
|
| 662 |
assert!(html.contains(r#"id="new-version-number""#), "{html}"); |
| 663 |
assert!(html.contains(r#"name="new-version-number""#), "{html}"); |
| 664 |
assert!(html.contains(r#"id="version-changelog""#), "{html}"); |
| 665 |
assert!(html.contains(r#"placeholder="e.g., 1.0""#), "{html}"); |
| 666 |
} |
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
#[test] |
| 672 |
fn upload_all_carries_its_address_and_no_transport() { |
| 673 |
let html = super::version_upload_all("11111111-1111-1111-1111-111111111111"); |
| 674 |
|
| 675 |
assert!(html.contains("<button"), "{html}"); |
| 676 |
assert!(html.contains("data-act"), "{html}"); |
| 677 |
assert!( |
| 678 |
html.contains( |
| 679 |
r#"data-sends="/api/items/11111111-1111-1111-1111-111111111111/versions""# |
| 680 |
), |
| 681 |
"{html}" |
| 682 |
); |
| 683 |
assert!(html.contains("Upload All"), "{html}"); |
| 684 |
assert!(!html.contains("hx-post"), "{html}"); |
| 685 |
} |
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
#[test] |
| 690 |
fn the_queue_owns_its_label_and_its_hint() { |
| 691 |
let html = super::version_queue(); |
| 692 |
|
| 693 |
assert_eq!(html.matches(">Files<").count(), 1, "{html}"); |
| 694 |
assert!(html.contains("Add one file per platform"), "{html}"); |
| 695 |
} |
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
#[test] |
| 701 |
fn the_uploader_surface_names_one_control_and_where_it_lands() { |
| 702 |
use askama::Template as _; |
| 703 |
|
| 704 |
let html = crate::templates::ItemVersionUploadTemplate { |
| 705 |
item: audio_item(None), |
| 706 |
versions: Vec::new(), |
| 707 |
} |
| 708 |
.render() |
| 709 |
.expect("render the uploader"); |
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
assert_eq!(html.matches("<button").count(), 4, "{html}"); |
| 717 |
assert!(!html.contains("field-repeat-add"), "{html}"); |
| 718 |
assert!( |
| 719 |
html.contains( |
| 720 |
r#"data-upload-goes="/dashboard/item/11111111-1111-1111-1111-111111111111?tab=files""# |
| 721 |
), |
| 722 |
"{html}" |
| 723 |
); |
| 724 |
assert!(!html.contains("data-item-id"), "{html}"); |
| 725 |
} |
| 726 |
} |
| 727 |
|