Skip to content

Commit 1bb6abd

Browse files
resolved testcase issue
1 parent 765c920 commit 1bb6abd

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/frontend/src/pages/draft/Draft.test.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ describe('Draft Component', () => {
124124
isLoadedSections: [{ title: 'Section 1', content: 'Content of section 1' },
125125
{ title: 'Section 2', content: 'Content of section 2.' }
126126
],
127+
draftedDocument: {
128+
sections: [
129+
{ title: 'Section 1', content: 'Content of section 1' },
130+
{ title: 'Section 2', content: 'Content of section 2.' }
131+
]
132+
},
133+
draftedDocumentTitle: '', // this must be explicitly ''
127134
}
128135
renderComponent(mockStateWithIncompleteLoad)
129136
await waitFor(() => {
@@ -139,6 +146,13 @@ describe('Draft Component', () => {
139146
isLoadedSections: [{ title: 'Section 1', content: 'Content of section 1' },
140147
{ title: 'Section 2', content: 'Content of section 2.' }
141148
],
149+
draftedDocument: {
150+
sections: [
151+
{ title: 'Section 1', content: 'Content of section 1' },
152+
{ title: 'Section 2', content: 'Content of section 2.' }
153+
]
154+
},
155+
draftedDocumentTitle: '', // critical for button to be enabled
142156
}
143157
renderComponent(mockStateWithIncompleteLoad)
144158

@@ -231,6 +245,13 @@ describe('Draft Component', () => {
231245
isLoadedSections: [{ title: 'Section 1', content: 'Content of section 1' },
232246
{ title: 'Section 2', content: 'Content of section 2.' }
233247
], // One section not loaded
248+
draftedDocument: {
249+
sections: [
250+
{ title: 'Section 1', content: 'Content of section 1' },
251+
{ title: 'Section 2', content: 'Content of section 2.' }
252+
]
253+
},
254+
draftedDocumentTitle: '', // must be empty string
234255
}
235256
renderComponent(mockStateWithIncompleteLoad)
236257

@@ -253,7 +274,13 @@ describe('Draft Component', () => {
253274
isLoadedSections: [{ title: 'Section 1', content: 'Content of section 1' },
254275
{ title: 'Section 2', content: 'Content of section 2.' }
255276
],
256-
draftedDocumentTitle: null
277+
draftedDocument: {
278+
sections: [
279+
{ title: 'Section 1', content: 'Content of section 1' },
280+
{ title: 'Section 2', content: 'Content of section 2.' }
281+
]
282+
},
283+
draftedDocumentTitle: null // allow null here
257284
}
258285
renderComponent(mockStateWithIncompleteLoad)
259286
await waitFor(async () => {

src/frontend/src/pages/draft/Draft.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ const Draft = (): JSX.Element => {
4949

5050

5151
useEffect(() => {
52-
if (isLoadedSections?.length === sections.length && draftedDocumentTitle === '') {
52+
const title = draftedDocumentTitle ?? '' // Normalize null to ''
53+
if (isLoadedSections?.length === sections.length && title === '') {
5354
setIsExportButtonDisable(false);
5455
}
5556
else {

0 commit comments

Comments
 (0)