[Libreoffice-commits] online.git: cypress_test/integration_tests
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Mon Mar 9 13:57:14 UTC 2020
cypress_test/integration_tests/common/helper.js | 149 ---------
cypress_test/integration_tests/mobile/writer/apply_font_spec.js | 35 +-
cypress_test/integration_tests/mobile/writer/apply_paragraph_properties_spec.js | 43 +-
cypress_test/integration_tests/mobile/writer/bottom_toolbar_spec.js | 31 +-
cypress_test/integration_tests/mobile/writer/insert_field_spec.js | 15
cypress_test/integration_tests/mobile/writer/insert_formatting_mark_spec.js | 15
cypress_test/integration_tests/mobile/writer/insert_object_spec.js | 7
cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js | 3
cypress_test/integration_tests/mobile/writer/shape_properties_spec.js | 5
cypress_test/integration_tests/mobile/writer/spellchecking_spec.js | 7
cypress_test/integration_tests/mobile/writer/table_properties_spec.js | 35 +-
cypress_test/integration_tests/mobile/writer/writer_helper.js | 151 ++++++++++
12 files changed, 254 insertions(+), 242 deletions(-)
New commits:
commit 9396cedd288380d9b6f373a491b80a802cb2cf61
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 9 14:00:44 2020 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Mon Mar 9 14:56:56 2020 +0100
cypress: mobile: move writer related helper functions to a separate file.
Change-Id: I02dee0270d3b572ae26b3f871fa4c41c0c397e54
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90222
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 773c394f6..0e06a7d0e 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -46,105 +46,6 @@ function loadTestDoc(fileName, subFolder, mobile) {
cy.get('.leaflet-tile-loaded', {timeout : 10000});
}
-function selectAllMobile() {
- // Remove selection if exist
- cy.get('#document-container').click();
- cy.get('.leaflet-marker-icon')
- .should('not.exist');
-
- // Enable editing if it's in read-only mode
- cy.get('#mobile-edit-button')
- .then(function(button) {
- if (button.css('display') !== 'none') {
- cy.get('#mobile-edit-button')
- .click();
- }
- });
-
- // Open hamburger menu
- cy.get('#toolbar-hamburger')
- .click();
-
- // Open edit menu
- cy.get('.ui-header.level-0 .menu-entry-with-icon')
- .contains('Edit')
- .click();
-
- cy.get('.ui-header.level-1 .menu-entry-with-icon')
- .should('be.visible')
- .wait(100);
-
- // Do the selection
- cy.get('.ui-header.level-1 .menu-entry-with-icon')
- .contains('Select All')
- .click();
-
- cy.get('.leaflet-marker-icon')
- .should('exist');
-}
-
-function copyTextToClipboard() {
- // Do a new selection
- selectAllMobile();
-
- // 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;
- longPressOnDocument(XPos, YPos);
- });
-
- // 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');
-}
-
-function copyTableToClipboard() {
- // Do a new selection
- selectAllMobile();
-
- // Open context menu
- cy.get('.leaflet-marker-icon')
- .then(function(markers) {
- expect(markers.length).to.have.greaterThan(1);
- for (var i = 0; i < markers.length; i++) {
- if (markers[i].classList.contains('leaflet-selection-marker-start')) {
- var startPos = markers[i].getBoundingClientRect();
- } else if (markers[i].classList.contains('leaflet-selection-marker-end')) {
- var endPos = markers[i].getBoundingClientRect();
- }
- }
-
- var XPos = startPos.right + 10;
- var YPos = (startPos.top + endPos.top) / 2;
- longPressOnDocument(XPos, YPos);
- });
-
- // Execute copy
- cy.get('.ui-header.level-0.mobile-wizard.ui-widget .context-menu-link .menu-entry-with-icon')
- .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');
-}
-
function beforeAllMobile(fileName, subFolder) {
loadTestDoc(fileName, subFolder, true);
@@ -190,56 +91,6 @@ function detectLOCoreVersion() {
}
}
-function longPressOnDocument(posX, posY) {
- cy.get('.leaflet-pane.leaflet-map-pane')
- .then(function(items) {
- expect(items).have.length(1);
-
- var eventOptions = {
- force: true,
- button: 0,
- pointerType: 'mouse',
- x: posX - items[0].getBoundingClientRect().left,
- y: posY - items[0].getBoundingClientRect().top
- };
-
- cy.get('.leaflet-pane.leaflet-map-pane')
- .trigger('pointerdown', eventOptions)
- .trigger('pointermove', eventOptions);
-
- cy.wait(600);
-
- cy.get('.leaflet-pane.leaflet-map-pane')
- .trigger('pointerup', eventOptions);
- });
-}
-
-// Use this method when a test openes the same mobile
-// wizard more times during a test.
-// Recent issue with this scenario is that the mobile
-// wizard is opened first with an old content, then
-// when the sidebar's state arrives the wizard is
-// rerendered again which might cause a test failure
-// because the test finds the old HTML item
-// which will be detached from DOM.
-function clearMobileWizardState() {
- // Open hamburger menu
- cy.get('#toolbar-hamburger')
- .click();
-
- cy.get('.ui-header.level-0 .menu-entry-with-icon')
- .contains('About');
-
- // Close hamburger menu
- cy.get('#toolbar-hamburger')
- .click();
-}
-
module.exports.loadTestDoc = loadTestDoc;
-module.exports.selectAllMobile = selectAllMobile;
-module.exports.copyTextToClipboard = copyTextToClipboard;
-module.exports.copyTableToClipboard = copyTableToClipboard;
module.exports.afterAll = afterAll;
module.exports.beforeAllMobile = beforeAllMobile;
-module.exports.longPressOnDocument = longPressOnDocument;
-module.exports.clearMobileWizardState = clearMobileWizardState;
diff --git a/cypress_test/integration_tests/mobile/writer/apply_font_spec.js b/cypress_test/integration_tests/mobile/writer/apply_font_spec.js
index d5b9071ad..f266d804d 100644
--- a/cypress_test/integration_tests/mobile/writer/apply_font_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/apply_font_spec.js
@@ -1,6 +1,7 @@
/* global describe it cy beforeEach require afterEach*/
var helper = require('../../common/helper');
+var writerHelper = require('./writer_helper');
describe('Apply font changes.', function() {
beforeEach(function() {
@@ -10,7 +11,7 @@ describe('Apply font changes.', function() {
cy.get('#mobile-edit-button').click();
// Do a new selection
- helper.selectAllMobile();
+ writerHelper.selectAllMobile();
// Open mobile wizard
cy.get('#tb_actionbar_item_mobile_wizard')
@@ -24,7 +25,7 @@ describe('Apply font changes.', function() {
function applyStyle(styleName) {
// Do a new selection
- helper.selectAllMobile();
+ writerHelper.selectAllMobile();
// Open mobile wizard
cy.get('#tb_actionbar_item_mobile_wizard')
@@ -81,7 +82,7 @@ describe('Apply font changes.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p font')
.should('have.attr', 'face', 'Linux Libertine G');
@@ -107,7 +108,7 @@ describe('Apply font changes.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p font')
.should('have.attr', 'style', 'font-size: 36pt');
@@ -122,7 +123,7 @@ describe('Apply font changes.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p b')
.should('exist');
@@ -137,7 +138,7 @@ describe('Apply font changes.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p i')
.should('exist');
@@ -154,7 +155,7 @@ describe('Apply font changes.', function() {
cy.get('#mobile-wizard-content')
.should('not.be.visible');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p u')
.should('exist');
@@ -171,7 +172,7 @@ describe('Apply font changes.', function() {
cy.get('#mobile-wizard-content')
.should('not.be.visible');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p strike')
.should('exist');
@@ -188,7 +189,7 @@ describe('Apply font changes.', function() {
cy.get('#mobile-wizard-content')
.should('not.be.visible');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
// TODO: Shadowed is not in the clipboard content.
});
@@ -204,7 +205,7 @@ describe('Apply font changes.', function() {
cy.get('#mobile-wizard-content')
.should('not.be.visible');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p font')
.should('have.attr', 'style', 'font-size: 42pt');
@@ -221,7 +222,7 @@ describe('Apply font changes.', function() {
cy.get('#mobile-wizard-content')
.should('not.be.visible');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p font')
.should('have.attr', 'style', 'font-size: 38pt');
@@ -247,7 +248,7 @@ describe('Apply font changes.', function() {
cy.get('#mobile-wizard-content')
.should('not.be.visible');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p font')
.should('have.attr', 'color', '#6aa84f');
@@ -273,7 +274,7 @@ describe('Apply font changes.', function() {
cy.get('#mobile-wizard-content')
.should('not.be.visible');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p font span')
.should('have.attr', 'style', 'background: #93c47d');
@@ -290,7 +291,7 @@ describe('Apply font changes.', function() {
cy.get('#mobile-wizard-content')
.should('not.be.visible');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p sup')
.should('exist');
@@ -307,7 +308,7 @@ describe('Apply font changes.', function() {
cy.get('#mobile-wizard-content')
.should('not.be.visible');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p sub')
.should('exist');
@@ -329,7 +330,7 @@ describe('Apply font changes.', function() {
// Apply Title style
applyStyle('Title');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p font')
.should('have.attr', 'face', 'Liberation Sans, sans-serif');
@@ -339,7 +340,7 @@ describe('Apply font changes.', function() {
// Clear formatting
applyStyle('Clear formatting');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('have.attr', 'style', 'margin-bottom: 0in; line-height: 100%');
diff --git a/cypress_test/integration_tests/mobile/writer/apply_paragraph_properties_spec.js b/cypress_test/integration_tests/mobile/writer/apply_paragraph_properties_spec.js
index a4628f5d4..0b482565b 100644
--- a/cypress_test/integration_tests/mobile/writer/apply_paragraph_properties_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/apply_paragraph_properties_spec.js
@@ -1,6 +1,7 @@
/* global describe it cy beforeEach require expect afterEach Cypress*/
var helper = require('../../common/helper');
+var writerHelper = require('./writer_helper');
describe('Apply paragraph properties.', function() {
beforeEach(function() {
@@ -10,7 +11,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#mobile-edit-button').click();
// Do a selection
- helper.selectAllMobile();
+ writerHelper.selectAllMobile();
// Open mobile wizard
cy.get('#tb_actionbar_item_mobile_wizard')
@@ -48,7 +49,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('have.attr', 'align', 'left');
@@ -63,7 +64,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('have.attr', 'align', 'center');
@@ -78,7 +79,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('have.attr', 'align', 'right');
@@ -93,7 +94,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('have.attr', 'align', 'justify');
@@ -108,13 +109,13 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('have.attr', 'dir', 'rtl');
// Select text
- helper.selectAllMobile();
+ writerHelper.selectAllMobile();
// Open mobile wizard
cy.get('#tb_actionbar_item_mobile_wizard')
@@ -132,7 +133,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('not.have.attr', 'dir');
@@ -151,7 +152,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container ul li p')
.should('exist');
@@ -170,7 +171,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container ol li p')
.should('exist');
@@ -199,7 +200,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -219,7 +220,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -229,7 +230,7 @@ describe('Apply paragraph properties.', function() {
});
// Select text
- helper.selectAllMobile();
+ writerHelper.selectAllMobile();
// Open mobile wizard
cy.get('#tb_actionbar_item_mobile_wizard')
@@ -247,7 +248,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -287,7 +288,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -308,7 +309,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -317,7 +318,7 @@ describe('Apply paragraph properties.', function() {
});
// Select text
- helper.selectAllMobile();
+ writerHelper.selectAllMobile();
// Open mobile wizard
cy.get('#tb_actionbar_item_mobile_wizard')
@@ -335,7 +336,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -359,7 +360,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -383,7 +384,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -407,7 +408,7 @@ describe('Apply paragraph properties.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
diff --git a/cypress_test/integration_tests/mobile/writer/bottom_toolbar_spec.js b/cypress_test/integration_tests/mobile/writer/bottom_toolbar_spec.js
index 9915d7323..b92923e91 100644
--- a/cypress_test/integration_tests/mobile/writer/bottom_toolbar_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/bottom_toolbar_spec.js
@@ -1,6 +1,7 @@
/* global describe it cy beforeEach require afterEach expect*/
var helper = require('../../common/helper');
+var writerHelper = require('./writer_helper');
describe('Pushing bottom toolbar items.', function() {
beforeEach(function() {
@@ -10,7 +11,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#mobile-edit-button').click();
// Do a new selection
- helper.selectAllMobile();
+ writerHelper.selectAllMobile();
});
afterEach(function() {
@@ -27,7 +28,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_bold div table')
.should('have.class', 'checked');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p b')
.should('exist');
@@ -43,7 +44,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_italic div table')
.should('have.class', 'checked');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p i')
.should('exist');
@@ -59,7 +60,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_underline div table')
.should('have.class', 'checked');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p u')
.should('exist');
@@ -75,7 +76,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_strikeout div table')
.should('have.class', 'checked');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p strike')
.should('exist');
@@ -91,7 +92,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('.w2ui-tb-image.w2ui-icon.textcolor')
.should('have.attr', 'style', 'box-shadow: rgb(255, 255, 255) 0px -2px inset, rgb(0, 0, 255) 0px -6px inset;');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p font')
.should('have.attr', 'color', '#0000ff');
@@ -107,7 +108,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('.w2ui-tb-image.w2ui-icon.backcolor')
.should('have.attr', 'style', 'box-shadow: rgb(255, 255, 255) 0px -2px inset, rgb(255, 0, 255) 0px -6px inset;');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p font span')
.should('have.attr', 'style', 'background: #ff00ff');
@@ -123,7 +124,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_rightpara div table')
.should('have.class', 'checked');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('have.attr', 'align', 'right');
@@ -137,7 +138,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_leftpara div table')
.should('have.class', 'checked');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('have.attr', 'align', 'left');
@@ -153,7 +154,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_centerpara div table')
.should('have.class', 'checked');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('have.attr', 'align', 'center');
@@ -169,7 +170,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_justifypara div table')
.should('have.class', 'checked');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.should('have.attr', 'align', 'justify');
@@ -185,7 +186,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_defaultnumbering div table')
.should('have.class', 'checked');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container ol li p')
.should('exist');
@@ -201,7 +202,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_defaultbullet div table')
.should('have.class', 'checked');
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container ul li p')
.should('exist');
@@ -211,7 +212,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_incrementindent')
.click().click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -222,7 +223,7 @@ describe('Pushing bottom toolbar items.', function() {
cy.get('#tb_editbar_item_decrementindent')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
diff --git a/cypress_test/integration_tests/mobile/writer/insert_field_spec.js b/cypress_test/integration_tests/mobile/writer/insert_field_spec.js
index 5e9b14b89..05335ac92 100644
--- a/cypress_test/integration_tests/mobile/writer/insert_field_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/insert_field_spec.js
@@ -1,6 +1,7 @@
/* global describe it cy beforeEach require afterEach*/
var helper = require('../../common/helper');
+var writerHelper = require('./writer_helper');
describe('Insert fields via insertion wizard.', function() {
beforeEach(function() {
@@ -34,7 +35,7 @@ describe('Insert fields via insertion wizard.', function() {
.contains('Page Number')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p span sdfield')
.should('have.attr', 'type', 'PAGE')
@@ -47,7 +48,7 @@ describe('Insert fields via insertion wizard.', function() {
.contains('Page Count')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p span sdfield')
.should('have.attr', 'type', 'DOCSTAT')
@@ -60,7 +61,7 @@ describe('Insert fields via insertion wizard.', function() {
.contains('Date')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p span sdfield')
.should('have.attr', 'type', 'DATETIME')
@@ -73,7 +74,7 @@ describe('Insert fields via insertion wizard.', function() {
.contains('Time')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p span sdfield')
.should('have.attr', 'type', 'DATETIME')
@@ -86,7 +87,7 @@ describe('Insert fields via insertion wizard.', function() {
.contains('Title')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p span sdfield')
.should('have.attr', 'type', 'DOCINFO')
@@ -99,7 +100,7 @@ describe('Insert fields via insertion wizard.', function() {
.contains('First Author')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p span sdfield')
.should('have.attr', 'type', 'DOCINFO')
@@ -113,7 +114,7 @@ describe('Insert fields via insertion wizard.', function() {
.contains('Subject')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p span sdfield')
.should('have.attr', 'type', 'DOCINFO')
diff --git a/cypress_test/integration_tests/mobile/writer/insert_formatting_mark_spec.js b/cypress_test/integration_tests/mobile/writer/insert_formatting_mark_spec.js
index 3f83e2a1f..5154a4b90 100644
--- a/cypress_test/integration_tests/mobile/writer/insert_formatting_mark_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/insert_formatting_mark_spec.js
@@ -1,6 +1,7 @@
/* global describe it cy beforeEach require expect afterEach*/
var helper = require('../../common/helper');
+var writerHelper = require('./writer_helper');
describe('Insert formatting mark via insertion wizard.', function() {
beforeEach(function() {
@@ -33,7 +34,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
.contains('Non-breaking space')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -47,7 +48,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
.contains('Non-breaking hyphen')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -61,7 +62,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
.contains('Soft hyphen')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -75,7 +76,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
.contains('No-width optional break')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -89,7 +90,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
.contains('No-width no break')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -103,7 +104,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
.contains('Left-to-right mark')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
@@ -117,7 +118,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
.contains('Right-to-left mark')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
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 19e938fca..ca195481f 100644
--- a/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
@@ -1,6 +1,7 @@
/* global describe it cy beforeEach require expect afterEach Cypress*/
var helper = require('../../common/helper');
+var writerHelper = require('./writer_helper');
describe('Insert objects via insertion wizard.', function() {
beforeEach(function() {
@@ -77,7 +78,7 @@ describe('Insert objects via insertion wizard.', function() {
cy.get('.leaflet-marker-icon.table-column-resize-marker')
.should('exist');
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Two rows
cy.get('#copy-paste-container tr')
@@ -118,7 +119,7 @@ describe('Insert objects via insertion wizard.', function() {
cy.get('.leaflet-marker-icon.table-column-resize-marker')
.should('exist');
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Three rows
cy.get('#copy-paste-container tr')
@@ -351,7 +352,7 @@ describe('Insert objects via insertion wizard.', function() {
cy.get('.vex-content.hyperlink-dialog .vex-dialog-button-primary')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.contains('some text');
diff --git a/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js b/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js
index 47790dc47..70ea2ba08 100644
--- a/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js
@@ -1,6 +1,7 @@
/* global describe it cy beforeEach require afterEach*/
var helper = require('../../common/helper');
+var writerHelper = require('./writer_helper');
describe('Mobile wizard state tests', function() {
beforeEach(function() {
@@ -102,7 +103,7 @@ describe('Mobile wizard state tests', function() {
.should('have.class', 'checked');
// Open context wizard by right click on document
- helper.longPressOnDocument(40, 40);
+ writerHelper.longPressOnDocument(40, 40);
cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon')
.contains('Paste');
diff --git a/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js b/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js
index eb01e78e5..7802c939a 100644
--- a/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js
@@ -1,6 +1,7 @@
/* global describe it cy beforeEach require afterEach Cypress*/
var helper = require('../../common/helper');
+var writerHelper = require('./writer_helper');
describe('Change shape properties via mobile wizard.', function() {
var defaultGeometry = 'M 1965,4810 L 7957,10802 1965,10802 1965,4810 1965,4810 Z';
@@ -33,7 +34,7 @@ describe('Change shape properties via mobile wizard.', function() {
});
function triggerNewSVG() {
- helper.clearMobileWizardState();
+ writerHelper.clearMobileWizardState();
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
@@ -258,7 +259,7 @@ describe('Change shape properties via mobile wizard.', function() {
cy.get('.leaflet-pane.leaflet-overlay-pane svg g svg g g g path[fill="none"]')
.should('have.attr', 'stroke-width', '141');
- helper.clearMobileWizardState();
+ writerHelper.clearMobileWizardState();
openLinePropertyPanel();
diff --git a/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js b/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js
index fb0e86a67..a7de2b37f 100644
--- a/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js
@@ -1,6 +1,7 @@
/* global describe it cy beforeEach require afterEach expect*/
var helper = require('../../common/helper');
+var writerHelper = require('./writer_helper');
describe('Spell checking menu.', function() {
beforeEach(function() {
@@ -16,7 +17,7 @@ describe('Spell checking menu.', function() {
function openContextMenu() {
// Do a new selection
- helper.selectAllMobile();
+ writerHelper.selectAllMobile();
// Open context menu
cy.get('.leaflet-marker-icon')
@@ -38,7 +39,7 @@ describe('Spell checking menu.', function() {
var XPos = startPos.right + 10;
var YPos = endPos.top - 10;
- helper.longPressOnDocument(XPos, YPos);
+ writerHelper.longPressOnDocument(XPos, YPos);
});
cy.get('#mobile-wizard-content')
@@ -52,7 +53,7 @@ describe('Spell checking menu.', function() {
.contains('hello')
.click();
- helper.copyTextToClipboard();
+ writerHelper.copyTextToClipboard();
cy.get('#copy-paste-container p')
.then(function(item) {
diff --git a/cypress_test/integration_tests/mobile/writer/table_properties_spec.js b/cypress_test/integration_tests/mobile/writer/table_properties_spec.js
index 1d68e8f6a..0a083fb3c 100644
--- a/cypress_test/integration_tests/mobile/writer/table_properties_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/table_properties_spec.js
@@ -1,6 +1,7 @@
/* global describe it cy require afterEach expect Cypress beforeEach*/
var helper = require('../../common/helper');
+var writerHelper = require('./writer_helper');
describe('Change table properties / layout via mobile wizard.', function() {
beforeEach(function() {
@@ -37,7 +38,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
}
function moveCursorToFirstCell() {
- helper.selectAllMobile();
+ writerHelper.selectAllMobile();
cy.get('.blinking-cursor')
.then(function(cursor) {
@@ -69,7 +70,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check rows / columns
cy.get('#copy-paste-container tr')
@@ -102,7 +103,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check rows / columns
cy.get('#copy-paste-container tr')
@@ -135,7 +136,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check rows / columns
cy.get('#copy-paste-container tr')
@@ -168,7 +169,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check rows / columns
cy.get('#copy-paste-container tr')
@@ -201,7 +202,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check rows / columns
cy.get('#copy-paste-container tr')
@@ -234,7 +235,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check rows / columns
cy.get('#copy-paste-container tr')
@@ -269,7 +270,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
.click();
// Do a new selection
- helper.selectAllMobile();
+ writerHelper.selectAllMobile();
// Check markers are in the same row (we have text selection only)
cy.get('.leaflet-marker-icon')
@@ -302,7 +303,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check rows / columns
cy.get('#copy-paste-container tr')
@@ -336,7 +337,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check row height
cy.get('#copy-paste-container td')
@@ -368,7 +369,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check row height
cy.get('#copy-paste-container td')
@@ -397,7 +398,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check new row height
cy.get('#copy-paste-container td')
@@ -425,7 +426,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check new row height
cy.get('#copy-paste-container td')
@@ -463,7 +464,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check new row height
cy.get('#copy-paste-container td')
@@ -501,7 +502,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check new row height
cy.get('#copy-paste-container td')
@@ -534,7 +535,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check new row height
cy.get('#copy-paste-container td')
@@ -570,7 +571,7 @@ describe('Change table properties / layout via mobile wizard.', function() {
cy.get('#tb_actionbar_item_mobile_wizard')
.click();
- helper.copyTableToClipboard();
+ writerHelper.copyTableToClipboard();
// Check new row height
cy.get('#copy-paste-container td')
diff --git a/cypress_test/integration_tests/mobile/writer/writer_helper.js b/cypress_test/integration_tests/mobile/writer/writer_helper.js
new file mode 100644
index 000000000..28a1fb161
--- /dev/null
+++ b/cypress_test/integration_tests/mobile/writer/writer_helper.js
@@ -0,0 +1,151 @@
+/* global cy expect*/
+
+function selectAllMobile() {
+ // Remove selection if exist
+ cy.get('#document-container').click();
+ cy.get('.leaflet-marker-icon')
+ .should('not.exist');
+
+ // Enable editing if it's in read-only mode
+ cy.get('#mobile-edit-button')
+ .then(function(button) {
+ if (button.css('display') !== 'none') {
+ cy.get('#mobile-edit-button')
+ .click();
+ }
+ });
+
+ // Open hamburger menu
+ cy.get('#toolbar-hamburger')
+ .click();
+
+ // Open edit menu
+ cy.get('.ui-header.level-0 .menu-entry-with-icon')
+ .contains('Edit')
+ .click();
+
+ cy.get('.ui-header.level-1 .menu-entry-with-icon')
+ .should('be.visible')
+ .wait(100);
+
+ // Do the selection
+ cy.get('.ui-header.level-1 .menu-entry-with-icon')
+ .contains('Select All')
+ .click();
+
+ cy.get('.leaflet-marker-icon')
+ .should('exist');
+}
+
+function copyTextToClipboard() {
+ // Do a new selection
+ selectAllMobile();
+
+ // 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;
+ longPressOnDocument(XPos, YPos);
+ });
+
+ // 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');
+}
+
+function copyTableToClipboard() {
+ // Do a new selection
+ selectAllMobile();
+
+ // Open context menu
+ cy.get('.leaflet-marker-icon')
+ .then(function(markers) {
+ expect(markers.length).to.have.greaterThan(1);
+ for (var i = 0; i < markers.length; i++) {
+ if (markers[i].classList.contains('leaflet-selection-marker-start')) {
+ var startPos = markers[i].getBoundingClientRect();
+ } else if (markers[i].classList.contains('leaflet-selection-marker-end')) {
+ var endPos = markers[i].getBoundingClientRect();
+ }
+ }
+
+ var XPos = startPos.right + 10;
+ var YPos = (startPos.top + endPos.top) / 2;
+ longPressOnDocument(XPos, YPos);
+ });
+
+ // Execute copy
+ cy.get('.ui-header.level-0.mobile-wizard.ui-widget .context-menu-link .menu-entry-with-icon')
+ .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');
+}
+
+function longPressOnDocument(posX, posY) {
+ cy.get('.leaflet-pane.leaflet-map-pane')
+ .then(function(items) {
+ expect(items).have.length(1);
+
+ var eventOptions = {
+ force: true,
+ button: 0,
+ pointerType: 'mouse',
+ x: posX - items[0].getBoundingClientRect().left,
+ y: posY - items[0].getBoundingClientRect().top
+ };
+
+ cy.get('.leaflet-pane.leaflet-map-pane')
+ .trigger('pointerdown', eventOptions)
+ .trigger('pointermove', eventOptions);
+
+ cy.wait(600);
+
+ cy.get('.leaflet-pane.leaflet-map-pane')
+ .trigger('pointerup', eventOptions);
+ });
+}
+
+// Use this method when a test openes the same mobile
+// wizard more times during a test.
+// Recent issue with this scenario is that the mobile
+// wizard is opened first with an old content, then
+// when the sidebar's state arrives the wizard is
+// rerendered again which might cause a test failure
+// because the test finds the old HTML item
+// which will be detached from DOM.
+function clearMobileWizardState() {
+ // Open hamburger menu
+ cy.get('#toolbar-hamburger')
+ .click();
+
+ cy.get('.ui-header.level-0 .menu-entry-with-icon')
+ .contains('About');
+
+ // Close hamburger menu
+ cy.get('#toolbar-hamburger')
+ .click();
+}
+
+module.exports.selectAllMobile = selectAllMobile;
+module.exports.copyTextToClipboard = copyTextToClipboard;
+module.exports.copyTableToClipboard = copyTableToClipboard;
+module.exports.longPressOnDocument = longPressOnDocument;
+module.exports.clearMobileWizardState = clearMobileWizardState;
More information about the Libreoffice-commits
mailing list