Skip to content

Commit

Permalink
Upgrades code-mirror, browsermob-proxy and mouse-trap (oppia#6940)
Browse files Browse the repository at this point in the history
* Initial upgrade

* test

* update ui-code mirror

* Update diff_match

* Change the version of code-mirror

* Fresh package-lock.json

* Merge conflicts

* Merge conflicts-2

* Add diff_match_patch

* update the link diff-match-patch

* Fix mistakes with cdn link

* Change dpm verison

* Update e2e Tests

* Fix lint

* Fix lines

* Remove eslint

* Add Doctring

* Update highlight text function

* Update docstrings

* Add scroll to checker

* Fix Lint

* Minor Nits

* Revert Package lock

* Revert Package lock

* update string

* Minnor nits
  • Loading branch information
Nisheal John authored and apb7 committed Jun 29, 2019
1 parent 14ad8cf commit 4081b19
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 635 deletions.
6 changes: 3 additions & 3 deletions core/templates/dev/head/tests/form_builder_test_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ <h5><[form.name]></h5>

{% block footer_js %}
<script src="/third_party/static/ckeditor-4.9.2/ckeditor.js"></script>
<script src="/third_party/static/code-mirror-3.19.0/lib/codemirror.js"></script>
<script src="/third_party/static/code-mirror-3.19.0/mode/python/python.js"></script>
<script src="/third_party/static/ui-codemirror-0.1.2/src/ui-codemirror.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/lib/codemirror.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/mode/python/python.js"></script>
<script src="/third_party/static/ui-codemirror-0.3.0/src/ui-codemirror.js"></script>
{{ super() }}
<script src="/templates/dev/head/components/forms/ConvertUnicodeWithParamsToHtmlFilter.js"></script>
<script src="/templates/dev/head/components/forms/ConvertHtmlToUnicodeFilter.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion core/tests/gae_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
os.path.join(
OPPIA_TOOLS_DIR, 'google_appengine_1.9.67', 'google_appengine',
'lib', 'webob_0_9'),
os.path.join(OPPIA_TOOLS_DIR, 'browsermob-proxy-0.7.1'),
os.path.join(OPPIA_TOOLS_DIR, 'browsermob-proxy-0.8.0'),
os.path.join(OPPIA_TOOLS_DIR, 'selenium-3.13.0'),
os.path.join(OPPIA_TOOLS_DIR, 'Pillow-6.0.0'),
CURR_DIR,
Expand Down
10 changes: 5 additions & 5 deletions core/tests/protractor_desktop/explorationHistoryTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('Exploration history', function() {
highlighted: true
},
48: {
text: ' ',
text: '',
highlighted: false
}
};
Expand Down Expand Up @@ -390,7 +390,7 @@ describe('Exploration history', function() {
highlighted: true
},
31: {
text: ' ',
text: '',
highlighted: false
}
};
Expand Down Expand Up @@ -428,7 +428,7 @@ describe('Exploration history', function() {
' translations_mapping:\n' +
' content: {}\n' +
' default_outcome: {}\n' +
' ';
'';

var expectedHistoryStates = [{
label: 'first (was: Introd...',
Expand All @@ -451,7 +451,7 @@ describe('Exploration history', function() {
historyGraph.closeStateHistory();

historyGraph.openStateHistory('second');
historyGraph.expectTextToMatch(STATE_2_STRING, ' ');
historyGraph.expectTextToMatch(STATE_2_STRING, '');
historyGraph.closeStateHistory();

// Reset all checkboxes.
Expand Down Expand Up @@ -486,7 +486,7 @@ describe('Exploration history', function() {
historyGraph.expectNumberOfLinksToMatch(3, 1, 2);

historyGraph.openStateHistory('second');
historyGraph.expectTextToMatch(' ', STATE_2_STRING);
historyGraph.expectTextToMatch('', STATE_2_STRING);
historyGraph.closeStateHistory();

// Check renaming a state.
Expand Down
12 changes: 8 additions & 4 deletions core/tests/protractor_utils/ExplorationEditorHistoryTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,12 @@ var ExplorationEditorHistoryTab = function() {
*/
expectTextToMatch: function(v1StateContents, v2StateContents) {
forms.CodeMirrorChecker(
element.all(by.css('.CodeMirror-code')).first()
element.all(by.css('.CodeMirror-code')).first(),
'first'
).expectTextToBe(v1StateContents);
forms.CodeMirrorChecker(
element.all(by.css('.CodeMirror-code')).last()
element.all(by.css('.CodeMirror-code')).last(),
'last'
).expectTextToBe(v2StateContents);
},
/*
Expand All @@ -221,10 +223,12 @@ var ExplorationEditorHistoryTab = function() {
expectTextWithHighlightingToMatch: function(
v1StateContents, v2StateContents) {
forms.CodeMirrorChecker(
element.all(by.css('.CodeMirror-code')).first()
element.all(by.css('.CodeMirror-code')).first(),
'first'
).expectTextWithHighlightingToBe(v1StateContents);
forms.CodeMirrorChecker(
element.all(by.css('.CodeMirror-code')).last()
element.all(by.css('.CodeMirror-code')).last(),
'last'
).expectTextWithHighlightingToBe(v2StateContents);
}
};
Expand Down
28 changes: 20 additions & 8 deletions core/tests/protractor_utils/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ var toRichText = function(text) {
* CodeMirror loads a part of the text at once, and scrolling in the element
* loads more divs.
*/
var CodeMirrorChecker = function(elem) {
var CodeMirrorChecker = function(elem, codeMirrorPaneToScroll) {
// The number of pixels to scroll between reading different sections of
// CodeMirror's text. 400 pixels is about 15 lines, which will work if
// codemirror's buffer (viewportMargin) is set to at least 10 (the default).
Expand All @@ -560,6 +560,8 @@ var CodeMirrorChecker = function(elem) {
* currentLineNumber is the current largest line number processed,
* scrollTo is the number of pixels from the top of the text that
* codemirror should scroll to,
* codeMirrorPaneToScroll specifies the CodeMirror's left or right pane
* which is to be scrolled.
* compareDict is an object whose keys are line numbers and whose values are
* objects corresponding to that line with the following key-value pairs:
* - 'text': the exact string of text expected on that line
Expand All @@ -568,12 +570,12 @@ var CodeMirrorChecker = function(elem) {
*/
var _compareTextAndHighlightingFromLine = function(
currentLineNumber, scrollTo, compareDict) {
// This is used to scroll the text in codemirror to a point scrollTo pixels
// from the top of the text or the bottom of the text if scrollTo is too
// large.
// This is used to match and scroll the text in codemirror to a point
// scrollTo pixels from the top of the text or the bottom of the text
// if scrollTo is too large.
browser.executeScript(
"$('.CodeMirror-vscrollbar').first().scrollTop(" + String(scrollTo) +
');');
'$(\'.CodeMirror-vscrollbar\').' + codeMirrorPaneToScroll +
'().scrollTop(' + String(scrollTo) + ');');
elem.all(by.xpath('./div')).map(function(lineElement) {
return lineElement.element(by.css('.CodeMirror-linenumber')).getText()
.then(function(lineNumber) {
Expand Down Expand Up @@ -618,21 +620,31 @@ var CodeMirrorChecker = function(elem) {
* currentLineNumber is the current largest line number processed,
* scrollTo is the number of pixels from the top of the text that
* codemirror should scroll to,
* codeMirrorPaneToScroll specifies the CodeMirror's left or right pane
* which is to be scrolled.
* compareDict is an object whose keys are line numbers and whose values are
* objects corresponding to that line with the following key-value pairs:
* - 'text': the exact string of text expected on that line
* - 'checked': true or false, whether the line has been checked
*/
var _compareTextFromLine = function(
currentLineNumber, scrollTo, compareDict) {
// This is used to match and scroll the text in codemirror to a point
// scrollTo pixels from the top of the text or the bottom of the text
// if scrollTo is too large.
browser.executeScript(
"$('.CodeMirror-vscrollbar').first().scrollTop(" + String(scrollTo) +
');');
'$(\'.CodeMirror-vscrollbar\').' + codeMirrorPaneToScroll +
'().scrollTop(' + String(scrollTo) + ');');
elem.getText().then(function(text) {
// The 'text' arg is a string 2n lines long representing n lines of text
// codemirror has loaded. The (2i)th line contains a line number and the
// (2i+1)th line contains the text on that line.
var textArray = text.split('\n');
// We have an empty line in the codemirror panes which is retrived as NULL
// in codemirror5's getText() method. Therefore, we need to add an empty
// string at the end of the textArray to match with compareDict.

textArray[textArray.length] = '';
for (var i = 0; i < textArray.length; i += 2) {
var lineNumber = textArray[i];
var lineText = textArray[i + 1];
Expand Down
22 changes: 11 additions & 11 deletions extensions/dependencies/codemirror.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script src="/third_party/static/code-mirror-3.19.0/lib/codemirror.js"></script>
<script src="/third_party/static/code-mirror-3.19.0/mode/coffeescript/coffeescript.js"></script>
<script src="/third_party/static/code-mirror-3.19.0/mode/javascript/javascript.js"></script>
<script src="/third_party/static/code-mirror-3.19.0/mode/lua/lua.js"></script>
<script src="/third_party/static/code-mirror-3.19.0/mode/python/python.js"></script>
<script src="/third_party/static/code-mirror-3.19.0/mode/ruby/ruby.js"></script>
<script src="/third_party/static/code-mirror-3.19.0/mode/scheme/scheme.js"></script>
<script src="/third_party/static/code-mirror-3.19.0/mode/yaml/yaml.js"></script>
<script src="/third_party/static/ui-codemirror-0.1.2/src/ui-codemirror.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/lib/codemirror.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/mode/coffeescript/coffeescript.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/mode/javascript/javascript.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/mode/lua/lua.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/mode/python/python.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/mode/ruby/ruby.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/mode/scheme/scheme.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/mode/yaml/yaml.js"></script>
<script src="/third_party/static/ui-codemirror-0.3.0/src/ui-codemirror.js"></script>

<script src="/third_party/static/code-mirror-3.19.0/addon/merge/dep/diff_match_patch.js"></script>
<script src="/third_party/static/code-mirror-3.19.0/addon/merge/merge.js"></script>
<script src="/third_party/static/diff-match-patch-1.0.0/diff_match_patch.js"></script>
<script src="/third_party/static/code-mirror-5.17.0/addon/merge/merge.js"></script>
15 changes: 11 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@
}
},
"codemirror": {
"version": "3.19.0",
"version": "5.17.0",
"downloadFormat": "zip",
"url": "https://github.com/marijnh/CodeMirror/archive/3.19.0.zip",
"url": "https://github.com/codemirror/CodeMirror/archive/5.17.0.zip",
"rootDirPrefix": "CodeMirror-",
"targetDirPrefix": "code-mirror-",
"bundle": {
Expand All @@ -306,6 +306,13 @@
"js": ["d3.min.js"]
}
},
"diff-match-patch": {
"version": "1.0.0",
"downloadFormat": "files",
"url": "https://cdnjs.cloudflare.com/ajax/libs/diff_match_patch/20121119",
"targetDirPrefix": "diff-match-patch-",
"files": ["diff_match_patch.js"]
},
"fontAwesome": {
"version": "5.8.1",
"downloadFormat": "zip",
Expand Down Expand Up @@ -507,9 +514,9 @@
}
},
"uiCodemirror": {
"version": "0.1.2",
"version": "0.3.0",
"downloadFormat": "zip",
"url": "https://github.com/angular-ui/ui-codemirror/archive/src0.1.2.zip",
"url": "https://github.com/angular-ui/ui-codemirror/archive/src0.3.0.zip",
"rootDirPrefix": "ui-codemirror-src",
"targetDirPrefix": "ui-codemirror-"
},
Expand Down
Loading

0 comments on commit 4081b19

Please sign in to comment.