fix(board): warn on unverified addresses

This commit is contained in:
Tommaso Casaburi
2026-05-21 17:33:14 +07:00
parent 75d90c8264
commit a31c3b44d3
38 changed files with 154 additions and 36 deletions
+67 -1
View File
@@ -20,6 +20,14 @@ type TestComment = {
timestamp?: number;
};
type TestCommunity = {
error?: Error;
nameResolved?: boolean;
shortAddress?: string;
state?: string;
title?: string;
};
const testState = vi.hoisted(() => ({
account: { subscriptions: [] as string[] },
accountComments: [] as TestComment[],
@@ -60,7 +68,7 @@ const testState = vi.hoisted(() => ({
shortAddress: 'music-posting.eth',
state: 'ready',
title: '/mu/ - Music',
},
} as TestCommunity,
communitySnapshot: {
shortAddress: 'music-posting.eth',
title: '/mu/ - Music',
@@ -404,6 +412,64 @@ describe('Board', () => {
]);
});
it('warns when a loaded board address is not verified', async () => {
testState.directories = [{ address: 'business-and-finance.bso', directoryCode: 'biz', title: '/biz/ - Business & Finance' }];
testState.directoryByAddress = {
'business-and-finance.bso': {
address: 'business-and-finance.bso',
features: { postsPerPage: 2 },
},
};
testState.resolvedCommunityAddress = 'business-and-finance.bso';
testState.community = {
nameResolved: false,
shortAddress: 'business-and-finance.bso',
state: 'ready',
title: '/biz/ - Business & Finance',
};
testState.communitySnapshot = {
shortAddress: 'business-and-finance.bso',
title: '/biz/ - Business & Finance',
};
await renderBoard({
boardProps: { boardIdentifier: 'business-and-finance.bso', viewType: 'board' },
initialEntry: '/business-and-finance.bso',
routePath: '/:boardIdentifier/*',
});
expect(container.textContent).toContain('board_address_unverified_warning');
});
it('does not warn when a loaded board address is verified', async () => {
testState.directories = [{ address: 'business-and-finance.bso', directoryCode: 'biz', title: '/biz/ - Business & Finance' }];
testState.directoryByAddress = {
'business-and-finance.bso': {
address: 'business-and-finance.bso',
features: { postsPerPage: 2 },
},
};
testState.resolvedCommunityAddress = 'business-and-finance.bso';
testState.community = {
nameResolved: true,
shortAddress: 'business-and-finance.bso',
state: 'ready',
title: '/biz/ - Business & Finance',
};
testState.communitySnapshot = {
shortAddress: 'business-and-finance.bso',
title: '/biz/ - Business & Finance',
};
await renderBoard({
boardProps: { boardIdentifier: 'business-and-finance.bso', viewType: 'board' },
initialEntry: '/business-and-finance.bso',
routePath: '/:boardIdentifier/*',
});
expect(container.textContent).not.toContain('board_address_unverified_warning');
});
it('renders the current page feed, inserts recent account comments, and wires footer actions', async () => {
const currentTimestamp = Math.floor(Date.now() / 1000);
testState.feed = [
+5
View File
@@ -7,6 +7,11 @@
padding: 15px 0 0 5px;
}
.addressWarning {
color: var(--mod-queue-alert-color, red);
padding: 15px 5px 0 5px;
}
.footer {
color: var(--post-mobile-abbr-text-color);
padding: 15px 0 20px 5px;
+12
View File
@@ -594,6 +594,13 @@ const Board = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, t
}, [title, shortAddress, communityAddress, isVisible, params.boardIdentifier, boardIdentifierProp, directories, isInAllView, isInSubscriptionsView, isInModView, t]);
const shouldShowErrorToUser = communityError?.message && feed.length === 0;
const shouldShowUnverifiedAddressWarning =
!isMultiboardView &&
typeof communityIdentifier?.name === 'string' &&
communityIdentifier.name.includes('.') &&
typeof communityIdentifier.publicKey === 'string' &&
communityIdentifier.publicKey.length > 0 &&
communityData?.nameResolved === false;
const displayFeed = effectiveInfiniteScroll ? combinedFeed : currentPageFeed;
return (
@@ -605,6 +612,11 @@ const Board = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, t
<ErrorDisplay error={communityError} />
</div>
)}
{shouldShowUnverifiedAddressWarning && (
<div className={styles.addressWarning} role='status'>
{t('board_address_unverified_warning')}
</div>
)}
{effectiveInfiniteScroll ? (
<Virtuoso
defaultItemHeight={defaultBoardItemHeight}