Skip to content

Commit c83eec3

Browse files
committed
fix(davinci-app): handle ReadOnlyCollector in label component to fix CI crashes
label.ts was typed to accept only RichTextCollector but main.ts was passing ReadOnlyCollector, causing a runtime crash when accessing richContent (undefined) that silently killed the collector render loop and caused e2e timeouts.
1 parent 6738de5 commit c83eec3

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

e2e/davinci-app/components/label.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7-
import type { RichTextCollector } from '@forgerock/davinci-client/types';
7+
import type { ReadOnlyCollector, RichTextCollector } from '@forgerock/davinci-client/types';
88

9-
export default function (formEl: HTMLFormElement, collector: RichTextCollector) {
9+
export default function (
10+
formEl: HTMLFormElement,
11+
collector: ReadOnlyCollector | RichTextCollector,
12+
) {
1013
const p = document.createElement('p');
1114
p.style.whiteSpace = 'pre-line';
15+
16+
if (collector.type !== 'RichTextCollector') {
17+
p.innerText = collector.output.content;
18+
formEl?.appendChild(p);
19+
return;
20+
}
21+
1222
const { richContent } = collector.output;
1323

1424
if (richContent.replacements.length === 0) {

e2e/davinci-app/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ const urlParams = new URLSearchParams(window.location.search);
221221
davinciClient.update(collector), // Returns an update function for this collector
222222
submitForm,
223223
);
224-
} else if (collector.type === 'ReadOnlyCollector') {
224+
} else if (collector.type === 'ReadOnlyCollector' || collector.type === 'RichTextCollector') {
225225
labelComponent(
226226
formEl, // You can ignore this; it's just for rendering
227227
collector, // This is the plain object of the collector

0 commit comments

Comments
 (0)