Get webpack builds working again

This is a combination of 3 commits.
The first commit's message is:

fix quiz log auditing build in webpack

fixes: CNVS-33125

test plan:
* webpack aux build & selenium should pass
* enable the quiz log auditing feature flag
* go to the quiz log audit page:
  eg: http://c.dev/courses/1/quizzes/2/submissions/1/log
* make sure the page loads without any script errors

This is the 2nd commit message:

fix webpack build of ember screenreader gradebook

fixes: CNVS-33051

test plan:
* tests should pass, both in webpack and requireJS
* in both webpack and requireJS
* go to the the screenreader gradebook page
* it should load without errors

This is the 3rd commit message:

fix js tests in webpack

Change-Id: I75e2d3d8ec3c817d5ac7d4aade5204f9a6016c10
Reviewed-on: https://gerrit.instructure.com/94497
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
This commit is contained in:
Ryan Shaw 2016-11-04 11:22:45 -06:00
parent b8d2c81b76
commit fd06de9022
11 changed files with 260 additions and 281 deletions

View File

@ -1,13 +1,17 @@
define [
'jquery'
'underscore'
'ic-ajax'
'../start_app'
'ember'
'../shared_ajax_fixtures'
'../../controllers/screenreader_gradebook_controller'
'compiled/userSettings'
'vendor/jquery.ba-tinypubsub'
], ($, _, startApp, Ember, fixtures, SRGBController, userSettings) ->
], ($, _, ajax, startApp, Ember, fixtures, SRGBController, userSettings) ->
workAroundRaceCondition = ->
ajax.request()
App = null
originalIsDraft = null
@ -50,9 +54,10 @@ define [
equal @srgb.get('students.firstObject').name, fixtures.students[0].user.name
test 'calculates assignments properly', ->
equal @srgb.get('assignments.length'), 7
ok !@srgb.get('assignments').findBy('name', 'Not Graded')
equal @srgb.get('assignments.firstObject').name, fixtures.assignment_groups[0].assignments[0].name
workAroundRaceCondition().then =>
equal @srgb.get('assignments.length'), 7
ok !@srgb.get('assignments').findBy('name', 'Not Graded')
equal @srgb.get('assignments.firstObject').name, fixtures.assignment_groups[0].assignments[0].name
test 'calculates outcomes properly', ->
equal @srgb.get('outcomes.length'), 2
@ -63,12 +68,14 @@ define [
strictEqual @srgb.get('students').findBy('id', obj.id), obj
test 'assignmentGroupsHash retuns the expected hash', ->
_.each @srgb.assignmentGroupsHash(), (obj) =>
strictEqual @srgb.get('assignment_groups').findBy('id', obj.id), obj
workAroundRaceCondition().then =>
_.each @srgb.assignmentGroupsHash(), (obj) =>
strictEqual @srgb.get('assignment_groups').findBy('id', obj.id), obj
test 'student objects have isLoaded flag set to true once submissions are loaded', ->
@srgb.get('students').forEach (s) ->
equal Ember.get(s, 'isLoaded'), true
workAroundRaceCondition().then =>
@srgb.get('students').forEach (s) ->
equal Ember.get(s, 'isLoaded'), true
test 'displayName is hiddenName when hideStudentNames is true', ->
@srgb.set('hideStudentNames', true)
@ -108,35 +115,40 @@ define [
equal @srgb.get('studentsInSelectedSection.firstObject').name, 'Buffy'
test 'sorting assignments by position', ->
Ember.run =>
@srgb.set('assignmentSort', @srgb.get('assignmentSortOptions').findBy('value', 'assignment_group'))
equal @srgb.get('assignments.firstObject.name'), 'Z Eats Soup'
equal @srgb.get('assignments.lastObject.name'), 'Da Fish and Chips!'
workAroundRaceCondition().then =>
Ember.run =>
@srgb.set('assignmentSort', @srgb.get('assignmentSortOptions').findBy('value', 'assignment_group'))
equal @srgb.get('assignments.firstObject.name'), 'Z Eats Soup'
equal @srgb.get('assignments.lastObject.name'), 'Da Fish and Chips!'
test 'updates assignment_visibility on an assignment', ->
assignments = @srgb.get('assignments')
assgn = assignments.objectAt(2)
@srgb.updateAssignmentVisibilities(assgn, '3')
ok !assgn.assignment_visibility.contains('3')
workAroundRaceCondition().then =>
assignments = @srgb.get('assignments')
assgn = assignments.objectAt(2)
@srgb.updateAssignmentVisibilities(assgn, '3')
ok !assgn.assignment_visibility.contains('3')
test 'studentsThatCanSeeAssignment doesnt return all students', ->
assgn = @srgb.get('assignments.firstObject')
students = @srgb.studentsThatCanSeeAssignment(assgn)
ids = Object.keys(students)
equal ids.length, 1
equal ids[0], '1'
workAroundRaceCondition().then =>
assgn = @srgb.get('assignments.firstObject')
students = @srgb.studentsThatCanSeeAssignment(assgn)
ids = Object.keys(students)
equal ids.length, 1
equal ids[0], '1'
test 'sorting assignments alphabetically', ->
Ember.run =>
@srgb.set('assignmentSort', @srgb.get('assignmentSortOptions').findBy('value', 'alpha'))
equal @srgb.get('assignments.firstObject.name'), 'Apples are good'
equal @srgb.get('assignments.lastObject.name'), 'Z Eats Soup'
workAroundRaceCondition().then =>
Ember.run =>
@srgb.set('assignmentSort', @srgb.get('assignmentSortOptions').findBy('value', 'alpha'))
equal @srgb.get('assignments.firstObject.name'), 'Apples are good'
equal @srgb.get('assignments.lastObject.name'), 'Z Eats Soup'
test 'sorting assignments by due date', ->
Ember.run =>
@srgb.set('assignmentSort', @srgb.get('assignmentSortOptions').findBy('value', 'due_date'))
equal @srgb.get('assignments.firstObject.name'), 'Can You Eat Just One?'
equal @srgb.get('assignments.lastObject.name'), 'Drink Water'
workAroundRaceCondition().then =>
Ember.run =>
@srgb.set('assignmentSort', @srgb.get('assignmentSortOptions').findBy('value', 'due_date'))
equal @srgb.get('assignments.firstObject.name'), 'Can You Eat Just One?'
equal @srgb.get('assignments.lastObject.name'), 'Drink Water'
module 'screenreader_gradebook_controller: with selected student',
@ -154,52 +166,61 @@ define [
module 'screenreader_gradebook_controller: with selected student, assignment, and outcome',
setup: ->
setup.call this
Ember.run =>
@student = @srgb.get('students.firstObject')
@assignment = @srgb.get('assignments.firstObject')
@outcome = @srgb.get('outcomes.firstObject')
@srgb.set('selectedStudent', @student)
@srgb.set('selectedAssignment', @assignment)
@srgb.set('selectedOutcome', @outcome)
@completeSetup = =>
Ember.run =>
workAroundRaceCondition().then =>
@student = @srgb.get('students.firstObject')
@assignment = @srgb.get('assignments.firstObject')
@outcome = @srgb.get('outcomes.firstObject')
@srgb.set('selectedStudent', @student)
@srgb.set('selectedAssignment', @assignment)
@srgb.set('selectedOutcome', @outcome)
teardown: ->
teardown.call this
test 'assignmentDetails is computed properly', ->
ad = @srgb.get('assignmentDetails')
selectedAssignment = @srgb.get('selectedAssignment')
strictEqual ad.assignment, selectedAssignment
strictEqual ad.cnt, 1
@completeSetup().then =>
ad = @srgb.get('assignmentDetails')
selectedAssignment = @srgb.get('selectedAssignment')
strictEqual ad.assignment, selectedAssignment
strictEqual ad.cnt, 1
test 'outcomeDetails is computed properly', ->
od = @srgb.get('outcomeDetails')
selectedOutcome = @srgb.get('selectedOutcome')
strictEqual od.cnt, 1
@completeSetup().then =>
od = @srgb.get('outcomeDetails')
selectedOutcome = @srgb.get('selectedOutcome')
strictEqual od.cnt, 1
test 'selectedSubmission is computed properly', ->
selectedSubmission = @srgb.get('selectedSubmission')
sub = _.find(fixtures.submissions, (s) => s.user_id == @student.id)
submission = _.find(sub.submissions, (s) => s.assignment_id == @assignment.id)
_.each submission, (val, key) =>
equal selectedSubmission[key], val, "#{key} is the expected value on selectedSubmission"
@completeSetup().then =>
selectedSubmission = @srgb.get('selectedSubmission')
sub = _.find(fixtures.submissions, (s) => s.user_id == @student.id)
submission = _.find(sub.submissions, (s) => s.assignment_id == @assignment.id)
_.each submission, (val, key) =>
equal selectedSubmission[key], val, "#{key} is the expected value on selectedSubmission"
test 'selectedSubmission sets gradeLocked', ->
selectedSubmission = @srgb.get('selectedSubmission')
equal selectedSubmission.gradeLocked, false
@completeSetup().then =>
selectedSubmission = @srgb.get('selectedSubmission')
equal selectedSubmission.gradeLocked, false
test 'selectedSubmission sets gradeLocked for unassigned students', ->
@student = @srgb.get('students')[1]
Ember.run =>
@srgb.set('selectedStudent', @student)
selectedSubmission = @srgb.get('selectedSubmission')
equal selectedSubmission.gradeLocked, true
@completeSetup().then =>
@student = @srgb.get('students')[1]
Ember.run =>
@srgb.set('selectedStudent', @student)
selectedSubmission = @srgb.get('selectedSubmission')
equal selectedSubmission.gradeLocked, true
module 'screenreader_gradebook_controller: with selected assignment',
setup: ->
setup.call this
@assignment = @srgb.get('assignments.firstObject')
Ember.run =>
@srgb.set('selectedAssignment', @assignment)
@completeSetup = =>
workAroundRaceCondition().then =>
@assignment = @srgb.get('assignments.firstObject')
Ember.run =>
@srgb.set('selectedAssignment', @assignment)
teardown: ->
@contextGetStub.restore()
@ -207,40 +228,44 @@ define [
Ember.run App, 'destroy'
test 'gets the submission types', ->
equal @srgb.get('assignmentSubmissionTypes'), 'None'
Ember.run =>
assignments = @srgb.get('assignments')
@srgb.set('selectedAssignment', assignments.objectAt(1))
equal @srgb.get('assignmentSubmissionTypes'), 'Online URL, Online text entry'
@completeSetup().then =>
equal @srgb.get('assignmentSubmissionTypes'), 'None'
Ember.run =>
assignments = @srgb.get('assignments')
@srgb.set('selectedAssignment', assignments.objectAt(1))
equal @srgb.get('assignmentSubmissionTypes'), 'Online URL, Online text entry'
module 'screenreader_gradebook_controller:draftState',
setup: ->
setup.call this, true
Ember.run =>
@srgb.get('assignment_groups').pushObject
id: '100'
name: 'Silent Assignments'
position: 2
assignments: [
{
id: '21'
name: 'Unpublished Assignment'
points_possible: 10
grading_type: "percent"
submission_types: ["none"]
due_at: null
position: 6
assignment_group_id:'4'
published: false
}
]
@completeSetup = =>
workAroundRaceCondition().then =>
Ember.run =>
@srgb.get('assignment_groups').pushObject
id: '100'
name: 'Silent Assignments'
position: 2
assignments: [
{
id: '21'
name: 'Unpublished Assignment'
points_possible: 10
grading_type: "percent"
submission_types: ["none"]
due_at: null
position: 6
assignment_group_id:'4'
published: false
}
]
teardown: ->
teardown.call this
test 'calculates assignments properly', ->
equal @srgb.get('assignments.length'), 7
ok !@srgb.get('assignments').findBy('name', 'Unpublished Assignment')
@completeSetup().then =>
equal @srgb.get('assignments.length'), 7
ok !@srgb.get('assignments').findBy('name', 'Unpublished Assignment')
calc_stub = {
@ -318,14 +343,16 @@ define [
calculationSetup.call this
test 'calculates final grade', ->
equal @srgb.get('students.firstObject.total_percent'), 79.55
workAroundRaceCondition().then =>
equal @srgb.get('students.firstObject.total_percent'), 79.55
module 'grade calc with 0s',
setup: ->
calculationSetup.call this, calc_stub_with_0_possible
test 'calculates final grade', ->
equal @srgb.get('students.firstObject.total_percent'), 0
workAroundRaceCondition().then =>
equal @srgb.get('students.firstObject.total_percent'), 0
module 'screenreader_gradebook_controller: notes computed props',
@ -448,13 +475,14 @@ define [
equal @srgb.get('selectedSubmissionHidden'), false
test 'selectedSubmissionHidden is true when students dont have visibility', ->
student = @srgb.get('students').objectAt(2)
assignment = @srgb.get('assignments.firstObject')
workAroundRaceCondition().then =>
student = @srgb.get('students').objectAt(2)
assignment = @srgb.get('assignments.firstObject')
Ember.run =>
@srgb.set('selectedAssignment', assignment)
@srgb.set('selectedStudent', student)
equal @srgb.get('selectedSubmissionHidden'), true
Ember.run =>
@srgb.set('selectedAssignment', assignment)
@srgb.set('selectedStudent', student)
equal @srgb.get('selectedSubmissionHidden'), true
module 'screenreader_gradebook_controller: selectedOutcomeResult',
setup: -> setup.call @

View File

@ -1,4 +1,38 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define(['old_version_of_react_used_by_canvas_quizzes_client_apps'],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.ReactRouter=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
! function(e) {
if ("object" == typeof exports && "undefined" != typeof module) module.exports = e();
else if ("function" == typeof define && define.amd) define(['old_version_of_react_used_by_canvas_quizzes_client_apps'], e);
else {
var f;
"undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self), f.ReactRouter = e()
}
}(function() {
var define, module, exports;
return (function e(t, n, r) {
function s(o, u) {
if (!n[o]) {
if (!t[o]) {
// INSTRUCTURE put this line to make it work for webpack
if (o === 'old_version_of_react_used_by_canvas_quizzes_client_apps') return require('old_version_of_react_used_by_canvas_quizzes_client_apps');
var a = typeof require == "function" && require;
if (!u && a) return a(o, !0);
if (i) return i(o, !0);
throw new Error("Cannot find module '" + o + "'")
}
var f = n[o] = {
exports: {}
};
t[o][0].call(f.exports, function(e) {
var n = t[o][1][e];
return s(n ? n : e)
}, f, f.exports, e, t, n, r)
}
return n[o].exports
}
var i = typeof require == "function" && require;
for (var o = 0; o < r.length; o++) s(r[o]);
return s
}
)({1: [function(_dereq_, module, exports) {
/**
* Actions that modify the URL.
*/
@ -68,7 +102,7 @@ var ScrollToTopBehavior = {
module.exports = ScrollToTopBehavior;
},{}],4:[function(_dereq_,module,exports){
var merge = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge');
var merge = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge');
var Route = _dereq_('./Route');
/**
@ -88,10 +122,10 @@ function DefaultRoute(props) {
module.exports = DefaultRoute;
},{"./Route":8,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge":71}],5:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
var classSet = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/cx');
var merge = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge');
},{"./Route":8,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge":71}],5:[function(_dereq_,module,exports){
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
var classSet = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/cx');
var merge = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge');
var ActiveState = _dereq_('../mixins/ActiveState');
var Navigation = _dereq_('../mixins/Navigation');
@ -197,8 +231,8 @@ var Link = React.createClass({
module.exports = Link;
},{"../mixins/ActiveState":15,"../mixins/Navigation":18,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/cx":61,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge":71}],6:[function(_dereq_,module,exports){
var merge = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge');
},{"../mixins/ActiveState":15,"../mixins/Navigation":18,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/cx":61,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge":71}],6:[function(_dereq_,module,exports){
var merge = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge');
var Route = _dereq_('./Route');
/**
@ -219,8 +253,8 @@ function NotFoundRoute(props) {
module.exports = NotFoundRoute;
},{"./Route":8,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge":71}],7:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
},{"./Route":8,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/merge":71}],7:[function(_dereq_,module,exports){
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
var Route = _dereq_('./Route');
function createRedirectHandler(to, _params, _query) {
@ -252,7 +286,7 @@ function Redirect(props) {
module.exports = Redirect;
},{"./Route":8}],8:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
var withoutProperties = _dereq_('../utils/withoutProperties');
/**
@ -345,10 +379,10 @@ var Route = React.createClass({
module.exports = Route;
},{"../utils/withoutProperties":30}],9:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
var warning = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/warning');
var invariant = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var copyProperties = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties');
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
var warning = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/warning');
var invariant = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var copyProperties = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties');
var HashLocation = _dereq_('../locations/HashLocation');
var ActiveContext = _dereq_('../mixins/ActiveContext');
var LocationContext = _dereq_('../mixins/LocationContext');
@ -915,7 +949,7 @@ var Routes = React.createClass({
module.exports = Routes;
},{"../locations/HashLocation":11,"../mixins/ActiveContext":14,"../mixins/LocationContext":17,"../mixins/RouteContext":19,"../mixins/ScrollContext":20,"../utils/Path":22,"../utils/Redirect":24,"../utils/Transition":26,"../utils/reversedArray":28,"./Route":8,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties":60,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/warning":76}],10:[function(_dereq_,module,exports){
},{"../locations/HashLocation":11,"../mixins/ActiveContext":14,"../mixins/LocationContext":17,"../mixins/RouteContext":19,"../mixins/ScrollContext":20,"../utils/Path":22,"../utils/Redirect":24,"../utils/Transition":26,"../utils/reversedArray":28,"./Route":8,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties":60,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/warning":76}],10:[function(_dereq_,module,exports){
exports.DefaultRoute = _dereq_('./components/DefaultRoute');
exports.Link = _dereq_('./components/Link');
exports.NotFoundRoute = _dereq_('./components/NotFoundRoute');
@ -1122,8 +1156,8 @@ var RefreshLocation = {
module.exports = RefreshLocation;
},{"../utils/getWindowPath":27}],14:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
var copyProperties = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties');
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
var copyProperties = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties');
/**
* A mixin for components that store the active state of routes,
@ -1192,8 +1226,8 @@ var ActiveContext = {
module.exports = ActiveContext;
},{"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties":60}],15:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
},{"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties":60}],15:[function(_dereq_,module,exports){
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
/**
* A mixin for components that need to know the routes, URL
@ -1256,7 +1290,7 @@ var ActiveState = {
module.exports = ActiveState;
},{}],16:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
/**
* A mixin for components that need to know the current URL path.
@ -1290,9 +1324,9 @@ var CurrentPath = {
module.exports = CurrentPath;
},{}],17:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
var invariant = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var canUseDOM = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ExecutionEnvironment').canUseDOM;
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
var invariant = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var canUseDOM = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ExecutionEnvironment').canUseDOM;
var HashLocation = _dereq_('../locations/HashLocation');
var HistoryLocation = _dereq_('../locations/HistoryLocation');
var RefreshLocation = _dereq_('../locations/RefreshLocation');
@ -1391,8 +1425,8 @@ var LocationContext = {
module.exports = LocationContext;
},{"../locations/HashLocation":11,"../locations/HistoryLocation":12,"../locations/RefreshLocation":13,"../stores/PathStore":21,"../utils/supportsHistory":29,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ExecutionEnvironment":42,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],18:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
},{"../locations/HashLocation":11,"../locations/HistoryLocation":12,"../locations/RefreshLocation":13,"../stores/PathStore":21,"../utils/supportsHistory":29,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ExecutionEnvironment":42,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],18:[function(_dereq_,module,exports){
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
/**
* A mixin for components that modify the URL.
@ -1451,8 +1485,8 @@ var Navigation = {
module.exports = Navigation;
},{}],19:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
var invariant = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
var invariant = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var Path = _dereq_('../utils/Path');
/**
@ -1621,10 +1655,10 @@ var RouteContext = {
module.exports = RouteContext;
},{"../utils/Path":22,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],20:[function(_dereq_,module,exports){
var React = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps');
var invariant = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var canUseDOM = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ExecutionEnvironment').canUseDOM;
},{"../utils/Path":22,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],20:[function(_dereq_,module,exports){
var React = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps');
var invariant = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var canUseDOM = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ExecutionEnvironment').canUseDOM;
var ImitateBrowserBehavior = _dereq_('../behaviors/ImitateBrowserBehavior');
var ScrollToTopBehavior = _dereq_('../behaviors/ScrollToTopBehavior');
@ -1738,8 +1772,8 @@ var ScrollContext = {
module.exports = ScrollContext;
},{"../behaviors/ImitateBrowserBehavior":2,"../behaviors/ScrollToTopBehavior":3,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ExecutionEnvironment":42,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],21:[function(_dereq_,module,exports){
var invariant = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
},{"../behaviors/ImitateBrowserBehavior":2,"../behaviors/ScrollToTopBehavior":3,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ExecutionEnvironment":42,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],21:[function(_dereq_,module,exports){
var invariant = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var EventEmitter = _dereq_('events').EventEmitter;
var LocationActions = _dereq_('../actions/LocationActions');
@ -1829,8 +1863,8 @@ var PathStore = {
module.exports = PathStore;
},{"../actions/LocationActions":1,"events":31,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],22:[function(_dereq_,module,exports){
var invariant = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
},{"../actions/LocationActions":1,"events":31,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],22:[function(_dereq_,module,exports){
var invariant = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var merge = _dereq_('qs/lib/utils').merge;
var qs = _dereq_('qs');
@ -2007,7 +2041,7 @@ var Path = {
module.exports = Path;
},{"qs":32,"qs/lib/utils":36,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],23:[function(_dereq_,module,exports){
},{"qs":32,"qs/lib/utils":36,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],23:[function(_dereq_,module,exports){
var Promise = _dereq_('when/lib/Promise');
// TODO: Use process.env.NODE_ENV check + envify to enable
@ -2028,15 +2062,15 @@ function Redirect(to, params, query) {
module.exports = Redirect;
},{}],25:[function(_dereq_,module,exports){
var ReactDescriptor = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactDescriptor');
var ReactInstanceHandles = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactInstanceHandles');
var ReactMarkupChecksum = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactMarkupChecksum');
var ReactServerRenderingTransaction = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactServerRenderingTransaction');
var ReactDescriptor = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactDescriptor');
var ReactInstanceHandles = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactInstanceHandles');
var ReactMarkupChecksum = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactMarkupChecksum');
var ReactServerRenderingTransaction = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactServerRenderingTransaction');
var cloneWithProps = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/cloneWithProps');
var copyProperties = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties');
var instantiateReactComponent = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/instantiateReactComponent');
var invariant = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
var cloneWithProps = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/cloneWithProps');
var copyProperties = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties');
var instantiateReactComponent = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/instantiateReactComponent');
var invariant = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant');
function cloneRoutesForServerRendering(routes) {
return cloneWithProps(routes, {
@ -2137,8 +2171,8 @@ module.exports = {
renderRoutesToStaticMarkup: renderRoutesToStaticMarkup
};
},{"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactDescriptor":47,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactInstanceHandles":49,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactMarkupChecksum":50,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactServerRenderingTransaction":54,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/cloneWithProps":59,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties":60,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/instantiateReactComponent":65,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],26:[function(_dereq_,module,exports){
var mixInto = _dereq_('./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/mixInto');
},{"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactDescriptor":47,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactInstanceHandles":49,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactMarkupChecksum":50,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/ReactServerRenderingTransaction":54,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/cloneWithProps":59,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/copyProperties":60,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/instantiateReactComponent":65,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/invariant":66}],26:[function(_dereq_,module,exports){
var mixInto = _dereq_('old_version_of_react_used_by_canvas_quizzes_client_apps/lib/mixInto');
var Promise = _dereq_('./Promise');
var Redirect = _dereq_('./Redirect');
@ -2178,7 +2212,7 @@ mixInto(Transition, {
module.exports = Transition;
},{"./Promise":23,"./Redirect":24,"./old_version_of_react_used_by_canvas_quizzes_client_apps/lib/mixInto":74}],27:[function(_dereq_,module,exports){
},{"./Promise":23,"./Redirect":24,"old_version_of_react_used_by_canvas_quizzes_client_apps/lib/mixInto":74}],27:[function(_dereq_,module,exports){
/**
* Returns the current URL path from `window.location`, including query string
*/

View File

@ -22,6 +22,7 @@ module.exports = {
},
resolve: {
alias: {
'old_version_of_react_used_by_canvas_quizzes_client_apps': __dirname + '/../client_apps/canvas_quizzes/vendor/js/old_version_of_react_used_by_canvas_quizzes_client_apps',
handlebars: __dirname + '/../node_modules/handlebars/dist/handlebars.runtime',
'node_modules-version-of-backbone': __dirname + '/../node_modules/backbone',
'node_modules-version-of-moment': __dirname + '/../node_modules/moment',
@ -141,7 +142,6 @@ module.exports = {
{
test: /\.hbs$/,
include: [
path.resolve(__dirname, "../app/coffeescript/ember"),
/app\/coffeescripts\/ember\/screenreader_gradebook\/templates\//,
/app\/coffeescripts\/ember\/shared\/templates\//
],

View File

@ -52,7 +52,7 @@ var emitTemplate = function(path, name, result, dependencies){
module.exports = function (source) {
this.cacheable();
var name = resourceName(this.resourcePath)
var dependencies = ['shims/ember', 'coffeescripts/ember/shared/helpers/common'];
var dependencies = ['ember', 'coffeescripts/ember/shared/helpers/common'];
var result = compileHandlebars({path: this.resourcePath, source: source, ember: true});

View File

@ -1,11 +1,11 @@
const i18nRegex = /["']vendor\/i18n['"]/
const emberRegex = /['"]ember["']/
module.exports = function nonAmdLoader(input){
this.cacheable()
return input
return input.replace(i18nRegex, match =>
// Make I18n available on the window so that libraries
// that expect to find it there don't die
.replace(i18nRegex, match => match.replace('vendor', 'expose?I18n!exports?I18n!vendor'))
.replace(emberRegex, "'shims/ember'")
match.replace('vendor', 'expose?I18n!exports?I18n!vendor')
)
}

View File

@ -1,47 +1,17 @@
// today, our spec files use qunit without requiring it. That sort of sucks
// for webpack. This adds a requirement for qunit to each spec file that's digested,
// and adds "qunit." to module and test calls. Can be cleaned up later, but helps
// us get off the ground running tests in webpack from day one.
// Our spec files use qunit's global variables. in webpack.test.config.js, we set
// up some 'imports' loaders for 'test', 'asyncTest', and 'start' so they are available
// globally but we can't do the same for 'module' because if you define a global
// variable 'module' that screws everything up. so this just replaces
// "module(..." calls with "qunit.module"
// We should get rid of all these loaders and just change our actual source
// to s/test/qunit.test/ and s/module/qunit.module/
module.exports = function(source){
var newSource = source;
const lineThatStartsWithTheWordModule = /^\s+(return )?module\(/gm
// add a qunit dependency to the dependency list
newSource = newSource.replace(/(define|require)\(?\s*\[[^\]]/, function(match){
return match.replace(/\[/, function(innerMatch){
return innerMatch + "'qunit',";
});
});
// don't want the comma if the list is empty
newSource = newSource.replace(/(define|require)\(?\s*\[\s*\]/, function(match){
return match.replace(/\[/, function(innerMatch){
return innerMatch + "'qunit'";
});
});
// add a qunit reference in the AMD callback to capture the qunit dependency
newSource = newSource.replace(/\],\s*\(.+(\n.+)*\)\s*->/, function(match){
return match.replace(/\],\s*\(/, function(innerMatch){
return innerMatch + "qunit,";
});
});
// don't want the comma if the list is empty
newSource = newSource.replace(/\],\s*\(\s*\)\s*->/, function(match){
return match.replace(/\],\s*\(/, function(innerMatch){
return innerMatch + "qunit";
});
});
// replace module and test calls with "qunit.module" and "qunit.test"
newSource = newSource.replace(/^\s+module\s/gm, function(match){
return match.replace("module", "qunit.module");
});
newSource = newSource.replace(/^\s+test\s/gm, function(match){
return match.replace("test", "qunit.test");
});
return newSource;
};
module.exports = function(source) {
this.cacheable()
// replace "module(..." calls with "qunit.module"
return source.replace(lineThatStartsWithTheWordModule, match =>
match.replace('module', 'qunit.module')
)
}

View File

@ -1,55 +0,0 @@
// today, our spec files use qunit without requiring it. That sort of sucks
// for webpack. This adds a requirement for qunit to each spec file that's digested,
// and adds "qunit." to module and test calls. Can be cleaned up later, but helps
// us get off the ground running tests in webpack from day one.
module.exports = function(source){
var newSource = source;
// add a qunit dependency to the dependency list
newSource = newSource.replace(/(define|require)\(?\s*\[[^\]]/, function(match){
return match.replace(/\[/, function(innerMatch){
return innerMatch + "'qunit',";
});
});
// don't want the comma if the list is empty
newSource = newSource.replace(/(define|require)\(?\s*\[\s*\]/, function(match){
return match.replace(/\[/, function(innerMatch){
return innerMatch + "'qunit'";
});
});
// add a qunit reference in the AMD callback to capture the qunit dependency
newSource = newSource.replace(/(define|require)[\s\S]*\],\s*\([\s\S]+\)\s*=>/, function(match){
return match.replace(/\],\s*\(/, function(innerMatch){
return innerMatch + "qunit,";
});
});
// don't want the comma if the list is empty
newSource = newSource.replace(/(define|require)[\s\S]*\],\s*\(\s*\)\s*=>/, function(match){
return match.replace(/\],\s*\(/, function(innerMatch){
return innerMatch + "qunit";
});
});
// replace module and test calls with "qunit.module" and "qunit.test" IN JSX
newSource = newSource.replace(/^\s+module\(/gm, function(match){
return match.replace("module", "qunit.module");
});
newSource = newSource.replace(/^\s+test\(/gm, function(match){
return match.replace("test", "qunit.test");
});
newSource = newSource.replace(/^\s+asyncTest\(/gm, function(match){
return match.replace("asyncTest", "qunit.asyncTest");
});
newSource = newSource.replace(/^\s+start\(/gm, function(match){
return match.replace("start", "qunit.start");
});
return newSource;
};

View File

@ -39,6 +39,7 @@ module Canvas
def paths(cache_busting = false)
@paths ||= {
ember: 'bower/ember/ember',
:common => 'compiled/bundles/common',
:jqueryui => 'vendor/jqueryui',
handlebars: 'symlink_to_node_modules/handlebars/dist/handlebars.runtime',
@ -119,7 +120,7 @@ module Canvas
def shims
<<-JS.gsub(%r{\A +|^ {8}}, '')
{
'bower/ember/ember': {
'ember': {
deps: ['jquery', 'handlebars'],
exports: 'Ember'
},

View File

@ -1,2 +1,16 @@
define(['bower/ember/ember'], function(Ember) { return Ember; });
var jQuery = require("jquery");
// this gets the full handlebars.js file, instead of just handlebars.runtime that we alias 'handlebars' to in baseWebpackConfig.js
var Handlebars = require("exports?Handlebars!handlebars/../handlebars");
window.Ember = {
imports: {
Handlebars: Handlebars,
jQuery: jQuery
}
};
window.Handlebars = Handlebars;
var Ember = require("exports?Ember!bower/ember/ember");
module.exports = Ember;

View File

@ -1,16 +0,0 @@
var jQuery = require("jquery");
// this gets the full handlebars.js file, instead of just handlebars.runtime that we alias 'handlebars' to in baseWebpackConfig.js
var Handlebars = require("exports?Handlebars!handlebars/../handlebars");
window.Ember = {
imports: {
Handlebars: Handlebars,
jQuery: jQuery
}
};
window.Handlebars = Handlebars;
var Ember = require("exports?Ember!bower/ember/ember");
module.exports = Ember;

View File

@ -24,6 +24,10 @@ testWebpackConfig.output.path = __dirname + '/spec/javascripts/webpack';
testWebpackConfig.output.pathinfo = true;
testWebpackConfig.output.filename = "[name].bundle.test.js";
testWebpackConfig.plugins = [
// expose a 'qunit' global variable to any file that uses it
new webpack.ProvidePlugin({qunit: 'qunitjs'}),
new I18nPlugin(),
new ClientAppsPlugin(),
new CompiledReferencePlugin(),
@ -32,32 +36,31 @@ testWebpackConfig.plugins = [
new webpack.IgnorePlugin(/package.json/)
];
testWebpackConfig.resolve.alias.qunit = "qunitjs/qunit/qunit.js";
testWebpackConfig.resolve.alias.qunit = 'qunitjs';
testWebpackConfig.resolve.root.push(__dirname + '/spec/coffeescripts');
testWebpackConfig.resolve.root.push(__dirname + '/spec/javascripts/support');
testWebpackConfig.module.loaders.push({
test: /\/spec\/coffeescripts\//,
loaders: ["qunitDependencyLoader"]
});
// Some plugins use a special spec_canvas path for their specs
testWebpackConfig.module.loaders.push({
test: /\/spec_canvas\/coffeescripts\//,
testWebpackConfig.module.loaders.unshift({
test: [
/\/spec\/coffeescripts\//,
/\/spec_canvas\/coffeescripts\//,
/\/spec\/javascripts\/jsx\//,
/\/ember\/.*\/tests\//
],
// Our spec files expect qunit's global `test`, `module`, `asyncTest` and `start` variables.
// These imports loaders make it so they are avalable as local variables
// inside of a closure, without truly making them globals.
// We should get rid of this and just change our actual source to s/test/qunit.test/ and s/module/qunit.module/
loaders: [
'qunitDependencyLoader'
'imports?test=>qunit.test',
'imports?asyncTest=>qunit.asyncTest',
'imports?start=>qunit.start',
"qunitDependencyLoader"
]
});
testWebpackConfig.module.loaders.push({
test: /\/spec\/javascripts\/jsx\//,
loaders: ["qunitJsxDependencyLoader"]
});
testWebpackConfig.module.loaders.push({
test: /\/ember\/.*\/tests\//,
loaders: ["qunitDependencyLoader"]
});
testWebpackConfig.module.postLoaders = [{
test: /(jsx.*(\.js$|\.jsx$)|\.coffee$|public\/javascripts\/.*\.js$)/,