fix: Prevent Novel Screen Empty State Flash (Closes #2034)

This commit is contained in:
Rajarshee Chatterjee
2026-09-07 21:13:47 +05:30
parent 2426e6fe3e
commit 9bde3df74d
2 changed files with 18 additions and 2 deletions
@@ -1,6 +1,7 @@
import { NovelInfo } from '@database/types';
import { getString } from '@i18n/translations';
import { createNovelStoreActions } from '../store/novelStore.actions';
import { createNovelSlice } from '../store/novelStore';
interface BootstrapServiceSlice {
bootstrapNovelAsync: jest.Mock;
@@ -88,6 +89,21 @@ describe('novelStore.bootstrap', () => {
jest.clearAllMocks();
});
it('starts in a loading state until the initial bootstrap completes', () => {
const state = createNovelSlice({
pluginId: 'plugin.test',
novelPath: '/x',
initialNovelSettings: {
sort: 'positionAsc',
filter: [],
showChapterTitles: true,
},
});
expect(state.loading).toBe(true);
expect(state.fetching).toBe(true);
});
it('maps a missing novel to the not-found error', async () => {
const harness = createHarness();
harness.bootstrapService.bootstrapNovelAsync.mockResolvedValue({
@@ -21,8 +21,8 @@ export const createNovelSlice = ({
initialLastRead,
}: CreateNovelStoreParams) => {
return {
loading: false,
fetching: false,
loading: true,
fetching: true,
error: undefined,
pluginId,
novelPath,