Skip to content

Commit

Permalink
add integration testing hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Oct 18, 2022
1 parent 2dc0405 commit e394ea6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/session/DeputyRootSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/ui/root/DeputyContributionSurveyRevision.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ export default class DeputyContributionSurveyRevision
* @inheritDoc
*/
render(): HTMLElement {

const commentElement = <span
class="comment comment--without-parentheses"
/** Stranger danger! Yes. */
Expand Down
2 changes: 0 additions & 2 deletions src/ui/root/DeputyContributionSurveyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,6 @@ export default class DeputyContributionSurveyRow implements DeputyUIElement {
{ this.element }
</div> as HTMLElement;

this.loadData();

return this.rootElement;
}

Expand Down
12 changes: 12 additions & 0 deletions src/ui/root/DeputyContributionSurveySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) {
Expand Down Expand Up @@ -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<void> {
await Promise.all( this.rows.map( row => row.loadData() ) );
}

/**
* @inheritDoc
*/
Expand Down

0 comments on commit e394ea6

Please sign in to comment.