Cypress: Retry selectTextOfShape
Most users of selectTextOfShape also need to select all text.
Sometimes the cursor appears but does not allow CTRL+a to select
all text. Work around this by including the selection in the retry
using waitUntil.
Fixes mobile/impress/apply_paragraph_props_text_spec.js, which started
failing sporadically after commit e0a0646ce1
.
I also adjusted the dblclick selector because it was finding multiple
elements but I think that is unrelated
I also created a separate function editTextInShape, for tests
that do not need to select all text
Signed-off-by: Neil Guertin <neil.guertin@collabora.com>
Change-Id: Icdfa731ba9a5f8d08a858192a4f1f5bc79b09b76
pull/8882/head
parent
d1a58af640
commit
ed731b7091
|
@ -161,12 +161,31 @@ function triggerNewSVGForShapeInTheCenter() {
|
|||
// Select the text inside a preselected shape. So we assume
|
||||
// we have already a shape selected. We try to select the
|
||||
// text of this shape by double clicking into it, until the
|
||||
// cursor becomes visible.
|
||||
function selectTextOfShape(selectAllText = true) {
|
||||
// cursor becomes visible and the text is selected
|
||||
function selectTextOfShape() {
|
||||
cy.log('>> selectTextOfShape - start');
|
||||
|
||||
// Double click onto the selected shape
|
||||
// Retry until the cursor appears
|
||||
// Retry until the cursor appears and the text is selected
|
||||
cy.waitUntil(function() {
|
||||
cy.cGet('svg g svg').dblclick({force: true});
|
||||
helper.typeIntoDocument('{ctrl}a');
|
||||
return cy.cGet('.leaflet-marker-pane')
|
||||
.then(function(markerPane) {
|
||||
return markerPane.children().length !== 0;
|
||||
});
|
||||
});
|
||||
|
||||
helper.textSelectionShouldExist();
|
||||
|
||||
cy.log('<< selectTextOfShape - end');
|
||||
}
|
||||
|
||||
// Double click on the shape to edit the text
|
||||
// and wait for the cursor to appear
|
||||
function editTextInShape() {
|
||||
cy.log('>> editTextInShape - start');
|
||||
|
||||
cy.waitUntil(function() {
|
||||
cy.cGet('svg g .leaflet-interactive').dblclick({force: true});
|
||||
return cy.cGet('.cursor-overlay')
|
||||
|
@ -174,13 +193,9 @@ function selectTextOfShape(selectAllText = true) {
|
|||
return overlay.children('.leaflet-cursor-container').length !== 0;
|
||||
});
|
||||
});
|
||||
|
||||
cy.cGet('.leaflet-cursor.blinking-cursor').should('exist');
|
||||
|
||||
if (selectAllText)
|
||||
helper.selectAllText();
|
||||
|
||||
cy.log('<< selectTextOfShape - end');
|
||||
cy.log('<< editTextInShape - end');
|
||||
}
|
||||
|
||||
// Step into text editing of the preselected shape. So we assume
|
||||
|
@ -249,6 +264,7 @@ module.exports.selectTextShapeInTheCenter = selectTextShapeInTheCenter;
|
|||
module.exports.triggerNewSVGForShapeInTheCenter = triggerNewSVGForShapeInTheCenter;
|
||||
module.exports.removeShapeSelection = removeShapeSelection;
|
||||
module.exports.selectTextOfShape = selectTextOfShape;
|
||||
module.exports.editTextInShape =editTextInShape;
|
||||
module.exports.dblclickOnSelectedShape = dblclickOnSelectedShape;
|
||||
module.exports.addSlide = addSlide;
|
||||
module.exports.changeSlide = changeSlide;
|
||||
|
|
|
@ -5,7 +5,6 @@ var desktopHelper = require('../../common/desktop_helper');
|
|||
var impressHelper = require('../../common/impress_helper');
|
||||
var ceHelper = require('../../common/contenteditable_helper');
|
||||
|
||||
|
||||
function selectTextShape(i) {
|
||||
cy.log('Selecting text shape - start.');
|
||||
if (typeof i !== 'number' || i <= 0 || i > 2)
|
||||
|
@ -41,7 +40,7 @@ describe(['taga11yenabled'], 'Editable area - Basic typing and caret moving', fu
|
|||
it.skip('Editing top text shape', function () {
|
||||
// select shape and activate editing
|
||||
selectTextShape(1);
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
// initial position
|
||||
ceHelper.checkHTMLContent('');
|
||||
ceHelper.checkCaretPosition(0);
|
||||
|
@ -54,7 +53,7 @@ describe(['taga11yenabled'], 'Editable area - Basic typing and caret moving', fu
|
|||
ceHelper.checkHTMLContent('');
|
||||
// activate editing again
|
||||
selectTextShape(1);
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
ceHelper.checkPlainContent('Hello World');
|
||||
ceHelper.moveCaret('end');
|
||||
ceHelper.checkCaretPosition(11);
|
||||
|
@ -64,7 +63,7 @@ describe(['taga11yenabled'], 'Editable area - Basic typing and caret moving', fu
|
|||
it('Deleting text', function () {
|
||||
// select shape and activate editing
|
||||
selectTextShape(1);
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
// initial position
|
||||
ceHelper.checkHTMLContent('');
|
||||
ceHelper.checkCaretPosition(0);
|
||||
|
@ -88,7 +87,7 @@ describe(['taga11yenabled'], 'Editable area - Basic typing and caret moving', fu
|
|||
it.skip('Editing bottom text shape', function () {
|
||||
// select shape and activate editing
|
||||
selectTextShape(2);
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
// initial position
|
||||
ceHelper.checkHTMLContent('');
|
||||
ceHelper.checkCaretPosition(0);
|
||||
|
@ -99,7 +98,7 @@ describe(['taga11yenabled'], 'Editable area - Basic typing and caret moving', fu
|
|||
impressHelper.removeShapeSelection();
|
||||
// activate editing again
|
||||
selectTextShape(2);
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
ceHelper.checkPlainContent('Hello World');
|
||||
ceHelper.moveCaret('end');
|
||||
ceHelper.checkCaretPosition(11);
|
||||
|
@ -110,7 +109,7 @@ describe(['taga11yenabled'], 'Editable area - Basic typing and caret moving', fu
|
|||
impressHelper.removeShapeSelection();
|
||||
// activate editing again
|
||||
selectTextShape(2);
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
// navigating between paragraphs
|
||||
ceHelper.checkPlainContent('Green red');
|
||||
ceHelper.moveCaret('up');
|
||||
|
@ -121,7 +120,7 @@ describe(['taga11yenabled'], 'Editable area - Basic typing and caret moving', fu
|
|||
it.skip('Editing both text shapes', function () {
|
||||
// select top shape and activate editing
|
||||
selectTextShape(1);
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
// initial position
|
||||
ceHelper.checkHTMLContent('');
|
||||
ceHelper.checkCaretPosition(0);
|
||||
|
@ -132,7 +131,7 @@ describe(['taga11yenabled'], 'Editable area - Basic typing and caret moving', fu
|
|||
// select bottom shape and activate editing
|
||||
selectTextShape(2);
|
||||
ceHelper.checkHTMLContent('');
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
// typing
|
||||
ceHelper.checkHTMLContent('');
|
||||
ceHelper.checkCaretPosition(0);
|
||||
|
@ -142,7 +141,7 @@ describe(['taga11yenabled'], 'Editable area - Basic typing and caret moving', fu
|
|||
// select top shape and activate editing
|
||||
selectTextShape(1);
|
||||
ceHelper.checkHTMLContent('');
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
ceHelper.checkPlainContent('Hello World');
|
||||
ceHelper.moveCaret('end');
|
||||
ceHelper.type(' Yellow');
|
||||
|
@ -150,7 +149,7 @@ describe(['taga11yenabled'], 'Editable area - Basic typing and caret moving', fu
|
|||
// select bottom shape and activate editing
|
||||
selectTextShape(2);
|
||||
ceHelper.checkHTMLContent('');
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
ceHelper.checkPlainContent('Green red');
|
||||
// remove shape selection
|
||||
impressHelper.removeShapeSelection();
|
||||
|
|
|
@ -12,7 +12,7 @@ describe(['tagdesktop'], 'Editing Operations', function() {
|
|||
desktopHelper.switchUIToCompact();
|
||||
desktopHelper.selectZoomLevel('30');
|
||||
impressHelper.selectTextShapeInTheCenter();
|
||||
impressHelper.selectTextOfShape(false);
|
||||
impressHelper.editTextInShape();
|
||||
});
|
||||
|
||||
function undo() {
|
||||
|
|
Loading…
Reference in New Issue