Skip to content

Commit

Permalink
chore: fix comments, remove and add some code for karma
Browse files Browse the repository at this point in the history
  • Loading branch information
salman2013 committed Oct 2, 2023
1 parent 3ecf2b9 commit d668af2
Show file tree
Hide file tree
Showing 10 changed files with 514 additions and 68 deletions.
4 changes: 2 additions & 2 deletions common/djangoapps/terrain/stubs/lti.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def do_POST(self):
'callback_url': self.post_dict.get('lis_outcome_service_url').replace('https', 'http'),
'sourcedId': self.post_dict.get('lis_result_sourcedid')
}
host = os.environ.get(self.server.server_address[0])
host = self.server.server_address[0]
submit_url = f'//{host}:{self.server.server_address[1]}'
content = self._create_content(status_message, submit_url)
self.send_response(200, content)
Expand Down Expand Up @@ -296,7 +296,7 @@ def _check_oauth_signature(self, params, client_signature):
"""
client_secret = str(self.server.config.get('client_secret', self.DEFAULT_CLIENT_SECRET))
host = os.environ.get('127.0.0.1')
host = '127.0.0.1'
port = self.server.server_address[1]
lti_base = self.DEFAULT_LTI_ADDRESS.format(host=host, port=port)
lti_endpoint = self.server.config.get('lti_endpoint', self.DEFAULT_LTI_ENDPOINT)
Expand Down
12 changes: 12 additions & 0 deletions common/static/common/js/jasmine.common.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-env node */

'use strict';

// By default, fixtures are loaded from spec/javascripts/fixtures but in karma everything gets served from /base
jasmine.getFixtures().fixturesPath = '/base/';

// https://github.com/edx/js-test-tool/blob/master/js_test_tool/templates/jasmine_test_runner.html#L10
// Stub out modal dialog alerts, which will prevent
// us from accessing the test results in the DOM
window.confirm = function() { return true; };
window.alert = function() { };
29 changes: 29 additions & 0 deletions common/static/common/js/jasmine_stack_trace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* This file overrides ExceptionFormatter of jasmine before it's initialization in karma-jasmine's
boot.js. It's important because ExceptionFormatter returns a constructor function. Once the method has been
initialized we can't override the ExceptionFormatter as Jasmine then uses the stored reference to the function */
(function() {
/* globals jasmineRequire */

'use strict';

var OldExceptionFormatter = jasmineRequire.ExceptionFormatter(),
oldExceptionFormatter = new OldExceptionFormatter(),
MAX_STACK_TRACE_LINES = 10;

jasmineRequire.ExceptionFormatter = function() {
function ExceptionFormatter() {
this.message = oldExceptionFormatter.message;
this.stack = function(error) {
var errorMsg = null;

if (error) {
errorMsg = error.stack.split('\n').slice(0, MAX_STACK_TRACE_LINES).join('\n');
}

return errorMsg;
};
}

return ExceptionFormatter;
};
}());
Loading

0 comments on commit d668af2

Please sign in to comment.