Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2316 refactor mocha tests to qunit #2330

Merged
merged 2 commits into from
Dec 10, 2021
Merged

Conversation

candunaj
Copy link
Contributor

@candunaj candunaj commented Oct 5, 2021

Removed mocha. Added Qunit. Refactored unit tests.

{{content-for "test-body-footer"}}
</body>
</html>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are changes in this file necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change in this file fixed route /tests when you run it with "ember s", so I believe that the change in this file is valid.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I see, qunit needs some element it can hook into, so we should probably just go back to the old index.html file and add this below test-body block:

  <div id="qunit"></div>
  <div id="qunit-fixture">
    <div id="ember-testing-container">
      <div id="ember-testing"></div>
    </div>
  </div>

"@glimmer/component": "^1.0.0",
"@glimmer/tracking": "^1.0.0",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"chai": "^4.1.0",
"chai": "^4.3.4",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chai is a part of mocha, so we want to remove it as well.

@@ -31,11 +31,13 @@
},
"devDependencies": {
"@ember/optional-features": "^1.3.0",
"@ember/test-helpers": "^2.4.2",
"@embroider/test-setup": "^0.43.5",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Embroider test setup is not needed for the migration

"@glimmer/component": "^1.0.0",
"@glimmer/tracking": "^1.0.0",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"chai": "^4.1.0",
"chai": "^4.3.4",
"ember-cli": "~3.18.0",
"ember-cli-blueprint-test-helpers": "^0.19.2",
"ember-cli-chai": "^0.5.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chai ✂️

@marcoow
Copy link
Member

marcoow commented Oct 20, 2021

🎉 Yay!

Could we implement the strategy for getting CI green that we discussed first though so we can merge this with a green CI?

@candunaj
Copy link
Contributor Author

candunaj commented Oct 20, 2021 via email

@marcoow
Copy link
Member

marcoow commented Oct 20, 2021

@candunaj so in our call recently we talked about the strategy for making things work with the current Torii situation. Can we make a separate PR for implementing that first? We can't just not run tests for ember-beta to "fix" CI :)

@candunaj candunaj force-pushed the 2316-refactor-mocha-tests-to-qunit branch 2 times, most recently from 27c3c4f to 8702ed2 Compare October 26, 2021 08:24
@marcoow
Copy link
Member

marcoow commented Oct 29, 2021

@candunaj can we move 8702ed2 into its own PR?

@candunaj candunaj force-pushed the 2316-refactor-mocha-tests-to-qunit branch from 8702ed2 to 3cd3507 Compare October 29, 2021 11:03
@candunaj candunaj changed the title 2316 refactor mocha tests to qunit [WIP] 2316 refactor mocha tests to qunit Nov 4, 2021
@candunaj candunaj force-pushed the 2316-refactor-mocha-tests-to-qunit branch from 3cd3507 to 142c23a Compare November 4, 2021 15:11
@candunaj candunaj changed the title [WIP] 2316 refactor mocha tests to qunit 2316 refactor mocha tests to qunit Nov 12, 2021
Copy link
Member

@marcoow marcoow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work 🙌

I found some things that I think still should be addressed but I'm looking forward getting this merged!

One general thing I recognized is that this replaces the nested describe blocks with a flat structure with just one module and tests nested directly into that (at least in some of the test files).Can we use nested modules instead? I feel a flat list of tests is much harder to navigate (plus, in a nested structure it's much easier to build up preconditions for tests in nested blocks incrementally).

@@ -56,8 +56,6 @@ jobs:
- classic-test-app
- test-app
test-suite:
- test:one ember-3.0
- test:one ember-lts-3.4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this change? Can we not support 3.0 and 3.4 when using QUnit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wanted to write ember-qunit 5. ember-qunit 5 supports ember 3.8+.
https:/emberjs/ember-qunit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a version of ember-qunit that supports Ember 3.0 as well? I'd rather upgrade to ember-qunit 5 (and drop support for Ember < 3.8) in a separate PR then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can use ember-qunit 4 with some change in the source code. I will do it.

@@ -70,4 +68,4 @@
"cssstyle": "~1.2.2",
"jsdom": "^11.10.0"
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems unrelated anyway

packages/classic-test-app/tests/.eslintrc.js Show resolved Hide resolved
// test files
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above – I assume this should go into the config that previously contained the Mocha linting settings?

@@ -1,4 +1,4 @@
import { alias, oneWay } from '@ember/object/computed';
import { alias, readOnly } from '@ember/object/computed';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unrelated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 2 unit tests which expect three properties in session service to be readOnly and fail when set. So I have changed properties isAuthenticated, data and store to readOnly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But oneWay should be the same? My point is migrating the tests from Mocha to Qunit shouldn't require any changes in the tested code?

Copy link
Contributor Author

@candunaj candunaj Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oneWay will not throw an error when set. I have found the bug in mocha tests so the bug was always there.

it('is read-only', function() {
      expect(() => {
        sessionService.set('store', 'some other store');
      }).to.throw;
    });

it should be

}).to.throw();

Change isAuthenticated from oneWay to readOnly has fixed 3 tests, but it can be considered as breaking change. So maybe we should remove these tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, we should definitely move that into a separate PR to not also mix actual changes to the behavior into this – it's already a huge PR (necessarily) so I'd keep it as limited as possible :)

@@ -1,52 +1,51 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -73,4 +71,4 @@
"cssstyle": "~1.2.2",
"jsdom": "^11.10.0"
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

// eslint-disable-next-line node/no-missing-require
najax = require('najax');
} catch (err) {
// ignore the error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this error ignored?

packages/test-app/tests/.eslintrc.js Show resolved Hide resolved
{{content-for "test-body-footer"}}
</body>

</html>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this diff of this file is a bit messed up because of the reformatting (and now missing indentation)?

@BobrImperator
Copy link
Collaborator

BobrImperator commented Nov 25, 2021

I went through the changes and there isn't anything from my side apart from what Marco's pointed out.
Although, I'm not sure if we were supposed to change test and classic-testapps as well, thought that just ESA package refactor is enough.

Though again, it probably makes sense as it's what we need to do for Ember 4.0 anyway.

@candunaj candunaj force-pushed the 2316-refactor-mocha-tests-to-qunit branch 8 times, most recently from 69a2dd9 to e9d4eb7 Compare November 30, 2021 07:30
@@ -14,24 +14,22 @@
"test:fastboot": "ember fastboot:test"
},
"devDependencies": {
"@ember/jquery": "^2.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this related?

'token_type_hint': 'refresh_token',
'token': 'refresh token!'
});
if (body.token_type_hint === 'refresh_token') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@candunaj I assume the if could just be dropped?

@candunaj candunaj force-pushed the 2316-refactor-mocha-tests-to-qunit branch 2 times, most recently from f78d5d6 to 5b35bbd Compare December 9, 2021 10:53
@candunaj candunaj force-pushed the 2316-refactor-mocha-tests-to-qunit branch from 5b35bbd to ee701a8 Compare December 9, 2021 11:07
@candunaj candunaj force-pushed the 2316-refactor-mocha-tests-to-qunit branch from ee701a8 to 57f659e Compare December 10, 2021 11:22
Copy link
Member

@marcoow marcoow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job 🎉

@marcoow marcoow merged commit 9fde2c2 into master Dec 10, 2021
@delete-merged-branch delete-merged-branch bot deleted the 2316-refactor-mocha-tests-to-qunit branch December 10, 2021 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants