fix/add tests, update heatmap range, finish android release, add readme

Stop tracking gradle.properties
This commit is contained in:
Rene Kievits
2025-12-24 06:50:04 +01:00
parent eaed23a678
commit c140bb8292
66 changed files with 350 additions and 89 deletions

View File

@@ -178,7 +178,7 @@ describe('Sync Service', () => {
});
it('should sync items in chunks', async () => {
const manyIds = Array.from({ length: 150 }, (_, i) => i + 1);
const manyIds = Array.from({ length: 100 }, (_, i) => i + 1);
const subjectData = manyIds.map(id => ({ data: { subject_id: id } }));
fetch.mockResolvedValueOnce({
@@ -202,11 +202,90 @@ describe('Sync Service', () => {
});
StudyItem.insertMany.mockResolvedValue(true);
StudyItem.countDocuments.mockResolvedValue(150);
StudyItem.countDocuments.mockResolvedValue(100);
await syncWithWaniKani(mockUser);
expect(fetch).toHaveBeenCalledTimes(3);
expect(StudyItem.insertMany).toHaveBeenCalledTimes(2);
});
it('should fetch and map radicals for items, handling missing meanings', async () => {
fetch.mockResolvedValueOnce({
ok: true,
json: async () => ({
data: [{ data: { subject_id: 500 } }],
pages: { next_url: null }
})
});
StudyItem.find.mockReturnValue({ select: vi.fn().mockResolvedValue([]) });
fetch.mockResolvedValueOnce({
ok: true,
json: async () => ({
data: [{
id: 500,
data: {
characters: 'Kanji',
meanings: [{ primary: true, meaning: 'K_Mean' }],
level: 5,
readings: [],
component_subject_ids: [10, 11, 12]
}
}]
})
});
fetch.mockResolvedValueOnce({
ok: true,
json: async () => ({
data: [
{
id: 10,
data: {
characters: 'R1',
meanings: [{ primary: true, meaning: 'Rad1' }],
character_images: []
}
},
{
id: 11,
data: {
characters: null,
meanings: [{ primary: true, meaning: 'Rad2' }],
character_images: [
{ content_type: 'image/png', url: 'bad.png', metadata: {} },
{ content_type: 'image/svg+xml', url: 'good.svg', metadata: { inline_styles: false } }
]
}
},
{
id: 12,
data: {
characters: 'R2',
meanings: [{ primary: false, meaning: 'Secondary' }],
character_images: []
}
}
]
})
});
StudyItem.insertMany.mockResolvedValue(true);
StudyItem.countDocuments.mockResolvedValue(1);
await syncWithWaniKani(mockUser);
expect(StudyItem.insertMany).toHaveBeenCalledWith(expect.arrayContaining([
expect.objectContaining({
wkSubjectId: 500,
radicals: expect.arrayContaining([
expect.objectContaining({ meaning: 'Rad1', char: 'R1' }),
expect.objectContaining({ meaning: 'Rad2', image: 'good.svg' }),
expect.objectContaining({ meaning: 'Unknown', char: 'R2' })
])
})
]));
});
});