Repository navigation
Snapshot the response block tests, narrow the operation snapshot - #4684
Merged
Merged
Conversation
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>
Contributor
Author
|
@Mpdreamz do you think it would be better to have partial snapshot or entire pages? |
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. |
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4684/ |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three tests in
ResponsesBlockRenderingTestsnow 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 onmain.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
ContainandNotContainon 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
mainstayed 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_RendersStaticRowWithoutEmptyBodyandRender_ResponseWithTwoContentTypes_TagsTheActiveTypeAndPicksFromASelectInTheBodyeach callMatchHtmlSnapshoton 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<selectfor the pills test and noresponse-panel-bodyfor 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
OperationHeadingLevelTestsnow removes thepopover-dataattribute from its snapshot. That attribute holds product text and availability built by the applicability feature. The badge attributes that come from the spec, such asbadge-versionand the lifecycle, stay. The verified snapshot changes by two lines, the twopopover-dataattributes.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
ResponsesBlockRenderingTests: 51 before and 21 after. Across the PR,.csfiles gain 12 lines and lose 41, and the three new snapshots add 105 lines.Verify
dotnet test --project tests/Elastic.ApiExplorer.TestsAll 1,423 tests pass.
🤖 Generated with Claude Code