summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2020-12-07 15:59:52 +0100
committerTamás Zolnai <zolnaitamas2000@gmail.com>2020-12-08 20:21:36 +0100
commit963f97349ff17aee4af5ee9719fb990997e02f1f (patch)
treee34dafbbaa81fbc7ae21d15a4da3e5a057a2bdb3
parentJSDialog: Improve expanders (diff)
downloadonline-963f97349ff17aee4af5ee9719fb990997e02f1f.tar.gz
online-963f97349ff17aee4af5ee9719fb990997e02f1f.zip
cypress: add helper methods for text selection.
Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com> Change-Id: Id799c5389adb518e42aac7c5838e27405d4ecb1f
-rw-r--r--cypress_test/integration_tests/common/helper.js39
-rw-r--r--cypress_test/integration_tests/desktop/writer/top_toolbar_spec.js6
-rw-r--r--cypress_test/integration_tests/mobile/impress/hamburger_menu_spec.js3
-rw-r--r--cypress_test/integration_tests/mobile/impress/searchbar_spec.js7
-rw-r--r--cypress_test/integration_tests/mobile/impress/spellchecking_spec.js3
-rw-r--r--cypress_test/integration_tests/mobile/writer/hamburger_menu_spec.js27
-rw-r--r--cypress_test/integration_tests/mobile/writer/insert_object_spec.js4
-rw-r--r--cypress_test/integration_tests/mobile/writer/searchbar_spec.js37
-rw-r--r--cypress_test/integration_tests/mobile/writer/spellchecking_spec.js4
9 files changed, 63 insertions, 67 deletions
diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js
index c703d2052a..3cd4955e6d 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -332,8 +332,7 @@ function selectAllText(assertFocus = true) {
// Trigger select all
typeIntoDocument('{ctrl}a');
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ textSelectionShouldExist();
}
// Clear all text by selecting all and deleting.
@@ -345,14 +344,12 @@ function clearAllText() {
// Trigger select all
typeIntoDocument('{ctrl}a');
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ textSelectionShouldExist();
// Then remove
typeIntoDocument('{del}');
- cy.get('.leaflet-marker-icon')
- .should('not.exist');
+ textSelectionShouldNotExist();
}
// Check that the clipboard text matches with the specified text.
@@ -851,6 +848,34 @@ function getCursorPos(offsetProperty, aliasName) {
.should('be.greaterThan', 0);
}
+function textSelectionShouldExist() {
+ cy.log('Make sure text selection exists - start.');
+
+ cy.get('.leaflet-selection-marker-start')
+ .should('exist');
+
+ cy.get('.leaflet-selection-marker-end')
+ .should('exist');
+
+ // One of the marker should be visible at least (if not both).
+ cy.get('.leaflet-selection-marker-start, .leaflet-selection-marker-end')
+ .should('be.visible');
+
+ cy.log('Make sure text selection exists - end.');
+}
+
+function textSelectionShouldNotExist() {
+ cy.log('Make sure there is no text selection - start.');
+
+ cy.get('.leaflet-selection-marker-start')
+ .should('not.exist');
+
+ cy.get('.leaflet-selection-marker-end')
+ .should('not.exist');
+
+ cy.log('Make sure there is no text selection - end.');
+}
+
module.exports.loadTestDoc = loadTestDoc;
module.exports.assertCursorAndFocus = assertCursorAndFocus;
module.exports.assertNoKeyboardInput = assertNoKeyboardInput;
@@ -882,3 +907,5 @@ module.exports.moveCursor = moveCursor;
module.exports.typeIntoDocument = typeIntoDocument;
module.exports.loadFileToNextCloud = loadFileToNextCloud;
module.exports.getCursorPos = getCursorPos;
+module.exports.textSelectionShouldExist = textSelectionShouldExist;
+module.exports.textSelectionShouldNotExist = textSelectionShouldNotExist;
diff --git a/cypress_test/integration_tests/desktop/writer/top_toolbar_spec.js b/cypress_test/integration_tests/desktop/writer/top_toolbar_spec.js
index e829d17d6b..bc4ca587cb 100644
--- a/cypress_test/integration_tests/desktop/writer/top_toolbar_spec.js
+++ b/cypress_test/integration_tests/desktop/writer/top_toolbar_spec.js
@@ -497,13 +497,11 @@ describe('Top toolbar tests.', function() {
// Select one character at the beginning of the text.
helper.typeIntoDocument('{home}');
- cy.get('.leaflet-marker-icon')
- .should('not.exist');
+ helper.textSelectionShouldNotExist();
helper.typeIntoDocument('{shift}{rightArrow}');
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
// Apply bold and try to clone it to the whole word.
cy.get('#tb_editbar_item_bold')
diff --git a/cypress_test/integration_tests/mobile/impress/hamburger_menu_spec.js b/cypress_test/integration_tests/mobile/impress/hamburger_menu_spec.js
index dda2502645..8ae468f97d 100644
--- a/cypress_test/integration_tests/mobile/impress/hamburger_menu_spec.js
+++ b/cypress_test/integration_tests/mobile/impress/hamburger_menu_spec.js
@@ -260,8 +260,7 @@ describe('Trigger hamburger menu options.', function() {
mobileHelper.selectHamburgerMenuItem(['Edit', 'Select All']);
- cy.get('.leaflet-marker-icon')
- .should('be.visible');
+ helper.textSelectionShouldExist();
helper.expectTextForClipboard('X');
});
diff --git a/cypress_test/integration_tests/mobile/impress/searchbar_spec.js b/cypress_test/integration_tests/mobile/impress/searchbar_spec.js
index cd9a00591f..ce385c557b 100644
--- a/cypress_test/integration_tests/mobile/impress/searchbar_spec.js
+++ b/cypress_test/integration_tests/mobile/impress/searchbar_spec.js
@@ -41,16 +41,13 @@ describe('Searching via search bar.', function() {
helper.selectAllText();
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
searchHelper.tpyeIntoSearchField('q');
searchHelper.searchNext();
- // Should be no selection
- cy.get('.leaflet-marker-icon')
- .should('not.exist');
+ helper.textSelectionShouldNotExist();
});
it('Search next / prev instance.', function() {
diff --git a/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js b/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js
index 26eebff5fc..06aafc7d1c 100644
--- a/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js
+++ b/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js
@@ -30,8 +30,7 @@ describe('Spell checking menu.', function() {
helper.typeIntoDocument('{leftArrow}');
- cy.get('.leaflet-marker-icon')
- .should('not.exist');
+ helper.textSelectionShouldNotExist();
// Open context menu
cy.get('g path.leaflet-interactive')
diff --git a/cypress_test/integration_tests/mobile/writer/hamburger_menu_spec.js b/cypress_test/integration_tests/mobile/writer/hamburger_menu_spec.js
index 41eb6557f5..2f7e4e82a3 100644
--- a/cypress_test/integration_tests/mobile/writer/hamburger_menu_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/hamburger_menu_spec.js
@@ -293,8 +293,7 @@ describe('Trigger hamburger menu options.', function() {
mobileHelper.selectHamburgerMenuItem(['Edit', 'Select All']);
- cy.get('.leaflet-marker-icon')
- .should('be.visible');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('contain.text', 'xxxxxx');
@@ -308,8 +307,7 @@ describe('Trigger hamburger menu options.', function() {
mobileHelper.selectHamburgerMenuItem(['Track Changes', 'Previous']);
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
// We should have 'q' selected.
cy.get('#copy-paste-container p')
@@ -322,8 +320,7 @@ describe('Trigger hamburger menu options.', function() {
mobileHelper.selectHamburgerMenuItem(['Track Changes', 'Previous']);
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
// We should have 'q' selected.
cy.get('#copy-paste-container p')
@@ -342,18 +339,14 @@ describe('Trigger hamburger menu options.', function() {
// By default track changed are shown.
writerHelper.selectAllTextOfDoc();
- // We have selection markers.
- cy.get('.leaflet-marker-icon')
- .should('exist');
-
// No actual text sent from core because of the removal.
cy.get('#copy-paste-container p')
.should('have.text', '\n\n\n');
// We have a multiline selection
- cy.get('.leaflet-marker-icon:nth-of-type(1)')
+ cy.get('.leaflet-selection-marker-start')
.then(function(firstMarker) {
- cy.get('.leaflet-marker-icon:nth-of-type(2)')
+ cy.get('.leaflet-selection-marker-end')
.then(function(secondMarker) {
expect(firstMarker.offset().top).to.be.lessThan(secondMarker.offset().top);
expect(firstMarker.offset().left).to.be.lessThan(secondMarker.offset().left);
@@ -370,9 +363,9 @@ describe('Trigger hamburger menu options.', function() {
helper.typeIntoDocument('{ctrl}a');
// Both selection markers should be in the same line
- cy.get('.leaflet-marker-icon:nth-of-type(1)')
+ cy.get('.leaflet-selection-marker-start')
.then(function(firstMarker) {
- cy.get('.leaflet-marker-icon:nth-of-type(2)')
+ cy.get('.leaflet-selection-marker-end')
.then(function(secondMarker) {
expect(firstMarker.offset().top).to.be.equal(secondMarker.offset().top);
expect(firstMarker.offset().left).to.be.lessThan(secondMarker.offset().left);
@@ -398,8 +391,7 @@ describe('Trigger hamburger menu options.', function() {
cy.wait(1000);
// No selection
- cy.get('.leaflet-marker-icon')
- .should('not.exist');
+ helper.textSelectionShouldNotExist();
});
it('Reject all changes.', function() {
@@ -471,8 +463,7 @@ describe('Trigger hamburger menu options.', function() {
helper.clickOnIdle('#search');
// Part of the text should be selected
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('have.text', '\na');
diff --git a/cypress_test/integration_tests/mobile/writer/insert_object_spec.js b/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
index 15a99460fb..0e5e03dc62 100644
--- a/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
@@ -77,7 +77,7 @@ describe('Insert objects via insertion wizard.', function() {
cy.get('.leaflet-marker-icon.table-column-resize-marker')
.should('exist');
- writerHelper.selectAllTextOfDoc();
+ helper.typeIntoDocument('{ctrl}a');
// Two rows
cy.get('#copy-paste-container tr')
@@ -111,7 +111,7 @@ describe('Insert objects via insertion wizard.', function() {
cy.get('.leaflet-marker-icon.table-column-resize-marker')
.should('exist');
- writerHelper.selectAllTextOfDoc();
+ helper.typeIntoDocument('{ctrl}a');
// Three rows
cy.get('#copy-paste-container tr')
diff --git a/cypress_test/integration_tests/mobile/writer/searchbar_spec.js b/cypress_test/integration_tests/mobile/writer/searchbar_spec.js
index 67d845f9cf..a81b7482f7 100644
--- a/cypress_test/integration_tests/mobile/writer/searchbar_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/searchbar_spec.js
@@ -24,8 +24,7 @@ describe('Searching via search bar.', function() {
searchHelper.tpyeIntoSearchField('a');
// Part of the text should be selected
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('have.text', '\na');
@@ -34,21 +33,15 @@ describe('Searching via search bar.', function() {
it('Search not existing word.', function() {
writerHelper.selectAllTextOfDoc();
- cy.get('.leaflet-marker-icon')
- .should('exist');
-
searchHelper.tpyeIntoSearchField('q');
- // Should be no selection
- cy.get('.leaflet-marker-icon')
- .should('not.exist');
+ helper.textSelectionShouldNotExist();
});
it('Search next / prev instance.', function() {
searchHelper.tpyeIntoSearchField('a');
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('have.text', '\na');
@@ -62,8 +55,7 @@ describe('Searching via search bar.', function() {
cy.get('#copy-paste-container p b')
.should('exist');
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('have.text', '\na');
@@ -74,8 +66,7 @@ describe('Searching via search bar.', function() {
cy.get('#copy-paste-container p b')
.should('not.exist');
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('have.text', '\na');
@@ -84,8 +75,7 @@ describe('Searching via search bar.', function() {
it('Search at the document end.', function() {
searchHelper.tpyeIntoSearchField('a');
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('have.text', '\na');
@@ -99,8 +89,7 @@ describe('Searching via search bar.', function() {
cy.get('#copy-paste-container p b')
.should('exist');
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('have.text', '\na');
@@ -111,8 +100,7 @@ describe('Searching via search bar.', function() {
cy.get('#copy-paste-container p b')
.should('not.exist');
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('have.text', '\na');
@@ -122,8 +110,7 @@ describe('Searching via search bar.', function() {
searchHelper.tpyeIntoSearchField('a');
// Part of the text should be selected
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('have.text', '\na');
@@ -131,8 +118,7 @@ describe('Searching via search bar.', function() {
// Cancel search -> selection removed
searchHelper.cancelSearch();
- cy.get('.leaflet-marker-icon')
- .should('not.exist');
+ helper.textSelectionShouldNotExist();
cy.get('input#search-input')
.should('be.visible');
@@ -142,8 +128,7 @@ describe('Searching via search bar.', function() {
searchHelper.tpyeIntoSearchField('a');
// Part of the text should be selected
- cy.get('.leaflet-marker-icon')
- .should('exist');
+ helper.textSelectionShouldExist();
cy.get('#copy-paste-container p')
.should('have.text', '\na');
diff --git a/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js b/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js
index 4068df911e..ef6108492a 100644
--- a/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js
@@ -36,8 +36,8 @@ describe('Spell checking menu.', function() {
// Remove selection
helper.typeIntoDocument('{downarrow}');
- cy.get('.leaflet-marker-icon')
- .should('not.exist');
+
+ helper.textSelectionShouldNotExist();
var XPos = startPos.right + 10;
var YPos = endPos.top - 10;