2020-01-30 06:16:09 -06:00
|
|
|
/* global cy Cypress expect*/
|
2020-01-24 10:13:51 -06:00
|
|
|
|
2020-02-12 11:01:47 -06:00
|
|
|
function loadTestDoc(fileName, subFolder, mobile) {
|
2020-01-24 10:13:51 -06:00
|
|
|
// Get a clean test document
|
2020-02-12 11:01:47 -06:00
|
|
|
if (subFolder === undefined) {
|
|
|
|
cy.task('copyFile', {
|
|
|
|
sourceDir: Cypress.env('DATA_FOLDER'),
|
|
|
|
destDir: Cypress.env('WORKDIR'),
|
|
|
|
fileName: fileName,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
cy.task('copyFile', {
|
|
|
|
sourceDir: Cypress.env('DATA_FOLDER') + subFolder + '/',
|
|
|
|
destDir: Cypress.env('WORKDIR') + subFolder + '/',
|
|
|
|
fileName: fileName,
|
|
|
|
});
|
|
|
|
}
|
2020-01-24 10:13:51 -06:00
|
|
|
|
|
|
|
if (mobile === true) {
|
2020-02-02 23:23:55 -06:00
|
|
|
cy.viewport('iphone-6');
|
2020-01-24 10:13:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Open test document
|
2020-02-12 11:01:47 -06:00
|
|
|
var URI;
|
|
|
|
if (subFolder === undefined) {
|
2020-02-19 19:25:01 -06:00
|
|
|
URI = 'http://localhost:'+
|
|
|
|
Cypress.env('SERVER_PORT') +
|
|
|
|
'/loleaflet/' +
|
2020-02-12 11:01:47 -06:00
|
|
|
Cypress.env('WSD_VERSION_HASH') +
|
2020-02-13 11:03:58 -06:00
|
|
|
'/loleaflet.html?lang=en-US&file_path=file://' +
|
2020-02-12 11:01:47 -06:00
|
|
|
Cypress.env('WORKDIR') + fileName;
|
|
|
|
} else {
|
2020-02-19 19:25:01 -06:00
|
|
|
URI = 'http://localhost:'+
|
|
|
|
Cypress.env('SERVER_PORT') +
|
|
|
|
'/loleaflet/' +
|
2020-02-12 11:01:47 -06:00
|
|
|
Cypress.env('WSD_VERSION_HASH') +
|
2020-02-13 11:03:58 -06:00
|
|
|
'/loleaflet.html?lang=en-US&file_path=file://' +
|
2020-02-12 11:01:47 -06:00
|
|
|
Cypress.env('WORKDIR') + subFolder + '/' + fileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
cy.visit(URI, {
|
2020-01-27 10:05:48 -06:00
|
|
|
onLoad: function(win) {
|
|
|
|
win.onerror = cy.onUncaughtException;
|
|
|
|
}});
|
2020-01-24 10:13:51 -06:00
|
|
|
// Wait for the document to fully load
|
|
|
|
cy.get('.leaflet-tile-loaded', {timeout : 10000});
|
|
|
|
}
|
|
|
|
|
2020-03-01 09:48:10 -06:00
|
|
|
// Enable editing if we are in read-only mode.
|
|
|
|
function enableEditingMobile() {
|
|
|
|
cy.get('#mobile-edit-button')
|
|
|
|
.then(function(button) {
|
|
|
|
if (button.css('display') !== 'none') {
|
|
|
|
cy.get('#mobile-edit-button')
|
|
|
|
.click();
|
|
|
|
}
|
|
|
|
});
|
2020-03-18 05:41:16 -05:00
|
|
|
|
|
|
|
cy.get('#tb_actionbar_item_mobile_wizard')
|
|
|
|
.should('not.have.class', 'disabled');
|
2020-03-01 09:48:10 -06:00
|
|
|
}
|
|
|
|
|
leaflet: maintain the keyboard state after toolbar actions
Previously we supressed the keyboard after toolbar
actions, but that is problematic because then the
user is unable to delete/replace selected text,
because the keyboard is hidden and there is no way
of showing keyboard without changing the selection.
Now we maintain the keyboard state, which is likely
visible, since a selection shows the keyboard.
This might not be ideal, because the user might
hide the keyboard on the device and we will restore
it after invoking a toolbar action, but at least
it's more usable now. Unfortunately, there is no
API to track the keyboard visibility.
New Cypress tests added to validate the above.
The tests depend on checking the last keyboard
visibility state in Map, because there is no
reliable (or any?) way to know whether the keyboard
is visible or not. There are many cases where we
actually hide the keyboard, while having the input
focus on the textarea element, so that is no indication
that the keyboard is visible. We do this for usability
purposes. For example, during zooming, when selecting
cells and graphics/shapes, etc.
The purpose of the cell is to validate that we restored
the keyboard visibility or we changed it, depending
on which is expected after each operation.
Change-Id: If0f2e96909ff20753043734789397d190cedb502
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90663
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-03-17 11:02:59 -05:00
|
|
|
// 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();
|
|
|
|
expect(acceptInput, 'Should accept input').to.equal(false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assert that keyboard input is accepted (i.e. keyboard should be VISIBLE).
|
|
|
|
function assertHaveKeyboardInput() {
|
|
|
|
cy.window().then(win => {
|
|
|
|
var acceptInput = win.map._textInput.shouldAcceptInput();
|
|
|
|
expect(acceptInput, 'Should accept input').to.equal(true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-03-01 09:48:10 -06:00
|
|
|
// Assert that we have cursor and focus.
|
|
|
|
function assertCursorAndFocus() {
|
|
|
|
cy.log('Verifying Cursor and Focus.');
|
|
|
|
|
|
|
|
// In edit mode, we should have the blinking cursor.
|
|
|
|
cy.get('.leaflet-cursor.blinking-cursor')
|
|
|
|
.should('exist');
|
|
|
|
cy.get('.leaflet-cursor-container')
|
|
|
|
.should('exist');
|
|
|
|
|
leaflet: maintain the keyboard state after toolbar actions
Previously we supressed the keyboard after toolbar
actions, but that is problematic because then the
user is unable to delete/replace selected text,
because the keyboard is hidden and there is no way
of showing keyboard without changing the selection.
Now we maintain the keyboard state, which is likely
visible, since a selection shows the keyboard.
This might not be ideal, because the user might
hide the keyboard on the device and we will restore
it after invoking a toolbar action, but at least
it's more usable now. Unfortunately, there is no
API to track the keyboard visibility.
New Cypress tests added to validate the above.
The tests depend on checking the last keyboard
visibility state in Map, because there is no
reliable (or any?) way to know whether the keyboard
is visible or not. There are many cases where we
actually hide the keyboard, while having the input
focus on the textarea element, so that is no indication
that the keyboard is visible. We do this for usability
purposes. For example, during zooming, when selecting
cells and graphics/shapes, etc.
The purpose of the cell is to validate that we restored
the keyboard visibility or we changed it, depending
on which is expected after each operation.
Change-Id: If0f2e96909ff20753043734789397d190cedb502
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90663
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-03-17 11:02:59 -05:00
|
|
|
assertHaveKeyboardInput();
|
|
|
|
|
2020-03-01 09:48:10 -06:00
|
|
|
cy.log('Cursor and Focus verified.');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Select all text via CTRL+A shortcut.
|
|
|
|
function selectAllText() {
|
|
|
|
assertCursorAndFocus();
|
|
|
|
|
|
|
|
cy.log('Select all text');
|
|
|
|
|
2020-03-16 15:27:00 -05:00
|
|
|
// Trigger select all
|
2020-03-01 09:48:10 -06:00
|
|
|
cy.get('textarea.clipboard')
|
2020-03-16 15:27:00 -05:00
|
|
|
.type('{ctrl}a');
|
|
|
|
|
|
|
|
cy.get('.leaflet-marker-icon')
|
|
|
|
.should('exist');
|
2020-03-01 09:48:10 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clear all text by selecting all and deleting.
|
|
|
|
function clearAllText() {
|
|
|
|
assertCursorAndFocus();
|
|
|
|
|
|
|
|
cy.log('Clear all text');
|
|
|
|
|
|
|
|
cy.get('textarea.clipboard')
|
|
|
|
.type('{ctrl}a{del}').wait(300);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the text that should go to the
|
|
|
|
// clipboard on Ctrl+C.
|
|
|
|
// So this isn't equivalent to reading the
|
|
|
|
// clipboard (which Cypress doesn't support).
|
|
|
|
// Takes a closure f that takes the text
|
|
|
|
// string as argument. Use as follows:
|
|
|
|
// helper.getTextForClipboard((htmlText, plainText) => {
|
|
|
|
// expect(plainText, 'Selection Text').to.equal(testText);
|
|
|
|
// });
|
|
|
|
function getTextForClipboard(f) {
|
|
|
|
cy.window().then(win => {
|
|
|
|
var htmlText = win.map._clip._getHtmlForClipboard();
|
|
|
|
var plainText = win.map._clip.stripHTML(htmlText);
|
|
|
|
f(htmlText, plainText);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Expects getTextForClipboard return the given
|
|
|
|
// plain-text, and asserts equality.
|
|
|
|
function expectTextForClipboard(expectedPlainText) {
|
|
|
|
getTextForClipboard((htmlText, plainText) => {
|
|
|
|
expect(plainText, 'Selection Text').to.equal(expectedPlainText);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-02-12 11:01:47 -06:00
|
|
|
function beforeAllMobile(fileName, subFolder) {
|
|
|
|
loadTestDoc(fileName, subFolder, true);
|
2020-02-06 07:12:18 -06:00
|
|
|
|
|
|
|
detectLOCoreVersion();
|
|
|
|
}
|
|
|
|
|
2020-03-13 09:27:33 -05:00
|
|
|
function afterAll(fileName) {
|
2020-02-02 22:34:25 -06:00
|
|
|
// Make sure that the document is closed
|
2020-02-19 19:25:01 -06:00
|
|
|
cy.visit('http://admin:admin@localhost:' +
|
|
|
|
Cypress.env('SERVER_PORT') +
|
|
|
|
'/loleaflet/dist/admin/admin.html');
|
2020-03-13 09:27:33 -05:00
|
|
|
|
|
|
|
cy.get('#uptime')
|
|
|
|
.should('not.have.text', '0');
|
|
|
|
|
|
|
|
cy.get('#doclist td:nth-child(2)')
|
|
|
|
.should('not.contain.text', fileName);
|
2020-01-30 07:31:10 -06:00
|
|
|
}
|
|
|
|
|
2020-02-06 06:04:41 -06:00
|
|
|
function detectLOCoreVersion() {
|
|
|
|
if (Cypress.env('LO_CORE_VERSION') === undefined) {
|
|
|
|
// Open hamburger menu
|
|
|
|
cy.get('#toolbar-hamburger')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
// Open about dialog
|
|
|
|
cy.get('.ui-header.level-0 .menu-entry-with-icon')
|
|
|
|
.contains('About')
|
|
|
|
.click();
|
|
|
|
|
2020-03-13 06:36:50 -05:00
|
|
|
cy.get('.vex-content')
|
|
|
|
.should('exist');
|
|
|
|
|
2020-02-06 06:04:41 -06:00
|
|
|
// Get the version
|
|
|
|
cy.get('#lokit-version')
|
|
|
|
.then(function(items) {
|
|
|
|
expect(items).have.lengthOf(1);
|
|
|
|
if (items[0].textContent.includes('Collabora OfficeDev 6.2')) {
|
|
|
|
Cypress.env('LO_CORE_VERSION', 'cp-6-2');}
|
|
|
|
else {
|
|
|
|
Cypress.env('LO_CORE_VERSION', 'master');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Close about dialog
|
2020-03-13 06:36:50 -05:00
|
|
|
cy.get('.vex-close')
|
|
|
|
.click({force : true});
|
|
|
|
|
|
|
|
cy.get('.vex-content')
|
|
|
|
.should('not.exist');
|
2020-02-06 06:04:41 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-09 11:49:56 -05:00
|
|
|
function longPressOnDocument(posX, posY) {
|
|
|
|
cy.get('.leaflet-pane.leaflet-map-pane')
|
|
|
|
.then(function(items) {
|
|
|
|
expect(items).have.length(1);
|
|
|
|
|
|
|
|
var eventOptions = {
|
|
|
|
force: true,
|
|
|
|
button: 0,
|
|
|
|
pointerType: 'mouse',
|
|
|
|
x: posX - items[0].getBoundingClientRect().left,
|
|
|
|
y: posY - items[0].getBoundingClientRect().top
|
|
|
|
};
|
|
|
|
|
|
|
|
cy.get('.leaflet-pane.leaflet-map-pane')
|
|
|
|
.trigger('pointerdown', eventOptions)
|
|
|
|
.trigger('pointermove', eventOptions);
|
|
|
|
|
|
|
|
cy.wait(600);
|
|
|
|
|
|
|
|
cy.get('.leaflet-pane.leaflet-map-pane')
|
|
|
|
.trigger('pointerup', eventOptions);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-24 10:13:51 -06:00
|
|
|
module.exports.loadTestDoc = loadTestDoc;
|
2020-03-01 09:48:10 -06:00
|
|
|
module.exports.enableEditingMobile = enableEditingMobile;
|
|
|
|
module.exports.assertCursorAndFocus = assertCursorAndFocus;
|
leaflet: maintain the keyboard state after toolbar actions
Previously we supressed the keyboard after toolbar
actions, but that is problematic because then the
user is unable to delete/replace selected text,
because the keyboard is hidden and there is no way
of showing keyboard without changing the selection.
Now we maintain the keyboard state, which is likely
visible, since a selection shows the keyboard.
This might not be ideal, because the user might
hide the keyboard on the device and we will restore
it after invoking a toolbar action, but at least
it's more usable now. Unfortunately, there is no
API to track the keyboard visibility.
New Cypress tests added to validate the above.
The tests depend on checking the last keyboard
visibility state in Map, because there is no
reliable (or any?) way to know whether the keyboard
is visible or not. There are many cases where we
actually hide the keyboard, while having the input
focus on the textarea element, so that is no indication
that the keyboard is visible. We do this for usability
purposes. For example, during zooming, when selecting
cells and graphics/shapes, etc.
The purpose of the cell is to validate that we restored
the keyboard visibility or we changed it, depending
on which is expected after each operation.
Change-Id: If0f2e96909ff20753043734789397d190cedb502
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90663
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-03-17 11:02:59 -05:00
|
|
|
module.exports.assertNoKeyboardInput = assertNoKeyboardInput;
|
|
|
|
module.exports.assertHaveKeyboardInput = assertHaveKeyboardInput;
|
2020-03-01 09:48:10 -06:00
|
|
|
module.exports.selectAllText = selectAllText;
|
|
|
|
module.exports.clearAllText = clearAllText;
|
|
|
|
module.exports.getTextForClipboard = getTextForClipboard;
|
|
|
|
module.exports.expectTextForClipboard = expectTextForClipboard;
|
2020-02-02 22:34:25 -06:00
|
|
|
module.exports.afterAll = afterAll;
|
2020-02-06 07:12:18 -06:00
|
|
|
module.exports.beforeAllMobile = beforeAllMobile;
|
2020-03-09 11:49:56 -05:00
|
|
|
module.exports.longPressOnDocument = longPressOnDocument;
|