Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ type ProjectRow = {
};

let projectsFixture: ProjectRow[] = [];
let projectsError = false;
const retryProjects = vi.fn();

vi.mock('../hooks/queries', () => ({
useProjects: () => ({ projects: projectsFixture, isLoading: false }),
useProjects: () => ({
projects: projectsFixture,
isLoading: false,
error: projectsError,
isRetrying: false,
retry: retryProjects,
}),
}));

vi.mock('@tanstack/react-router', async (importOriginal) => ({
Expand All @@ -37,6 +45,8 @@ describe('ProjectBreadcrumbSwitcher', () => {
mockLocation.pathname =
'/dashboard/org-1/projects/proj-getting-started/files';
mockLocation.search = {};
projectsError = false;
retryProjects.mockReset();
projectsFixture = [
{ _id: CURRENT_ID, name: 'Getting started' },
{ _id: OTHER_ID, name: 'Acme AG' },
Expand Down Expand Up @@ -135,7 +145,48 @@ describe('ProjectBreadcrumbSwitcher', () => {
expect(mockNavigate).not.toHaveBeenCalled();
});

it('keeps the current name and offers a retry when the project list fails', () => {
projectsError = true;
render(
<ProjectBreadcrumbSwitcher
organizationId="org-1"
projectId={CURRENT_ID}
projectName="Getting started"
/>,
);
expect(screen.getByText('Getting started')).toBeInTheDocument();
expect(screen.getByRole('alert')).toHaveTextContent(
'Project list unavailable',
);
screen.getByRole('button', { name: 'Retry' }).click();
expect(retryProjects).toHaveBeenCalledOnce();
});

it('recovers the switcher after a successful retry', () => {
projectsError = true;
const view = render(
<ProjectBreadcrumbSwitcher
organizationId="org-1"
projectId={CURRENT_ID}
projectName="Getting started"
/>,
);
projectsError = false;
view.rerender(
<ProjectBreadcrumbSwitcher
organizationId="org-1"
projectId={CURRENT_ID}
projectName="Getting started"
/>,
);
expect(
screen.getByRole('button', { name: /switch project/i }),
).toBeInTheDocument();
});

it('renders a plain name when the project list is empty', () => {
projectsError = false;
retryProjects.mockReset();
projectsFixture = [];
render(
<ProjectBreadcrumbSwitcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function ProjectBreadcrumbSwitcher({
const { t } = useT('projects');
const navigate = useNavigate();
const location = useLocation();
const { projects } = useProjects(organizationId);
const { projects, error, isRetrying, retry } = useProjects(organizationId);

const onTasksPath = isProjectTasksPath(location.pathname, projectId);
const allProjectsActive =
Expand Down Expand Up @@ -74,6 +74,24 @@ export function ProjectBreadcrumbSwitcher({
? ALL_PROJECTS_SWITCHER_VALUE
: projectId;

if (error) {
return (
<div role="alert" className="inline-flex items-center gap-2">
<span>{displayName}</span>
<span>{t('switcher.readError')}</span>
<button
type="button"
className="focus-visible:ring-ring text-sm underline focus-visible:ring-2 focus-visible:outline-none"
disabled={isRetrying}
aria-busy={isRetrying}
onClick={retry}
>
{isRetrying ? t('switcher.retrying') : t('switcher.retry')}
</button>
</div>
);
}

return (
<HeaderBreadcrumbSwitcher
value={selectedValue}
Expand Down
17 changes: 13 additions & 4 deletions services/platform/app/features/projects/hooks/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,22 @@ export function useProjects(
organizationId: string,
options?: { includeArchived?: boolean },
) {
const { data, isLoading } = useBackendQuery('projects/queries:listProjects', {
organizationId,
includeArchived: options?.includeArchived,
});
const { data, isLoading, isError, isFetching, refetch } = useBackendQuery(
'projects/queries:listProjects',
{
organizationId,
includeArchived: options?.includeArchived,
},
);
const retry = useCallback(() => {
void refetch();
}, [refetch]);
return {
projects: data ?? [],
isLoading,
error: isError,
isRetrying: isFetching,
retry,
};
}

Expand Down
3 changes: 3 additions & 0 deletions services/platform/messages/de/projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ switcher:
empty: Keine Projekte gefunden
ariaLabel: 'Projekt wechseln, aktuell: {name}'
allProjects: Alle Projekte
retry: Erneut versuchen
retrying: Wird erneut versucht…
readError: Projektliste nicht verfügbar
navigation:
overview: Allgemein
files: Wissen
Expand Down
3 changes: 3 additions & 0 deletions services/platform/messages/en/projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ switcher:
empty: No projects found
ariaLabel: 'Switch project, current: {name}'
allProjects: All projects
retry: Retry
retrying: Retrying…
readError: Project list unavailable
navigation:
overview: General
files: Knowledge
Expand Down
3 changes: 3 additions & 0 deletions services/platform/messages/fr/projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ switcher:
empty: Aucun projet trouvé
ariaLabel: 'Changer de projet, actuel : {name}'
allProjects: Tous les projets
retry: Réessayer
retrying: Nouvelle tentative…
readError: Liste des projets indisponible
navigation:
overview: Général
files: Connaissances
Expand Down
2 changes: 2 additions & 0 deletions services/platform/tests/manual/reference/automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ in EN/DE/FR that clear after correction:
covers the component boundary and axe audit; real API persistence and browser
layout remain manual.

Project breadcrumb keeps the current project name and offers a localized Retry action when the project list read fails; retry recovery restores switching. `app/features/projects/components/project-breadcrumb-switcher.test.tsx` owns failure, retry, and recovery coverage.

Website status sync records the five-minute throttle only after success. Failed
syncs retry on remount, clear expired timestamps and expose an accessible Retry
alert that stays visible during retry and clears on success. Organization-scoped
Expand Down
1 change: 1 addition & 0 deletions tools/cli/scripts/cli-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ describe('CLI command test targets', () => {
'deployment.test.ts',
'doctor.test.ts',
'hash-password.test.ts',
'observation.test.ts',
'platform-configuration.test.ts',
'provision.test.ts',
]);
Expand Down