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
11 changes: 11 additions & 0 deletions docs/development/journeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ Each folder under `journeys/` is an area, and each area has one test class under
| `landing` | The home page and the 404 page |
| `navigation` | The sidebar and the table of contents |
| `content` | Tabs, dropdowns, admonitions and the code copy button |
| `markdown-alternates` | The `<page>.md` alternate of a page (`.http` files; isolated target only) |
| `mcp` | The remote MCP server: health, `initialize`, `tools/list` (`.http` files, in memory) |
| `docs-api` | The docs API: health and liveness (`.http` files, in memory) |

## HTTP areas

Areas that need no browser use `.http` files in `http/<area>/`, the format Visual Studio, Rider and VS Code run. Each file is one test, and its responses are in `.snapshots/http/<area>/<name>.verified.responses`.

- `markdown-alternates` sends its requests to the site the target serves. It uses pages of this repository's `docs/` folder, so the assembler and Codex targets skip it with a reason.
- `mcp` and `docs-api` start `Elastic.Documentation.Mcp.Remote` and `Elastic.Documentation.Api` in memory with `WebApplicationFactory`, whatever the target is. They only cover requests that need no credentials: a tool call that searches Elasticsearch has no file yet.
- Page bodies are cut to their first line (`BodyScrubbers.FirstQuotedLine`) and MCP descriptions to an ellipsis (`BodyScrubbers.WithoutProse`), so a snapshot changes when behaviour changes and not when the wording does. `Mcp.Remote.Tests` still snapshots the full handshake.

## Write a journey

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## health: GET /docs/_api/health
status: 200 OK
content-type: text/plain

> Healthy

## alive: GET /docs/_api/alive
status: 200 OK
content-type: text/plain

> Healthy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## a page as Markdown: GET /syntax/tabs.md
status: 200 OK
content-type: text/markdown; charset=utf-8

> # Tabs
> …

## the home page as Markdown: GET /index.md
status: 200 OK
content-type: text/markdown; charset=utf-8

> # docs-builder
> …

## a page that does not exist: GET /missing/page.md
status: 404 Not Found
content-type: text/html

> <!DOCTYPE html>
> …
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
## initialize: POST /docs/_mcp
status: 200 OK
content-type: text/event-stream

> event: message
> data: {
> "result": {
> "protocolVersion": "2025-11-25",
> "capabilities": {
> "logging": {},
> "tools": {}
> },
> "serverInfo": {
> "name": "docs-mcp",
> "version": "{server-version}"
> },
> "instructions": "…"
> },
> "id": 1,
> "jsonrpc": "2.0"
> }
>
>

## tools/list: POST /docs/_mcp
status: 200 OK
content-type: text/event-stream

> event: message
> data: {
> "result": {
> "tools": [
> {
> "name": "find_docs_inconsistencies",
> "description": "…",
> "inputSchema": {
> "type": "object",
> "properties": {
> "topic": {
> "description": "…",
> "type": "string"
> },
> "focusArea": {
> "description": "…",
> "type": [
> "string",
> "null"
> ],
> "default": null
> }
> },
> "required": [
> "topic"
> ]
> },
> "annotations": {
> "destructiveHint": false,
> "idempotentHint": true,
> "openWorldHint": false,
> "readOnlyHint": true
> },
> "execution": {
> "taskSupport": "optional"
> }
> },
> {
> "name": "check_docs_coherence",
> "description": "…",
> "inputSchema": {
> "type": "object",
> "properties": {
> "topic": {
> "description": "…",
> "type": "string"
> },
> "limit": {
> "description": "…",
> "type": "integer",
> "default": 20
> }
> },
> "required": [
> "topic"
> ]
> },
> "annotations": {
> "destructiveHint": false,
> "idempotentHint": true,
> "openWorldHint": false,
> "readOnlyHint": true
> },
> "execution": {
> "taskSupport": "optional"
> }
> },
> {
> "name": "find_related_docs",
> "description": "…",
> "inputSchema": {
> "type": "object",
> "properties": {
> "topic": {
> "description": "…",
> "type": "string"
> },
> "limit": {
> "description": "…",
> "type": "integer",
> "default": 10
> },
> "productFilter": {
> "description": "…",
> "type": [
> "string",
> "null"
> ],
> "default": null
> }
> },
> "required": [
> "topic"
> ]
> },
> "annotations": {
> "destructiveHint": false,
> "idempotentHint": true,
> "openWorldHint": false,
> "readOnlyHint": true
> },
> "execution": {
> "taskSupport": "optional"
> }
> },
> {
> "name": "get_document_by_url",
> "description": "…",
> "inputSchema": {
> "type": "object",
> "properties": {
> "url": {
> "description": "…",
> "type": "string"
> },
> "includeBody": {
> "description": "…",
> "type": "boolean",
> "default": false
> }
> },
> "required": [
> "url"
> ]
> },
> "annotations": {
> "destructiveHint": false,
> "idempotentHint": true,
> "openWorldHint": false,
> "readOnlyHint": true
> },
> "execution": {
> "taskSupport": "optional"
> }
> },
> {
> "name": "search_docs",
> "description": "…",
> "inputSchema": {
> "type": "object",
> "properties": {
> "query": {
> "description": "…",
> "type": "string"
> },
> "pageNumber": {
> "description": "…",
> "type": "integer",
> "default": 1
> },
> "pageSize": {
> "description": "…",
> "type": "integer",
> "default": 10
> },
> "productFilter": {
> "description": "…",
> "type": [
> "string",
> "null"
> ],
> "default": null
> },
> "sectionFilter": {
> "description": "…",
> "type": [
> "string",
> "null"
> ],
> "default": null
> }
> },
> "required": [
> "query"
> ]
> },
> "annotations": {
> "destructiveHint": false,
> "idempotentHint": true,
> "openWorldHint": false,
> "readOnlyHint": true
> },
> "execution": {
> "taskSupport": "optional"
> }
> },
> {
> "name": "analyze_document_structure",
> "description": "…",
> "inputSchema": {
> "type": "object",
> "properties": {
> "url": {
> "description": "…",
> "type": "string"
> }
> },
> "required": [
> "url"
> ]
> },
> "annotations": {
> "destructiveHint": false,
> "idempotentHint": true,
> "openWorldHint": false,
> "readOnlyHint": true
> },
> "execution": {
> "taskSupport": "optional"
> }
> }
> ]
> },
> "id": 2,
> "jsonrpc": "2.0"
> }
>
>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## health: GET /docs/_mcp/health
status: 200 OK
content-type: text/plain

