From a029dca9fe548d51063fdaa59f7ba72c4c17c8d4 Mon Sep 17 00:00:00 2001 From: Xavier FACQ Date: Fri, 28 Jun 2024 14:01:58 +0200 Subject: [PATCH] [issue-2922] Add more information on Nightly page (#2927) * [issue-2922] Add more information on Nightly page * Correct & fix snapshot * Add test on getVersionAsString() --- .../TemurinNightlyTable.test.tsx.snap | 19 ++++++++ src/components/TemurinNightlyTable/index.tsx | 12 +++++- .../__tests__/getVersionAsString.test.tsx | 43 +++++++++++++++++++ src/hooks/index.tsx | 6 +++ .../__snapshots__/nightly.test.tsx.snap | 5 +++ 5 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/hooks/__tests__/getVersionAsString.test.tsx diff --git a/src/components/TemurinNightlyTable/__tests__/__snapshots__/TemurinNightlyTable.test.tsx.snap b/src/components/TemurinNightlyTable/__tests__/__snapshots__/TemurinNightlyTable.test.tsx.snap index 581fc28ff..8427148cd 100644 --- a/src/components/TemurinNightlyTable/__tests__/__snapshots__/TemurinNightlyTable.test.tsx.snap +++ b/src/components/TemurinNightlyTable/__tests__/__snapshots__/TemurinNightlyTable.test.tsx.snap @@ -23,6 +23,11 @@ exports[`TemurinNightlyTable component > renders correctly - no data 1`] = ` > Type + + Build/Tag + @@ -78,6 +83,11 @@ exports[`TemurinNightlyTable component > renders correctly 1`] = ` > Type + + Build/Tag + @@ -114,6 +124,9 @@ exports[`TemurinNightlyTable component > renders correctly 1`] = ` type_mock + + release_name_mock + January 1, 2020 @@ -121,6 +134,7 @@ exports[`TemurinNightlyTable component > renders correctly 1`] = ` extension_mock (0 MB) @@ -150,6 +164,9 @@ exports[`TemurinNightlyTable component > renders correctly 1`] = ` type_mock + + release_name_mock + January 1, 2020 @@ -157,6 +174,7 @@ exports[`TemurinNightlyTable component > renders correctly 1`] = ` extension_mock (0 MB) @@ -165,6 +183,7 @@ exports[`TemurinNightlyTable component > renders correctly 1`] = ` installer_extension_mock diff --git a/src/components/TemurinNightlyTable/index.tsx b/src/components/TemurinNightlyTable/index.tsx index 824a96da8..6674036a4 100644 --- a/src/components/TemurinNightlyTable/index.tsx +++ b/src/components/TemurinNightlyTable/index.tsx @@ -3,6 +3,10 @@ import { Link, Trans, useI18next } from 'gatsby-plugin-react-i18next'; import { capitalize } from '../../util/capitalize'; import { localeDate } from '../../util/localeDate'; +const getFileName = (link: URL) => { + return link.toString().split('/').slice(-1); +} + const TemurinNightlyTable = ({results}) => { const { language } = useI18next(); @@ -13,6 +17,7 @@ const TemurinNightlyTable = ({results}) => { Platform Type + Build/Tag Date Binary Installer @@ -32,10 +37,13 @@ const TemurinNightlyTable = ({results}) => { {capitalize(asset.os)} {asset.architecture === 'x32' ? 'x86' : asset.architecture} {asset.type} + {release.release_name} {localeDate(release.timestamp, language)} - {`${asset.extension} (${asset.size} MB)`} + {`${asset.extension} (${asset.size} MB)`} {asset.installer_link ? ( - {asset.installer_extension} + {asset.installer_extension} ) : } diff --git a/src/hooks/__tests__/getVersionAsString.test.tsx b/src/hooks/__tests__/getVersionAsString.test.tsx new file mode 100644 index 000000000..523a27ce2 --- /dev/null +++ b/src/hooks/__tests__/getVersionAsString.test.tsx @@ -0,0 +1,43 @@ +import { describe, expect, it, vi } from 'vitest' +import { VersionMetaData, getVersionAsString } from '..'; + + +describe('getVersionAsString', () => { + it('getVersionAsString works correctly', async () => { + const vmd: VersionMetaData = { + major: 21, + minor: 0, + security: 4, + pre: 'beta', + patch: 1, + build: 5, + optional: "ea", + adopt_build_number: 9, + openjdk_version: "mock-openjdk_version", + semver: "mock-semver", + }; + + const result = getVersionAsString(vmd, true); + + expect(result).toBe("21.0.4.1-beta+5.9-ea"); + }) + + it('getVersionAsString with allowShortNotation works correctly', async () => { + const vmd: VersionMetaData = { + major: 21, + minor: 0, + security: 0, + pre: undefined, + patch: 0, + build: 0, + optional: undefined, + adopt_build_number: 0, + openjdk_version: "mock-openjdk_version", + semver: "mock-semver", + }; + + const result = getVersionAsString(vmd, true); + + expect(result).toBe("21"); + }) +}); diff --git a/src/hooks/index.tsx b/src/hooks/index.tsx index 8254e51af..6ebf458bd 100644 --- a/src/hooks/index.tsx +++ b/src/hooks/index.tsx @@ -57,9 +57,15 @@ export function getVersionAsString(version: VersionMetaData, allowShortNotation: if(version.patch) { result += `.${version.patch}`; } + if(version.pre) { + result += `-${version.pre}`; + } if(version.build) { result += `+${version.build}`; if(version.adopt_build_number) result += `.${version.adopt_build_number}`; } + if(version.optional) { + result += `-${version.optional}`; + } return result; } diff --git a/src/pages/temurin/__tests__/__snapshots__/nightly.test.tsx.snap b/src/pages/temurin/__tests__/__snapshots__/nightly.test.tsx.snap index 282133632..135ff6514 100644 --- a/src/pages/temurin/__tests__/__snapshots__/nightly.test.tsx.snap +++ b/src/pages/temurin/__tests__/__snapshots__/nightly.test.tsx.snap @@ -256,6 +256,11 @@ exports[`Temurin Nightly page > renders correctly 1`] = ` > Type + + Build/Tag +