Page MenuHomePhabricator

Wikibase: Fix tests to not assume synchronous jQuery.Deferred
Closed, ResolvedPublic

Description

Draft change with details at https://gerrit.wikimedia.org/r/323445/.

Each QUnit test should either return a Promise to QUnit.test (which QUnit will automatically wait for and also report a test failure if the Promise is rejected), or manually use assert.async() where needed.

Examples:

QUnit.test( 'example should pass', function ( assert ) {
  return something().then( function ( val ) {
    assert.equals( val, 'expected' );
  } );
} );

QUnit.test( 'example should fail', function ( assert ) {
  var done = assert.async();
  something().fail( function ( val ) {
    assert.equals( val, 'error message' );
  } ).always( done );
} );

This is in preparation for jQuery 3.0, where $.Deferred callbacks are processed asynchronously. https://jquery.com/upgrade-guide/3.0/

Failures can be seen at the pending core patch: https://gerrit.wikimedia.org/r/322812/.

Event Timeline

Change 323445 had a related patch set uploaded (by Krinkle):
Don't assume synchronous jQuery.Deferred in QUnit tests

https://gerrit.wikimedia.org/r/323445

Change 323445 merged by jenkins-bot:
[mediawiki/extensions/Wikibase] Don't assume synchronous jQuery.Deferred in QUnit tests

https://gerrit.wikimedia.org/r/323445

Change 323445 merged by jenkins-bot:
[mediawiki/extensions/Wikibase] Don't assume synchronous jQuery.Deferred in QUnit tests

https://gerrit.wikimedia.org/r/323445

@Lydia_Pintscher @Jonas Per my comment on Gerrit, this patch was not finished. Please ensure the other tests are migrated as well. You can test locally by checking out https://gerrit.wikimedia.org/r/#/c/322812/ in your MediaWiki install and run the Wikibase test suite to observe the failures. Essentially just needs the same patterns in that patch applied to the remaining tests. This is blocking the migration to jQuery 3.0.

Jonas raised the priority of this task from Medium to High.Mar 23 2017, 12:10 PM
Jonas moved this task from Proposed to Backlog on the Wikidata-Former-Sprint-Board board.

Change 344405 had a related patch set uploaded (by Jonas Kress (WMDE)):
[mediawiki/extensions/Wikibase@master] Replace QUnit.start()/.stop() with assert.async()

https://gerrit.wikimedia.org/r/344405

Change 344405 merged by Hoo man:
[mediawiki/extensions/Wikibase@master] Replace QUnit.start()/.stop() with assert.async()

https://gerrit.wikimedia.org/r/344405

What's outstanding here?

From comments on https://gerrit.wikimedia.org/r/344405:

@Jonas wrote:

@Krinkle this is what you need for all Wikibase tests right?

@Krinkle wrote:

LGTM, but there are a few more failures remaining still at https://gerrit.wikimedia.org/r/#/c/322812/

@Jonas wrote:

I just wanted to check if that is the fix you need, before I fix all the places needed [..]

So, like the first patch, this only converted a few tests. There are still a handful left that use the unsupported format.

FAILED TESTS:
  wikibase.entityChangers.EntityTermsChanger
    ✖ save performs correct API calls for new label
    failed, expected argument to be truthy, was: false

    ✖ save performs correct API calls for changed label
    failed, expected argument to be truthy, was: false

    ✖ save performs correct API calls for removed label
    failed, expected argument to be truthy, was: false

    ✖ save performs correct API calls for new description
    failed, expected argument to be truthy, was: false

    ✖ save performs correct API calls for changed description
    failed, expected argument to be truthy, was: false

    ✖ save performs correct API calls for removed description
    failed, expected argument to be truthy, was: false

    ✖ save performs correct API calls for new aliases
    failed, expected argument to be truthy, was: false

    ✖ save performs correct API calls for changed aliases
    failed, expected argument to be truthy, was: false

    ✖ save performs correct API calls for removed aliases
    failed, expected argument to be truthy, was: false

  wikibase.entityChangers.SiteLinkSetsChanger
    ✖ save performs correct API call
    failed, expected argument to be truthy, was: false

    ✖ save performs correct API call for removal
    failed, expected argument to be truthy, was: false

  jquery.wikibase.entitytermsforlanguagelistview
    ✖ Create & destroy
    afterEach failed on Create & destroy: Unfinished animations: 2
    Error: Unfinished animations: 2

    ✖ setError()
    afterEach failed on setError(): Unfinished animations: 2
    Error: Unfinished animations: 2

Change 346753 had a related patch set uploaded (by Jonas Kress (WMDE)):
[mediawiki/extensions/Wikibase@master] Replace QUnit.start()/.stop() with assert.async()

https://gerrit.wikimedia.org/r/346753

Change 346753 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Replace QUnit.start()/.stop() with assert.async()

https://gerrit.wikimedia.org/r/346753

Change 347167 had a related patch set uploaded (by Aleksey Bekh-Ivanov (WMDE)):
[mediawiki/extensions/Wikibase@master] Prepare EntityTermsChanger.tests for jQuery version migration

https://gerrit.wikimedia.org/r/347167

Change 347349 had a related patch set uploaded (by Jonas Kress (WMDE)):
[mediawiki/extensions/Wikibase@master] Prepare SiteLinkSetsChanger.tests for jQuery version migration

https://gerrit.wikimedia.org/r/347349

Change 347167 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Prepare EntityTermsChanger.tests for jQuery version migration

https://gerrit.wikimedia.org/r/347167

Change 347349 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Prepare SiteLinkSetsChanger.tests for jQuery version migration

https://gerrit.wikimedia.org/r/347349