fix(document): fix test regressions from DocumentListItem migration
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m32s
CI / OCR Service Tests (pull_request) Successful in 20s
CI / Backend Unit Tests (pull_request) Successful in 3m46s
CI / fail2ban Regex (pull_request) Successful in 42s
CI / Semgrep Security Scan (pull_request) Successful in 19s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m0s
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m32s
CI / OCR Service Tests (pull_request) Successful in 20s
CI / Backend Unit Tests (pull_request) Successful in 3m46s
CI / fail2ban Regex (pull_request) Successful in 42s
CI / Semgrep Security Scan (pull_request) Successful in 19s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m0s
- Use documentService.getDocumentById() in detail_stillReturnsTrainingLabels
so the Document.full entity graph eager-loads trainingLabels
- Flatten makeItem() factory in DocumentList.svelte.test.ts (nested
document: {} overrides broke item.id / item.documentDate access)
- Remove { document: {} } wrapper from DocumentMultiSelect.svelte.spec.ts
mock responses — component now reads body.items directly as flat items
- Flatten single nested item in page.svelte.test.ts document list test
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -90,8 +90,8 @@ class DocumentListItemIntegrationTest {
|
|||||||
.trainingLabels(new HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
.trainingLabels(new HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
// Document.full entity graph (used by findById) must still load trainingLabels
|
// Document.full entity graph (used by getDocumentById) must still load trainingLabels
|
||||||
Document loaded = documentRepository.findById(saved.getId()).orElseThrow();
|
Document loaded = documentService.getDocumentById(saved.getId());
|
||||||
|
|
||||||
assertThat(loaded.getTrainingLabels()).containsExactly(TrainingLabel.KURRENT_RECOGNITION);
|
assertThat(loaded.getTrainingLabels()).containsExactly(TrainingLabel.KURRENT_RECOGNITION);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function mockSearchResponse(items: ReturnType<typeof docFactory>[]) {
|
|||||||
'fetch',
|
'fetch',
|
||||||
vi.fn().mockResolvedValue({
|
vi.fn().mockResolvedValue({
|
||||||
ok: true,
|
ok: true,
|
||||||
json: vi.fn().mockResolvedValue({ items: items.map((document) => ({ document })) })
|
json: vi.fn().mockResolvedValue({ items })
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -91,10 +91,7 @@ describe('DocumentMultiSelect — search and select', () => {
|
|||||||
const fetchMock = vi.fn().mockResolvedValue({
|
const fetchMock = vi.fn().mockResolvedValue({
|
||||||
ok: true,
|
ok: true,
|
||||||
json: vi.fn().mockResolvedValue({
|
json: vi.fn().mockResolvedValue({
|
||||||
items: [
|
items: [docFactory('d1', 'Already attached'), docFactory('d2', 'Not attached')]
|
||||||
{ document: docFactory('d1', 'Already attached') },
|
|
||||||
{ document: docFactory('d2', 'Not attached') }
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
vi.stubGlobal('fetch', fetchMock);
|
vi.stubGlobal('fetch', fetchMock);
|
||||||
|
|||||||
@@ -20,11 +20,31 @@ const { default: DocumentList } = await import('./DocumentList.svelte');
|
|||||||
|
|
||||||
afterEach(cleanup);
|
afterEach(cleanup);
|
||||||
|
|
||||||
const sender = { id: 's1', displayName: 'Anna Schmidt' };
|
const sender = {
|
||||||
const receiver = { id: 'r1', displayName: 'Bert Meier' };
|
id: 's1',
|
||||||
|
lastName: 'Schmidt',
|
||||||
|
displayName: 'Anna Schmidt',
|
||||||
|
personType: 'PERSON' as const,
|
||||||
|
familyMember: false
|
||||||
|
};
|
||||||
|
const receiver = {
|
||||||
|
id: 'r1',
|
||||||
|
lastName: 'Meier',
|
||||||
|
displayName: 'Bert Meier',
|
||||||
|
personType: 'PERSON' as const,
|
||||||
|
familyMember: false
|
||||||
|
};
|
||||||
|
|
||||||
|
const emptyMatchData = {
|
||||||
|
titleOffsets: [],
|
||||||
|
senderMatched: false,
|
||||||
|
matchedReceiverIds: [],
|
||||||
|
matchedTagIds: [],
|
||||||
|
snippetOffsets: [],
|
||||||
|
summaryOffsets: []
|
||||||
|
};
|
||||||
|
|
||||||
const makeItem = (overrides: Record<string, unknown> = {}) => ({
|
const makeItem = (overrides: Record<string, unknown> = {}) => ({
|
||||||
document: {
|
|
||||||
id: 'd1',
|
id: 'd1',
|
||||||
title: 'Brief 1923',
|
title: 'Brief 1923',
|
||||||
originalFilename: 'b.pdf',
|
originalFilename: 'b.pdf',
|
||||||
@@ -32,17 +52,14 @@ const makeItem = (overrides: Record<string, unknown> = {}) => ({
|
|||||||
sender,
|
sender,
|
||||||
receivers: [receiver],
|
receivers: [receiver],
|
||||||
tags: [],
|
tags: [],
|
||||||
thumbnailUrl: null,
|
summary: undefined,
|
||||||
contentType: 'application/pdf',
|
archiveBox: undefined,
|
||||||
summary: null,
|
archiveFolder: undefined,
|
||||||
archiveBox: null,
|
location: undefined,
|
||||||
archiveFolder: null,
|
matchData: emptyMatchData,
|
||||||
location: null,
|
|
||||||
...overrides
|
|
||||||
},
|
|
||||||
matchData: null,
|
|
||||||
completionPercentage: 0,
|
completionPercentage: 0,
|
||||||
contributors: []
|
contributors: [],
|
||||||
|
...overrides
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('DocumentList', () => {
|
describe('DocumentList', () => {
|
||||||
@@ -87,8 +104,26 @@ describe('DocumentList', () => {
|
|||||||
render(DocumentList, {
|
render(DocumentList, {
|
||||||
props: {
|
props: {
|
||||||
items: [
|
items: [
|
||||||
makeItem({ id: 'd1', sender: { id: 's1', displayName: 'Anna Schmidt' } }),
|
makeItem({
|
||||||
makeItem({ id: 'd2', sender: { id: 's2', displayName: 'Bert Meier' } })
|
id: 'd1',
|
||||||
|
sender: {
|
||||||
|
id: 's1',
|
||||||
|
lastName: 'Schmidt',
|
||||||
|
displayName: 'Anna Schmidt',
|
||||||
|
personType: 'PERSON',
|
||||||
|
familyMember: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
makeItem({
|
||||||
|
id: 'd2',
|
||||||
|
sender: {
|
||||||
|
id: 's2',
|
||||||
|
lastName: 'Meier',
|
||||||
|
displayName: 'Bert Meier',
|
||||||
|
personType: 'PERSON',
|
||||||
|
familyMember: false
|
||||||
|
}
|
||||||
|
})
|
||||||
],
|
],
|
||||||
canWrite: false,
|
canWrite: false,
|
||||||
sort: 'SENDER' as const
|
sort: 'SENDER' as const
|
||||||
|
|||||||
@@ -140,15 +140,12 @@ describe('documents/+ page', () => {
|
|||||||
data: baseData({
|
data: baseData({
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
document: {
|
|
||||||
id: 'd1',
|
id: 'd1',
|
||||||
title: 'Brief 1899',
|
title: 'Brief 1899',
|
||||||
status: 'TRANSCRIBED',
|
|
||||||
documentDate: '1899-04-14',
|
documentDate: '1899-04-14',
|
||||||
summary: '',
|
|
||||||
originalFilename: 'b1.pdf',
|
originalFilename: 'b1.pdf',
|
||||||
receivers: []
|
receivers: [],
|
||||||
},
|
tags: [],
|
||||||
matchData: {
|
matchData: {
|
||||||
titleOffsets: [],
|
titleOffsets: [],
|
||||||
senderMatched: false,
|
senderMatched: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user