feat: add Exclude home world for activity tab

This commit is contained in:
pa
2026-03-23 11:23:14 +09:00
parent fb4750e9bc
commit 520c41f280
6 changed files with 173 additions and 36 deletions
+40
View File
@@ -0,0 +1,40 @@
import { beforeEach, describe, expect, test, vi } from 'vitest';
import { createPinia, setActivePinia } from 'pinia';
const mocks = vi.hoisted(() => ({
getMyTopWorlds: vi.fn()
}));
vi.mock('../../services/database', () => ({
database: {
getMyTopWorlds: mocks.getMyTopWorlds
}
}));
vi.mock('../../workers/activityWorkerRunner', () => ({
runActivityWorkerTask: vi.fn()
}));
import { useActivityStore } from '../activity';
describe('useActivityStore', () => {
beforeEach(() => {
setActivePinia(createPinia());
vi.clearAllMocks();
});
test('forwards excludeWorldId to top worlds query', async () => {
mocks.getMyTopWorlds.mockResolvedValue([{ worldId: 'wrld_1' }]);
const store = useActivityStore();
const result = await store.loadTopWorldsView({
userId: 'usr_me',
rangeDays: 30,
limit: 5,
sortBy: 'time',
excludeWorldId: 'wrld_home'
});
expect(result).toEqual([{ worldId: 'wrld_1' }]);
expect(mocks.getMyTopWorlds).toHaveBeenCalledWith(30, 5, 'time', 'wrld_home');
});
});
+5 -3
View File
@@ -296,10 +296,10 @@ export const useActivityStore = defineStore('Activity', () => {
async function loadTopWorlds(
userId,
{ rangeDays = 30, limit = 5, sortBy = 'time' }
{ rangeDays = 30, limit = 5, sortBy = 'time', excludeWorldId = '' }
) {
void userId;
return database.getMyTopWorlds(rangeDays, limit, sortBy);
return database.getMyTopWorlds(rangeDays, limit, sortBy, excludeWorldId);
}
async function refreshActivity(userId, options) {
@@ -358,12 +358,14 @@ export const useActivityStore = defineStore('Activity', () => {
userId,
rangeDays = 30,
limit = 5,
sortBy = 'time'
sortBy = 'time',
excludeWorldId = ''
}) {
return loadTopWorlds(userId, {
rangeDays,
limit,
sortBy,
excludeWorldId,
isSelf: true
});
}