From e15e2c4d1448aae3a93113d79f8c5456117dd9e5 Mon Sep 17 00:00:00 2001 From: WMDE-Fisch Date: Mon, 15 Jan 2024 19:03:22 +0100 Subject: [PATCH] Increase test coverage More of a random thing done to increase the coverage a bit because there are upcomming features that seem to be hard to test. - Found one test case in reference previews that was configured wrongly - Adding some sanity checks to the settingsDialogRender test Change-Id: I95d3c6f30388b2dcc76b018d5dc0f958d06aad91 --- .../isReferencePreviewsEnabled.test.js | 2 +- tests/node-qunit/ui/settingsDialogRenderer.test.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/node-qunit/ext.popups.referencePreviews/isReferencePreviewsEnabled.test.js b/tests/node-qunit/ext.popups.referencePreviews/isReferencePreviewsEnabled.test.js index eef01ca02..696e529ba 100644 --- a/tests/node-qunit/ext.popups.referencePreviews/isReferencePreviewsEnabled.test.js +++ b/tests/node-qunit/ext.popups.referencePreviews/isReferencePreviewsEnabled.test.js @@ -109,7 +109,7 @@ QUnit.test( 'all relevant combinations of flags', ( assert ) => { // TODO: This combination will make much more sense when the server-side // wgPopupsReferencePreviews flag doesn't include the user's setting any more testCase: 'manually disabled by the registered user', - wgPopupsReferencePreviews: false, + wgPopupsReferencePreviews: true, wgPopupsConflictsWithRefTooltipsGadget: false, isMobile: false, isAnon: false, diff --git a/tests/node-qunit/ui/settingsDialogRenderer.test.js b/tests/node-qunit/ui/settingsDialogRenderer.test.js index 399942ebd..87b816610 100644 --- a/tests/node-qunit/ui/settingsDialogRenderer.test.js +++ b/tests/node-qunit/ui/settingsDialogRenderer.test.js @@ -38,6 +38,7 @@ QUnit.test( '#toggleHelp', ( assert ) => { } ); QUnit.test( '#render', ( assert ) => { + const main = document.createElement( 'main' ); const boundActions = { saveSettings() {}, hideSettings() {} @@ -50,14 +51,23 @@ QUnit.test( '#render', ( assert ) => { toggleHelp() {}, setEnabled() {} }, - result = createSettingsDialogRenderer( mw.config )( boundActions, {} ); + dialogRenderer = createSettingsDialogRenderer( mw.config )( boundActions, {} ); // Specifically NOT a deep equal. Only structure. assert.propEqual( - result, + dialogRenderer, expected, 'Interface exposed has the expected methods' ); + + // Sanity checks for some methods + assert.strictEqual( main.childElementCount, 0 ); + dialogRenderer.appendTo( main ); + assert.strictEqual( main.childElementCount, 1 ); + + assert.strictEqual( $( main.children[ 0 ] ).css( 'display' ), 'block' ); + dialogRenderer.hide(); + assert.strictEqual( $( main.children[ 0 ] ).css( 'display' ), 'none' ); } ); // FIXME: Add Qunit integration tests about the rendering and the behavior of