2020-03-01 09:48:10 -06:00
|
|
|
/* global describe it cy beforeEach require afterEach expect */
|
2020-02-10 09:28:18 -06:00
|
|
|
|
2020-02-12 11:01:47 -06:00
|
|
|
var helper = require('../../common/helper');
|
2020-03-01 09:48:10 -06:00
|
|
|
var impress = require('../../common/impress');
|
2020-02-10 09:28:18 -06:00
|
|
|
|
|
|
|
describe('Impress focus tests', function() {
|
|
|
|
beforeEach(function() {
|
2020-02-20 15:01:27 -06:00
|
|
|
helper.beforeAllMobile('focus.odp', 'impress');
|
2020-02-10 09:28:18 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function() {
|
2020-03-13 09:27:33 -05:00
|
|
|
helper.afterAll('focus.odp');
|
2020-02-10 09:28:18 -06:00
|
|
|
});
|
|
|
|
|
2020-03-01 09:48:10 -06:00
|
|
|
it('Select text box, no editing', function() {
|
|
|
|
|
|
|
|
helper.enableEditingMobile();
|
|
|
|
|
|
|
|
impress.assertNotInTextEditMode();
|
2020-02-10 09:28:18 -06:00
|
|
|
|
|
|
|
cy.get('#tb_actionbar_item_mobile_wizard')
|
|
|
|
.should('not.have.class', 'disabled');
|
|
|
|
|
|
|
|
// Body has the focus -> can't type in the document
|
|
|
|
cy.document().its('activeElement.tagName')
|
|
|
|
.should('be.eq', 'BODY');
|
|
|
|
|
2020-03-01 09:48:10 -06:00
|
|
|
// One tap on a text shape, on the whitespace area,
|
|
|
|
// does not start editing.
|
2020-02-10 09:28:18 -06:00
|
|
|
cy.get('#document-container')
|
2020-03-01 09:48:10 -06:00
|
|
|
.then(function(items) {
|
|
|
|
expect(items).have.length(1);
|
2020-02-10 09:28:18 -06:00
|
|
|
|
2020-03-01 09:48:10 -06:00
|
|
|
// Click in the left-bottom corner where there is no text.
|
|
|
|
let posX = items[0].getBoundingClientRect().left + items[0].getBoundingClientRect().width / 4;
|
|
|
|
let posY = items[0].getBoundingClientRect().top + items[0].getBoundingClientRect().height / 2;
|
|
|
|
cy.log('Got left-bottom quantile at (' + posX + ', ' + posY + ')');
|
|
|
|
|
|
|
|
cy.get('#document-container')
|
|
|
|
.click(posX, posY);
|
|
|
|
});
|
2020-02-10 09:28:18 -06:00
|
|
|
|
|
|
|
// No focus
|
|
|
|
cy.document().its('activeElement.tagName')
|
|
|
|
.should('be.eq', 'BODY');
|
|
|
|
|
2020-03-01 09:48:10 -06:00
|
|
|
// Shape selection.
|
|
|
|
cy.get('.leaflet-pane.leaflet-overlay-pane svg g')
|
|
|
|
.should('exist');
|
|
|
|
|
|
|
|
// But no editing.
|
|
|
|
impress.assertNotInTextEditMode();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Double-click to edit', function() {
|
|
|
|
|
|
|
|
helper.enableEditingMobile();
|
|
|
|
|
|
|
|
impress.assertNotInTextEditMode();
|
|
|
|
|
|
|
|
// Enter edit mode by double-clicking.
|
|
|
|
cy.get('#document-container')
|
|
|
|
.dblclick();
|
|
|
|
|
|
|
|
impress.typeTextAndVerify('Hello Impress');
|
|
|
|
|
|
|
|
// End editing.
|
|
|
|
cy.get('#document-container')
|
|
|
|
.type('{esc}').wait(500);
|
|
|
|
|
|
|
|
impress.assertNotInTextEditMode();
|
|
|
|
|
|
|
|
// Enter edit mode by double-clicking again.
|
2020-02-10 09:28:18 -06:00
|
|
|
cy.get('#document-container')
|
|
|
|
.dblclick();
|
|
|
|
|
2020-03-01 09:48:10 -06:00
|
|
|
// Clear the text.
|
|
|
|
helper.clearAllText();
|
|
|
|
|
|
|
|
impress.typeTextAndVerify('Bazinga Impress');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Single-click to edit', function() {
|
|
|
|
|
|
|
|
helper.enableEditingMobile();
|
|
|
|
|
|
|
|
impress.assertNotInTextEditMode();
|
|
|
|
|
|
|
|
cy.get('#document-container')
|
|
|
|
.then(function(items) {
|
|
|
|
expect(items).have.length(1);
|
|
|
|
|
|
|
|
// Click in the top left corner where there is no text.
|
|
|
|
let posX = items[0].getBoundingClientRect().width / 2;
|
|
|
|
let posY = items[0].getBoundingClientRect().height / 2;
|
|
|
|
cy.log('Got center coordinates at (' + posX + ', ' + posY + ')');
|
|
|
|
|
|
|
|
// Start editing; click on the text.
|
|
|
|
cy.get('#document-container')
|
|
|
|
.click(posX, posY);
|
|
|
|
|
|
|
|
impress.typeTextAndVerify('Hello Impress');
|
|
|
|
|
|
|
|
// End editing.
|
|
|
|
cy.get('#document-container')
|
|
|
|
.type('{esc}').wait(500);
|
|
|
|
|
|
|
|
impress.assertNotInTextEditMode();
|
|
|
|
|
|
|
|
// Single-click to re-edit.
|
|
|
|
cy.get('#document-container')
|
|
|
|
.then(function(items) {
|
|
|
|
expect(items).have.length(1);
|
|
|
|
|
|
|
|
cy.get('#document-container')
|
|
|
|
.click(posX, posY).wait(500);
|
|
|
|
|
|
|
|
impress.assertInTextEditMode();
|
|
|
|
|
|
|
|
// Clear the text.
|
|
|
|
helper.clearAllText();
|
|
|
|
|
|
|
|
impress.typeTextAndVerify('Bazinga Impress');
|
|
|
|
|
|
|
|
// End editing.
|
|
|
|
cy.get('#document-container')
|
|
|
|
.type('{esc}').wait(500);
|
|
|
|
|
|
|
|
impress.assertNotInTextEditMode();
|
|
|
|
});
|
|
|
|
});
|
2020-02-10 09:28:18 -06:00
|
|
|
});
|
|
|
|
});
|