[Libreoffice-commits] online.git: cypress_test/integration_tests
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 5 17:00:47 UTC 2020
cypress_test/integration_tests/common/helper.js | 57 ++++++++++
cypress_test/integration_tests/desktop/calc/focus_spec.js | 4
cypress_test/integration_tests/mobile/calc/focus_spec.js | 2
cypress_test/integration_tests/multiuser/simultaneous_typing_user1_spec.js | 10 -
4 files changed, 63 insertions(+), 10 deletions(-)
New commits:
commit eb179113e5a8696a0fd900064f12774e4b8964a7
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Aug 5 17:17:43 2020 +0200
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Aug 5 19:00:28 2020 +0200
cypress: introduce moveCursor() helper method.
Change-Id: I67a1e74fe03e464e71100428969f9458b8a018a2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100179
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js
index 484b8cad0..bd2598a7a 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -411,6 +411,62 @@ function doIfOnDesktop(callback) {
});
}
+function moveCursor(direction) {
+ cy.log('Moving text cursor - start.');
+ cy.log('Param - direction: ' + direction);
+
+ initAliasToNegative('origCursorPos');
+
+ cy.get('.blinking-cursor')
+ .should('be.visible');
+
+ if (direction === 'up' || direction === 'down') {
+ cy.get('.blinking-cursor')
+ .invoke('offset')
+ .its('top')
+ .as('origCursorPos');
+ } else if (direction === 'left' || direction === 'right') {
+ cy.get('.blinking-cursor')
+ .invoke('offset')
+ .its('left')
+ .as('origCursorPos');
+ }
+
+ cy.get('@origCursorPos')
+ .should('be.greaterThan', 0);
+
+ var key = '';
+ if (direction === 'up') {
+ key = '{uparrow}';
+ } else if (direction === 'down') {
+ key = '{downarrow}';
+ } else if (direction === 'left') {
+ key = '{leftarrow}';
+ } else if (direction === 'right') {
+ key = '{rightarrow}';
+ }
+ cy.get('textarea.clipboard')
+ .type(key);
+
+ cy.get('@origCursorPos')
+ .then(function(origCursorPos) {
+ cy.get('.blinking-cursor')
+ .should(function(cursor) {
+ if (direction === 'up') {
+ expect(cursor.offset().top).to.be.lessThan(origCursorPos);
+ } else if (direction === 'down') {
+ expect(cursor.offset().top).to.be.greaterThan(origCursorPos);
+ } else if (direction === 'left') {
+ expect(cursor.offset().left).to.be.lessThan(origCursorPos);
+ } else if (direction === 'right') {
+ expect(cursor.offset().left).to.be.greaterThan(origCursorPos);
+ }
+ });
+ });
+
+ cy.log('Moving text cursor - end.');
+}
+
module.exports.loadTestDoc = loadTestDoc;
module.exports.assertCursorAndFocus = assertCursorAndFocus;
@@ -435,3 +491,4 @@ module.exports.inputOnIdle = inputOnIdle;
module.exports.waitUntilIdle = waitUntilIdle;
module.exports.doIfOnMobile = doIfOnMobile;
module.exports.doIfOnDesktop = doIfOnDesktop;
+module.exports.moveCursor = moveCursor;
diff --git a/cypress_test/integration_tests/desktop/calc/focus_spec.js b/cypress_test/integration_tests/desktop/calc/focus_spec.js
index 568e1fd11..2d9cd623b 100644
--- a/cypress_test/integration_tests/desktop/calc/focus_spec.js
+++ b/cypress_test/integration_tests/desktop/calc/focus_spec.js
@@ -61,10 +61,10 @@ describe('Calc focus tests', function() {
calcHelper.clickFormulaBar();
helper.assertCursorAndFocus();
- // Move cursor before text2
+ // Move cursor inside text2
cy.get('textarea.clipboard').type('{end}');
for (var i = 0; i < 6; i++)
- cy.get('textarea.clipboard').type('{leftarrow}');
+ helper.moveCursor('left');
var text3 = ' BAZINGA';
helper.typeText('textarea.clipboard', text3);
diff --git a/cypress_test/integration_tests/mobile/calc/focus_spec.js b/cypress_test/integration_tests/mobile/calc/focus_spec.js
index d12385daf..b9d4dd341 100644
--- a/cypress_test/integration_tests/mobile/calc/focus_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/focus_spec.js
@@ -141,7 +141,7 @@ describe('Calc focus tests', function() {
// Move cursor before text2
cy.get('textarea.clipboard').type('{end}');
for (var i = 0; i < text2.length; i++)
- cy.get('textarea.clipboard').type('{leftarrow}');
+ helper.moveCursor('left');
var text3 = ', BAZINGA';
helper.typeText('textarea.clipboard', text3);
diff --git a/cypress_test/integration_tests/multiuser/simultaneous_typing_user1_spec.js b/cypress_test/integration_tests/multiuser/simultaneous_typing_user1_spec.js
index 14d277a3a..a4c238854 100644
--- a/cypress_test/integration_tests/multiuser/simultaneous_typing_user1_spec.js
+++ b/cypress_test/integration_tests/multiuser/simultaneous_typing_user1_spec.js
@@ -23,8 +23,8 @@ describe('Simultaneous typing: user-1.', function() {
.should('have.text', '2 users');
// We have a table in the document, move the cursor into the second row.
- cy.get('textarea.clipboard')
- .type('{downarrow}');
+ helper.moveCursor('down');
+
// And now type some text, while user-2 does the same.
var text = 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq';
helper.typeText('textarea.clipboard', text, 100);
@@ -35,11 +35,7 @@ describe('Simultaneous typing: user-1.', function() {
.should('contain.text', text);
// Change paragraph alignment to trigger user-2 actions
- cy.get('textarea.clipboard')
- .type('{uparrow}');
-
- // TODO
- cy.wait(1000);
+ helper.moveCursor('up');
cy.get('#tb_editbar_item_centerpara .w2ui-button')
.click();
More information about the Libreoffice-commits
mailing list