tests: Prevent native "Back" navigation in mmv.test.js

This makes the test report inaccessible in the browser. I'm adding
it at the module level given that nearly all test cases in this
file trigger it:

* "Progress"
* "Progress when switching images"
* "New image loaded while another one is loading"
* "Events are not trapped after the viewer is closed"
* "document.title"

```
-   QUnit.module( 'mmv', QUnit.newMwEnvironment() );
+   QUnit.module( 'mmv', QUnit.newMwEnvironment( {
+       beforeEach: function () {
+           this.sandbox.stub( require( 'mediawiki.router' ), 'back', function () {
+               console.log( QUnit.config.current.testName );
+               console.trace();
+           } );
+       }
+   } ) );
```

Change-Id: I0cb7ed6c76d5547bcef9c183c9305b6fd08ec9eb
This commit is contained in:
Timo Tijhof 2023-10-05 19:58:23 -07:00 committed by Krinkle
parent 01652054b3
commit 1260d98c78

View file

@ -3,7 +3,12 @@ const { getMultimediaViewer } = require( './mmv.testhelpers.js' );
const { MultimediaViewerBootstrap } = require( 'mmv.bootstrap' );
( function () {
QUnit.module( 'mmv', QUnit.newMwEnvironment() );
QUnit.module( 'mmv', QUnit.newMwEnvironment( {
beforeEach: function () {
// prevent a real "back" navigation from taking place
this.sandbox.stub( require( 'mediawiki.router' ), 'back' );
}
} ) );
QUnit.test( 'eachPreloadableLightboxIndex()', function ( assert ) {
var viewer = getMultimediaViewer(),
@ -702,7 +707,6 @@ const { MultimediaViewerBootstrap } = require( 'mmv.bootstrap' );
title = new mw.Title( 'File:This_should_show_up_in_document_title.png' ),
oldDocumentTitle = document.title;
this.sandbox.stub( bootstrap.router, 'back' );
this.sandbox.stub( mw.loader, 'using' ).returns( $.Deferred().resolve( viewer ) );
viewer.currentImageFileTitle = title;
bootstrap.setupEventHandlers();