Move chunk builder into SetupPage via useChunkBuilder
- The setup form, active chapter tab, verse range selection, typed/bulk/ cross-chapter chunk creation, reorder, and delete move out of App. - Setup now opens on the chapter holding the chunk last studied (e.g. after Back to Chunks), and the Add Chapter form suggests the chapter after the project's last one instead of repeating the current one. - openNewProject/goHome/resume/import no longer reset setup state by hand; SetupPage starts fresh each time it opens. - Tests: add-chapter default, Back to Chunks chapter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf02e071fa
commit
0f1a9c3d5b
6 files changed
+555
-518
No files matched your search
@@ -671,3 +671,32 @@ describe('Study editor', () => {
|
||||
expect(input).toHaveValue('');
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Chunk builder (useChunkBuilder, local to SetupPage)
|
||||
// ---------------------------------------------------------------------------
|
||||
describe('Chunk builder', () => {
|
||||
async function addSecondChapter(user) {
|
||||
await user.click(screen.getByRole('button', { name: /add chapter/i }));
|
||||
// The add-chapter form starts on the chapter after the project's last one.
|
||||
expect(screen.getByDisplayValue('2')).toBeInTheDocument();
|
||||
await user.click(screen.getByRole('button', { name: /load chapter/i }));
|
||||
return screen.findByRole('button', { name: 'Titus 2' });
|
||||
}
|
||||
|
||||
test('"Add Chapter" starts on the next chapter and adds it as a tab', async () => {
|
||||
const user = await loadChapter();
|
||||
expect(await addSecondChapter(user)).toHaveClass('bg-slate-900');
|
||||
});
|
||||
|
||||
test('"Back to Chunks" reopens the chapter of the chunk being studied', async () => {
|
||||
const user = await loadChapter();
|
||||
await addSecondChapter(user);
|
||||
addChunk('Paul, a servant', 'In hope of eternal'); // chunk in Titus 2 (now selected)
|
||||
await user.click(screen.getByRole('button', { name: 'Titus 1' }));
|
||||
await user.click(screen.getByRole('button', { name: /begin studying/i }));
|
||||
await screen.findByText(/chunk editor/i);
|
||||
await user.click(screen.getByRole('button', { name: /back to chunks/i }));
|
||||
expect(await screen.findByRole('button', { name: 'Titus 2' })).toHaveClass('bg-slate-900');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user