fix(mod-queue): show empty state instead of not-allowed redirect

When the account moderates no boards, render ModEmptyState on the global
/mod/queue route instead of sending users to /not-allowed.
This commit is contained in:
Tommaso Casaburi
2026-06-09 13:01:31 +07:00
parent dbf672f11a
commit 4308d26cf0
2 changed files with 16 additions and 4 deletions
+14 -3
View File
@@ -114,6 +114,13 @@ vi.mock('../lib/utils/preload-utils', () => ({
resolveAssetUrl: (path: string) => path, resolveAssetUrl: (path: string) => path,
})); }));
vi.mock('react-i18next', () => ({
Trans: ({ components, i18nKey }: { components?: Record<number, React.ReactNode>; i18nKey: string }) => createElement(React.Fragment, {}, i18nKey, components?.[1]),
useTranslation: () => ({
t: (key: string) => key,
}),
}));
function makeNamedComponent(name: string) { function makeNamedComponent(name: string) {
return () => createElement('div', { 'data-testid': name }, name); return () => createElement('div', { 'data-testid': name }, name);
} }
@@ -473,7 +480,7 @@ describe('App', () => {
expect(container.querySelector('[data-testid="not-found-view"]')).toBeTruthy(); expect(container.querySelector('[data-testid="not-found-view"]')).toBeTruthy();
}); });
it('allows the global mod queue only when the account moderates at least one board', async () => { it('shows the mod empty state from the global mod queue when the account moderates no boards', async () => {
testState.accountCommunityAddresses = ['music-posting.eth']; testState.accountCommunityAddresses = ['music-posting.eth'];
await renderApp('/mod/queue'); await renderApp('/mod/queue');
@@ -486,8 +493,12 @@ describe('App', () => {
testState.accountCommunityAddresses = []; testState.accountCommunityAddresses = [];
await renderApp('/mod/queue'); await renderApp('/mod/queue');
expect(latestLocation).toBe('/not-allowed'); expect(latestLocation).toBe('/mod/queue');
expect(container.querySelector('[data-testid="not-allowed-view"]')).toBeTruthy(); expect(container.textContent).toContain('not_mod_of_any_board');
expect(container.textContent).toContain('go_to_settings_to_import_mod_account');
expect(container.querySelector('output')?.className).toContain('modEmptyState');
expect(container.querySelector('output a')?.getAttribute('href')).toBe('/mod/settings#account-settings');
expect(container.querySelector('[data-testid="not-allowed-view"]')).toBeNull();
}); });
it('renders board archive routes and hides board form/buttons on that dedicated page', async () => { it('renders board archive routes and hides board form/buttons on that dedicated page', async () => {
+2 -1
View File
@@ -52,6 +52,7 @@ import PostForm from './components/post-form/post-form';
import BoardBlotter from './components/board-blotter/board-blotter'; import BoardBlotter from './components/board-blotter/board-blotter';
import BoardsBar from './components/boards-bar/boards-bar'; import BoardsBar from './components/boards-bar/boards-bar';
import ExternalQuoteStatus from './components/external-quote-status/external-quote-status'; import ExternalQuoteStatus from './components/external-quote-status/external-quote-status';
import ModEmptyState from './components/mod-empty-state/mod-empty-state';
const AccountDataEditor = lazy(() => import('./views/account-data-editor')); const AccountDataEditor = lazy(() => import('./views/account-data-editor'));
const BoardsBarEditModal = lazy(() => import('./components/boards-bar-edit-modal')); const BoardsBarEditModal = lazy(() => import('./components/boards-bar-edit-modal'));
@@ -265,7 +266,7 @@ const ModQueueRoute = () => {
} }
if (!boardIdentifier) { if (!boardIdentifier) {
return accountCommunityAddresses.length > 0 ? <ModQueueView /> : <Navigate to='/not-allowed' replace />; return accountCommunityAddresses.length > 0 ? <ModQueueView /> : <ModEmptyState />;
} }
// Wait for board role metadata before enforcing access to avoid false redirects during initial load. // Wait for board role metadata before enforcing access to avoid false redirects during initial load.