diff --git a/assets/jsconfig.json b/assets/jsconfig.json index 4ad710c10..377218ccb 100644 --- a/assets/jsconfig.json +++ b/assets/jsconfig.json @@ -3,8 +3,7 @@ "baseUrl": ".", "paths": { "*": [ - "*", - "../node_modules/*" + "*" ] } } diff --git a/config/_default/config.yml b/config/_default/config.yml new file mode 100644 index 000000000..917d78e2d --- /dev/null +++ b/config/_default/config.yml @@ -0,0 +1,2 @@ +import: + - hugo.yml \ No newline at end of file diff --git a/hugo.testing.yml b/config/testing/config.yml similarity index 60% rename from hugo.testing.yml rename to config/testing/config.yml index 5dbbe6f4a..f403c8347 100644 --- a/hugo.testing.yml +++ b/config/testing/config.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 diff --git a/cypress/e2e/content/example-page.cy.js b/cypress/e2e/content/example-page.cy.js deleted file mode 100644 index 5b5a59e98..000000000 --- a/cypress/e2e/content/example-page.cy.js +++ /dev/null @@ -1,45 +0,0 @@ -/// - -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 -}); \ No newline at end of file diff --git a/cypress/e2e/content/example.cy.js b/cypress/e2e/content/example.cy.js new file mode 100644 index 000000000..e69de29bb diff --git a/cypress/e2e/content/stable-version-callout.cy.js b/cypress/e2e/content/stable-version-callout.cy.js new file mode 100644 index 000000000..f8c6d7f20 --- /dev/null +++ b/cypress/e2e/content/stable-version-callout.cy.js @@ -0,0 +1,107 @@ +/// + +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') + ); + }); +}); diff --git a/cypress/support/hugo-server.js b/cypress/support/hugo-server.js index 42411bfd9..0e4e6a646 100644 --- a/cypress/support/hugo-server.js +++ b/cypress/support/hugo-server.js @@ -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} Child process object */ export async function startHugoServer({ - configFile = 'hugo.testing.yml', + configFile = 'config/testing/config.yml', port = HUGO_PORT, buildDrafts = true, noHTTPCache = true, diff --git a/cypress/support/run-e2e-specs.js b/cypress/support/run-e2e-specs.js index f5eab2ae7..35780bbca 100644 --- a/cypress/support/run-e2e-specs.js +++ b/cypress/support/run-e2e-specs.js @@ -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, diff --git a/data/products.yml b/data/products.yml index bc9d2b08c..c65516953 100644 --- a/data/products.yml +++ b/data/products.yml @@ -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 diff --git a/layouts/partials/article/stable-version.html b/layouts/partials/article/stable-version.html index cc53ed736..eb0b13781 100644 --- a/layouts/partials/article/stable-version.html +++ b/layouts/partials/article/stable-version.html @@ -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 "/" }} + +{{ $successorInfo := dict "exists" false }} +{{ $productName := $product | humanize }} +{{ $stableVersion := "" }} +{{ $stableVersionURL := "" }} +{{ $stableDefaultURL := "" }} + + +{{ 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 }} + + +{{ 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) }} + + {{ $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 + }} + + + {{ $stableVersion = $successorInfo.version }} + {{ $stableVersionURL = print "/" $successorInfo.namespace "/" $stableVersion "/" }} + {{ $stableDefaultURL = $stableVersionURL }} + {{ end }} +{{ else if isset .Site.Data.products $product }} + + {{ $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 }} - - {{ if lt (int (replaceRE `[a-z]` "" $version)) (int (replaceRE `[a-z]` "" $stableVersion)) }} + {{ if $successorInfo.exists }} +

This page documents an earlier version of {{ $productName }}. - {{ $productName }} {{ $stableVersion }} is the latest stable version. - - {{ if gt (len (.GetPage ((replaceRE `v[1-3]` $stableVersion .RelPermalink) | replaceRE `\/$` "")).Title) 0 }} - View this page in the {{ $stableVersion }} documentation. - - {{ else if $stablePageExists }} - See the equivalent InfluxDB {{ $stableVersion }} documentation: {{ $stableEquivalentPage.Title | .RenderString }}. - {{ else }} - See the InfluxDB {{ $stableVersion }} documentation. - {{ end }} + {{ $successorInfo.name }} is the latest stable version.

+ {{ else if $stableVersion }} + + {{ if lt (int (replaceRE `[a-z]` "" $version)) (int (replaceRE `[a-z]` "" $stableVersion)) }} +
+

+ This page documents an earlier version of {{ $productName }}. + {{ $productName }} {{ $stableVersion }} is the latest stable version. + + + {{ if gt (len (.GetPage ((replaceRE `v[1-3]` $stableVersion .RelPermalink) | replaceRE `\/$` "")).Title) 0 }} + View this page in the {{ $stableVersion }} documentation. + {{ else if $stablePageExists }} + See the equivalent {{ $productName }} {{ $stableVersion }} documentation: {{ $stableEquivalentPage.Title | .RenderString }}. + {{ else }} + See the {{ $productName }} {{ $stableVersion }} documentation. + {{ end }} +

+
+ {{ end }} {{ end }} -{{ end }} - -{{ if and .Page.Params.v2 (eq (findRE `v[1-3]` $version) (findRE `v[1-3]` $stableVersion)) }} -
-

- {{ if $stablePageExists }} - See the equivalent InfluxDB {{ $stableVersion }} documentation: {{ $stableEquivalentPage.Title | .RenderString }}. - {{ else }} - See the equivalent InfluxDB {{ $stableVersion }} documentation. - {{ end }} -

-
-{{ end }} +{{ end }} \ No newline at end of file diff --git a/layouts/partials/footer/javascript.html b/layouts/partials/footer/javascript.html index eb64ae5ad..2e0f85494 100644 --- a/layouts/partials/footer/javascript.html +++ b/layouts/partials/footer/javascript.html @@ -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 }}