Build and Push Docker Image / build-and-push (push) Successful in 6m47s
- Admin: sign-up Open / Invite only / Closed with single-use invite links - Present mode for scripts (auto-scroll) and outlines (step through, pace vs planned minutes) - Series: group studies on the dashboard, filter by series, calendar file for a study's sessions - Lesson handout: printable page per session (passage, outline, questions, writing lines) - Save a chunk's notes as your own study template (synced) - Voice dictation for notes and scripts (browser speech recognition) - Reading progress: map of the 66 books and a calendar of days read, synced and merged across devices - Export highlights and bookmarks as Markdown or Word, grouped by named colour - Verse of the day push to the ntfy topic (needs IQBIBLE_API_KEY) - Sharing: co-teacher editing via single-use invite links; read-only links can expire and take a passcode Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
55 lines
3.0 KiB
JavaScript
55 lines
3.0 KiB
JavaScript
import { test, expect } from 'vitest';
|
|
import { filterStudies, tagCounts, isTagQuery } from './studyFilter.js';
|
|
|
|
const index = [
|
|
{ id: 'a', title: 'Titus Notes', chapterSummary: 'Titus 1', tags: ['hope', 'leadership'] },
|
|
{ id: 'b', title: 'New Birth', chapterSummary: 'John 3', tags: ['grace', 'hope'] },
|
|
{ id: 'c', title: 'Grace Alone', chapterSummary: 'Romans 3', tags: [] },
|
|
];
|
|
const ids = (list) => list.map((e) => e.id);
|
|
|
|
test('the search box finds a study by title, passage or tag', () => {
|
|
expect(ids(filterStudies(index, { query: 'titus' }))).toEqual(['a']);
|
|
expect(ids(filterStudies(index, { query: 'romans' }))).toEqual(['c']);
|
|
expect(ids(filterStudies(index, { query: 'lead' }))).toEqual(['a']); // a tag
|
|
expect(ids(filterStudies(index, { query: 'grace' }))).toEqual(['b', 'c']); // a tag on one, a title on the other
|
|
});
|
|
|
|
test('starting with # searches tags only', () => {
|
|
expect(isTagQuery(' #grace')).toBe(true);
|
|
expect(ids(filterStudies(index, { query: '#grace' }))).toEqual(['b']); // not the study named "Grace Alone"
|
|
expect(ids(filterStudies(index, { query: '#HOP' }))).toEqual(['a', 'b']);
|
|
expect(ids(filterStudies(index, { query: '#' }))).toEqual(['a', 'b', 'c']);
|
|
expect(ids(filterStudies(index, { query: '#nothing' }))).toEqual([]);
|
|
});
|
|
|
|
test('chosen tags must all be present, and combine with the search', () => {
|
|
expect(ids(filterStudies(index, { tags: ['hope'] }))).toEqual(['a', 'b']);
|
|
expect(ids(filterStudies(index, { tags: ['hope', 'grace'] }))).toEqual(['b']);
|
|
expect(ids(filterStudies(index, { tags: ['hope'], query: 'john' }))).toEqual(['b']);
|
|
expect(ids(filterStudies(index, { tags: ['Hope'] }))).toEqual(['a', 'b']); // case does not matter
|
|
});
|
|
|
|
test('tags are counted, most used first', () => {
|
|
expect(tagCounts(index)).toEqual([{ tag: 'hope', count: 2 }, { tag: 'grace', count: 1 }, { tag: 'leadership', count: 1 }]);
|
|
});
|
|
|
|
import { groupBySeries, seriesList } from './studyFilter.js';
|
|
|
|
test('series are listed and studies grouped under them, with unsorted ones last', () => {
|
|
const idx = [
|
|
{ id: 'a', title: 'A', series: 'Romans' }, { id: 'b', title: 'B', series: '' },
|
|
{ id: 'c', title: 'C', series: 'Advent' }, { id: 'd', title: 'D', series: 'Romans' },
|
|
];
|
|
expect(seriesList(idx)).toEqual([{ name: 'Advent', count: 1 }, { name: 'Romans', count: 2 }]);
|
|
expect(groupBySeries(idx).map((g) => `${g.name || '(none)'}:${g.items.map((e) => e.id).join('')}`)).toEqual(['Advent:c', 'Romans:ad', '(none):b']);
|
|
expect(groupBySeries([{ id: 'x' }]).map((g) => g.name)).toEqual(['']);
|
|
});
|
|
|
|
test('a series can be chosen as a filter, and the search finds studies by series name', () => {
|
|
const idx = [{ id: 'a', title: 'Ch 8', series: 'Romans' }, { id: 'b', title: 'Ch 1' }, { id: 'c', title: 'Gen', series: 'Advent' }];
|
|
expect(filterStudies(idx, { series: 'Romans' }).map((e) => e.id)).toEqual(['a']);
|
|
expect(filterStudies(idx, { series: '__none' }).map((e) => e.id)).toEqual(['b']);
|
|
expect(filterStudies(idx, { query: 'advent' }).map((e) => e.id)).toEqual(['c']);
|
|
});
|