- **Improved successor handling in stable-version.html**
- Fixed logic to maintain current product context while using successor for version info - Added appropriate successor product display in callout warning - Fixed conditions for when callout should appear - Fixed potential `isset <nil>` problems with proper nil checks before accessing properties - **Added comprehensive Cypress tests for successor relationship** - Created `stable-version-callout.cy.js` for testing successor behavior - Tests that `/influxdb/v1/` and `/influxdb/v2/` pages show successor callout - Verifies "InfluxDB 3 Core" appears in callout with correct links - Checks product data configuration in `products.yml` - Includes JavaScript error detection - **Configured environment-specific Hugo settings** - Added `/config/testing/config.yml` for test environment - Configured port 1315 for test environment - Added build parameters specific to testing context - Separated test environment from development environment - **Updated Docker configuration** - Added new package.json script for building Docker image - Improved Docker-based testing commandspull/6075/head
parent
4cfff239f3
commit
02e10068ad
|
@ -3,8 +3,7 @@
|
|||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"*": [
|
||||
"*",
|
||||
"../node_modules/*"
|
||||
"*"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
import:
|
||||
- hugo.yml
|
|
@ -1,8 +1,7 @@
|
|||
# config.testing.toml
|
||||
# This configuration inherits from the base config and overrides draft settings
|
||||
baseURL: 'http://localhost:1315/'
|
||||
|
||||
# Import base configuration
|
||||
imports: ["hugo.yml"]
|
||||
server:
|
||||
port: 1315
|
||||
|
||||
# Override settings for testing
|
||||
buildFuture: true
|
|
@ -1,45 +0,0 @@
|
|||
/// <reference types="cypress" />
|
||||
|
||||
describe('Example page shortcodes and JavaScript', function() {
|
||||
before(function() {
|
||||
// Track JavaScript errors
|
||||
cy.on('uncaught:exception', (err, runnable) => {
|
||||
// Log the error to the Cypress command log
|
||||
cy.log(`JavaScript error: ${err.message}`);
|
||||
|
||||
// Add the error to the test failure message
|
||||
Cypress.failures = Cypress.failures || [];
|
||||
Cypress.failures.push(err.message);
|
||||
|
||||
// Return false to prevent Cypress from failing the test
|
||||
// We want to continue the test and record all errors
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
// Clear any stored failures before each test
|
||||
Cypress.failures = [];
|
||||
|
||||
// Visit the example page
|
||||
cy.visit('/example/');
|
||||
});
|
||||
|
||||
it('loads without JavaScript errors', function() {
|
||||
// Check if page loaded successfully
|
||||
cy.title().should('not.be.empty');
|
||||
|
||||
// Verify no JavaScript errors were recorded
|
||||
cy.wrap(Cypress.failures).should('be.empty',
|
||||
'The following JavaScript errors were detected:\n' +
|
||||
(Cypress.failures || []).join('\n'));
|
||||
});
|
||||
|
||||
it('has expected content structure', function() {
|
||||
// Basic page structure checks
|
||||
cy.get('h1').should('exist');
|
||||
cy.get('main').should('exist');
|
||||
});
|
||||
|
||||
// Add more specific tests for the example page content as needed
|
||||
});
|
|
@ -0,0 +1,107 @@
|
|||
/// <reference types="cypress" />
|
||||
|
||||
describe('Stable version', function () {
|
||||
before(function () {
|
||||
// Track JavaScript errors
|
||||
cy.on('uncaught:exception', (err, runnable) => {
|
||||
// Log the error to the Cypress command log
|
||||
cy.log(`JavaScript error: ${err.message}`);
|
||||
|
||||
// Add the error to the test failure message
|
||||
Cypress.failures = Cypress.failures || [];
|
||||
Cypress.failures.push(err.message);
|
||||
|
||||
// Return false to prevent Cypress from failing the test
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
// Clear any stored failures before each test
|
||||
Cypress.failures = [];
|
||||
});
|
||||
|
||||
it('should show InfluxDB 3 Core as successor product in InfluxDB v2 page', function () {
|
||||
// Visit the v2 documentation page
|
||||
cy.visit('/influxdb/v1/introduction/install/');
|
||||
|
||||
// Check for the warning block that appears for older versions
|
||||
cy.get('.warn.block.old-version').should('exist');
|
||||
|
||||
// Verify that the warning message references original product name
|
||||
cy.get('.warn.block.old-version p').should(
|
||||
'contain',
|
||||
'This page documents an earlier version of InfluxDB OSS'
|
||||
);
|
||||
|
||||
// Check for the link to the successor product
|
||||
cy.get('.warn.block.old-version a')
|
||||
.first()
|
||||
.should('contain', 'InfluxDB 3 Core')
|
||||
.and('have.attr', 'href', '/influxdb3/core/');
|
||||
|
||||
// Verify no JavaScript errors were recorded
|
||||
cy.wrap(Cypress.failures).should(
|
||||
'be.empty',
|
||||
'The following JavaScript errors were detected:\n' +
|
||||
(Cypress.failures || []).join('\n')
|
||||
);
|
||||
});
|
||||
|
||||
it('should show InfluxDB 3 Core as successor product in InfluxDB v1 page', function () {
|
||||
// Visit the v1 documentation page
|
||||
cy.visit('/influxdb/v1/');
|
||||
|
||||
// Check for the warning block that appears for older versions
|
||||
cy.get('.warn.block.old-version').should('exist');
|
||||
|
||||
// Verify that the warning message references original product name
|
||||
cy.get('.warn.block.old-version p').should(
|
||||
'contain',
|
||||
'This page documents an earlier version of InfluxDB OSS'
|
||||
);
|
||||
|
||||
// Check for the link to the latest stable version (successor product)
|
||||
cy.get('.warn.block.old-version a')
|
||||
.first()
|
||||
.should('contain', 'InfluxDB 3 Core')
|
||||
.and('have.attr', 'href', '/influxdb3/core/');
|
||||
|
||||
// Verify no JavaScript errors were recorded
|
||||
cy.wrap(Cypress.failures).should(
|
||||
'be.empty',
|
||||
'The following JavaScript errors were detected:\n' +
|
||||
(Cypress.failures || []).join('\n')
|
||||
);
|
||||
});
|
||||
|
||||
it('should verify the product succeeded_by relationship is configured correctly', function () {
|
||||
// Get the product data to verify succeeded_by field
|
||||
cy.task('getData', 'products').then((productData) => {
|
||||
// Check succeeded_by relationship in products.yml
|
||||
expect(productData.influxdb).to.have.property(
|
||||
'succeeded_by',
|
||||
'influxdb3_core'
|
||||
);
|
||||
|
||||
// Verify successor product exists
|
||||
expect(productData).to.have.property('influxdb3_core');
|
||||
expect(productData.influxdb3_core).to.have.property(
|
||||
'name',
|
||||
'InfluxDB 3 Core'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should verify behavior if the stable-version.html template changes', function () {
|
||||
// Visit a page that shouldn't have a successor redirect
|
||||
cy.visit('/telegraf/v1/');
|
||||
cy.get('.warn.block.old-version').should('not.exist');
|
||||
|
||||
cy.wrap(Cypress.failures).should(
|
||||
'be.empty',
|
||||
'The following JavaScript errors were detected:\n' +
|
||||
(Cypress.failures || []).join('\n')
|
||||
);
|
||||
});
|
||||
});
|
|
@ -28,7 +28,7 @@ export async function isPortInUse(port) {
|
|||
/**
|
||||
* Start the Hugo server with the specified options
|
||||
* @param {Object} options - Configuration options for Hugo
|
||||
* @param {string} options.configFile - Path to Hugo config file (e.g., 'hugo.testing.yml')
|
||||
* @param {string} options.configFile - Path to Hugo config file (e.g., 'config/testing/config.yml')
|
||||
* @param {number} options.port - Port number for Hugo server
|
||||
* @param {boolean} options.buildDrafts - Whether to build draft content
|
||||
* @param {boolean} options.noHTTPCache - Whether to disable HTTP caching
|
||||
|
@ -36,7 +36,7 @@ export async function isPortInUse(port) {
|
|||
* @returns {Promise<Object>} Child process object
|
||||
*/
|
||||
export async function startHugoServer({
|
||||
configFile = 'hugo.testing.yml',
|
||||
configFile = 'config/testing/config.yml',
|
||||
port = HUGO_PORT,
|
||||
buildDrafts = true,
|
||||
noHTTPCache = true,
|
||||
|
|
|
@ -253,7 +253,7 @@ async function main() {
|
|||
|
||||
// Use the startHugoServer function from hugo-server.js
|
||||
hugoProc = await startHugoServer({
|
||||
configFile: 'hugo.testing.yml',
|
||||
configFile: 'config/testing/config.yml',
|
||||
port: HUGO_PORT,
|
||||
buildDrafts: true,
|
||||
noHTTPCache: true,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
influxdb3_core:
|
||||
name: InfluxDB 3 Core
|
||||
altname: InfluxDB 3 Core
|
||||
namespace: influxdb
|
||||
namespace: influxdb3
|
||||
menu_category: self-managed
|
||||
versions: [core]
|
||||
list_order: 2
|
||||
|
@ -16,7 +16,7 @@ influxdb3_core:
|
|||
influxdb3_enterprise:
|
||||
name: InfluxDB 3 Enterprise
|
||||
altname: InfluxDB 3 Enterprise
|
||||
namespace: influxdb
|
||||
namespace: influxdb3
|
||||
menu_category: self-managed
|
||||
versions: [enterprise]
|
||||
list_order: 2
|
||||
|
@ -76,6 +76,7 @@ influxdb:
|
|||
name: InfluxDB
|
||||
altname: InfluxDB OSS
|
||||
namespace: influxdb
|
||||
succeeded_by: influxdb3_core
|
||||
menu_category: self-managed
|
||||
list_order: 1
|
||||
placeholder_host: localhost:8086
|
||||
|
|
|
@ -2,11 +2,47 @@
|
|||
{{ $product := index $productPathData 0 }}
|
||||
{{ $version := index $productPathData 1 | default "0"}}
|
||||
{{ $productKey := cond (eq $product "influxdb3") (print "influxdb3_" (replaceRE "-" "_" $version)) $product }}
|
||||
{{ $productName := cond (isset (index .Site.Data.products $productKey) "altname") (index .Site.Data.products $productKey).altname (index .Site.Data.products $productKey).name }}
|
||||
|
||||
{{ $stableVersion := (replaceRE `\.[0-9x]+$` "" (index .Site.Data.products $product).latest) }}
|
||||
{{ $stableVersionURL := replaceRE `v[1-3]` $stableVersion .RelPermalink }}
|
||||
{{ $stableDefaultURL := print "/" $product "/" $stableVersion "/" }}
|
||||
<!-- Initialize version variables -->
|
||||
{{ $successorInfo := dict "exists" false }}
|
||||
{{ $productName := $product | humanize }}
|
||||
{{ $stableVersion := "" }}
|
||||
{{ $stableVersionURL := "" }}
|
||||
{{ $stableDefaultURL := "" }}
|
||||
|
||||
<!-- Get current product name -->
|
||||
{{ if isset .Site.Data.products $productKey }}
|
||||
{{ $productName = cond (isset (index .Site.Data.products $productKey) "altname") (index .Site.Data.products $productKey).altname (index .Site.Data.products $productKey).name }}
|
||||
{{ end }}
|
||||
|
||||
<!-- Check for successor and get version information -->
|
||||
{{ if and (isset .Site.Data.products $productKey) (isset (index .Site.Data.products $productKey) "succeeded_by") }}
|
||||
{{ $successorKey := (index .Site.Data.products $productKey).succeeded_by }}
|
||||
|
||||
{{ if and $successorKey (isset .Site.Data.products $successorKey) }}
|
||||
<!-- Successor exists and is valid -->
|
||||
{{ $successorInfo = dict
|
||||
"exists" true
|
||||
"key" $successorKey
|
||||
"name" (cond (isset (index .Site.Data.products $successorKey) "altname")
|
||||
(index .Site.Data.products $successorKey).altname
|
||||
(index .Site.Data.products $successorKey).name)
|
||||
"version" (replaceRE `\.[0-9x]+$` "" (index .Site.Data.products $successorKey).latest)
|
||||
"namespace" (index .Site.Data.products $successorKey).namespace
|
||||
}}
|
||||
|
||||
<!-- Set stable version to successor version -->
|
||||
{{ $stableVersion = $successorInfo.version }}
|
||||
{{ $stableVersionURL = print "/" $successorInfo.namespace "/" $stableVersion "/" }}
|
||||
{{ $stableDefaultURL = $stableVersionURL }}
|
||||
{{ end }}
|
||||
{{ else if isset .Site.Data.products $product }}
|
||||
<!-- No successor, use current product's latest version -->
|
||||
{{ $stableVersion = (replaceRE `\.[0-9x]+$` "" (index .Site.Data.products $product).latest) }}
|
||||
{{ $stableVersionURL = replaceRE `v[1-3]` $stableVersion .RelPermalink }}
|
||||
{{ $stableDefaultURL = print "/" $product "/" $stableVersion "/" }}
|
||||
{{ end }}
|
||||
|
||||
{{ $stableEquivalentURL := index .Page.Params.alt_links $stableVersion | default "does-not-exist" }}
|
||||
{{ $stableEquivalentPage := .GetPage (replaceRE `\/$` "" $stableEquivalentURL) }}
|
||||
{{ $stablePageExists := gt (len $stableEquivalentPage.Title) 0 }}
|
||||
|
@ -14,34 +50,32 @@
|
|||
{{ $isMultiVersion := in (print "/" $version) "/v" }}
|
||||
|
||||
{{ if and (in $productWhiteList $product) $isMultiVersion }}
|
||||
<!-- Check if the current version is less than the stable version -->
|
||||
{{ if $successorInfo.exists }}
|
||||
<!-- Show callout for product with successor -->
|
||||
<div class="warn block old-version">
|
||||
<p>
|
||||
This page documents an earlier version of {{ $productName }}.
|
||||
<a href="{{ $stableDefaultURL }}">{{ $successorInfo.name }}</a> is the latest stable version.
|
||||
</p>
|
||||
</div>
|
||||
{{ else if $stableVersion }}
|
||||
<!-- Show callout for product with newer version (no successor) -->
|
||||
{{ if lt (int (replaceRE `[a-z]` "" $version)) (int (replaceRE `[a-z]` "" $stableVersion)) }}
|
||||
<div class="warn block old-version">
|
||||
<p>
|
||||
This page documents an earlier version of {{ $productName }}.
|
||||
<a href="/{{ $product }}/{{ $stableVersion }}/">{{ $productName }} {{ $stableVersion }}</a> is the latest stable version.
|
||||
<!-- Check if page exists in latest major version docs -->
|
||||
|
||||
<!-- Handle page navigation options -->
|
||||
{{ if gt (len (.GetPage ((replaceRE `v[1-3]` $stableVersion .RelPermalink) | replaceRE `\/$` "")).Title) 0 }}
|
||||
<a href="{{ $stableVersionURL }}">View this page in the {{ $stableVersion }} documentation</a>.
|
||||
<!-- Check if the stable equivalent page exists -->
|
||||
{{ else if $stablePageExists }}
|
||||
<span style="margin-right:.25rem">See the equivalent <strong>InfluxDB {{ $stableVersion }}</strong> documentation:</span> <a href="{{ $stableEquivalentPage.RelPermalink }}">{{ $stableEquivalentPage.Title | .RenderString }}</a>.
|
||||
<span style="margin-right:.25rem">See the equivalent <strong>{{ $productName }} {{ $stableVersion }}</strong> documentation:</span> <a href="{{ $stableEquivalentPage.RelPermalink }}">{{ $stableEquivalentPage.Title | .RenderString }}</a>.
|
||||
{{ else }}
|
||||
See the <a href="{{ $stableDefaultURL }}">InfluxDB {{ $stableVersion }} documentation</a>.
|
||||
See the <a href="{{ $stableDefaultURL }}">{{ $productName }} {{ $stableVersion }} documentation</a>.
|
||||
{{ end }}
|
||||
</p>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if and .Page.Params.v2 (eq (findRE `v[1-3]` $version) (findRE `v[1-3]` $stableVersion)) }}
|
||||
<div class="note block old-version">
|
||||
<p>
|
||||
{{ if $stablePageExists }}
|
||||
<span style="margin-right:.25rem">See the equivalent <strong>InfluxDB {{ $stableVersion }}</strong> documentation:</span> <a href="{{ $stableEquivalentPage.RelPermalink }}">{{ $stableEquivalentPage.Title | .RenderString }}</a>.
|
||||
{{ else }}
|
||||
See the <a href="{{ $stableEquivalentURL }}">equivalent InfluxDB {{ $stableVersion }} documentation</a>.
|
||||
{{ end }}
|
||||
</p>
|
||||
</div>
|
||||
{{ end }}
|
|
@ -8,7 +8,7 @@
|
|||
{{ $dateTime := resources.Get "js/datetime.js" }}
|
||||
{{ $homepageInteractions := resources.Get "js/home-interactions.js" }}
|
||||
{{ $releaseTOC := resources.Get "/js/release-toc.js" }}
|
||||
{{ $footerjs := slice $versionSelector $searchInteractions $listFilters $featureCallouts $keybindings $homepageInteractions | resources.Concat "js/footer.bundle.js" | resources.Fingerprint }}
|
||||
{{ $footerjs := slice $jquery $versionSelector $searchInteractions $listFilters $featureCallouts $keybindings $homepageInteractions | resources.Concat "js/footer.bundle.js" | resources.Fingerprint }}
|
||||
{{ $fluxGroupKeyjs := $fluxGroupKeys | resources.Fingerprint }}
|
||||
{{ $dateTimejs := $dateTime | resources.Fingerprint }}
|
||||
{{ $releaseTOCjs := $releaseTOC | resources.Fingerprint }}
|
||||
|
|
Loading…
Reference in New Issue