> Healthy

## alive: GET /docs/_mcp/alive
status: 200 OK
content-type: text/plain

> Healthy
43 changes: 43 additions & 0 deletions tests/Elastic.Documentation.Journeys.Tests/Areas/DocsApiHttp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

extern alias DocsApi;

using AwesomeAssertions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Nullean.Snapshots;
using Nullean.Snapshots.Http;
using Nullean.Snapshots.TUnit;

namespace Elastic.Documentation.Journeys.Tests.Areas;

/// <summary>The docs API (search, AI answers, page feedback), in memory, for the endpoints that need no credentials.</summary>
public class DocsApiHttp
{
[Test]
[HttpFiles("http/docs-api")]
public async Task Run(SnapshotFile file)
{
// The page-feedback bootstrap hosted service would call Elasticsearch with whatever credentials the environment or user secrets hold.
using var factory = new WebApplicationFactory<DocsApi::Program>().WithWebHostBuilder(builder => builder.ConfigureServices(services =>
{
var bootstrap = services.Where(
d => d.ServiceType == typeof(IHostedService) && d.ImplementationType?.Name == "PageFeedbackBootstrapService"
).ToList();
foreach (var descriptor in bootstrap)
_ = services.Remove(descriptor);
}));
using var client = factory.CreateClient();

var transcript = await HttpFileSnapshot.RunAsync(
file.Path,
new HttpFileSnapshotOptions { Client = client },
TestContext.Current!.Execution.CancellationToken
);
transcript.Should().MatchHttpFileSnapshot();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using AwesomeAssertions;
using Elastic.Documentation.Journeys.Tests.Targets;
using Nullean.Snapshots;
using Nullean.Snapshots.Http;
using Nullean.Snapshots.TUnit;

namespace Elastic.Documentation.Journeys.Tests.Areas;

/// <summary>
/// The Markdown alternate of a page: <c>&lt;page&gt;.md</c>. The requests use pages of this repository's <c>docs/</c> folder, so only
/// the isolated target runs them.
/// </summary>
[ClassDataSource<JourneyTarget>(Shared = SharedType.PerTestSession)]
public class MarkdownAlternatesHttp(JourneyTarget target)
{
[Test]
[HttpFiles("http/markdown-alternates")]
public async Task Run(SnapshotFile file)
{
if (target.Name != "isolated")
Skip.Test($"The requests use pages of this repository's docs/ folder; the {target.Name} target serves other pages.");

using var client = new HttpClient { BaseAddress = target.BaseUrl };
var transcript = await HttpFileSnapshot.RunAsync(
file.Path,
new HttpFileSnapshotOptions { Client = client },
TestContext.Current!.Execution.CancellationToken
);
transcript.Should().MatchHttpFileSnapshot(new SnapshotOptions().Scrub(BodyScrubbers.FirstQuotedLine));
}
}
Loading
Loading