mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 12:23:22 +00:00
fix(check): report failed update checks as failures (#643)
Return nonzero exit status for failed skill and agent checks while preserving JSON results. Propagate agent remote errors and prioritize dashboard check failures over the up-to-date summary. Add regression coverage and document exit status in all command reference locales. Related to runkids/skillshare-app#85.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { updateCheckTitle } from './updateCheckSummary';
|
||||
|
||||
describe('updateCheckTitle', () => {
|
||||
it.each([
|
||||
[true, true, 0, 'update.check.error'],
|
||||
[true, true, 2, 'update.check.error'],
|
||||
[true, false, 0, 'update.check.error'],
|
||||
[false, false, 0, 'update.tab.notChecked'],
|
||||
[false, true, 2, 'update.hero.available'],
|
||||
[false, true, 0, 'update.hero.allCurrent'],
|
||||
] as const)('failed=%s checked=%s available=%s', (failed, checked, available, expected) => {
|
||||
expect(updateCheckTitle(failed, checked, available)).toBe(expected);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
export function updateCheckTitle(failed: boolean, checked: boolean, available: number) {
|
||||
if (failed) return 'update.check.error';
|
||||
if (!checked) return 'update.tab.notChecked';
|
||||
return available > 0 ? 'update.hero.available' : 'update.hero.allCurrent';
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import { useToast } from '../components/Toast';
|
||||
import { useDiffQuery, useSkillsQuery } from '../hooks/useSharedQueries';
|
||||
import { countChanges, resourceGroups } from '../components/sync/syncView';
|
||||
import { invalidate } from '../lib/queryEvents';
|
||||
import { updateCheckTitle } from '../lib/updateCheckSummary';
|
||||
import { useInstallFromConfig } from '../hooks/useInstallFromConfig';
|
||||
|
||||
/* -- Types ---------------------------------------- */
|
||||
@@ -529,11 +530,12 @@ export default function UpdatePage({ kind }: { kind: Kind }) {
|
||||
};
|
||||
} else {
|
||||
const summary = lastChecked ? t('update.check.checkedAt', { time: formatRelativeTime(lastChecked, locale) }) : '';
|
||||
const checkFailed = units.some((u) => unitCheck(statuses, u).status === 'error');
|
||||
hero = {
|
||||
icon: <CircleArrowUp size={20} />,
|
||||
tone: '',
|
||||
title: !lastChecked ? t('update.tab.notChecked') : available > 0 ? t('update.hero.available', { count: available }) : t('update.hero.allCurrent'),
|
||||
sub: `${summary} ${t('update.tab.audited')}`.trim(),
|
||||
icon: checkFailed ? <CircleAlert size={20} /> : <CircleArrowUp size={20} />,
|
||||
tone: checkFailed ? 'warn' : '',
|
||||
title: t(updateCheckTitle(checkFailed, !!lastChecked, available), { count: available }),
|
||||
sub: `${checkFailed && available > 0 ? t('update.hero.available', { count: available }) + '. ' : ''}${summary} ${t('update.tab.audited')}`.trim(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user