From e394ea6af91cdf50f153254f36d8a15419f2728c Mon Sep 17 00:00:00 2001 From: Chlod Alejandro Date: Tue, 18 Oct 2022 12:29:43 +0800 Subject: [PATCH] add integration testing hooks --- src/session/DeputyRootSession.ts | 2 ++ src/ui/root/DeputyContributionSurveyRevision.tsx | 1 - src/ui/root/DeputyContributionSurveyRow.tsx | 2 -- src/ui/root/DeputyContributionSurveySection.tsx | 12 ++++++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/session/DeputyRootSession.ts b/src/session/DeputyRootSession.ts index d8a25635..2cd05bcc 100644 --- a/src/session/DeputyRootSession.ts +++ b/src/session/DeputyRootSession.ts @@ -529,6 +529,8 @@ export default class DeputyRootSession { await casePage.addActiveSection( sectionName ); heading.insertAdjacentElement( 'afterend', el.render() ); + await el.loadData(); + mw.hook( 'deputy.load.cci.root' ).fire(); return true; } diff --git a/src/ui/root/DeputyContributionSurveyRevision.tsx b/src/ui/root/DeputyContributionSurveyRevision.tsx index 53d5d887..427b7c07 100644 --- a/src/ui/root/DeputyContributionSurveyRevision.tsx +++ b/src/ui/root/DeputyContributionSurveyRevision.tsx @@ -172,7 +172,6 @@ export default class DeputyContributionSurveyRevision * @inheritDoc */ render(): HTMLElement { - const commentElement = as HTMLElement; - this.loadData(); - return this.rootElement; } diff --git a/src/ui/root/DeputyContributionSurveySection.tsx b/src/ui/root/DeputyContributionSurveySection.tsx index 708afc20..04120a28 100644 --- a/src/ui/root/DeputyContributionSurveySection.tsx +++ b/src/ui/root/DeputyContributionSurveySection.tsx @@ -301,6 +301,9 @@ export default class DeputyContributionSurveySection implements DeputyUIElement csr, rowElements[ csr.title.getPrefixedText() ], line, this ); } catch ( e ) { + console.warn( 'Could not parse row.', line, e ); + // For debugging and tests. + mw.hook( 'deputy.errors.cciRowParse' ).fire( { line, e } ); rowElement = line; } if ( typeof rowElement !== 'string' ) { @@ -394,6 +397,15 @@ export default class DeputyContributionSurveySection implements DeputyUIElement } ); } + /** + * Makes all rows of this section being loading data. + * + * @return A Promise that resolves when all rows have finished loading data. + */ + async loadData(): Promise { + await Promise.all( this.rows.map( row => row.loadData() ) ); + } + /** * @inheritDoc */