Skip to content

Commit

Permalink
[issue-2992] Fix pb with marketplace (#2997)
Browse files Browse the repository at this point in the history
* [issue-2992] Fix pb with marketplace

* add codecoverage
  • Loading branch information
xavierfacq committed Jul 31, 2024
1 parent c1ede95 commit c586b71
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/DownloadDropdowns/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const DownloadDropdowns = ({updaterAction, marketplace, Table}) => {
// @ts-ignore
let ext = gl && gl.getExtension('WEBGL_debug_renderer_info');
// @ts-ignore
let param = ext && ext.getParameter(d.UNMASKED_RENDERER_WEBGL) || "";
let param = ext && gl.getParameter(ext.UNMASKED_RENDERER_WEBGL) || "";
if (param.match(/Apple/) && !param.match(/Apple GPU/)) {
defaultSelectedArch = 'aarch64'
}
Expand Down
14 changes: 14 additions & 0 deletions src/components/LatestTemurin/__tests__/LatestTemurin.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,18 @@ describe('RandomContributor component', () => {
const { container } = render(<LatestTemurin />);
expect(container).toMatchSnapshot();
});

it('should render correctly - MAC', () => {
vi.spyOn(detectOSModule, 'detectOS').mockReturnValue(UserOS.MAC);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
useOnScreen.mockReturnValue(true);

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
fetchLatestForOS.mockReturnValue(createRandomLatestForOSData());

const { container } = render(<LatestTemurin />);
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,92 @@ exports[`RandomContributor component > should render correctly - Linux 1`] = `
</div>
`;

exports[`RandomContributor component > should render correctly - MAC 1`] = `
<div>
<div
class="container"
>
<h2
class="fw-light mt-3 "
>
Text
</h2>
<div
class="btn-group-vertical mx-auto col-6"
>
<a
class="btn btn-lg btn-primary mt-3 py-3 text-white"
href="/download"
state="[object Object]"
>
<svg
fill="currentColor"
height="1em"
stroke="currentColor"
stroke-width="0"
viewBox="0 0 512 512"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
/>
</svg>
Text
<br />
<span
class="font-weight-light"
style="font-size: .6em;"
>
release_name_mock
</span>
</a>
<a
class="btn btn-outline-dark mt-3"
href="/temurin/releases"
>
Text
<svg
fill="currentColor"
height="1em"
stroke="currentColor"
stroke-width="0"
viewBox="0 0 512 512"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M256 8c137 0 248 111 248 248S393 504 256 504 8 393 8 256 119 8 256 8zm-28.9 143.6l75.5 72.4H120c-13.3 0-24 10.7-24 24v16c0 13.3 10.7 24 24 24h182.6l-75.5 72.4c-9.7 9.3-9.9 24.8-.4 34.3l11 10.9c9.4 9.4 24.6 9.4 33.9 0L404.3 273c9.4-9.4 9.4-24.6 0-33.9L271.6 106.3c-9.4-9.4-24.6-9.4-33.9 0l-11 10.9c-9.5 9.6-9.3 25.1.4 34.4z"
/>
</svg>
</a>
<a
class="btn btn-outline-dark mt-3"
href="/temurin/archive"
>
Text
<svg
fill="currentColor"
height="1em"
stroke="currentColor"
stroke-width="0"
viewBox="0 0 512 512"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M32 448c0 17.7 14.3 32 32 32h384c17.7 0 32-14.3 32-32V160H32v288zm160-212c0-6.6 5.4-12 12-12h104c6.6 0 12 5.4 12 12v8c0 6.6-5.4 12-12 12H204c-6.6 0-12-5.4-12-12v-8zM480 32H32C14.3 32 0 46.3 0 64v48c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16V64c0-17.7-14.3-32-32-32z"
/>
</svg>
</a>
</div>
</div>
</div>
`;

exports[`RandomContributor component > should render correctly - Windows 1`] = `
<div>
<div
Expand Down
8 changes: 4 additions & 4 deletions src/components/LatestTemurin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const LatestTemurin = (props): JSX.Element => {
userOSName = 'macOS'
userOSAPIName = 'mac'
if (typeof document !== 'undefined') {
let w = document.createElement("canvas").getContext("webgl");
let gl = document.createElement("canvas").getContext("webgl");
// @ts-ignore
let d = w.getExtension('WEBGL_debug_renderer_info');
let ext = gl && gl.getExtension('WEBGL_debug_renderer_info');
// @ts-ignore
let g = d && w.getParameter(d.UNMASKED_RENDERER_WEBGL) || "";
let param = ext && gl.getParameter(ext.UNMASKED_RENDERER_WEBGL) || "";
isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
//Detect if the user is using a Apple GPU (M1)
if (isSafari || (g.match(/Apple/) && !g.match(/Apple GPU/))) {
if (isSafari || (param.match(/Apple/) && !param.match(/Apple GPU/))) {
arch = 'aarch64'
}
}
Expand Down

0 comments on commit c586b71

Please sign in to comment.