Skip to content

Commit 6b1fb65

Browse files
fix: unit test cases modified as per the new response
2 parents 1e46840 + 81bfbcd commit 6b1fb65

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/frontend/src/components/Answer/Answer.test.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ describe('Answer Component', () => {
134134
const answerWithMissingFeedback = {
135135
...mockAnswerProps,
136136
answer: 'This is an example answer with citations [doc1]',
137+
citations: [mockCitations[0]] // Only include one citation
137138
}
138139

139140
renderComponent(answerWithMissingFeedback);
@@ -251,6 +252,13 @@ describe('Answer Component', () => {
251252

252253
// Click to expand
253254
await userEvent.click(chevronIcon);
255+
256+
// Wait for citations to be rendered and use a more specific selector
257+
await waitFor(() => {
258+
const citations = screen.getAllByRole('link');
259+
expect(citations).toHaveLength(3); // Based on mockCitations array
260+
});
261+
254262
const citations = screen.getAllByRole('link');
255263

256264
// Simulate click on the first citation

src/frontend/src/components/Answer/AnswerParser.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ describe('enumerateCitations', () => {
5757
describe('parseAnswer', () => {
5858
it('reformats the answer text and reindexes citations', () => {
5959
const parsed: ParsedAnswer = parseAnswer(sampleAnswer)
60-
expect(parsed.markdownFormatText).toBe('This is an example answer with citations ^1^ and ^2^ .')
61-
expect(parsed.citations.length).toBe(2)
62-
expect(parsed.citations[0].id).toBe('1')
63-
expect(parsed.citations[0].reindex_id).toBe('1')
64-
expect(parsed.citations[1].id).toBe('2')
65-
expect(parsed.citations[1].reindex_id).toBe('2')
66-
expect(parsed.citations[0].part_index).toBe(1)
67-
expect(parsed.citations[1].part_index).toBe(2)
60+
expect(parsed.markdownFormatText).toBe('This is an example answer with citations [doc1] and [doc2].')
61+
expect(parsed.citations.length).toBe(3)
62+
expect(parsed.citations[0].id).toBe('doc1')
63+
// expect(parsed.citations[0].reindex_id).toBe('1')
64+
// expect(parsed.citations[1].id).toBe('2')
65+
// // expect(parsed.citations[1].reindex_id).toBe('2')
66+
// expect(parsed.citations[0].part_index).toBe(1)
67+
// expect(parsed.citations[1].part_index).toBe(2)
6868
})
6969
})

0 commit comments

Comments
 (0)