Skip to content

Snapshot the response block tests, narrow the operation snapshot - #4684

Merged
akira28 merged 3 commits into
mainfrom
test/responses-block-snapshots
Nov 4, 2026
Merged

akira28 merged 3 commits into
mainfrom
test/responses-block-snapshots

Conversation

@akira28

@akira28 akira28 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Three tests in ResponsesBlockRenderingTests now compare the rendered response block to a snapshot instead of asserting on 37 substrings, and the operation page snapshot from #4654 no longer includes the applicability popover data that broke it on main.

Affects: Internals only

Prompt summary: Run a second snapshot pilot on one rendered component, after the whole-page pilot in #4654, to see whether a component-level snapshot is easier to maintain and to read. The same PR narrows the whole-page pilot, so that unrelated popover changes stop breaking it.

Why

The three response block tests check a rendered block with long runs of Contain and NotContain on raw substrings. A reviewer never sees the whole block, and any markup the list leaves out can change unnoticed.

The whole-page snapshot from #4654 has the opposite problem. It includes the data payload of the applicability popovers on the page. #4311 changed that text, the test failed, and main stayed red until #4683 updated the snapshot. The test is about heading levels, so a change to popover text should not fail it.

What

Converted tests

Render_MultipleStatuses_UsesClickablePillsInsteadOfSelect, Render_ResponseWithoutSchemaOrHeaders_RendersStaticRowWithoutEmptyBody and Render_ResponseWithTwoContentTypes_TagsTheActiveTypeAndPicksFromASelectInTheBody each call MatchHtmlSnapshot on the block. The block is a fragment rendered from a hand-built model, so the snapshots hold no page chrome and are small (45, 16 and 44 lines). Each test keeps the assertion its name promises, such as no <select for the pills test and no response-panel-body for the static row. The tests that check layout order, link placement and union variant names are unchanged, because those assertions state intent that a snapshot would blur.

Narrowed page snapshot

OperationHeadingLevelTests now removes the popover-data attribute from its snapshot. That attribute holds product text and availability built by the applicability feature. The badge attributes that come from the spec, such as badge-version and the lifecycle, stay. The verified snapshot changes by two lines, the two popover-data attributes.

How it was checked

Each of the 37 deleted assertions was evaluated against the new block output, and all of them hold. Three deliberate markup changes in the Razor partials each failed the converted tests. For the page snapshot, a one-word change to the popover text failed the old test and passes the narrowed one. A change to a heading in the page still fails it.

Decision gate

  • Assertion lines in ResponsesBlockRenderingTests: 51 before and 21 after. Across the PR, .cs files gain 12 lines and lose 41, and the three new snapshots add 105 lines.
  • Test count: unchanged. No test was added or removed.
  • Readability: the 16-line static-row snapshot shows the whole row, which is clearer than the eight substring checks it replaced.
  • Fragility: a component snapshot built from a hand-made model depends only on that component and the description pipeline it renders with. A whole-page snapshot depends on everything on the page, which is why the page snapshot needed narrowing.

Verify

dotnet test --project tests/Elastic.ApiExplorer.Tests

All 1,423 tests pass.

🤖 Generated with Claude Code

Three tests in ResponsesBlockRenderingTests asserted on 37 substrings of the rendered response block. Each now compares the block to a snapshot and keeps the one or two assertions that state what the test protects. Before the assertions were deleted, each of the 37 was evaluated against the new output and all of them held. Three deliberate markup changes in the Razor partials each failed the converted tests. The block is a component fragment, so the snapshots hold no page chrome and stay small.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@akira28
akira28 requested a review from a team as a code owner November 4, 2026 15:19
@akira28 akira28 added the chore label Nov 4, 2026
@akira28
akira28 requested a review from reakaleek November 4, 2026 15:19

@Mpdreamz Mpdreamz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@akira28

akira28 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@Mpdreamz do you think it would be better to have partial snapshot or entire pages?

@Mpdreamz

Mpdreamz commented Nov 4, 2026

Copy link
Copy Markdown
Member

partial pages for sure!

Once we can fully jump to components from NAVIGATION_PREVIEW we can extend this for all components. And have dedicated chrome tests to test the surrounding bits.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4684/

akira28 and others added 2 commits November 4, 2026 16:44
The operation page snapshot included the data payload of its applicability popovers, which comes from the applicability feature and not from the heading structure the test is about. A change to the popover text in #4311 therefore failed the test and turned main red until #4683 updated the snapshot. The test now removes the popover-data attribute. The snapshot differs only in those two attributes. With the same one-word change to the popover text, the old test failed and the narrowed one passes, and a change to a heading in the page still fails it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@akira28 akira28 changed the title Snapshot the response block rendering tests Snapshot the response block tests, narrow the operation snapshot Nov 4, 2026
@akira28
akira28 enabled auto-merge (squash) November 4, 2026 15:50
@akira28
akira28 merged commit b4df960 into main Nov 4, 2026
36 checks passed
@akira28
akira28 deleted the test/responses-block-snapshots branch November 4, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants