Public Access
feat(sync): follow the visit sync on the dashboard
Show the "Syncing with Steam" badge while a visit sync runs, then reload the sync changes banner and the library.
This commit is contained in:
1 parent
8aa3181c37
commit
e5091de50e
6 files changed
+97
-5
No files matched your search
@@ -6,7 +6,10 @@ import {fetchRoutes, json} from '../test/fetchRoutes.js';
|
||||
import {renderWithProviders} from '../test/renderWithProviders.jsx';
|
||||
|
||||
vi.mock('react-i18next', () => import('../test/i18n-mock.js'));
|
||||
vi.mock('../hooks/useLibrarySync.js', () => ({default: () => ({status: 'OK', lastSyncedAt: null, isRunning: false})}));
|
||||
const watchSync = vi.hoisted(() => vi.fn());
|
||||
vi.mock('../hooks/useLibrarySync.js', () => ({
|
||||
default: () => ({status: 'OK', lastSyncedAt: null, isRunning: false, watch: watchSync}),
|
||||
}));
|
||||
vi.mock('../hooks/useForceSync.js', () => ({default: () => ({trigger: vi.fn(), busy: false})}));
|
||||
|
||||
const avatar = 'https://avatars.steamstatic.com/abc_full.jpg';
|
||||
@@ -42,6 +45,7 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
watchSync.mockClear();
|
||||
cleanup();
|
||||
localStorage.clear();
|
||||
});
|
||||
@@ -177,5 +181,22 @@ describe('Dashboard', () => {
|
||||
|
||||
expect(await screen.findByText(/DASHBOARD.HELLO/)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
it('watches the sync the server started for this visit', async () => {
|
||||
fetchRoutes({
|
||||
...dashboardRoutes(),
|
||||
'GET /api/library/games-count': json(200, {count: 1, hasSteamId: true, syncStarted: true}),
|
||||
});
|
||||
renderDashboard();
|
||||
|
||||
await waitFor(() => expect(watchSync).toHaveBeenCalledTimes(1));
|
||||
});
|
||||
|
||||
it('does not watch a sync when the server started none', async () => {
|
||||
fetchRoutes(dashboardRoutes());
|
||||
renderDashboard();
|
||||
|
||||
expect(await screen.findByText(/DASHBOARD.HELLO/)).toBeTruthy();
|
||||
expect(watchSync).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user