diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json new file mode 120000 index 000000000..7afe2ee9f --- /dev/null +++ b/npm-shrinkwrap.json @@ -0,0 +1 @@ +regulations/static/config/npm-shrinkwrap.json \ No newline at end of file diff --git a/regulations/management/commands/compile_frontend.py b/regulations/management/commands/compile_frontend.py index 336caceab..aed3e3b27 100644 --- a/regulations/management/commands/compile_frontend.py +++ b/regulations/management/commands/compile_frontend.py @@ -56,7 +56,8 @@ def remove_dirs(self): os.mkdir(self.BUILD_DIR) def create_configs(self): - for config_file in ('Gruntfile.js', 'package.json', '.babelrc'): + for config_file in ('Gruntfile.js', 'package.json', '.babelrc', + 'npm-shrinkwrap.json'): os.rename(os.path.join(self.BUILD_DIR, 'static', 'config', config_file), os.path.join(self.BUILD_DIR, config_file)) diff --git a/regulations/static/config/npm-shrinkwrap.json b/regulations/static/config/npm-shrinkwrap.json new file mode 100644 index 000000000..c9a5f9d7b --- /dev/null +++ b/regulations/static/config/npm-shrinkwrap.json @@ -0,0 +1,256 @@ +{ + "name": "regulations-site", + "version": "8.1.0", + "dependencies": { + "argparse": { + "version": "1.0.9", + "from": "argparse@>=1.0.2 <1.1.0", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz" + }, + "asap": { + "version": "2.0.6", + "from": "asap@>=2.0.3 <2.1.0", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz" + }, + "backbone": { + "version": "1.3.3", + "from": "backbone@>=1.3.3 <2.0.0", + "resolved": "https://registry.npmjs.org/backbone/-/backbone-1.3.3.tgz" + }, + "backbone-query-parameters": { + "version": "0.4.0", + "from": "backbone-query-parameters@0.4.0", + "resolved": "https://registry.npmjs.org/backbone-query-parameters/-/backbone-query-parameters-0.4.0.tgz" + }, + "backbone.localstorage": { + "version": "2.0.0", + "from": "backbone.localstorage@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/backbone.localstorage/-/backbone.localstorage-2.0.0.tgz" + }, + "bowser": { + "version": "1.7.1", + "from": "bowser@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/bowser/-/bowser-1.7.1.tgz" + }, + "browserkeymap": { + "version": "0.1.0", + "from": "browserkeymap@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/browserkeymap/-/browserkeymap-0.1.0.tgz" + }, + "clipboard": { + "version": "1.7.1", + "from": "clipboard@>=1.7.1 <2.0.0", + "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-1.7.1.tgz" + }, + "core-js": { + "version": "1.2.7", + "from": "core-js@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz" + }, + "create-react-class": { + "version": "15.6.0", + "from": "create-react-class@>=15.6.0 <16.0.0", + "resolved": "https://registry.npmjs.org/create-react-class/-/create-react-class-15.6.0.tgz" + }, + "datatables.net": { + "version": "1.10.15", + "from": "datatables.net@>=1.10.15 <2.0.0", + "resolved": "https://registry.npmjs.org/datatables.net/-/datatables.net-1.10.15.tgz" + }, + "delegate": { + "version": "3.1.3", + "from": "delegate@>=3.1.2 <4.0.0", + "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.1.3.tgz" + }, + "encoding": { + "version": "0.1.12", + "from": "encoding@>=0.1.11 <0.2.0", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz" + }, + "entities": { + "version": "1.1.1", + "from": "entities@>=1.1.1 <1.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz" + }, + "fbjs": { + "version": "0.8.14", + "from": "fbjs@>=0.8.9 <0.9.0", + "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.14.tgz" + }, + "filesize": { + "version": "3.5.10", + "from": "filesize@>=3.5.10 <4.0.0", + "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.5.10.tgz" + }, + "good-listener": { + "version": "1.2.2", + "from": "good-listener@>=1.1.4 <2.0.0", + "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz" + }, + "iconv-lite": { + "version": "0.4.18", + "from": "iconv-lite@>=0.4.13 <0.5.0", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.18.tgz" + }, + "is-stream": { + "version": "1.1.0", + "from": "is-stream@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz" + }, + "isomorphic-fetch": { + "version": "2.2.1", + "from": "isomorphic-fetch@>=2.1.1 <3.0.0", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz" + }, + "jquery": { + "version": "1.12.4", + "from": "jquery@>=1.12.4 <2.0.0", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-1.12.4.tgz" + }, + "jquery-lazyload": { + "version": "1.9.7", + "from": "jquery-lazyload@1.9.7", + "resolved": "https://registry.npmjs.org/jquery-lazyload/-/jquery-lazyload-1.9.7.tgz" + }, + "jquery-scrollstop": { + "version": "1.2.0", + "from": "jquery-scrollstop@1.2.0", + "resolved": "https://registry.npmjs.org/jquery-scrollstop/-/jquery-scrollstop-1.2.0.tgz" + }, + "js-tokens": { + "version": "3.0.2", + "from": "js-tokens@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz" + }, + "linkify-it": { + "version": "1.2.4", + "from": "linkify-it@>=1.2.0 <1.3.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-1.2.4.tgz" + }, + "lodash": { + "version": "4.17.4", + "from": "lodash@>=4.2.1 <5.0.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz" + }, + "lodash-es": { + "version": "4.17.4", + "from": "lodash-es@>=4.2.1 <5.0.0", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.4.tgz" + }, + "loose-envify": { + "version": "1.3.1", + "from": "loose-envify@>=1.1.0 <2.0.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz" + }, + "markdown-it": { + "version": "4.4.0", + "from": "markdown-it@>=4.4.0 <5.0.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-4.4.0.tgz" + }, + "mdurl": { + "version": "1.0.1", + "from": "mdurl@>=1.0.0 <1.1.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz" + }, + "node-fetch": { + "version": "1.7.2", + "from": "node-fetch@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.2.tgz" + }, + "object-assign": { + "version": "4.1.1", + "from": "object-assign@>=4.1.0 <5.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz" + }, + "promise": { + "version": "7.3.1", + "from": "promise@>=7.1.1 <8.0.0", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz" + }, + "prop-types": { + "version": "15.5.10", + "from": "prop-types@>=15.5.10 <16.0.0", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.5.10.tgz" + }, + "prosemirror": { + "version": "0.4.0", + "from": "prosemirror@0.4.0", + "resolved": "https://registry.npmjs.org/prosemirror/-/prosemirror-0.4.0.tgz" + }, + "query-command-supported": { + "version": "1.0.0", + "from": "query-command-supported@1.0.0", + "resolved": "https://registry.npmjs.org/query-command-supported/-/query-command-supported-1.0.0.tgz" + }, + "react": { + "version": "15.6.1", + "from": "react@>=15.4.1 <16.0.0", + "resolved": "https://registry.npmjs.org/react/-/react-15.6.1.tgz" + }, + "react-dom": { + "version": "15.6.1", + "from": "react-dom@>=15.4.1 <16.0.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-15.6.1.tgz" + }, + "redux": { + "version": "3.7.2", + "from": "redux@>=3.6.0 <4.0.0", + "resolved": "https://registry.npmjs.org/redux/-/redux-3.7.2.tgz" + }, + "respond.js": { + "version": "1.4.2", + "from": "respond.js@1.4.2", + "resolved": "https://registry.npmjs.org/respond.js/-/respond.js-1.4.2.tgz" + }, + "select": { + "version": "1.1.2", + "from": "select@>=1.0.6 <2.0.0", + "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz" + }, + "setimmediate": { + "version": "1.0.5", + "from": "setimmediate@>=1.0.5 <2.0.0", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz" + }, + "sprintf-js": { + "version": "1.0.3", + "from": "sprintf-js@>=1.0.2 <1.1.0", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz" + }, + "symbol-observable": { + "version": "1.0.4", + "from": "symbol-observable@>=1.0.3 <2.0.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.4.tgz" + }, + "tiny-emitter": { + "version": "2.0.1", + "from": "tiny-emitter@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.0.1.tgz" + }, + "ua-parser-js": { + "version": "0.7.14", + "from": "ua-parser-js@>=0.7.9 <0.8.0", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.14.tgz" + }, + "uc.micro": { + "version": "1.0.3", + "from": "uc.micro@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.3.tgz" + }, + "underscore": { + "version": "1.8.3", + "from": "underscore@1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz" + }, + "urijs": { + "version": "1.18.12", + "from": "urijs@>=1.18.10 <2.0.0", + "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.18.12.tgz" + }, + "whatwg-fetch": { + "version": "2.0.3", + "from": "whatwg-fetch@>=0.10.0", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz" + } + } +} diff --git a/regulations/static/config/package.json b/regulations/static/config/package.json index cdd70d240..7a3de4f1b 100644 --- a/regulations/static/config/package.json +++ b/regulations/static/config/package.json @@ -38,6 +38,7 @@ "chai": "^3.5.0", "coveralls": "^2.11.2", "deamdify": "^0.1.1", + "dom-storage": "^2.0.2", "eslint": "^3.12.2", "eslint-config-airbnb": "^13.0.0", "eslint-plugin-import": "^2.2.0", @@ -60,7 +61,6 @@ "minifyify": "^7.2.1", "mocha": "^3.2.0", "mocha-jsdom": "^1.1.0", - "node-localstorage": "^1.3.0", "sinon": "^1.17.3", "sinon-chai": "^2.8.0", "watch": "^0.17.1" @@ -75,23 +75,23 @@ } }, "dependencies": { - "backbone": "1.2.3", + "backbone": "^1.3.3", "backbone-query-parameters": "0.4.0", - "backbone.localstorage": "1.1.16", - "clipboard": "1.5.5", - "datatables.net": "1.10.10", - "filesize": "3.2.1", - "jquery": "1.12.2", - "jquery-lazyload": "1.9.7", - "jquery-scrollstop": "1.2.0", + "backbone.localstorage": "^2.0.0", + "clipboard": "^1.7.1", + "datatables.net": "^1.10.15", + "filesize": "^3.5.10", + "jquery": "^1.12.4", + "jquery-lazyload": "^1.9.7", + "jquery-scrollstop": "^1.2.0", "prosemirror": "0.4.0", - "query-command-supported": "1.0.0", + "query-command-supported": "^1.0.0", "react": "^15.4.1", "react-dom": "^15.4.1", "redux": "^3.6.0", - "respond.js": "1.4.2", - "underscore": "1.8.3", - "urijs": "1.17.1" + "respond.js": "^1.4.2", + "underscore": "^1.8.3", + "urijs": "^1.18.10" }, "config": { "travis-cov": { diff --git a/regulations/static/regulations/js/source/collections/comment-collection.js b/regulations/static/regulations/js/source/collections/comment-collection.js index fe5b04b73..39e55328f 100644 --- a/regulations/static/regulations/js/source/collections/comment-collection.js +++ b/regulations/static/regulations/js/source/collections/comment-collection.js @@ -2,7 +2,8 @@ const _ = require('underscore'); const Backbone = require('backbone'); -Backbone.LocalStorage = require('backbone.localstorage'); +const localStorage = require('backbone.localstorage'); +Backbone.LocalStorage = localStorage.LocalStorage; const commentModel = require('../models/comment-model'); diff --git a/regulations/static/regulations/js/unittests/specs/views/comment-confirm-view-spec.js b/regulations/static/regulations/js/unittests/specs/views/comment-confirm-view-spec.js index f0dd176ca..bce9bc83d 100644 --- a/regulations/static/regulations/js/unittests/specs/views/comment-confirm-view-spec.js +++ b/regulations/static/regulations/js/unittests/specs/views/comment-confirm-view-spec.js @@ -1,9 +1,7 @@ var chai = require('chai'); var expect = chai.expect; var jsdom = require('mocha-jsdom'); -var localStorage = require('node-localstorage'); - -var storage = new localStorage.LocalStorage('.'); +var Storage = require('dom-storage'); describe('CommentConfirmView', function() { jsdom(); @@ -15,7 +13,7 @@ describe('CommentConfirmView', function() { Backbone = require('backbone'); $ = require('jquery'); Backbone.$ = $; - global.localStorage = window.localStorage = storage; + global.localStorage = window.localStorage = new Storage(); comments = require('../../../source/collections/comment-collection'); CommentModel = require('../../../source/models/comment-model').CommentModel; CommentConfirmView = require('../../../source/views/comment/comment-confirm-view'); @@ -37,6 +35,7 @@ describe('CommentConfirmView', function() { comments.models.forEach(function(comment) { comment.destroy(); }); + window.localStorage.clear(); }); it('clears comments when metadata is defined', function() { diff --git a/regulations/static/regulations/js/unittests/specs/views/comment-view-spec.js b/regulations/static/regulations/js/unittests/specs/views/comment-view-spec.js index 36cfe4ef5..ae2605dd9 100644 --- a/regulations/static/regulations/js/unittests/specs/views/comment-view-spec.js +++ b/regulations/static/regulations/js/unittests/specs/views/comment-view-spec.js @@ -2,11 +2,9 @@ var chai = require('chai'); var expect = chai.expect; var sinon = require('sinon'); var jsdom = require('mocha-jsdom'); -var localStorage = require('node-localstorage'); +var Storage = require('dom-storage'); var _ = require('underscore'); -var storage = new localStorage.LocalStorage('.'); - describe('CommentView', function() { jsdom(); @@ -18,7 +16,7 @@ describe('CommentView', function() { $ = require('jquery'); Backbone.$ = $; edit = require('prosemirror/dist/edit'); - global.localStorage = window.localStorage = storage; + global.localStorage = window.localStorage = new Storage(); comments = require('../../../source/collections/comment-collection'); CommentEvents = require('../../../source/events/comment-events'); CommentView = require('../../../source/views/comment/comment-view'); @@ -60,6 +58,7 @@ describe('CommentView', function() { edit.ProseMirror.prototype.getContent.restore(); edit.ProseMirror.prototype.setContent.restore(); edit.ProseMirror.prototype.ensureOperation.restore(); + window.localStorage.clear(); }); it('removes an attachment', function() { diff --git a/regulations/static/regulations/js/unittests/specs/views/stars-helpers-spec.js b/regulations/static/regulations/js/unittests/specs/views/stars-helpers-spec.js index 6988da971..666b5e16f 100644 --- a/regulations/static/regulations/js/unittests/specs/views/stars-helpers-spec.js +++ b/regulations/static/regulations/js/unittests/specs/views/stars-helpers-spec.js @@ -2,45 +2,45 @@ var chai = require('chai'); var expect = chai.expect; var jsdom = require('mocha-jsdom'); +let $; // Must be loaded after the jsdom + +// jsdom doesn't support jQuery's latest revision of :visible +function isVisible($el) { + const elHidden = $el.css('display') === 'none'; + const parentHidden = $el.parents().filter( + (idx, p) => $(p).css('display') === 'none').length > 0; + return !elHidden && !parentHidden; +} + describe('starsHelpers.inline', function() { jsdom(); - var starsHelpers, $; + var starsHelpers, $li; before(function() { $ = require('jquery'); starsHelpers = require('../../../source/views/main/stars-helpers'); - }); - - it('does not hide the marker, but does hide the intro text', function() { - var $li = $( + $li = $( '
' + 'b.' + 'Remainder of the text' + '
' + - 'b.' + - 'Remainder of the text' + - '
' + - 'b.' + - 'Remainder of the text' + - '
' + 'b.' + 'Remainder of the text' + '
' + - 'b.' + - 'Remainder of the text' + - '
' + - 'b.' + - 'Remainder of the text' + - '