From c09dc4d211a06dcd8dc914b77fce09b4fec0cb9d Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Wed, 3 Jun 2026 16:49:33 +0200 Subject: [PATCH] fix(test): use groups not legacy role in recommendations-lookback mockUser (closes #935) The mockUser helper was still supplying `role: 'admin'` after the group-membership authz migration (#912/#917). permissions.ts isAdmin() now reads user.groups, so the old fixture always yielded canEdit=false, the lookback change listener was never attached, and 11 assertions failed on the base branch. Mirror the pattern already used in recommendations-permissions.test.ts: import ADMINISTRATORS_GROUP_ID and set groups: [ADMINISTRATORS_GROUP_ID] for admin, groups: [] for non-admin roles. --- frontend/src/__tests__/recommendations-lookback.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/__tests__/recommendations-lookback.test.ts b/frontend/src/__tests__/recommendations-lookback.test.ts index d9596dfe4..3d05e71d6 100644 --- a/frontend/src/__tests__/recommendations-lookback.test.ts +++ b/frontend/src/__tests__/recommendations-lookback.test.ts @@ -20,6 +20,7 @@ import { import * as api from '../api'; import { refreshRecommendations as refreshRecsAPI } from '../api/recommendations'; import { showToast } from '../toast'; +import { ADMINISTRATORS_GROUP_ID } from '../permissions'; jest.mock('../api', () => ({ getRecommendations: jest.fn().mockResolvedValue({ summary: {}, recommendations: [], regions: [] }), @@ -74,7 +75,7 @@ import * as state from '../state'; const mockUser = (role: string | null) => { (state.getCurrentUser as jest.Mock).mockReturnValue( - role === null ? null : { id: 'u', email: 'u@example.com', role }, + role === null ? null : { id: 'u', email: 'u@example.com', groups: role === 'admin' ? [ADMINISTRATORS_GROUP_ID] : [] }, ); };