mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(multiboards): expand time filters in place
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user