mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
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:
@@ -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
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user