summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cypress_test/integration_tests/common/helper.js10
-rw-r--r--loleaflet/src/map/Map.js25
2 files changed, 24 insertions, 11 deletions
diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js
index 505315594..402432bc8 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -63,7 +63,7 @@ function enableEditingMobile() {
// Assert that NO keyboard input is accepted (i.e. keyboard should be HIDDEN).
function assertNoKeyboardInput() {
cy.window().then(win => {
- var acceptInput = win.map._textInput.shouldAcceptInput();
+ var acceptInput = win.shouldAcceptInput();
expect(acceptInput, 'Should accept input').to.equal(false);
});
}
@@ -71,7 +71,7 @@ function assertNoKeyboardInput() {
// Assert that keyboard input is accepted (i.e. keyboard should be VISIBLE).
function assertHaveKeyboardInput() {
cy.window().then(win => {
- var acceptInput = win.map._textInput.shouldAcceptInput();
+ var acceptInput = win.shouldAcceptInput();
expect(acceptInput, 'Should accept input').to.equal(true);
});
}
@@ -126,16 +126,14 @@ function clearAllText() {
// });
function getTextForClipboard(f) {
cy.window().then(win => {
- var htmlText = win.map._clip._getHtmlForClipboard();
- var plainText = win.map._clip.stripHTML(htmlText);
- f(htmlText, plainText);
+ f(win.getTextForClipboard());
});
}
// Expects getTextForClipboard return the given
// plain-text, and asserts equality.
function expectTextForClipboard(expectedPlainText) {
- getTextForClipboard((htmlText, plainText) => {
+ getTextForClipboard((plainText) => {
expect(plainText, 'Selection Text').to.equal(expectedPlainText);
});
}
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 4e8bd7b75..cc683de13 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -97,11 +97,6 @@ L.Map = L.Evented.extend({
// lead to URL's of the form <webserver>//insertfile/...
options.webserver = options.webserver.replace(/\/*$/, '');
- if (L.Browser.cypressTest) {
- // Expose us in test mode.
- window.map = this;
- }
-
this._handlers = [];
this._layers = {};
this._zoomBoundLayers = {};
@@ -327,6 +322,26 @@ L.Map = L.Evented.extend({
this._docLoadedOnce = this._docLoaded;
}
}, this);
+
+ if (L.Browser.cypressTest) {
+ // Expose some helpers in test mode, as
+ // Cypress doesn't suppor them.
+ var map = this;
+
+ // This is used to track whether we *intended*
+ // the keyboard to be visible or hidden.
+ // There is no way track the keyboard state
+ // programmatically, so the next best thing
+ // is to track what we intended to do.
+ window.shouldAcceptInput = function() { return map.shouldAcceptInput(); };
+
+ // This is used to extract the text we *intended*
+ // to put on the clipboard. There is currently
+ // no way to actually put data on the clipboard
+ // programmatically, so this is the way to test
+ // what we "copied".
+ window.getTextForClipboard = function() { return map._clip.stripHTML(map._clip._getHtmlForClipboard()); };
+ }
},
loadDocument: function(socket) {