viewpoint_test/expect/
soft_page.rs1use std::sync::{Arc, Mutex};
6
7use super::page::PageAssertions;
8use super::soft::SoftAssertionError;
9
10pub struct SoftPageAssertions<'a> {
14 pub(super) assertions: PageAssertions<'a>,
15 pub(super) errors: Arc<Mutex<Vec<SoftAssertionError>>>,
16}
17
18impl SoftPageAssertions<'_> {
19 pub async fn to_have_url(&self, expected: impl AsRef<str>) {
21 let expected_str = expected.as_ref().to_string();
22 match self.assertions.to_have_url(&expected_str).await {
23 Ok(()) => {}
24 Err(e) => {
25 self.errors.lock().unwrap().push(
26 SoftAssertionError::new("to_have_url", e.to_string())
27 .with_expected(&expected_str)
28 );
29 }
30 }
31 }
32
33 pub async fn to_have_title(&self, expected: impl AsRef<str>) {
35 let expected_str = expected.as_ref().to_string();
36 match self.assertions.to_have_title(&expected_str).await {
37 Ok(()) => {}
38 Err(e) => {
39 self.errors.lock().unwrap().push(
40 SoftAssertionError::new("to_have_title", e.to_string())
41 .with_expected(&expected_str)
42 );
43 }
44 }
45 }
46}