diff --git a/examples/diff-showcase-report.html b/examples/diff-showcase-report.html index df34e613..56cca0c0 100644 --- a/examples/diff-showcase-report.html +++ b/examples/diff-showcase-report.html @@ -2382,8 +2382,374 @@

Macro changed fct_clinical_events
  • fct_encounters
  • - - +
    +
    + + +
    +
    +

    fct_clinical_events models/marts/core/fct_clinical_events.sql

    +

    2 call sites.

    +
      +
    • 11 {{ quarantine_filter() }}
    • +
    • 47 {{ quarantine_filter() }}
    • +
    +
    {{
    +    config(
    +        materialized='table',
    +        unique_key='clinical_event_key'
    +    )
    +}}
    +
    +with valid_encounters as (
    +    select encounter_id
    +    from {{ ref('stg_synthea__encounters') }}
    +    {{ quarantine_filter() }}
    +),
    +
    +conditions as (
    +    select
    +        condition_id as event_id
    +        , 'CONDITION' as event_type
    +        , patient_id
    +        , cond.encounter_id
    +        , condition_start_date as event_start_date
    +        , condition_end_date as event_end_date
    +        , condition_code as code
    +        , 'SNOMED-CT' as code_system
    +        , condition_description as description
    +        , cast(null as varchar) as reason_code
    +        , cast(null as varchar) as reason_description
    +        , cast(null as decimal(18, 2)) as event_cost
    +    from {{ ref('stg_synthea__conditions') }} as cond
    +    where cond.encounter_id in (select encounter_id from valid_encounters)
    +),
    +
    +medications as (
    +    select
    +        medication_id as event_id
    +        , 'MEDICATION' as event_type
    +        , patient_id
    +        , med.encounter_id
    +        , cast(medication_start_at as date) as event_start_date
    +        , cast(medication_end_at as date) as event_end_date
    +        , medication_code as code
    +        , 'RXNORM' as code_system
    +        , medication_description as description
    +        , reason_code
    +        , reason_description
    +        , total_cost as event_cost
    +    from {{ ref('stg_synthea__medications') }} as med
    +    {{ quarantine_filter() }}
    +    and med.encounter_id in (select encounter_id from valid_encounters)
    +),
    +
    +procedures as (
    +    select
    +        procedure_id as event_id
    +        , 'PROCEDURE' as event_type
    +        , patient_id
    +        , proc.encounter_id
    +        , cast(procedure_at as date) as event_start_date
    +        , cast(null as date) as event_end_date
    +        , procedure_code as code
    +        , 'SNOMED-CT' as code_system
    +        , procedure_description as description
    +        , reason_code
    +        , reason_description
    +        , base_cost as event_cost
    +    from {{ ref('stg_synthea__procedures') }} as proc
    +    where proc.encounter_id in (select encounter_id from valid_encounters)
    +),
    +
    +all_events as (
    +    select * from conditions
    +    union all
    +    select * from medications
    +    union all
    +    select * from procedures
    +),
    +
    +patients as (
    +    select
    +        patient_key
    +        , patient_id
    +    from {{ ref('dim_patients') }}
    +    where is_current = true
    +),
    +
    +dim_date as (
    +    select
    +        date_key
    +        , date_actual
    +    from {{ ref('dim_date') }}
    +),
    +
    +encounters as (
    +    select
    +        encounter_key
    +        , encounter_id
    +    from {{ ref('fct_encounters') }}
    +),
    +
    +final as (
    +    select
    +        -- surrogate key
    +        row_number() over (order by e.event_id) as clinical_event_key
    +
    +        -- event identifiers
    +        , e.event_type
    +        , e.event_id
    +
    +        -- dimension keys
    +        , coalesce(p.patient_key, -1) as patient_key
    +        , e.patient_id
    +        , coalesce(enc.encounter_key, -1) as encounter_key
    +        , e.encounter_id
    +        , coalesce(d.date_key, -1) as event_date_key
    +
    +        -- dates
    +        , e.event_start_date
    +        , e.event_end_date
    +
    +        -- code information
    +        , e.code
    +        , e.code_system
    +        , e.description
    +
    +        -- reason
    +        , e.reason_code
    +        , e.reason_description
    +
    +        -- cost
    +        , e.event_cost
    +
    +        -- metadata
    +        , current_timestamp as _loaded_at
    +
    +    from all_events as e
    +    left join patients as p on e.patient_id = p.patient_id
    +    left join encounters as enc on e.encounter_id = enc.encounter_id
    +    left join dim_date as d on e.event_start_date = d.date_actual
    +)
    +
    +select * from final
    +
    +-- cute-dbt fixture: synthetic body mod
    +
    +
    + + +
    +
    @@ -2582,7 +2948,7 @@

    Expected

    - +
    {% when None %}{% endmatch -%} {#- cute-dbt#260 (Slice 0 — the walking skeleton) — the governance diff --git a/tests/headless_toggle.rs b/tests/headless_toggle.rs index 04f15f44..703931d1 100644 --- a/tests/headless_toggle.rs +++ b/tests/headless_toggle.rs @@ -12271,13 +12271,15 @@ fn render_macro_lens_to_file(filename: &str) -> String { Some("shop".to_owned()), ), ); - let model = |bare: &str, ofp: &str| { + // Slice C: each model carries a real raw_code body calling the macro + // inline, so the model-selector + the first-order call sites render. + let model = |bare: &str, ofp: &str, raw: &str| { Node::new( NodeId::new(format!("model.shop.{bare}")), "model", Checksum::new("sha256", bare), Some("select 1".to_owned()), - None, + Some(raw.to_owned()), DependsOn::new(vec![macro_id.to_owned()], Vec::new()), Some(format!("models/{ofp}")), NodeConfig::default(), @@ -12287,8 +12289,16 @@ fn render_macro_lens_to_file(filename: &str) -> String { .with_identity(None, Some("shop".to_owned())) }; let nodes = [ - model("stg_orders", "staging/stg_orders.sql"), - model("fct_orders", "marts/core/fct_orders.sql"), + model( + "stg_orders", + "staging/stg_orders.sql", + "select *\nfrom raw_orders\n {{ add_dq_flags() }}", + ), + model( + "fct_orders", + "marts/core/fct_orders.sql", + "select *\nfrom stg_orders\n {{ add_dq_flags(amount) }}", + ), ]; let m = Manifest::new( ManifestMetadata::new("v12").with_project_name(Some("shop".to_owned())), @@ -12407,6 +12417,88 @@ fn macro_lens_section_renders_with_tree_in_a_real_browser() { let _ = tab.close(true); } +#[test] +#[ignore = "requires Chrome; runs explicitly in the headless-zero-egress CI job via `-- --ignored`"] +fn macro_lens_model_selector_switches_the_shown_model_in_a_real_browser() { + // cute-dbt#265 Slice C — the impacted-model selector (founder D4) is a + // pure renderer over server-rendered panels: every model's SQL + + // call-site panel is in the DOM; the