diff --git a/frontend/src/ts/components/pages/connections/FriendsList.tsx b/frontend/src/ts/components/pages/connections/FriendsList.tsx index b5a9dbb050a7..5fc7490809fa 100644 --- a/frontend/src/ts/components/pages/connections/FriendsList.tsx +++ b/frontend/src/ts/components/pages/connections/FriendsList.tsx @@ -179,17 +179,26 @@ function getColumns({ defineColumn("completedTests", { enableSorting: true, header: "tests", - cell: (info) => `${info.getValue()}/${info.row.original.startedTests}`, + cell: (info) => { + const completedTests = info.getValue(); + const startedTests = info.row.original.startedTests; + + return completedTests === undefined || startedTests === undefined + ? "-" + : `${completedTests}/${startedTests}`; + }, meta: { breakpoint: "lg", cellMeta: ({ row }) => { const testStats = formatTypingStatsRatio(row); + if (testStats.completedPercentage === "") { + return {}; + } + return { "data-balloon-pos": "up", - "aria-label": `${testStats.completedPercentage}% (${ - testStats.restartRatio - } restarts per completed test)`, + "aria-label": `${testStats.completedPercentage}% (${testStats.restartRatio} restarts per completed test)`, }; }, }, diff --git a/frontend/src/ts/utils/misc.ts b/frontend/src/ts/utils/misc.ts index 6480e38ae000..1cfd09126a47 100644 --- a/frontend/src/ts/utils/misc.ts +++ b/frontend/src/ts/utils/misc.ts @@ -726,10 +726,13 @@ export function formatTypingStatsRatio(stats: { completedPercentage: Math.floor( (stats.completedTests / stats.startedTests) * 100, ).toString(), - restartRatio: ( - (stats.startedTests - stats.completedTests) / - stats.completedTests - ).toFixed(1), + restartRatio: + stats.completedTests === 0 + ? "-" + : ( + (stats.startedTests - stats.completedTests) / + stats.completedTests + ).toFixed(1), }; }