← Back to Pull requests

[ZEPPELIN-6724] Add a convention for frontend type tests #5520

Closed
unknown closed this pull request without merging on Oct 03, 2026 02:05 UTC
View on GitHub
unknown unknown commented on Oct 02, 2026 17:12 UTC
Author

What is this PR for?


Type tests in the frontend currently come in two layouts: assertions inside an SDK spec (ZEPPELIN-6664) and a separate type-tests/ directory (ZEPPELIN-6663). This PR settles on the first and documents it in zeppelin-web-angular/AGENTS.md, so the next type test has one place to go.

The convention

  • Type assertions (expectTypeOf, assertType, @ts-expect-error) go in ordinary .spec.ts files, beside the interface they pin.

  • They count only where tsc checks the spec: today, the zeppelin-sdk and notebook-core specs. Lint now accepts a type-only test there and still rejects one elsewhere.

  • To show a value is accepted, pass it to assertType<T>(...). Prefer an exact matcher to @ts-expect-error, which any error on the next line satisfies.
  • Why ordinary specs

  • Type assertions are erased before Vitest runs a spec, so only tsc checks them. The two spec programs above already have a tsc pass in Maven (typecheck:sdk-contracts, typecheck:notebook-core), so a type test there needs no extra tsconfig, script or runner.

  • The usual alternative is separate .test-d.ts files checked by vitest --typecheck. It reports failures per test, but it is still experimental and reports a file outside its tsconfig as passed (vitest#7988), so a type test could go unchecked without anyone noticing. Per-test output is not worth that risk or a second checker.
  • Commits (each passes typecheck, lint and tests on its own)
    1. eslint.config.js: accept type assertions in the two typechecked spec programs.
    2. Move the CompletionItem type test into completion-item.spec.ts, using exact matchers instead of @ts-expect-error.
    3. Drop the now-empty type-tests/ include from the SDK spec tsconfig.
    4. List typecheck:sdk-contracts in AGENTS.md. Maven already ran it.
    5. Document the convention.
    6. Replace runtime expects on typed literals in the SDK specs with assertType. tsc already checked those literals; assertType keeps that check, excess properties included, without a variable that needs a use.

    What type of PR is it?


    Improvement

    Todos


    [x] Accept type-only tests in typechecked spec programs
    [x] Move the CompletionItem type test into an SDK spec
    [x] Document the convention in zeppelin-web-angular/AGENTS.md

    What is the Jira issue?


    https://issues.apache.org/jira/browse/ZEPPELIN-6724

    How should this be tested?


    cd zeppelin-web-angular
    npm run typecheck:sdk-contracts
    npm run typecheck:notebook-core
    npm run test:shell
    npx eslint projects/zeppelin-sdk projects/zeppelin-notebook-core test/notebook-core
    

  • To see the lint boundary, put a test containing only expectTypeOf under src/: vitest/expect-expect reports it. The same test under projects/zeppelin-sdk/src passes.

  • To see the type test fail, make CompletionItem.name optional: typecheck:sdk-contracts reports completion-item.spec.ts.
  • Screenshots (if appropriate)


    N/A

    Questions:


    Does the license files need to update? No
    Is there breaking changes for older versions? No
  • Does this needs documentation? Yes, zeppelin-web-angular/AGENTS.md is updated in this PR
  • Diff: 401 lines (+300 / -101) across 5 files Reviewer: jongyoul Review duration: 532m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 401 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5520"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.7% (MEDIUM) · Higher = larger blast radius
    44.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.7% · Safe to merge
    17.7%