Skip to content

Commit

Permalink
Correctly display checksum and buttons (#3259)
Browse files Browse the repository at this point in the history
* [issue-3221] Pb when checksum is not available

* Change all calls

* Improve codecov

* Set text = Not available

* Remove unused import

* Fix dowload table presentation / deal with sha265sum and sha256sum

* update snapshots

* update snapshots 2
  • Loading branch information
xavierfacq authored Nov 27, 2024
1 parent 503b01b commit 017b15f
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 56 deletions.
8 changes: 4 additions & 4 deletions src/__fixtures__/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const createRandomMarketplaceRelease = (installer, id): MarketplaceReleas
package: {
name: 'name_mock.tar.gz',
link: new URL('https://link_mock'),
sha265sum: `sha265sum_mock${id}`,
sha256sum: `sha256sum_mock${id}`,
sha256sum_link: new URL('https://sha256sum_link_mock'),
signature_link: new URL('https://signature_link_mock'),
},
Expand All @@ -64,7 +64,7 @@ export const createRandomMarketplaceRelease = (installer, id): MarketplaceReleas
{
name: 'installer_name_mock.msi',
link: new URL('https://installer_link_mock'),
sha265sum: 'installer_sha265sum_mock',
sha256sum: 'installer_sha256sum_mock',
sha256sum_link: new URL('https://installer_sha256sum_link_mock'),
signature_link: new URL('https://installer_signature_link_mock'),
},
Expand Down Expand Up @@ -109,7 +109,7 @@ export const mockLatestTemurin = (installer): LatestTemurin => ({
package: {
name: 'name_mock.tar.gz',
link: new URL('https://link_mock'),
checksum: 'sha265sum_mock',
checksum: 'sha256sum_mock',
checksum_link: new URL('https://sha256sum_link_mock'),
metadata_link: new URL('https://metadata_link_mock'),
signature_link: new URL('https://signature_link_mock'),
Expand All @@ -121,7 +121,7 @@ export const mockLatestTemurin = (installer): LatestTemurin => ({
{
name: 'installer_name_mock.msi',
link: new URL('https://installer_link_mock'),
checksum: 'installer_sha265sum_mock',
checksum: 'installer_sha256sum_mock',
checksum_link: new URL('https://installer_sha256sum_link_mock'),
metadata_link: new URL('https://installer_metadata_link_mock'),
signature_link: new URL('https://installer_signature_link_mock'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ describe('MarketplaceDownloadTable component', () => {
];

// erase checksum
releases[0].binary.package.sha256sum = undefined;
releases[0].binary.installer[0].sha256sum = undefined;

// Name of previous typo to be removed when vendors update their code to fix the typo
releases[0].binary.package.sha265sum = undefined;
releases[0].binary.installer[0].sha265sum = undefined;

Expand All @@ -71,4 +75,4 @@ describe('MarketplaceDownloadTable component', () => {

expect(container).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ exports[`MarketplaceDownloadTable component > renders correctly - Without checks
class="align-middle"
>
<table
class="table parent mb-0 w-auto"
class="table parent mb-0 w-100"
>
<tbody
class="table-light"
>
<tr>
<td
class="align-middle text-center"
class="align-middle text-center w-50"
>
<table>
<tbody>
Expand All @@ -142,7 +142,7 @@ exports[`MarketplaceDownloadTable component > renders correctly - Without checks
</table>
</td>
<td
class="align-middle"
class="align-middle w-50"
>
<a
class="btn btn-primary"
Expand Down Expand Up @@ -170,7 +170,7 @@ exports[`MarketplaceDownloadTable component > renders correctly - Without checks
</tr>
<tr>
<td
class="align-middle text-center"
class="align-middle text-center w-50"
>
<table>
<tbody>
Expand All @@ -183,7 +183,7 @@ exports[`MarketplaceDownloadTable component > renders correctly - Without checks
</table>
</td>
<td
class="align-middle"
class="align-middle w-50"
>
<a
class="btn btn-primary"
Expand Down Expand Up @@ -394,21 +394,21 @@ exports[`MarketplaceDownloadTable component > renders correctly 1`] = `
class="align-middle"
>
<table
class="table parent mb-0 w-auto"
class="table parent mb-0 w-100"
>
<tbody
class="table-light"
>
<tr>
<td
class="align-middle text-center"
class="align-middle text-center w-50"
>
<table>
<tbody>
<tr>
<td>
<a
data-bs-checksum="sha265sum_mock1"
data-bs-checksum="sha256sum_mock1"
data-bs-target="#checksumModal"
data-bs-toggle="modal"
href=""
Expand All @@ -422,7 +422,7 @@ exports[`MarketplaceDownloadTable component > renders correctly 1`] = `
</table>
</td>
<td
class="align-middle"
class="align-middle w-50"
>
<a
class="btn btn-primary"
Expand Down Expand Up @@ -526,21 +526,21 @@ exports[`MarketplaceDownloadTable component > renders correctly 1`] = `
class="align-middle"
>
<table
class="table parent mb-0 w-auto"
class="table parent mb-0 w-100"
>
<tbody
class="table-light"
>
<tr>
<td
class="align-middle text-center"
class="align-middle text-center w-50"
>
<table>
<tbody>
<tr>
<td>
<a
data-bs-checksum="installer_sha265sum_mock"
data-bs-checksum="installer_sha256sum_mock"
data-bs-target="#checksumModal"
data-bs-toggle="modal"
href=""
Expand All @@ -554,7 +554,7 @@ exports[`MarketplaceDownloadTable component > renders correctly 1`] = `
</table>
</td>
<td
class="align-middle"
class="align-middle w-50"
>
<a
class="btn btn-primary"
Expand Down Expand Up @@ -582,14 +582,14 @@ exports[`MarketplaceDownloadTable component > renders correctly 1`] = `
</tr>
<tr>
<td
class="align-middle text-center"
class="align-middle text-center w-50"
>
<table>
<tbody>
<tr>
<td>
<a
data-bs-checksum="sha265sum_mock2"
data-bs-checksum="sha256sum_mock2"
data-bs-target="#checksumModal"
data-bs-toggle="modal"
href=""
Expand All @@ -603,7 +603,7 @@ exports[`MarketplaceDownloadTable component > renders correctly 1`] = `
</table>
</td>
<td
class="align-middle"
class="align-middle w-50"
>
<a
class="btn btn-primary"
Expand Down
10 changes: 5 additions & 5 deletions src/components/MarketplaceDownloadTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ const DownloadTable = ({results}) => {
{pkg.binary.architecture}
</td>
<td className="align-middle">
<table className="table parent mb-0 w-auto">
<table className="table parent mb-0 w-100">
<tbody className="table-light">
{pkg.binary.installer && (
<BinaryTable
checksum={pkg.binary.installer[0].sha265sum}
checksum={pkg.binary.installer[0].sha256sum||pkg.binary.installer[0].sha265sum}
filename={pkg.binary.installer[0].name}
link={pkg.binary.installer[0].link}
os={pkg.binary.os}
Expand All @@ -70,7 +70,7 @@ const DownloadTable = ({results}) => {
/>
)}
<BinaryTable
checksum={pkg.binary.package.sha265sum}
checksum={pkg.binary.package.sha256sum||pkg.binary.package.sha265sum}
filename={pkg.binary.package.name}
link={pkg.binary.package.link}
os={pkg.binary.os}
Expand Down Expand Up @@ -108,7 +108,7 @@ interface DownloadProps {
const BinaryTable = ({ checksum, link, filename, os, arch, pkgType, javaVersion, vendor }: DownloadProps): null | JSX.Element => {
return (
<tr key={checksum}>
<td className="align-middle text-center">
<td className="align-middle text-center w-50">
<table><tbody>
<tr>
<td>
Expand All @@ -120,7 +120,7 @@ const BinaryTable = ({ checksum, link, filename, os, arch, pkgType, javaVersion,
</tr>
</tbody></table>
</td>
<td className="align-middle">
<td className="align-middle w-50">
<Link to="/download" state={{ link: link, checksum: checksum, os: os, arch: arch, pkg_type: pkgType, java_version: javaVersion, vendor: vendor }} className="btn btn-primary" style={{width: "6em"}}>
<FaDownload /> {fetchExtension(filename)}
</Link>
Expand Down
Loading

0 comments on commit 017b15f

Please sign in to comment.