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
Ahsan/removal underscore string from commerce js #12401
Ahsan/removal underscore string from commerce js #12401
Conversation
jenkins run a11y |
jenkins run python |
jenkins run bokchoy |
@andy-armstrong @bjacobel @mattdrayer I have fixed the JS issue regarding |
@ahsan-ul-haq Thanks for tackling this again, and for adding a regression test. There seems to be some issue where the test doesn't get full code coverage: https://build.testeng.edx.org/job/edx-platform-js-pr/18172/Diff_Coverage_Report/ Can you investigate whether this is because the test isn't actually running, or if there's an issue with the code coverage itself. I'd expect to see the spec file get 100% coverage, and then the covered file should also get substantially more than 16.7% |
@andy-armstrong I have made the changes and now spec file got 100% of coverage and covered file got 33.3% coverage. |
@ahsan-ul-haq you may want to hold off on merging this until https://github.com/edx/edx-platform/pull/12413 lands. The release branch contains a revert of the original commit. If you were to merge this before the revert lands in master, it might revert changes in this PR. @andy-armstrong and I learned about this the hard way a few releases back. |
<section class="wrapper carousel"> | ||
<div id="receipt-container" class="pay-and-verify hidden" data-is-payment-complete='True' | ||
data-platform-name='edx-platform' data-verified='True' data-username='user-1'> | ||
<h2>${_("Loading Order Data...")}</h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the fixture is intended to be rendered HTML, so it shouldn't include Python in it. It won't hurt as long as it is valid HTML, but it is a little confusing.
@rlucioni thanks for the heads up on that I would keep a close look on release to get merged into master before moving forward with this. |
"currency": "USD", | ||
"total_excl_tax": "10.00" | ||
}; | ||
view = new ReceiptView({el: $('#receipt-container')}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a subtle issue where events sometimes don't behave as you'd expect when you render views in the beforeEach
method. This has been the cause of a number of flaky Jasmine tests. I'd convert this into a createTestView
function, and then call it from your test to create a view.
I also find that it makes the test easier to read. I like tests to be of the form:
- do a thing
- verify the result
- do a thing
- verify the result
IMO having too much logic in the beforeEach makes it harder to read the test by itself without having to fully understand what the setup code is doing.
@ahsan-ul-haq Thanks for solving the issue with the spec coverage. Can you also get your changes to 100% coverage (this is just for lines you changed, not for the whole file): https://build.testeng.edx.org/job/edx-platform-js-pr/18244/Diff_Coverage_Report/ You just need tests for |
@ahsan-ul-haq This is looking great. I have a few more comments about the tests, so let me know when those are addressed. |
jenkins run js |
36a15eb
to
7a0e249
Compare
return new ReceiptView({el: $('#receipt-container')}); | ||
}; | ||
|
||
var loadReceiptFixture = function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add space between ()
and {
, like var loadReceiptFixture = function() {
Also add this var at top of this method.
@andy-armstrong I have added some new tests and although tests passes I am getting following error afterward
Do you have any idea about this? |
once tests fixed and build passes 👍 |
jenkins run bokchoy |
|
||
}); | ||
|
||
it("test render receipt", function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the test name should read like a sentence starting with it
, so something like:
it('renders a receipt correctly', function() {
@ahsan-ul-haq That line of Underscore.js appears to be in the function |
bfba4a6
to
6d41a0d
Compare
@andy-armstrong please review |
@AlasdairSwan please review |
AjaxHelpers.respondWithJson(requests, responseData); | ||
}; | ||
|
||
var mockRender = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should only be 1 var declaration at the top of the function, comma separating the variable names.
48d8661
to
026c739
Compare
@AlasdairSwan @andy-armstrong made the suggested changes please review. |
@ahsan-ul-haq First of all thanks for this work! I'm working on a small change to the I noticed following behavior when running tests for this view on my devstack: when I run whole lms test suite ( Could you please verify that is the case? If so I think that this would be worth fixing, as it may suggest some inter-dependencies between tests that could lead to sudden test failures in the future. Example stack-trace looks like that:
|
@jbzdak I have tried to investigate/fix this but could not find any inter-dependencies between the tests. If you could find any please let me know. |
'jquery', 'jquery.ajax-retry', | ||
'js/commerce/views/receipt_view', 'common/js/spec_helpers/ajax_helpers' | ||
], | ||
function ($, AjaxRetry, ReceiptView, AjaxHelpers){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is AjaxRetry
being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it's not being used in this file, it's being used in lms/static/js/commerce/views/receipt_view.js
? If so it should be in that file's define array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no define array in lms/static/js/commerce/views/receipt_view.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, I see now. Sorry, the function statement at the top made me think there was.
👍 |
1 similar comment
👍 |
@jbzdak @ahsan-ul-haq I've pushed up a fix for running the tests individually. I stepped through the code and found that it was silently throwing an error trying to record events for analytics. I added the standard code for adding spy methods for the expected analytics functions. I also renamed the spec file to mirror the file it was testing, and cleaned up the order of spec files in the Karma main.js file. |
@jbzdak @ahsan-ul-haq I should have mentioned that there are many tests that are not clearing the analytics spy once they are done, which is why running all the tests together allowed these tests to run. Ideally we would clean up this logic so that the spies are removed after each test is run, and also we would share the initialization. FYI @jzoldak @benpatterson. |
@andy-armstrong ugh. definitely thanks for noticing that, tho. Can you please make sure that there is a JIRA ticket for addressing the potential issues with the non-cleaned-up analytics spy? |
@ahsan-ul-haq @andy-armstrong Thanks, that really helped a lot! When I run the tests one by one they run well. However, on my devstack, when I run the whole fixture together (for example by this:
|
@jzoldak I've created a story to track the Jasmine spy issue: |
@andy-armstrong Thanks for catching this |
24daa42
to
af7eb1f
Compare
@jbzdak I have made the changes for individual tests to run in debug mode and now its working fine on my local devstack. Please confirm so I can move forward with merging this. |
jenkins run bokchoy |
be7b2d7
to
300002b
Compare
@mattdrayer This is the PR that is causing you trouble with the merge back. |
Here is the PR that is merging the release back to master: https://github.com/edx/edx-platform/pull/12495 We will have to be careful not to lose any of this newer PR with the merge. |
ECOM-4281
@awais786 @zubair-arbi @tasawernawaz @waheedahmed
Completed Order
on LMS checkout receipt page.underscore.string
dependency and use globalstring_utils
methods.Initial PR (Merged): https://github.com/edx/edx-platform/pull/12238
Reverted PR (falkytest): https://github.com/edx/edx-platform/pull/12273
Related PR (Underscore string changes): https://github.com/edx/edx-platform/pull/11631