diff --git a/CHANGELOG.md b/CHANGELOG.md
index d5a0355..4a181e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,10 +4,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## [Unreleased]
+## [1.1.1] - 2026-11-26
+
+This is a patch release that adds destination-aware framework view fallback routing and branded HTTP error pages with client-side recovery, expands unit, container, Playwright, and Cuemon acceptance tests, and enforces the six-tag versioned Docker image policy without `:latest`.
+
+### Added
+
+- Added destination-aware framework view fallback (`framework-views/FrameworkViewConventions.ps1`, `framework-views/Build-DocfxFrameworkViews.ps1`, `framework-views/framework-views.nginx.conf`, and `templates/ms-style/public/framework-view.js`), generating an ordinal-keyed, deduplicated `availability` inventory (`sets` and `pages`) in `framework-views.json`, merging missing API section links into shared root `toc.json` by item name and normalized identity href, routing unavailable HTML pages and directory indexes via NGINX HTTP `302` fallback (stripping `view` parameters while preserving other query parameters and returning HTTP `400` for excess duplicate `view` parameters), and resolving destination-aware links in `framework-view.js` across navigation, search results, and the framework selector,
+- Added branded HTTP error pages (`framework-views/DocfxHttpErrors.ps1`, `framework-views/http-error.md.tmpl`, `framework-views/http-error.js`, `framework-views/framework-views.nginx.conf`, `framework-views/Build-DocfxFrameworkViews.ps1`, and `framework-views/FrameworkViewConventions.ps1`), generating static DocFX error pages under `/_docfx-errors/` (reserving `_docfx-errors` in `Get-ApiPath`) for 19 HTTP status codes (`400`–`505`), routing HTML navigation errors to `/_docfx-errors/$status.html` and non-HTML requests to `@docfx_plain_error`, and serving isolated `public/docfx-http-error.js` recovery actions for documentation home, session-history back navigation, search, retry (including fresh `GET` navigation when URLs contain fragments), and `400`/`404` framework availability links,
+- Added expanded automated verification (`tests/framework-view/http-error.spec.js`, `tests/framework-view/framework-view.spec.js`, `tests/framework-view/FrameworkViewConventions.Tests.ps1`, `tests/framework-view/Build-DocfxFrameworkViews.Tests.ps1`, `tests/Test-DocfxContainer.ps1`, `tests/framework-view/Test-FrameworkView.ps1`, `tests/framework-view/Test-FrameworkViews.ps1`, `tests/framework-view/cuemon/Build-CuemonFixture.ps1`, `tests/framework-view/cuemon/Test-CuemonFrameworkViews.ps1`, and `tests/framework-view/fixture/`) covering destination-aware fallback, identity-based TOC merging, ordinal page availability keys, and branded HTTP error pages for multi-TFM and single-TFM sites.
### Changed
+- Updated repository documentation (`README.md`, `framework-views/README.md`, and `tests/framework-view/README.md`) to cover destination-aware framework view fallback, page availability metadata, shared root TOC merging, branded HTTP error pages, and the expanded browser and Cuemon acceptance tests,
- Updated repository documentation (`README.md`, `framework-views/README.md`, `AGENTS.md`) and delivery tests (`tests/BuildAndPushDocfxImage.Tests.ps1`, `tests/ReleaseDelivery.Tests.ps1`) to document and enforce the six-tag versioned Docker image policy (three floating versioned convenience tags and three Codebelt engine-qualified tags).
### Removed
@@ -104,7 +113,7 @@ This is the initial release of the DocFX builder Docker image.
- Added a DocFX builder Docker image that includes the default and modern templates,
- Added support for running the DocFX build process in a container.
-[Unreleased]: https://github.com/codebeltnet/docfx/compare/v1.1.0..HEAD
+[1.1.1]: https://github.com/codebeltnet/docfx/compare/v1.1.0..v1.1.1
[1.1.0]: https://github.com/codebeltnet/docfx/compare/v1.0.1..v1.1.0
[1.0.1]: https://github.com/codebeltnet/docfx/compare/v1.0.0..v1.0.1
[1.0.0]: https://github.com/codebeltnet/docfx/compare/v0.1.4..v1.0.0
diff --git a/README.md b/README.md
index 610b1e2..a2f246b 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,8 @@ This repository distributes the DocFX builder image, shared templates and native
Framework views generate one native set of API pages, xrefs and search results per evaluated project target framework. From the consumer repository root, the generator reads `.docfx/docfx.json` and writes to `.bot/docfx`. The same PowerShell entry point runs on Windows, Linux, CI and in the builder image. Ordinary DocFX sites continue to use the standard CLI. [Framework views setup and migration](framework-views/README.md)
+Sites served by the generated NGINX configuration automatically get branded HTTP error pages, including sites that target a single framework. [HTTP error pages](framework-views/README.md#http-error-pages)
+
Consuming repositories only need to provide their DocFX metadata and content with a command such as `ADD [".", "docfx"]` in their documentation Dockerfile.
The image includes DocFX's `default` and `modern` templates and the Codebelt `ms-style` compatibility overlay. The overlay is intended for API reference sites maintained by the Codebelt ecosystem, including:
diff --git a/framework-views/Build-DocfxFrameworkViews.ps1 b/framework-views/Build-DocfxFrameworkViews.ps1
index 70be7c0..693679d 100644
--- a/framework-views/Build-DocfxFrameworkViews.ps1
+++ b/framework-views/Build-DocfxFrameworkViews.ps1
@@ -13,6 +13,7 @@ $ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $false
. "$PSScriptRoot/FrameworkViewConventions.ps1"
. "$PSScriptRoot/DocfxMetadata.ps1"
+. "$PSScriptRoot/DocfxHttpErrors.ps1"
function Invoke-Step([string] $Log, [string] $Command, [string[]] $Arguments, [switch] $ReturnExitCode) {
& $Command @Arguments *> $Log
@@ -194,6 +195,7 @@ try {
New-Item -ItemType Directory -Path $cacheRoot -Force | Out-Null
}
$restored = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal)
+ $defaultView = @($views.Keys)[0]
foreach ($view in $views.Keys) {
$entry = $views[$view]
$tfm = $entry.tfm
@@ -263,6 +265,7 @@ try {
})
New-Item -ItemType Directory -Path "$stage/framework-template" | Out-Null
Copy-Item -LiteralPath $templateSource -Destination "$stage/framework-template/ms-style" -Recurse
+ if ($view -ceq $defaultView) { $errorStatuses = @(New-DocfxHttpErrors $stage $build $ApiPath) }
Write-Json "$stage/framework-build.json" @{ build = $build }
Invoke-Step "$stage/build.log" $docfx @('build', "$stage/framework-build.json")
Write-Host "$view rendered $count metadata UIDs"
@@ -271,7 +274,6 @@ try {
Pop-Location
}
- $defaultView = @($views.Keys)[0]
$site = "$work/site"
Copy-Item -LiteralPath "$work/$($views[$defaultView].directory)/$buildDestination" -Destination $site -Recurse
$routes = foreach ($view in $views.Keys) {
@@ -301,9 +303,15 @@ try {
$root = if ($view -ceq $defaultView) { '""' } else { "/_frameworks/$directory" }
' ~^{0}$ {1};' -f [regex]::Escape($directory), $root
}
- Write-Json "$site/framework-views.json" ([ordered]@{ schemaVersion = 1; apiPath = "/$ApiPath/"; defaultView = $defaultView; viewOrder = @($views.Keys); views = $views })
+ $availability = Get-FrameworkPageAvailability $site $ApiPath $defaultView $views
+ Merge-SharedNavigationToc $site $work $buildDestination $ApiPath $defaultView $views $availability
+ $fallbackRoutes = Get-FrameworkNginxFallbackRules $defaultView $views
+ Write-Json "$site/framework-views.json" ([ordered]@{ schemaVersion = 1; apiPath = "/$ApiPath/"; defaultView = $defaultView; viewOrder = @($views.Keys); views = $views; availability = $availability })
+ Complete-DocfxHttpErrors $site $errorStatuses
(Get-Content -LiteralPath "$PSScriptRoot/framework-views.nginx.conf" -Raw).Replace('__API__', "/$ApiPath/").
- Replace('__VIEWS__', ($routes -join "`n")).Replace('__SEARCH__', ($searchRoutes -join "`n")) | Set-Content -LiteralPath "$work/nginx.conf"
+ Replace('__VIEWS__', ($routes -join "`n")).Replace('__SEARCH__', ($searchRoutes -join "`n")).
+ Replace('__FALLBACK__', ($fallbackRoutes -join "`n")).
+ Replace('__ERROR_STATUS__', ($errorStatuses -join ' ')) | Set-Content -LiteralPath "$work/nginx.conf"
Write-Host "Site: $site"
} finally {
$outputLock.Dispose()
diff --git a/framework-views/DocfxHttpErrors.ps1 b/framework-views/DocfxHttpErrors.ps1
new file mode 100644
index 0000000..85ee157
--- /dev/null
+++ b/framework-views/DocfxHttpErrors.ps1
@@ -0,0 +1,55 @@
+function New-DocfxHttpErrors([string] $Stage, $Build, [string] $ApiPath) {
+ $source = "$Stage/framework-template/http-errors"
+ New-Item -ItemType Directory -Path $source | Out-Null
+ $template = Get-Content -LiteralPath "$PSScriptRoot/http-error.md.tmpl" -Raw
+ $errors = @(
+ ,@(400, 'Bad Request', 'Check the documentation address and any selected framework.')
+ ,@(401, 'Unauthorized', 'Sign in with an account that has access to this documentation.')
+ ,@(403, 'Forbidden', 'Your current access does not allow you to open this page.')
+ ,@(404, 'Not Found', 'The documentation page may have moved or the address may be incorrect.')
+ ,@(405, 'Method Not Allowed', 'Open the documentation page directly in your browser.')
+ ,@(408, 'Request Timeout', 'The request took too long to arrive. Try opening the page again.')
+ ,@(410, 'Gone', 'This documentation page has been removed. Search for its replacement.')
+ ,@(412, 'Precondition Failed', 'Open the page again to request its current version.')
+ ,@(413, 'Content Too Large', 'The request is too large. Try opening the page directly.')
+ ,@(414, 'URI Too Long', 'Shorten the address or search for the page from the documentation home.')
+ ,@(415, 'Unsupported Media Type', 'Open the documentation page directly in your browser.')
+ ,@(416, 'Range Not Satisfiable', 'Open the page again to request the complete document.')
+ ,@(429, 'Too Many Requests', 'Wait a moment before making another request.')
+ ,@(500, 'Internal Server Error', 'The page could not be served. Try again in a moment.')
+ ,@(501, 'Not Implemented', 'This request is unsupported. Open the page directly in your browser.')
+ ,@(502, 'Bad Gateway', 'The documentation is temporarily unavailable. Try again in a moment.')
+ ,@(503, 'Service Unavailable', 'The documentation is temporarily unavailable. Try again in a moment.')
+ ,@(504, 'Gateway Timeout', 'The request took too long to complete. Try again in a moment.')
+ ,@(505, 'HTTP Version Not Supported', 'Open the documentation in a current browser.')
+ )
+ foreach ($errorPage in $errors) {
+ $code, $heading, $message = $errorPage
+ $page = $template.Replace('__STATUS__', $code).Replace('__HEADING__', $heading).
+ Replace('__MESSAGE__', $message).Replace('__API_PATH__', "/$ApiPath/")
+ Set-Content -LiteralPath "$source/$code.md" -Value $page
+ $code
+ }
+ $Build.content = @($Build['content'] ?? @()) + @{ src = 'framework-template/http-errors'; dest = '_docfx-errors'; files = @('*.md') }
+}
+
+function Complete-DocfxHttpErrors([string] $Site, [int[]] $Statuses) {
+ # Compatible templates load this asset on documentation pages, where the recovery script records the last page.
+ Add-Content -LiteralPath "$Site/public/framework-view.js" -Value ("`n" + (Get-Content -LiteralPath "$PSScriptRoot/http-error.js" -Raw))
+ Copy-Item -LiteralPath "$PSScriptRoot/http-error.js" -Destination "$Site/public/docfx-http-error.js"
+ $head = @'
+$0
+
HTTP __STATUS__
+__MESSAGE__
+ +]*>\s*\S') "Missing authored example for $($file.BaseName) in $view."
}
Get-Page "/_frameworks/$($entry.directory)$factoryPath" 404 | Out-Null
- Write-Host "$view passed $($inventory.Count) UID, anchor, TOC and search checks across $($pages.Count) served API pages."
+ Write-Host "$view passed $($combinedUids.Count) UID ($($dotnetInventory.Count) dotnet + $aspnetCount aspnet), anchor, TOC, search and fallback checks across $($pages.Count) served API pages."
}
} finally {
$client.Dispose()
diff --git a/tests/framework-view/fixture/ModernApi/Endpoint.cs b/tests/framework-view/fixture/ModernApi/Endpoint.cs
new file mode 100644
index 0000000..4e87989
--- /dev/null
+++ b/tests/framework-view/fixture/ModernApi/Endpoint.cs
@@ -0,0 +1,14 @@
+namespace FrameworkFixture.ModernApi;
+
+///
+/// An endpoint available only in modern .NET frameworks.
+///
+///
+///
+/// Return to Widget.
+///
+public class Endpoint
+{
+ /// Invokes the endpoint.
+ public void Invoke() { }
+}
diff --git a/tests/framework-view/fixture/ModernApi/ModernApi.csproj b/tests/framework-view/fixture/ModernApi/ModernApi.csproj
new file mode 100644
index 0000000..6e28b75
--- /dev/null
+++ b/tests/framework-view/fixture/ModernApi/ModernApi.csproj
@@ -0,0 +1,5 @@
+
+
+ net11.0;net10.0
+
+
diff --git a/tests/framework-view/fixture/Runtime/Widget.cs b/tests/framework-view/fixture/Runtime/Widget.cs
index 50a5b92..92d2ea2 100644
--- a/tests/framework-view/fixture/Runtime/Widget.cs
+++ b/tests/framework-view/fixture/Runtime/Widget.cs
@@ -3,6 +3,15 @@ namespace FrameworkFixture.Runtime;
///
/// A shared widget. See .
///
+///
+/// Related APIs:
+/// modern feature link,
+/// standard feature link,
+/// legacy feature link,
+/// Modern Endpoint link,
+/// Standard Adapter link,
+/// missing page link.
+///
public class Widget
{
/// Resets the widget.
@@ -22,6 +31,11 @@ public class Companion { }
public class ModernFeature { }
#endif
+#if NETSTANDARD2_1 || NETSTANDARD2_0
+/// An API documented only in .NET Standard views.
+public class StandardFeature { }
+#endif
+
#if NET48
/// An API documented in the .NET Framework view.
public class LegacyFeature { }
diff --git a/tests/framework-view/fixture/StandardApi/Adapter.cs b/tests/framework-view/fixture/StandardApi/Adapter.cs
new file mode 100644
index 0000000..01e88b0
--- /dev/null
+++ b/tests/framework-view/fixture/StandardApi/Adapter.cs
@@ -0,0 +1,14 @@
+namespace FrameworkFixture.StandardApi;
+
+///
+/// An adapter available only in .NET Standard frameworks.
+///
+///
+///
+/// See Modern Endpoint.
+///
+public class Adapter
+{
+ /// Adapts a payload.
+ public void Adapt() { }
+}
diff --git a/tests/framework-view/fixture/StandardApi/StandardApi.csproj b/tests/framework-view/fixture/StandardApi/StandardApi.csproj
new file mode 100644
index 0000000..3302d17
--- /dev/null
+++ b/tests/framework-view/fixture/StandardApi/StandardApi.csproj
@@ -0,0 +1,5 @@
+
+
+ netstandard2.1;netstandard2.0
+
+
diff --git a/tests/framework-view/fixture/docfx.json b/tests/framework-view/fixture/docfx.json
index dbb1cff..d93e4b1 100644
--- a/tests/framework-view/fixture/docfx.json
+++ b/tests/framework-view/fixture/docfx.json
@@ -9,11 +9,22 @@
"src": [{ "src": "..", "files": ["Utilities/Utilities.csproj"] }],
"dest": "api/utilities",
"memberLayout": "separatePages"
+ },
+ {
+ "src": [{ "src": "..", "files": ["ModernApi/ModernApi.csproj"] }],
+ "dest": "api/modern",
+ "memberLayout": "separatePages"
+ },
+ {
+ "src": [{ "src": "..", "files": ["StandardApi/StandardApi.csproj"] }],
+ "dest": "api/standard",
+ "memberLayout": "separatePages"
}
],
"build": {
"content": [{ "files": ["api/**/*.yml", "index.md", "toc.yml"] }],
"globalMetadata": {
+ "_appName": "Framework Fixture",
"_enableSearch": true,
"_disableContribution": true
},
diff --git a/tests/framework-view/fixture/index.md b/tests/framework-view/fixture/index.md
index 80885ba..2ba784e 100644
--- a/tests/framework-view/fixture/index.md
+++ b/tests/framework-view/fixture/index.md
@@ -2,4 +2,9 @@
This page explains the compass.
-[Widget](xref:FrameworkFixture.Runtime.Widget)
+- [Widget](xref:FrameworkFixture.Runtime.Widget)
+- [Modern Endpoint](api/modern/FrameworkFixture.ModernApi.Endpoint.html)
+- [Modern Endpoint (unavailable view)](api/modern/FrameworkFixture.ModernApi.Endpoint.html?view=netstandard-2.0)
+- [Standard Adapter](api/standard/FrameworkFixture.StandardApi.Adapter.html)
+- [Standard Adapter (valid view)](api/standard/FrameworkFixture.StandardApi.Adapter.html?view=netstandard-2.0)
+- [Missing API](api/runtime/FrameworkFixture.Runtime.MissingPage.html)
diff --git a/tests/framework-view/fixture/toc.yml b/tests/framework-view/fixture/toc.yml
index 1446a60..5cf4a3b 100644
--- a/tests/framework-view/fixture/toc.yml
+++ b/tests/framework-view/fixture/toc.yml
@@ -4,3 +4,7 @@
href: api/runtime/FrameworkFixture.Runtime.yml
- name: Utilities API
href: api/utilities/FrameworkFixture.Utilities.yml
+- name: Modern API
+ href: api/modern/FrameworkFixture.ModernApi.yml
+- name: Standard API
+ href: api/standard/FrameworkFixture.StandardApi.yml
diff --git a/tests/framework-view/framework-view.spec.js b/tests/framework-view/framework-view.spec.js
index e147fab..9240031 100644
--- a/tests/framework-view/framework-view.spec.js
+++ b/tests/framework-view/framework-view.spec.js
@@ -5,9 +5,15 @@ const widget = runtime + 'Widget.html';
const reset = runtime + 'Widget.Reset.html';
const companion = runtime + 'Companion.html';
const modern = runtime + 'ModernFeature.html';
+const standard = runtime + 'StandardFeature.html';
const legacy = runtime + 'LegacyFeature.html';
+const missingPage = runtime + 'MissingPage.html';
const utilities = '/api/utilities/FrameworkFixture.Utilities.html';
const utility = '/api/utilities/FrameworkFixture.Utilities.Utility.html';
+const modernNamespace = '/api/modern/FrameworkFixture.ModernApi.html';
+const modernEndpoint = '/api/modern/FrameworkFixture.ModernApi.Endpoint.html';
+const standardNamespace = '/api/standard/FrameworkFixture.StandardApi.html';
+const standardAdapter = '/api/standard/FrameworkFixture.StandardApi.Adapter.html';
const net11 = 'net-11.0';
const net10 = 'net-10.0';
const standard21 = 'netstandard-2.1';
@@ -35,10 +41,13 @@ test.afterEach(async ({ page }) => {
expect(pageErrors.get(page)).toEqual([]);
});
-test('manifest determines the framework labels and default selection', async ({ page, request }) => {
+test('manifest determines the framework labels, availability and default selection', async ({ page, request }) => {
const manifest = await (await request.get('/framework-views.json')).json();
expect(manifest.apiPath).toBe('/api/');
expect(manifest.viewOrder).toEqual([net11, net10, standard21, standard20, net48]);
+ expect(manifest.availability.sets[manifest.availability.pages['modern/FrameworkFixture.ModernApi.Endpoint.html']]).toEqual([net11, net10]);
+ expect(manifest.availability.sets[manifest.availability.pages['standard/FrameworkFixture.StandardApi.Adapter.html']]).toEqual([standard21, standard20]);
+ expect(manifest.availability.sets[manifest.availability.pages['runtime/FrameworkFixture.Runtime.LegacyFeature.html']]).toEqual([net48]);
const defaultIndex = page.waitForResponse(response => new URL(response.url()).pathname === '/index.json');
await page.goto(widget);
@@ -49,6 +58,7 @@ test('manifest determines the framework labels and default selection', async ({
'.NET 11', '.NET 10', '.NET Standard 2.1', '.NET Standard 2.0', '.NET Framework 4.8'
]);
await expect(page.locator(`article a[href$="${companion.split('/').pop()}"]`).first()).toBeVisible();
+ await expect(page.locator(`#navbar a[href="${viewed(standardNamespace, standard21)}"]`).first()).toBeVisible();
await expect(page).toHaveURL(widget);
await page.goto('/index.html');
@@ -77,39 +87,45 @@ for (const fragment of ['#missing%', '#%FF', '#unknown-anchor']) {
});
}
-test('an encoded member fragment resolves through the native xref maps', async ({ page }) => {
- await page.goto(viewed(reset, net11));
+test('an encoded member fragment resolves through the native xref maps using unified precedence', async ({ page }) => {
+ await page.goto(viewed(reset, net10));
const declaration = page.locator('article [data-uid="FrameworkFixture.Runtime.Widget.Reset(System.Int32)"]');
const id = await declaration.getAttribute('id');
const encodedId = '%46' + id.slice(1);
expect(decodeURIComponent(encodedId)).toBe(id);
- await page.goto(viewed(reset, net11) + '#' + encodedId);
+ await page.goto(viewed(reset, net10) + '#' + encodedId);
await selector(page).selectOption(standard20);
- await expect(page).toHaveURL(viewed(reset, standard21) + '#' + id);
+ await expect(page).toHaveURL(viewed(reset, net11) + '#' + id);
await expect(declaration).toBeVisible();
- await expect(selector(page)).toHaveValue(standard21);
- await expect(status(page)).toContainText('Showing .NET Standard 2.1.');
+ await expect(selector(page)).toHaveValue(net11);
+ await expect(status(page)).toContainText('Showing .NET 11.');
});
-test('fallback navigates once to the nearest newer view and then keeps it', async ({ page, request }) => {
- await page.goto(viewed(modern, net11));
- await expect(selector(page)).toHaveValue(net11);
+test('selector fallback targets the first framework in precedence order for both default and non-default APIs', async ({ page }) => {
+ // Fallback targeting the default framework (.NET 11)
+ await page.goto(viewed(modern, net10));
+ await expect(selector(page)).toHaveValue(net10);
const navigations = [];
page.on('request', request => {
if (request.isNavigationRequest()) navigations.push(request);
});
await selector(page).selectOption(standard21);
- await expect(page).toHaveURL(viewed(modern, net10));
- await expect(selector(page)).toHaveValue(net10);
- await expect(status(page)).toHaveText('This API is not documented for .NET Standard 2.1. Showing .NET 10.');
+ await expect(page).toHaveURL(viewed(modern, net11));
+ await expect(selector(page)).toHaveValue(net11);
+ await expect(status(page)).toHaveText('This API is not documented for .NET Standard 2.1. Showing .NET 11.');
await selector(page).selectOption(standard21);
- await expect(status(page)).toHaveText('This API is not documented for .NET Standard 2.1. Showing .NET 10.');
- await expect(selector(page)).toHaveValue(net10);
- expect(navigations.map(request => new URL(request.url()).search)).toEqual(['?view=' + net10]);
+ await expect(status(page)).toHaveText('This API is not documented for .NET Standard 2.1. Showing .NET 11.');
+ await expect(selector(page)).toHaveValue(net11);
+ expect(navigations.map(request => new URL(request.url()).search)).toEqual(['?view=' + net11]);
expect(navigations[0].redirectedFrom()).toBeNull();
- const missing = await request.get(viewed(modern, standard21), { maxRedirects: 0 });
- expect(missing.status()).toBe(404);
- expect(missing.headers().location).toBeUndefined();
+
+ // Fallback targeting a non-default framework (.NET Standard 2.1)
+ await page.goto(viewed(standard, standard20));
+ await expect(selector(page)).toHaveValue(standard20);
+ await selector(page).selectOption(net11);
+ await expect(page).toHaveURL(viewed(standard, standard21));
+ await expect(selector(page)).toHaveValue(standard21);
+ await expect(status(page)).toHaveText('This API is not documented for .NET 11. Showing .NET Standard 2.1.');
});
test('an API documented only in an older view stays there', async ({ page }) => {
@@ -120,6 +136,194 @@ test('an API documented only in an older view stays there', async ({ page }) =>
await expect(selector(page)).toHaveValue(net48);
});
+test('global navigation resolves unavailable API sections to default and non-default fallbacks and preserves available views', async ({ page }) => {
+ // Reproduces the Cuemon scenario: on netstandard-2.0, click an API section only available in modern .NET -> falls back to net-11.0
+ await page.goto(viewed(widget, standard20));
+ await expect(selector(page)).toHaveValue(standard20);
+ const modernNavLink = page.locator(`#navbar a[href="${viewed(modernNamespace, net11)}"]`).first();
+ await expect(modernNavLink).toBeVisible();
+ const modernToc = page.waitForResponse(response => {
+ const url = new URL(response.url());
+ return url.pathname === '/api/modern/toc.json' && url.searchParams.get('view') === net11;
+ });
+ const modernIndex = page.waitForResponse(response => new URL(response.url()).pathname === '/_framework-search/net11/index.json');
+ await modernNavLink.click();
+ await expect(page).toHaveURL(viewed(modernNamespace, net11));
+ expect((await modernToc).ok()).toBeTruthy();
+ expect((await modernIndex).ok()).toBeTruthy();
+ await expect(selector(page)).toHaveValue(net11);
+ await expect(page.locator('article h1')).toContainText('FrameworkFixture.ModernApi');
+ await expect(page.locator(`#toc a[href="${viewed(modernEndpoint, net11)}"]`).first()).toBeVisible();
+
+ // Browser history Back/Forward works cleanly without redirect traps
+ await page.goBack();
+ await expect(page).toHaveURL(viewed(widget, standard20));
+ await expect(selector(page)).toHaveValue(standard20);
+ await page.goForward();
+ await expect(page).toHaveURL(viewed(modernNamespace, net11));
+ await expect(selector(page)).toHaveValue(net11);
+
+ // On net-10.0, clicking Modern API preserves net-10.0
+ await page.goto(viewed(widget, net10));
+ await page.locator(`#navbar a[href="${viewed(modernNamespace, net10)}"]`).first().click();
+ await expect(page).toHaveURL(viewed(modernNamespace, net10));
+ await expect(selector(page)).toHaveValue(net10);
+
+ // On net-11.0, clicking Standard API (unavailable in net-11.0 and net-10.0) falls back to non-default netstandard-2.1
+ await page.goto(viewed(widget, net11));
+ const standardNavLink = page.locator(`#navbar a[href="${viewed(standardNamespace, standard21)}"]`).first();
+ await expect(standardNavLink).toBeVisible();
+ const standardToc = page.waitForResponse(response => {
+ const url = new URL(response.url());
+ return url.pathname === '/api/standard/toc.json' && url.searchParams.get('view') === standard21;
+ });
+ const standardIndex = page.waitForResponse(response => new URL(response.url()).pathname === '/_framework-search/netstandard2.1/index.json');
+ await standardNavLink.click();
+ await expect(page).toHaveURL(viewed(standardNamespace, standard21));
+ expect((await standardToc).ok()).toBeTruthy();
+ expect((await standardIndex).ok()).toBeTruthy();
+ await expect(selector(page)).toHaveValue(standard21);
+ await expect(page.locator('article h1')).toContainText('FrameworkFixture.StandardApi');
+ await expect(page.locator(`#toc a[href="${viewed(standardAdapter, standard21)}"]`).first()).toBeVisible();
+
+ // On netstandard-2.0, clicking Standard API preserves netstandard-2.0
+ await page.goto(viewed(widget, standard20));
+ await page.locator(`#navbar a[href="${viewed(standardNamespace, standard20)}"]`).first().click();
+ await expect(page).toHaveURL(viewed(standardNamespace, standard20));
+ await expect(selector(page)).toHaveValue(standard20);
+});
+
+test('ordinary internal API hyperlinks resolve availability, preserve query/fragment and support new tabs without click interception', async ({ page, context }) => {
+ await page.goto(viewed(widget, standard20));
+ await expect(page.locator(`article a[href="${viewed(modern, net11)}"]`)).toBeVisible();
+ await expect(page.locator(`article a[href="${viewed(standard, standard20)}"]`)).toBeVisible();
+ await expect(page.locator(`article a[href="${viewed(legacy, net48)}"]`)).toBeVisible();
+ await expect(page.locator(`article a[href="${modernEndpoint}?source=remarks&view=${net11}#details"]`)).toBeVisible();
+ await expect(page.locator(`article a[href="${standardAdapter}?source=remarks&view=${standard20}#details"]`)).toBeVisible();
+ // Genuine missing page keeps the requested view rather than fabricating a fallback.
+ await expect(page.locator(`article a[href="${viewed(missingPage, standard20)}"]`)).toBeVisible();
+
+ // Open a resolved fallback hyperlink in a new tab using a plain middle-click (no JS click handler interception).
+ const endpointLink = page.locator(`article a[href="${modernEndpoint}?source=remarks&view=${net11}#details"]`);
+ const [tab] = await Promise.all([
+ context.waitForEvent('page'),
+ endpointLink.click({ button: 'middle' })
+ ]);
+ await expect(tab).toHaveURL(`${modernEndpoint}?source=remarks&view=${net11}#details`);
+ await expect(selector(tab)).toHaveValue(net11);
+ await expect(tab.locator('article h1')).toContainText('Endpoint Class');
+ await tab.close();
+
+ // Conceptual pages also resolve API links targeting unavailable views or non-default-only APIs.
+ await page.goto('/index.html');
+ await expect(page.locator(`article a[href="${modernEndpoint.slice(1)}"]`).first()).toBeVisible();
+ await expect(page.locator(`article a[href="${viewed(modernEndpoint, net11)}"]`).first()).toBeVisible();
+ await expect(page.locator(`article a[href="${viewed(standardAdapter, standard21)}"]`).first()).toBeVisible();
+ await expect(page.locator(`article a[href="${viewed(standardAdapter.slice(1), standard20)}"]`).first()).toBeVisible();
+ await expect(page.locator(`article a[href$="${missingPage.split('/').pop()}"]`).first()).toBeVisible();
+});
+
+test('JavaScript-disabled navigation resolves fallback via HTTP 302 and preserves query parameters, fragments and history', async ({ browser }) => {
+ const context = await browser.newContext({ javaScriptEnabled: false });
+ const page = await context.newPage();
+ try {
+ await page.goto(viewed(widget, standard20));
+ await expect(page).toHaveURL(viewed(widget, standard20));
+
+ // Direct navigation to default fallback with unrelated query params and fragment
+ await page.goto(`${modernEndpoint}?tag=a&view=${standard20}&tag=b#details`);
+ await expect(page).toHaveURL(`${modernEndpoint}?tag=a&tag=b&view=${net11}#details`);
+ await expect(page.locator('article h1')).toContainText('Endpoint Class');
+
+ // Back/Forward across server-side 302 redirect has no redirect loop
+ await page.goBack();
+ await expect(page).toHaveURL(viewed(widget, standard20));
+ await page.goForward();
+ await expect(page).toHaveURL(`${modernEndpoint}?tag=a&tag=b&view=${net11}#details`);
+
+ // Clicking a static HTML link in Widget remarks to a non-default-only API while JS is disabled triggers HTTP 302
+ await page.goto(widget);
+ await page.locator('article a', { hasText: 'Standard Adapter link' }).click();
+ await expect(page).toHaveURL(`${standardAdapter}?source=remarks&view=${standard21}#details`);
+ await expect(page.locator('article h1')).toContainText('Adapter Class');
+ } finally {
+ await context.close();
+ }
+});
+
+test('direct HTTP routing redirects unavailable page/framework combinations with 302 and preserves 404, 400 and isolation', async ({ request }) => {
+ const redirectCases = [
+ // Unavailable section -> default fallback
+ { from: viewed(modernEndpoint, standard20), to: viewed(modernEndpoint, net11) },
+ { from: viewed(modernEndpoint, standard21), to: viewed(modernEndpoint, net11) },
+ { from: `${modernEndpoint}?tag=a&view=${standard20}&tag=b`, to: `${modernEndpoint}?tag=a&tag=b&view=${net11}` },
+ { from: `${modernEndpoint}?VIEW=${standard20}&tag=a`, to: `${modernEndpoint}?tag=a&view=${net11}` },
+ { from: `${modernEndpoint}?tag=a&VIEW=${standard20}&view=${standard21}&tag=b`, to: `${modernEndpoint}?tag=a&tag=b&view=${net11}` },
+ { from: viewed(modern, standard21), to: viewed(modern, net11) },
+ // Unavailable section / type -> non-default fallback
+ { from: standardAdapter, to: viewed(standardAdapter, standard21) },
+ { from: viewed(standardAdapter, net11), to: viewed(standardAdapter, standard21) },
+ { from: `${standardAdapter}?tag=x&tag=y`, to: `${standardAdapter}?tag=x&tag=y&view=${standard21}` },
+ { from: viewed(standardAdapter, net48), to: viewed(standardAdapter, standard21) },
+ { from: viewed(standard, net10), to: viewed(standard, standard21) },
+ { from: legacy, to: viewed(legacy, net48) },
+ { from: viewed(legacy, net11), to: viewed(legacy, net48) },
+ { from: `${legacy}?view=`, to: viewed(legacy, net48) }
+ ];
+
+ for (const item of redirectCases) {
+ const response = await request.get(item.from, { maxRedirects: 0 });
+ expect(response.status(), item.from).toBe(302);
+ expect(response.headers().location, item.from).toBe(item.to);
+ expect(response.headers()['cache-control'], item.from).toContain('no-store');
+ expect(response.headers().etag, item.from).toBeUndefined();
+
+ const followed = await request.get(item.to, { maxRedirects: 0 });
+ expect(followed.status(), item.to).toBe(200);
+ expect(followed.headers().location, item.to).toBeUndefined();
+ }
+
+ // Preserved available views return 200 directly
+ for (const okPath of [
+ viewed(modernEndpoint, net10),
+ viewed(standardAdapter, standard20),
+ viewed(legacy, net48),
+ '/xrefmap.yml?view=' + standard20,
+ '/index.html?view=unknown',
+ '/public/docfx.min.css?view=unknown'
+ ]) {
+ const ok = await request.get(okPath, { maxRedirects: 0 });
+ expect(ok.status(), okPath).toBe(200);
+ }
+
+ // Genuine missing pages, non-HTML API resources and internal framework directories return 404 without redirecting
+ for (const notFoundPath of [
+ missingPage,
+ viewed(missingPage, standard20),
+ '/api/modern/toc.json?view=' + standard20,
+ '/api/standard/toc.json',
+ '/api/modern/missing.png?view=' + standard20,
+ '/_frameworks/net10' + widget
+ ]) {
+ const notFound = await request.get(notFoundPath, { maxRedirects: 0 });
+ expect(notFound.status(), notFoundPath).toBe(404);
+ expect(notFound.headers().location, notFoundPath).toBeUndefined();
+ }
+
+ // Unknown or wrong-case framework identifiers return 400 without redirecting
+ for (const badViewPath of [
+ viewed(modernEndpoint, 'unknown'),
+ viewed(modernEndpoint, 'NET-11.0'),
+ viewed(missingPage, 'unknown'),
+ '/xrefmap.yml?view=unknown',
+ `${modernEndpoint}?view=${standard20}&view=${standard21}&view=${net48}`
+ ]) {
+ const bad = await request.get(badViewPath, { maxRedirects: 0 });
+ expect(bad.status(), badViewPath).toBe(400);
+ expect(bad.headers().location, badViewPath).toBeUndefined();
+ }
+});
+
test('native TOC, breadcrumbs and cross-references stay in the view after reload and history', async ({ page }) => {
const toc = page.waitForResponse(response => {
const url = new URL(response.url());
@@ -172,7 +376,7 @@ test('explicit views load the index for the manifest directory', async ({ page,
test('dynamic links preserve query and fragment without repeated DOM updates', async ({ page }) => {
await page.goto(viewed(widget, net10));
- const result = await page.evaluate(async ({ companion, net10, net11 }) => {
+ const result = await page.evaluate(async ({ companion, legacy, net10, net11, net48 }) => {
const anchor = document.createElement('a');
const initial = `${companion}?tag=a&tag=b&VIEW=${net11}&view=${net11}#details`;
const expected = `${companion}?tag=a&tag=b&view=${net10}#details`;
@@ -183,18 +387,30 @@ test('dynamic links preserve query and fragment without repeated DOM updates', a
document.querySelector('article').append(anchor);
await new Promise(resolve => requestAnimationFrame(resolve));
const rewritten = anchor.getAttribute('href');
+ anchor.setAttribute('href', `${legacy}?tag=a#details`);
+ await new Promise(resolve => requestAnimationFrame(resolve));
+ const fallback = anchor.getAttribute('href');
anchor.setAttribute('href', '/index.html?tag=a#guide');
await new Promise(resolve => requestAnimationFrame(resolve));
const concept = anchor.getAttribute('href');
anchor.setAttribute('href', 'https://example.com/api/page.html?tag=a#guide');
await new Promise(resolve => requestAnimationFrame(resolve));
observer.disconnect();
- return { rewritten, expected, concept, external: anchor.getAttribute('href'), count: values.length };
- }, { companion, net10, net11 });
+ return {
+ rewritten,
+ expected,
+ fallback,
+ expectedFallback: `${legacy}?tag=a&view=${net48}#details`,
+ concept,
+ external: anchor.getAttribute('href'),
+ count: values.length
+ };
+ }, { companion, legacy, net10, net11, net48 });
expect(result.rewritten).toBe(result.expected);
+ expect(result.fallback).toBe(result.expectedFallback);
expect(result.concept).toBe('/index.html?tag=a#guide');
expect(result.external).toBe('https://example.com/api/page.html?tag=a#guide');
- expect(result.count).toBe(3);
+ expect(result.count).toBe(5);
});
for (const [view, term, expected] of [[net10, 'ModernFeature', modern], [net48, 'LegacyFeature', legacy]]) {
diff --git a/tests/framework-view/http-error.spec.js b/tests/framework-view/http-error.spec.js
new file mode 100644
index 0000000..b5aa0da
--- /dev/null
+++ b/tests/framework-view/http-error.spec.js
@@ -0,0 +1,235 @@
+const { test, expect } = require('@playwright/test');
+
+const endpoint = '/api/modern/FrameworkFixture.ModernApi.Endpoint.html';
+const widget = '/api/runtime/FrameworkFixture.Runtime.Widget.html';
+const missing = '/deep/nested/documentation/does-not-exist.html';
+const back = page => page.getByRole('link', { name: 'Go back' });
+const heading = (page, name) => page.getByRole('heading', { name, exact: true });
+const alternatives = page => page.locator('#docfx-error-framework-links a');
+
+test('deep document errors reuse branding, assets, navigation and search', async ({ page, request }) => {
+ const assetErrors = [];
+ page.on('response', response => {
+ if (response.status() >= 400 && !response.request().isNavigationRequest()) {
+ assetErrors.push(new URL(response.url()).pathname);
+ }
+ });
+ expect((await page.goto(missing)).status()).toBe(404);
+ await expect(heading(page, 'Not Found')).toBeVisible();
+ await expect(page.locator('html')).toHaveAttribute('lang', 'en');
+ await expect(page.locator('.navbar-brand')).toContainText('Framework Fixture');
+ await expect(page.locator('#navbar a[href$="/index.html"]').first()).toBeVisible();
+ await expect(page.locator('footer')).toBeVisible();
+ await expect(page.locator('#docfx-http-error')).toHaveCSS('padding-top', '24px');
+ expect((await page.reload()).status()).toBe(404);
+ await expect(page).toHaveURL(missing);
+ await expect(alternatives(page)).toHaveCount(0);
+ await expect(back(page)).toHaveAttribute('href', '/');
+
+ await page.getByRole('button', { name: 'Search documentation' }).click();
+ const search = page.getByRole('searchbox', { name: 'Search', exact: true });
+ await expect(search).toBeFocused();
+ await search.fill('compass');
+ await expect(page.locator('#search-results .item-title a').first()).toHaveAttribute('href', '/index.html?q=compass');
+ expect(assetErrors).toEqual([]);
+
+ const index = await request.get('/index.json');
+ expect(await index.text()).not.toContain('_docfx-errors');
+});
+
+test('recovery remembers the last successful document across consecutive errors', async ({ page }) => {
+ const previous = widget + '?view=net-10.0';
+ expect((await page.goto(previous + '&tag=discarded')).status()).toBe(200);
+ expect((await page.goto(missing + '?token=secret-query-value')).status()).toBe(404);
+ await page.getByText('Technical details').click();
+ await expect(page.locator('#docfx-error-path')).toHaveText(missing);
+ await expect(page.locator('#docfx-http-error')).not.toContainText('secret-query-value');
+ const other = '/%3Cstrong%3Epath%3C%2Fstrong%3E.html';
+ expect((await page.goto(other)).status()).toBe(404);
+ await page.getByText('Technical details').click();
+ await expect(page.locator('#docfx-error-path')).toHaveText(other);
+ await expect(page.locator('#docfx-error-path strong')).toHaveCount(0);
+ await back(page).click();
+ await expect(page).toHaveURL(previous);
+ await expect(page.locator('#docfx-http-error')).toHaveCount(0);
+});
+
+test('automatic fallback takes precedence and an invalid request lists only working frameworks', async ({ page, request }) => {
+ const unavailable = endpoint + '?view=netstandard-2.0';
+ const fallback = await request.get(unavailable, { maxRedirects: 0 });
+ expect(fallback.status()).toBe(302);
+ expect(fallback.headers().location).toBe(endpoint + '?view=net-11.0');
+ expect((await page.goto(unavailable)).status()).toBe(200);
+ await expect(page).toHaveURL(endpoint + '?view=net-11.0');
+
+ const rejected = unavailable + '&view=netstandard-2.0&view=netstandard-2.0&token=secret-query-value';
+ expect((await page.goto(rejected)).status()).toBe(400);
+ await expect(heading(page, 'Bad Request')).toBeVisible();
+ await expect(page.locator('#docfx-error-framework-message')).toContainText('unavailable for netstandard2.0');
+ await expect(alternatives(page)).toHaveText(['net11.0 (default)', 'net10.0']);
+ await page.getByText('Technical details').click();
+ await expect(page.locator('#docfx-error-view')).toHaveText('netstandard2.0');
+ await expect(page.locator('#docfx-http-error')).not.toContainText('secret-query-value');
+ for (const link of await alternatives(page).all()) {
+ expect((await request.get(await link.getAttribute('href'), { maxRedirects: 0 })).status()).toBe(200);
+ }
+ await alternatives(page).last().click();
+ await expect(page).toHaveURL(endpoint + '?view=net-10.0');
+});
+
+test('missing framework metadata leaves standard actions available', async ({ page }) => {
+ const metadata = page.waitForResponse(response => new URL(response.url()).pathname === '/framework-views.json');
+ await page.route('**/framework-views.json', route => route.fulfill({ status: 404 }));
+ expect((await page.goto(endpoint + '?view=unavailable')).status()).toBe(400);
+ await metadata;
+ await expect(heading(page, 'Bad Request')).toBeVisible();
+ await expect(alternatives(page)).toHaveCount(0);
+ await back(page).click();
+ await expect(page).toHaveURL('/');
+});
+
+test('error recovery works with a compatible template that requires framework metadata', async ({ page }) => {
+ const scriptErrors = [];
+ page.on('pageerror', error => scriptErrors.push(error.message));
+ await page.route('**/public/framework-view.js', async route => {
+ const response = await route.fetch();
+ const script = await response.text();
+ await route.fulfill({
+ response,
+ body: `document.querySelector('meta[name="docfx:framework-api"]').content;\n${script}`
+ });
+ });
+
+ expect((await page.goto(missing)).status()).toBe(404);
+ await expect(back(page)).toBeVisible({ timeout: 3000 });
+ expect(scriptErrors).toEqual([]);
+});
+
+test('themes and search work on a narrow viewport', async ({ page }) => {
+ await page.setViewportSize({ width: 375, height: 740 });
+ await page.emulateMedia({ colorScheme: 'dark' });
+ await page.goto(missing);
+ await expect(page.locator('html')).toHaveAttribute('data-bs-theme', 'dark');
+ for (const theme of ['light', 'dark']) {
+ await page.evaluate(theme => localStorage.setItem('theme', theme), theme);
+ await page.reload();
+ await expect(page.locator('html')).toHaveAttribute('data-bs-theme', theme);
+ await expect(page.locator('body')).toHaveCSS('background-color',
+ theme === 'light' ? 'rgb(255, 255, 255)' : 'rgb(27, 27, 27)');
+ }
+ await page.getByRole('button', { name: 'Search documentation' }).click();
+ await expect(page.getByRole('searchbox', { name: 'Search', exact: true })).toBeFocused();
+ expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBe(375);
+});
+
+test.describe('without JavaScript', () => {
+ test.use({ javaScriptEnabled: false });
+ test('retains branded styling, details and a working home link', async ({ page }) => {
+ expect((await page.goto(missing)).status()).toBe(404);
+ await expect(heading(page, 'Not Found')).toBeVisible();
+ await expect(page.locator('#docfx-http-error')).toHaveCSS('padding-top', '24px');
+ await page.getByText('Technical details').click();
+ await expect(page.getByText('404 Not Found', { exact: true })).toBeVisible();
+ await expect(back(page)).toBeHidden();
+ await page.getByRole('link', { name: 'Documentation home' }).click();
+ await expect(heading(page, 'Concept guide')).toBeVisible();
+ });
+});
+
+test('supported HTTP statuses and applicable headers are retained', async ({ request }) => {
+ const statuses = {
+ 400: 'Bad Request', 401: 'Unauthorized', 403: 'Forbidden', 404: 'Not Found',
+ 405: 'Method Not Allowed', 410: 'Gone', 429: 'Too Many Requests',
+ 500: 'Internal Server Error', 502: 'Bad Gateway', 503: 'Service Unavailable', 504: 'Gateway Timeout'
+ };
+ for (const [code, title] of Object.entries(statuses)) {
+ const response = await request.get('/_status/' + code + '.html', { maxRedirects: 0 });
+ expect(response.status()).toBe(Number(code));
+ expect(response.headers()['content-type']).toContain('text/html');
+ expect(response.headers()['cache-control']).toContain('no-store');
+ expect(response.headers().location).toBeUndefined();
+ expect(await response.text()).toContain('' + title + '
');
+ if (code === '401') expect(response.headers()['www-authenticate']).toContain('Fixture documentation');
+ if (code === '405') expect(response.headers().allow).toBe('GET, HEAD');
+ if (code === '429') expect(response.headers()['retry-after']).toBe('30');
+ if (code === '503') expect(response.headers()['retry-after']).toBe('60');
+ }
+ expect((await request.post('/index.html')).status()).toBe(405);
+ const range = await request.get('/index.html', { headers: { range: 'bytes=99999999-' } });
+ expect(range.status()).toBe(416);
+ expect(range.headers()['content-range']).toMatch(/^bytes \*\/\d+$/);
+ expect(await range.text()).toContain('Range Not Satisfiable
');
+ const head = await request.head(missing);
+ expect(head.status()).toBe(404);
+ expect(await head.text()).toBe('');
+
+ for (const [path, headers] of [
+ ['/public/missing-01234567.js', {}], ['/_docfx-errors/404.html', {}],
+ [missing, { accept: 'application/json' }], [missing, { 'sec-fetch-dest': 'script' }]
+ ]) {
+ const response = await request.get(path, { headers });
+ expect(response.status()).toBe(404);
+ expect(response.headers()['content-type']).toContain('text/plain');
+ expect(response.headers()['cache-control']).toContain('no-store');
+ expect(await response.text()).not.toContain('docfx-http-error');
+ }
+});
+
+test('retry is explicit and opens the original URL', async ({ page }) => {
+ const url = '/_status/503.html?source=retry';
+ expect((await page.goto(url)).status()).toBe(503);
+ const retry = page.getByRole('button', { name: 'Retry' });
+ const navigation = page.waitForResponse(response => response.request().isNavigationRequest());
+ await retry.click();
+ expect((await navigation).status()).toBe(503);
+ await expect(page).toHaveURL(url);
+});
+
+for (const method of ['GET', 'POST']) {
+ test(`retry makes a fresh GET and keeps the fragment after a failed ${method}`, async ({ page }) => {
+ const path = '/_status/503.html?source=retry&tag=a%20b&tag=c';
+ const url = path + '#members';
+ const requests = [];
+ await page.route(target => target.pathname === '/_status/503.html', async route => {
+ const request = route.request();
+ const target = new URL(request.url());
+ requests.push([request.method(), target.pathname + target.search]);
+ if (requests.length === 1) {
+ await route.fulfill({ response: await route.fetch({ method: 'GET' }) });
+ } else {
+ await route.fulfill({ contentType: 'text/html', body: 'Recovered
' });
+ }
+ });
+
+ if (method === 'POST') {
+ await page.goto('/');
+ await page.evaluate(url => {
+ const form = document.createElement('form');
+ form.action = url;
+ form.method = 'POST';
+ document.body.append(form);
+ form.submit();
+ }, url);
+ } else {
+ await page.goto(url);
+ }
+ await expect(heading(page, 'Service Unavailable')).toBeVisible();
+ await expect(page).toHaveURL(url);
+ await page.getByRole('button', { name: 'Retry' }).click();
+ await expect(heading(page, 'Recovered')).toBeVisible({ timeout: 3000 });
+ expect(requests).toEqual([[method, path], ['GET', path]]);
+ await expect(page).toHaveURL(url);
+ });
+}
+
+test('the generated server brands errors for sites with a single TFM', async ({ page, request }) => {
+ const origin = process.env.DOCFX_TEST_SINGLE_ORIGIN;
+ expect(origin).toBeTruthy();
+ const manifest = await (await request.get(origin + '/framework-views.json')).json();
+ expect(manifest.viewOrder).toEqual(['net-11.0']);
+ expect((await page.goto(origin + missing)).status()).toBe(404);
+ await expect(heading(page, 'Not Found')).toBeVisible();
+ await expect(alternatives(page)).toHaveCount(0);
+ await page.getByRole('link', { name: 'Documentation home' }).click();
+ await expect(heading(page, 'Concept guide')).toBeVisible();
+});