Skip to content

Commit

Permalink
[issue-2922] Add more information on Nightly page (#2927)
Browse files Browse the repository at this point in the history
* [issue-2922] Add more information on Nightly page

* Correct & fix snapshot

* Add test on getVersionAsString()
  • Loading branch information
xavierfacq authored Jun 28, 2024
1 parent 0f09759 commit a029dca
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ exports[`TemurinNightlyTable component > renders correctly - no data 1`] = `
>
Type
</td>
<td
class="fw-bold"
>
Build/Tag
</td>
<td
class="fw-bold"
>
Expand Down Expand Up @@ -78,6 +83,11 @@ exports[`TemurinNightlyTable component > renders correctly 1`] = `
>
Type
</td>
<td
class="fw-bold"
>
Build/Tag
</td>
<td
class="fw-bold"
>
Expand Down Expand Up @@ -114,13 +124,17 @@ exports[`TemurinNightlyTable component > renders correctly 1`] = `
<td>
type_mock
</td>
<td>
release_name_mock
</td>
<td>
January 1, 2020
</td>
<td>
<a
href="/download"
state="[object Object]"
title=""
>
extension_mock (0 MB)
</a>
Expand Down Expand Up @@ -150,13 +164,17 @@ exports[`TemurinNightlyTable component > renders correctly 1`] = `
<td>
type_mock
</td>
<td>
release_name_mock
</td>
<td>
January 1, 2020
</td>
<td>
<a
href="/download"
state="[object Object]"
title=""
>
extension_mock (0 MB)
</a>
Expand All @@ -165,6 +183,7 @@ exports[`TemurinNightlyTable component > renders correctly 1`] = `
<a
href="/download"
state="[object Object]"
title=""
>
installer_extension_mock
</a>
Expand Down
12 changes: 10 additions & 2 deletions src/components/TemurinNightlyTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -13,6 +17,7 @@ const TemurinNightlyTable = ({results}) => {
<tr>
<td className="fw-bold">Platform</td>
<td className="fw-bold">Type</td>
<td className="fw-bold">Build/Tag</td>
<td className="fw-bold">Date</td>
<td className="fw-bold">Binary</td>
<td className="fw-bold">Installer</td>
Expand All @@ -32,10 +37,13 @@ const TemurinNightlyTable = ({results}) => {
<tr key={`${key}-${asset.type}`} className="nightly-row">
<td>{capitalize(asset.os)} {asset.architecture === 'x32' ? 'x86' : asset.architecture}</td>
<td>{asset.type}</td>
<td>{release.release_name}</td>
<td>{localeDate(release.timestamp, language)}</td>
<td><Link to="/download" state={{ link: asset.link, checksum: asset.checksum, os: capitalize(key.split("-")[0]), arch: key.split("-")[1], pkg_type: asset.type, java_version: 'nightly' }}>{`${asset.extension} (${asset.size} MB)`}</Link></td>
<td><Link
title={getFileName(asset.link)}
to="/download" state={{ link: asset.link, checksum: asset.checksum, os: capitalize(key.split("-")[0]), arch: key.split("-")[1], pkg_type: asset.type, java_version: 'nightly' }}>{`${asset.extension} (${asset.size} MB)`}</Link></td>
{asset.installer_link ? (
<td><Link to="/download" state={{ link: asset.installer_link, checksum: asset.installer_checksum }}>{asset.installer_extension}</Link></td>
<td><Link title={getFileName(asset.installer_link)} to="/download" state={{ link: asset.installer_link, checksum: asset.installer_checksum }}>{asset.installer_extension}</Link></td>
) :
<td><Trans i18nKey='download.not.available' defaults='Not Available' /></td>
}
Expand Down
43 changes: 43 additions & 0 deletions src/hooks/__tests__/getVersionAsString.test.tsx
Original file line number Diff line number Diff line change
@@ -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");
})
});
6 changes: 6 additions & 0 deletions src/hooks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ exports[`Temurin Nightly page > renders correctly 1`] = `
>
Type
</td>
<td
class="fw-bold"
>
Build/Tag
</td>
<td
class="fw-bold"
>
Expand Down

0 comments on commit a029dca

Please sign in to comment.