Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion crates/trusted-server-core/src/integrations/gpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ mod tests {
"bootstrap should scan ID-bearing elements instead of interpolating div_id into CSS"
);
assert!(
combined.contains(".startsWith(slot.div_id)"),
combined.contains("candidate.id.startsWith(divId)"),
"bootstrap should match metacharacter-containing div_id prefixes with startsWith"
);
assert!(
Expand All @@ -1262,6 +1262,35 @@ mod tests {
);
}

#[test]
fn head_inserts_bootstrap_installs_inner_div_slot_handoff() {
let integration = GptIntegration::new(test_config());
let doc_state = IntegrationDocumentState::default();
let ctx = IntegrationHtmlContext {
request_host: "edge.example.com",
request_scheme: "https",
origin_host: "example.com",
document_state: &doc_state,
};
let combined = integration.head_inserts(&ctx).join("");
assert!(
combined.contains("gptSlotHandoffs"),
"bootstrap should keep late publisher slot handoff state on window.tsjs"
);
assert!(
combined.contains("__tsSlotHandoffPatched"),
"bootstrap should install idempotent GPT handoff wrappers"
);
assert!(
combined.contains("return googletag.defineSlot") && combined.contains("actualDivId"),
"bootstrap should define the TS fallback on the actual inner div"
);
assert!(
!combined.contains("actualDivId + \"-container\""),
"bootstrap must not define a competing outer-container GPT slot"
);
}

#[test]
fn head_inserts_bootstrap_guards_enable_services_with_idempotency_flag() {
let config = test_config();
Expand Down
Loading
Loading