page-issues sectionNumbers consistency on modalClose event

For the page-issues modalClose event, the number of values for `sectionNumbers`
and `issuesSeverity` should be the same, since `sectionNumbers` should describe
the the section of each visible issue in the modal, not the section of the
modal itself.

Bug: T203050
Change-Id: Ic58c5940a6059e71aa3aeed26232afbe8faf1618
This commit is contained in:
Jan Drewniak 2018-09-01 00:54:21 +02:00
parent 34ead3f8c5
commit 1a9bcd1e8a
2 changed files with 36 additions and 6 deletions

View File

@ -85,10 +85,19 @@
* @return {void}
*/
onExit: function () {
this.log( {
action: 'modalClose',
issuesSeverity: this.issues.map( issueSummaryToSeverity )
} );
var logData = {
action: 'modalClose',
issuesSeverity: this.issues.map( issueSummaryToSeverity )
},
currentSection = this.section;
// When users close the modal, `sectionNumbers` should correlate to each visible issue in
// the modal, provided that this.section is a valid number and not `KEYWORD_ALL_SECTIONS`.
if ( this.section !== KEYWORD_ALL_SECTIONS ) {
logData.sectionNumbers = this.issues.map( function () {
return currentSection;
} );
}
this.log( logData );
},
/**

View File

@ -22,15 +22,36 @@
} );
QUnit.test( '#log (section=1)', function ( assert ) {
var overlay = new PageIssuesOverlay( [], this.logger, '1', 0 );
var overlay = new PageIssuesOverlay( [
{
severity: 'MEDIUM'
}
], this.logger, '1', 0 );
overlay.onExit();
assert.strictEqual(
this.logger.log.calledWith( {
action: 'modalClose',
issuesSeverity: [],
issuesSeverity: [ 'MEDIUM' ],
sectionNumbers: [ '1' ]
} ), true, 'sectionNumbers is set'
);
} );
QUnit.test( '#log (section=2) multiple issues', function ( assert ) {
var overlay = new PageIssuesOverlay(
[ {
severity: 'MEDIUM'
},
{
severity: 'LOW'
} ], this.logger, '2', 0 );
overlay.onExit();
assert.strictEqual(
this.logger.log.calledWith( {
action: 'modalClose',
issuesSeverity: [ 'MEDIUM', 'LOW' ],
sectionNumbers: [ '2', '2' ]
} ), true, 'sectionNumbers is set for each issue'
);
} );
}( mw.mobileFrontend ) );