libreoffice-online/cypress_test/integration_tests/common/impress.js

100 lines
2.5 KiB
JavaScript
Raw Normal View History

/* global cy require expect*/
var helper = require('./helper');
// Assert that Impress is *not* in Text Edit Mode.
function assertNotInTextEditMode() {
cy.log('Verifying NO Text-Edit context.');
// In edit mode, we should have the blinking cursor.
cy.get('.leaflet-cursor.blinking-cursor')
.should('not.exist');
cy.get('.leaflet-cursor-container')
.should('not.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
helper.assertNoKeyboardInput();
cy.log('NO Text-Edit context verified.');
}
// Assert that Impress is in Text Edit Mode.
function assertInTextEditMode() {
cy.log('Verifying Impress in Text-Edit context.');
// In edit mode, we should have the edit container.
cy.get('#doc-clipboard-container')
.should('exist');
cy.get('.leaflet-zoom-animated')
.should('exist');
cy.get('.leaflet-interactive')
.should('exist');
cy.get('.leaflet-pane.leaflet-overlay-pane svg g')
.should('exist');
helper.assertCursorAndFocus();
cy.log('Impress Text-Edit context verified.');
}
// Enter some text and confirm we get it back.
function typeTextAndVerify(text, expected) {
if (!expected)
expected = text;
assertInTextEditMode();
// Type some text.
cy.get('#document-container')
.type(text);
// Still in edit mode.
assertInTextEditMode();
helper.selectAllText();
//FIXME: Should retry the next check instead of
// an unreliable sleep, but for now this will do.
cy.wait(600);
helper.expectTextForClipboard(expected);
}
function copyShapeContentToClipboard() {
// TODO: this fails on assertHaveKeyboardInput()
// assertInTextEditMode();
helper.selectAllText(false);
// Open context menu
cy.get('.leaflet-marker-icon')
.then(function(marker) {
expect(marker).to.have.lengthOf(2);
var XPos = (marker[0].getBoundingClientRect().right + marker[1].getBoundingClientRect().left) / 2;
var YPos = marker[0].getBoundingClientRect().top - 5;
helper.longPressOnDocument(XPos, YPos);
});
cy.get('#mobile-wizard')
.should('be.visible');
// Execute copy
cy.get('.ui-header.level-0.mobile-wizard.ui-widget .context-menu-link .menu-entry-with-icon', {timeout : 10000})
.contains('Copy')
.click();
// Close warning about clipboard operations
cy.get('.vex-dialog-button-primary.vex-dialog-button.vex-first')
.click();
// Wait until it's closed
cy.get('.vex-overlay')
.should('not.exist');
}
module.exports.assertNotInTextEditMode = assertNotInTextEditMode;
module.exports.assertInTextEditMode = assertInTextEditMode;
module.exports.typeTextAndVerify = typeTextAndVerify;
module.exports.copyShapeContentToClipboard = copyShapeContentToClipboard;