From 405df965e74779ef1d2d15b3c5d7df20c19d341e Mon Sep 17 00:00:00 2001 From: ldm0 Date: Tue, 20 Oct 2026 03:43:03 +0800 Subject: [PATCH] test(cdp): adapt captured navigation bodies to Base64 --- .../no_document_navigation.rs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/moli-protocol/src/domains/page/tests/same_document_history/no_document_navigation.rs b/moli-protocol/src/domains/page/tests/same_document_history/no_document_navigation.rs index d8bf8626e6f..dc17ca650b9 100644 --- a/moli-protocol/src/domains/page/tests/same_document_history/no_document_navigation.rs +++ b/moli-protocol/src/domains/page/tests/same_document_history/no_document_navigation.rs @@ -1,4 +1,8 @@ use super::*; +use base64::engine::general_purpose::STANDARD as BASE64_STANDARD; + +const NO_DOCUMENT_RESPONSE_BODY: &str = + ""; async fn no_document_page(status: u16, attachment: bool) -> SameDocumentPage { let routes = axum::Router::new().route( @@ -14,7 +18,7 @@ async fn no_document_page(status: u16, attachment: bool) -> SameDocumentPage { .unwrap(); } let body = if status == 200 { - "" + NO_DOCUMENT_RESPONSE_BODY } else { "" }; @@ -356,11 +360,18 @@ async fn no_document_navigation_handles_fetch_interception() { let body = page .command("Fetch.getResponseBody", json!({"requestId":request_id})) .await; - assert!( - body["body"] - .as_str() - .is_some_and(|body| body.contains("unexpectedResponseScript")), - "{body}" + assert_eq!(body["base64Encoded"], true, "{body}"); + let captured = BASE64_STANDARD + .decode( + body["body"] + .as_str() + .expect("captured body must be a string"), + ) + .expect("captured body must be Base64"); + assert_eq!( + captured, + NO_DOCUMENT_RESPONSE_BODY.as_bytes(), + "{status}/{mode}: {body}" ); } let (method, params) = match mode {