feat(multiboards): expand time filters in place

This commit is contained in:
Tommaso Casaburi
2026-04-18 16:47:04 +07:00
parent df01cbfb49
commit 70d8c37222
8 changed files with 186 additions and 25 deletions
+28 -1
View File
@@ -51,6 +51,7 @@ const testState = vi.hoisted(() => ({
hasMore: false,
imageSize: 'Small' as 'Large' | 'Small',
incrementFilterCountMock: vi.fn(),
expandTimeWindowMock: vi.fn(),
loadMoreMock: vi.fn(),
pageSizes: {
guiPostsPerPage: 2,
@@ -161,6 +162,7 @@ vi.mock('@bitsocialnet/bitsocial-react-hooks', () => ({
return {
feed: getScopedFeed(options),
hasMore: testState.hasMore,
expandTimeWindow: testState.expandTimeWindowMock,
loadMore: testState.loadMoreMock,
reset: testState.resetMock,
};
@@ -504,7 +506,32 @@ describe('Catalog', () => {
expect.objectContaining({ newerThan: 365 * 24 * 60 * 60 }),
]),
);
expect(Array.from(container.querySelectorAll('a')).some((link) => link.getAttribute('href') === '/all/catalog?t=1w')).toBe(true);
expect(container.querySelector('[data-testid="expand-time-window-button"]')).toBeTruthy();
});
it('expands the multiboard catalog time window in place from the footer suggestion', async () => {
const now = Math.floor(Date.now() / 1000);
localStorage.setItem(LAST_VISIT_STORAGE_KEY, String((now - 3 * 24 * 60 * 60) * 1000));
testState.feed = [
{ cid: 'recent-post', title: 'recent', communityAddress: 'music-posting.eth', timestamp: now - 2 * 24 * 60 * 60 },
{ cid: 'older-post', title: 'older', communityAddress: 'music-posting.eth', timestamp: now - 5 * 24 * 60 * 60 },
];
await renderCatalog({
catalogProps: { viewType: 'all' },
initialEntry: '/all/catalog?t=last',
routePath: '/all/*',
});
const expandButton = container.querySelector('[data-testid="expand-time-window-button"]');
expect(expandButton).toBeTruthy();
expect(Array.from(container.querySelectorAll('a')).some((link) => link.getAttribute('href') === '/all/catalog?t=1w')).toBe(false);
await act(async () => {
expandButton?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
});
expect(testState.expandTimeWindowMock).toHaveBeenCalledWith(7 * 24 * 60 * 60);
});
it('keeps broader catalog suggestion feeds on the base page size so their identities stay stable while scrolling', async () => {