cypress_test/Makefile.am | 12 cypress_test/integration_tests/common/helper.js | 70 ++++ cypress_test/integration_tests/mobile/apply_font_spec.js | 118 +------- cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js | 142 +--------- cypress_test/integration_tests/mobile/focus_spec.js | 6 cypress_test/integration_tests/mobile/insert_field_spec.js | 51 --- cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js | 49 --- cypress_test/integration_tests/mobile/insert_object_spec.js | 5 cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js | 6 cypress_test/integration_tests/mobile/toolbar_spec.js | 6 10 files changed, 153 insertions(+), 312 deletions(-)
New commits: commit 1a65e4040f3d9478e0dbec7e6e0b8bd9d25cd5c5 Author: Tamás Zolnai <[email protected]> AuthorDate: Thu Jan 30 15:17:29 2020 +0100 Commit: Tamás Zolnai <[email protected]> CommitDate: Thu Jan 30 15:24:14 2020 +0100 cypress: Check JS errors in all test code. Change-Id: Ifb33b98b5da61ac69cce91b9985e313863764d5c diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index c4addaab7..8cf139647 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -13,20 +13,20 @@ MOBILE_WORKDIR = ${abs_srcdir}/workdir/mobile/ if HAVE_LO_PATH check-local: @JAILS_PATH@ node_modules - $(call run_JS_error_check,$(abs_srcdir)) + $(call run_JS_error_check) $(call start_loolwsd) $(call run_desktop_tests) $(call run_mobile_tests) @pkill loolwsd || true check-desktop: @JAILS_PATH@ node_modules - $(call run_JS_error_check,$(abs_srcdir)/integration_tests/desktop) + $(call run_JS_error_check) $(call start_loolwsd) $(call run_desktop_tests,$(spec)) @pkill loolwsd || true check-mobile: @JAILS_PATH@ node_modules - $(call run_JS_error_check,$(abs_srcdir)/integration_tests/mobile) + $(call run_JS_error_check) $(call start_loolwsd) $(call run_mobile_tests,$(spec)) @pkill loolwsd || true @@ -52,9 +52,9 @@ run-mobile: @JAILS_PATH@ node_modules @pkill loolwsd || true define run_JS_error_check - @echo "Checking for JS errors in the next folder..." - @echo $(1) - @NODE_PATH=$(abs_srcdir)/node_modules $(NODE) node_modules/eslint/bin/eslint.js $(1) \ + @echo "Checking for JS errors in test code..." + @echo + @NODE_PATH=$(abs_srcdir)/node_modules $(NODE) node_modules/eslint/bin/eslint.js $(abs_srcdir) \ --ignore-path $(abs_srcdir)/.eslintignore --config $(abs_top_srcdir)/loleaflet/.eslintrc @echo endef commit 43e09d20bbddfd482001e88174a3b6aaa5390688 Author: Tamás Zolnai <[email protected]> AuthorDate: Thu Jan 30 14:31:10 2020 +0100 Commit: Tamás Zolnai <[email protected]> CommitDate: Thu Jan 30 15:17:39 2020 +0100 cypress: mobile: Extract after method to close document properly. Change-Id: Id88aec59546cf1bdb51630405756a4321ecabd6c diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js index 7b34f3a21..631df38b9 100644 --- a/cypress_test/integration_tests/common/helper.js +++ b/cypress_test/integration_tests/common/helper.js @@ -83,6 +83,13 @@ function copyTextToClipboard() { .should('not.exist'); } +function afterAllMobile() { + cy.visit('http://localhost:9980/loleaflet/' + + Cypress.env('WSD_VERSION_HASH') + + '/loleaflet.html?file_path=file://'); +} + module.exports.loadTestDoc = loadTestDoc; module.exports.selectAllMobile = selectAllMobile; module.exports.copyTextToClipboard = copyTextToClipboard; +module.exports.afterAllMobile = afterAllMobile; diff --git a/cypress_test/integration_tests/mobile/apply_font_spec.js b/cypress_test/integration_tests/mobile/apply_font_spec.js index 662a7275f..bbff393f2 100644 --- a/cypress_test/integration_tests/mobile/apply_font_spec.js +++ b/cypress_test/integration_tests/mobile/apply_font_spec.js @@ -19,8 +19,7 @@ describe('Apply font changes.', function() { }); afterEach(function() { - cy.get('.closemobile').click(); - cy.wait(200); // wait some time to actually release the document + helper.afterAllMobile(); }); it('Apply font name.', function() { diff --git a/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js b/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js index 43aadfe89..d41964293 100644 --- a/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js +++ b/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js @@ -23,8 +23,7 @@ describe('Apply paragraph properties.', function() { }); afterEach(function() { - cy.get('.closemobile').click(); - cy.wait(200); // wait some time to actually release the document + helper.afterAllMobile(); }); it('Apply left alignment.', function() { diff --git a/cypress_test/integration_tests/mobile/focus_spec.js b/cypress_test/integration_tests/mobile/focus_spec.js index f79e6cb4a..115632146 100644 --- a/cypress_test/integration_tests/mobile/focus_spec.js +++ b/cypress_test/integration_tests/mobile/focus_spec.js @@ -1,4 +1,4 @@ -/* global describe it cy beforeEach require*/ +/* global describe it cy beforeEach require afterEach*/ var helper = require('../common/helper'); @@ -7,6 +7,10 @@ describe('Focus tests', function() { helper.loadTestDoc('empty.odt', true); }); + afterEach(function() { + helper.afterAllMobile(); + }); + it('Focus after document fully loaded.', function() { // The document body should have the focus cy.document().its('activeElement.tagName') diff --git a/cypress_test/integration_tests/mobile/insert_field_spec.js b/cypress_test/integration_tests/mobile/insert_field_spec.js index 879bd0e5e..d1a8cf92a 100644 --- a/cypress_test/integration_tests/mobile/insert_field_spec.js +++ b/cypress_test/integration_tests/mobile/insert_field_spec.js @@ -16,8 +16,7 @@ describe('Insert fields via insertion wizard.', function() { }); afterEach(function() { - cy.get('.closemobile').click(); - cy.wait(200); // wait some time to actually release the document + helper.afterAllMobile(); }); it('Insert page number field.', function() { diff --git a/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js b/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js index b1cc38121..e29756a56 100644 --- a/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js +++ b/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js @@ -16,8 +16,7 @@ describe('Insert formatting mark via insertion wizard.', function() { }); afterEach(function() { - cy.get('.closemobile').click(); - cy.wait(200); // wait some time to actually release the document + helper.afterAllMobile(); }); it('Insert non-breaking space.', function() { diff --git a/cypress_test/integration_tests/mobile/insert_object_spec.js b/cypress_test/integration_tests/mobile/insert_object_spec.js index ba124bf74..67b53e3ac 100644 --- a/cypress_test/integration_tests/mobile/insert_object_spec.js +++ b/cypress_test/integration_tests/mobile/insert_object_spec.js @@ -16,8 +16,7 @@ describe('Insert objects via insertion wizard.', function() { }); afterEach(function() { - cy.get('.closemobile').click(); - cy.wait(200); // wait some time to actually release the document + helper.afterAllMobile(); }); it('Insert local image.', function() { diff --git a/cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js b/cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js index a679afd5a..d1a1bed04 100644 --- a/cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js +++ b/cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js @@ -1,4 +1,4 @@ -/* global describe it cy beforeEach require*/ +/* global describe it cy beforeEach require afterEach*/ var helper = require('../common/helper'); @@ -7,6 +7,10 @@ describe('Mobile wizard state tests', function() { helper.loadTestDoc('empty.odt', true); }); + afterEach(function() { + helper.afterAllMobile(); + }); + it('Open and close mobile wizard by toolbar item.', function() { // Click on edit button cy.get('#mobile-edit-button').click(); diff --git a/cypress_test/integration_tests/mobile/toolbar_spec.js b/cypress_test/integration_tests/mobile/toolbar_spec.js index 1cdee9678..94708277d 100644 --- a/cypress_test/integration_tests/mobile/toolbar_spec.js +++ b/cypress_test/integration_tests/mobile/toolbar_spec.js @@ -1,4 +1,4 @@ -/* global describe it cy beforeEach require*/ +/* global describe it cy beforeEach require afterEach*/ var helper = require('../common/helper'); @@ -7,6 +7,10 @@ describe('Toolbar tests', function() { helper.loadTestDoc('empty.odt', true); }); + afterEach(function() { + helper.afterAllMobile(); + }); + it('State of mobile wizard toolbar item.', function() { // Mobile wizard toolbar button is disabled by default cy.get('#tb_actionbar_item_mobile_wizard') commit 92f93481ddd2a73b9002e07ab30533828bc78790 Author: Tamás Zolnai <[email protected]> AuthorDate: Thu Jan 30 13:16:09 2020 +0100 Commit: Tamás Zolnai <[email protected]> CommitDate: Thu Jan 30 15:17:39 2020 +0100 cypress: mobile: Extract copy to clipboard method. Change-Id: I1c4a74b7e50a1b8dae503c8fd8af04c9a49a07b6 diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js index 6a1da3598..7b34f3a21 100644 --- a/cypress_test/integration_tests/common/helper.js +++ b/cypress_test/integration_tests/common/helper.js @@ -1,4 +1,4 @@ -/* global cy Cypress */ +/* global cy Cypress expect*/ function loadTestDoc(fileName, mobile) { // Get a clean test document @@ -56,5 +56,33 @@ function selectAllMobile() { .click(); } +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; + cy.get('body').rightclick(XPos, YPos); + }); + + // Execute copy + cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon .context-menu-link') + .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'); +} + module.exports.loadTestDoc = loadTestDoc; module.exports.selectAllMobile = selectAllMobile; +module.exports.copyTextToClipboard = copyTextToClipboard; diff --git a/cypress_test/integration_tests/mobile/apply_font_spec.js b/cypress_test/integration_tests/mobile/apply_font_spec.js index 76498b0f6..662a7275f 100644 --- a/cypress_test/integration_tests/mobile/apply_font_spec.js +++ b/cypress_test/integration_tests/mobile/apply_font_spec.js @@ -1,4 +1,4 @@ -/* global describe it cy beforeEach require expect afterEach*/ +/* global describe it cy beforeEach require afterEach*/ var helper = require('../common/helper'); @@ -23,29 +23,6 @@ describe('Apply font changes.', function() { cy.wait(200); // wait some time to actually release the document }); - function generateTextHTML() { - // Do a new selection - helper.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; - cy.get('body').rightclick(XPos, YPos); - }); - - // Execute copy - cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon .context-menu-link') - .contains('Copy') - .click(); - - // Close warning about clipboard operations - cy.get('.vex-dialog-button-primary.vex-dialog-button.vex-first') - .click(); - } - it('Apply font name.', function() { // Change font name cy.get('#fontnamecombobox') @@ -66,7 +43,7 @@ describe('Apply font changes.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p font') .should('have.attr', 'face', 'Linux Libertine G'); @@ -92,7 +69,7 @@ describe('Apply font changes.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p font') .should('have.attr', 'style', 'font-size: 36pt'); @@ -107,7 +84,7 @@ describe('Apply font changes.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p b') .should('exist'); @@ -122,7 +99,7 @@ describe('Apply font changes.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p i') .should('exist'); @@ -139,7 +116,7 @@ describe('Apply font changes.', function() { cy.get('#mobile-wizard-content') .should('not.be.visible'); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p u') .should('exist'); @@ -156,7 +133,7 @@ describe('Apply font changes.', function() { cy.get('#mobile-wizard-content') .should('not.be.visible'); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p strike') .should('exist'); @@ -173,7 +150,7 @@ describe('Apply font changes.', function() { cy.get('#mobile-wizard-content') .should('not.be.visible'); - generateTextHTML(); + helper.copyTextToClipboard(); // TODO: Shadowed is not in the clipboard content. }); @@ -189,7 +166,7 @@ describe('Apply font changes.', function() { cy.get('#mobile-wizard-content') .should('not.be.visible'); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p font') .should('have.attr', 'style', 'font-size: 42pt'); @@ -206,7 +183,7 @@ describe('Apply font changes.', function() { cy.get('#mobile-wizard-content') .should('not.be.visible'); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p font') .should('have.attr', 'style', 'font-size: 38pt'); @@ -232,7 +209,7 @@ describe('Apply font changes.', function() { cy.get('#mobile-wizard-content') .should('not.be.visible'); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p font') .should('have.attr', 'color', '#00ff00'); @@ -258,7 +235,7 @@ describe('Apply font changes.', function() { cy.get('#mobile-wizard-content') .should('not.be.visible'); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p font span') .should('have.attr', 'style', 'background: #00ff00'); @@ -275,7 +252,7 @@ describe('Apply font changes.', function() { cy.get('#mobile-wizard-content') .should('not.be.visible'); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p sup') .should('exist'); @@ -292,7 +269,7 @@ describe('Apply font changes.', function() { cy.get('#mobile-wizard-content') .should('not.be.visible'); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p sub') .should('exist'); diff --git a/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js b/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js index e1ccff74b..43aadfe89 100644 --- a/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js +++ b/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js @@ -27,29 +27,6 @@ describe('Apply paragraph properties.', function() { cy.wait(200); // wait some time to actually release the document }); - function generateTextHTML() { - // Select text - helper.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; - cy.get('body').rightclick(XPos, YPos); - }); - - // Execute copy - cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon .context-menu-link') - .contains('Copy') - .click(); - - // Close warning about clipboard operations - cy.get('.vex-dialog-button-primary.vex-dialog-button.vex-first') - .click(); - } - it('Apply left alignment.', function() { // Change alignment cy.get('#CenterPara') @@ -59,7 +36,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .should('have.attr', 'align', 'center'); @@ -83,7 +60,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .should('have.attr', 'align', 'left'); @@ -98,7 +75,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .should('have.attr', 'align', 'center'); @@ -113,7 +90,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .should('have.attr', 'align', 'right'); @@ -128,7 +105,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .should('have.attr', 'align', 'justify'); @@ -143,7 +120,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .should('have.attr', 'dir', 'rtl'); @@ -167,7 +144,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .should('not.have.attr', 'dir'); @@ -181,7 +158,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container ul li p') .should('exist'); @@ -195,7 +172,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container ol li p') .should('exist'); @@ -219,7 +196,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -239,7 +216,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -267,7 +244,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -307,7 +284,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -328,7 +305,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -355,7 +332,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -379,7 +356,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -403,7 +380,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -427,7 +404,7 @@ describe('Apply paragraph properties.', function() { cy.get('#tb_actionbar_item_mobile_wizard') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { diff --git a/cypress_test/integration_tests/mobile/insert_field_spec.js b/cypress_test/integration_tests/mobile/insert_field_spec.js index 81623212d..879bd0e5e 100644 --- a/cypress_test/integration_tests/mobile/insert_field_spec.js +++ b/cypress_test/integration_tests/mobile/insert_field_spec.js @@ -1,4 +1,4 @@ -/* global describe it cy beforeEach require expect afterEach*/ +/* global describe it cy beforeEach require afterEach*/ var helper = require('../common/helper'); @@ -20,29 +20,6 @@ describe('Insert fields via insertion wizard.', function() { cy.wait(200); // wait some time to actually release the document }); - function generateTextHTML() { - // Do a new selection - helper.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; - cy.get('body').rightclick(XPos, YPos); - }); - - // Execute copy - cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon .context-menu-link') - .contains('Copy') - .click(); - - // Close warning about clipboard operations - cy.get('.vex-dialog-button-primary.vex-dialog-button.vex-first') - .click(); - } - it('Insert page number field.', function() { // Open fields submenu cy.get('.sub-menu-title') @@ -54,7 +31,7 @@ describe('Insert fields via insertion wizard.', function() { .contains('Page Number') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p span sdfield') .should('have.attr', 'type', 'PAGE') @@ -72,7 +49,7 @@ describe('Insert fields via insertion wizard.', function() { .contains('Page Count') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p span sdfield') .should('have.attr', 'type', 'DOCSTAT') @@ -90,7 +67,7 @@ describe('Insert fields via insertion wizard.', function() { .contains('Date') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p span sdfield') .should('have.attr', 'type', 'DATETIME') @@ -108,7 +85,7 @@ describe('Insert fields via insertion wizard.', function() { .contains('Time') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p span sdfield') .should('have.attr', 'type', 'DATETIME') @@ -126,7 +103,7 @@ describe('Insert fields via insertion wizard.', function() { .contains('Title') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p span sdfield') .should('have.attr', 'type', 'DOCINFO') @@ -144,7 +121,7 @@ describe('Insert fields via insertion wizard.', function() { .contains('First Author') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p span sdfield') .should('have.attr', 'type', 'DOCINFO') @@ -163,7 +140,7 @@ describe('Insert fields via insertion wizard.', function() { .contains('Subject') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p span sdfield') .should('have.attr', 'type', 'DOCINFO') diff --git a/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js b/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js index c09f3202d..b1cc38121 100644 --- a/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js +++ b/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js @@ -20,29 +20,6 @@ describe('Insert formatting mark via insertion wizard.', function() { cy.wait(200); // wait some time to actually release the document }); - function generateTextHTML() { - // Do a new selection - helper.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; - cy.get('body').rightclick(XPos, YPos); - }); - - // Execute copy - cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon .context-menu-link') - .contains('Copy') - .click(); - - // Close warning about clipboard operations - cy.get('.vex-dialog-button-primary.vex-dialog-button.vex-first') - .click(); - } - it('Insert non-breaking space.', function() { // Open formatting marks cy.get('.sub-menu-title') @@ -54,7 +31,7 @@ describe('Insert formatting mark via insertion wizard.', function() { .contains('Non-breaking space') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -74,7 +51,7 @@ describe('Insert formatting mark via insertion wizard.', function() { .contains('Non-breaking hyphen') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -94,7 +71,7 @@ describe('Insert formatting mark via insertion wizard.', function() { .contains('Soft hyphen') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -114,7 +91,7 @@ describe('Insert formatting mark via insertion wizard.', function() { .contains('No-width optional break') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -134,7 +111,7 @@ describe('Insert formatting mark via insertion wizard.', function() { .contains('No-width no break') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -154,7 +131,7 @@ describe('Insert formatting mark via insertion wizard.', function() { .contains('Left-to-right mark') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { @@ -174,7 +151,7 @@ describe('Insert formatting mark via insertion wizard.', function() { .contains('Right-to-left mark') .click(); - generateTextHTML(); + helper.copyTextToClipboard(); cy.get('#copy-paste-container p') .then(function(item) { commit 8d906e4b1a32250b145421d9b87352faf92db573 Author: Tamás Zolnai <[email protected]> AuthorDate: Thu Jan 30 12:39:09 2020 +0100 Commit: Tamás Zolnai <[email protected]> CommitDate: Thu Jan 30 15:17:39 2020 +0100 cypress: mobile: Extract selection method. Change-Id: I0fb69a9f5acf90ce76951a83b4220ac52e550fb2 diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js index e4cc9cc39..6a1da3598 100644 --- a/cypress_test/integration_tests/common/helper.js +++ b/cypress_test/integration_tests/common/helper.js @@ -24,4 +24,37 @@ function loadTestDoc(fileName, 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 .sub-menu-title') + .contains('Edit') + .click(); + + cy.wait(200); + + // Do the selection + cy.get('.ui-header.level-1 .menu-entry-with-icon') + .contains('Select All') + .click(); +} + module.exports.loadTestDoc = loadTestDoc; +module.exports.selectAllMobile = selectAllMobile; diff --git a/cypress_test/integration_tests/mobile/apply_font_spec.js b/cypress_test/integration_tests/mobile/apply_font_spec.js index ad8153e8f..76498b0f6 100644 --- a/cypress_test/integration_tests/mobile/apply_font_spec.js +++ b/cypress_test/integration_tests/mobile/apply_font_spec.js @@ -9,6 +9,9 @@ describe('Apply font changes.', function() { // Click on edit button cy.get('#mobile-edit-button').click(); + // Do a new selection + helper.selectAllMobile(); + // Open mobile wizard cy.get('#tb_actionbar_item_mobile_wizard') .should('not.have.class', 'disabled') @@ -22,16 +25,7 @@ describe('Apply font changes.', function() { function generateTextHTML() { // Do a new selection - cy.get('#document-container').click(); - cy.get('.leaflet-marker-icon') - .should('not.exist'); - - cy.wait(200); - - cy.get('body').type('{shift}{home}'); - cy.get('.leaflet-marker-icon'); - - cy.wait(200); + helper.selectAllMobile(); // Open context menu cy.get('.leaflet-marker-icon') @@ -53,10 +47,6 @@ describe('Apply font changes.', function() { } it('Apply font name.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change font name cy.get('#fontnamecombobox') .click(); @@ -83,10 +73,6 @@ describe('Apply font changes.', function() { }); it('Apply font size.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change font size cy.get('#fontsizecombobox') .click(); @@ -113,10 +99,6 @@ describe('Apply font changes.', function() { }); it('Apply bold font.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Apply bold cy.get('#Bold') .click(); @@ -132,10 +114,6 @@ describe('Apply font changes.', function() { }); it('Apply italic font.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Apply italic cy.get('#Italic') .click(); @@ -151,10 +129,6 @@ describe('Apply font changes.', function() { }); it('Apply underline.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change underline cy.get('#Underlineimg') .click(); @@ -172,10 +146,6 @@ describe('Apply font changes.', function() { }); it('Apply strikeout.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change strikeout cy.get('#Strikeoutimg') .click(); @@ -193,10 +163,6 @@ describe('Apply font changes.', function() { }); it('Apply shadowed.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Apply shadowed cy.get('#Shadowedimg') .click(); @@ -213,10 +179,6 @@ describe('Apply font changes.', function() { }); it('Apply grow.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Push grow cy.get('#Growimg') .click(); @@ -234,10 +196,6 @@ describe('Apply font changes.', function() { }); it('Apply shrink.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Push shrink cy.get('#Shrinkimg') .click(); @@ -255,10 +213,6 @@ describe('Apply font changes.', function() { }); it('Apply font color.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change font color cy.get('#FontColor') .click(); @@ -285,10 +239,6 @@ describe('Apply font changes.', function() { }); it('Apply highlight color.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change highlight color cy.get('#BackColor') .click(); @@ -315,10 +265,6 @@ describe('Apply font changes.', function() { }); it('Apply superscript.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Apply superscript cy.get('#SuperScriptimg') .click(); @@ -336,10 +282,6 @@ describe('Apply font changes.', function() { }); it('Apply subscript.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Apply superscript cy.get('#SubScriptimg') .click(); diff --git a/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js b/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js index 1660bec7e..e1ccff74b 100644 --- a/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js +++ b/cypress_test/integration_tests/mobile/apply_paragraph_properties_spec.js @@ -9,6 +9,9 @@ describe('Apply paragraph properties.', function() { // Click on edit button cy.get('#mobile-edit-button').click(); + // Do a selection + helper.selectAllMobile(); + // Open mobile wizard cy.get('#tb_actionbar_item_mobile_wizard') .should('not.have.class', 'disabled') @@ -25,17 +28,8 @@ describe('Apply paragraph properties.', function() { }); function generateTextHTML() { - // Do a new selection - cy.get('#document-container').click(); - cy.get('.leaflet-marker-icon') - .should('not.exist'); - - cy.wait(200); - - cy.get('body').type('{shift}{home}'); - cy.get('.leaflet-marker-icon'); - - cy.wait(200); + // Select text + helper.selectAllMobile(); // Open context menu cy.get('.leaflet-marker-icon') @@ -57,10 +51,6 @@ describe('Apply paragraph properties.', function() { } it('Apply left alignment.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change alignment cy.get('#CenterPara') .click(); @@ -75,8 +65,7 @@ describe('Apply paragraph properties.', function() { .should('have.attr', 'align', 'center'); // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); + helper.selectAllMobile(); // Open mobile wizard cy.get('#tb_actionbar_item_mobile_wizard') @@ -101,10 +90,6 @@ describe('Apply paragraph properties.', function() { }); it('Apply center alignment.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change alignment cy.get('#CenterPara') .click(); @@ -120,10 +105,6 @@ describe('Apply paragraph properties.', function() { }); it('Apply right alignment.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change alignment cy.get('#RightPara') .click(); @@ -139,10 +120,6 @@ describe('Apply paragraph properties.', function() { }); it('Apply justify alignment.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change alignment cy.get('#JustifyPara') .click(); @@ -158,10 +135,6 @@ describe('Apply paragraph properties.', function() { }); it('Change writing direction.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change writing mode cy.get('#ParaRightToLeft') .click(); @@ -176,8 +149,7 @@ describe('Apply paragraph properties.', function() { .should('have.attr', 'dir', 'rtl'); // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); + helper.selectAllMobile(); // Open mobile wizard cy.get('#tb_actionbar_item_mobile_wizard') @@ -202,10 +174,6 @@ describe('Apply paragraph properties.', function() { }); it('Apply default bulleting.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - cy.get('#DefaultBullet') .click(); @@ -220,10 +188,6 @@ describe('Apply paragraph properties.', function() { }); it('Apply default numbering.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - cy.get('#DefaultNumbering') .click(); @@ -238,10 +202,6 @@ describe('Apply paragraph properties.', function() { }); it('Apply background color.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change background color cy.get('#BackgroundColor') .click(); @@ -269,10 +229,6 @@ describe('Apply paragraph properties.', function() { }); it('Increase / decrease para spacing.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Increase para spacing cy.get('#ParaspaceIncrease') .click(); @@ -293,8 +249,7 @@ describe('Apply paragraph properties.', function() { }); // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); + helper.selectAllMobile(); // Open mobile wizard cy.get('#tb_actionbar_item_mobile_wizard') @@ -323,10 +278,6 @@ describe('Apply paragraph properties.', function() { }); it('Change para spacing via combobox.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Check para spacing current value cy.get('#aboveparaspacing .spinfield') .should('have.attr', 'value', '0.0'); @@ -367,10 +318,6 @@ describe('Apply paragraph properties.', function() { }); it('Increase / decrease indent.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Increase indent cy.get('#IncrementIndent') .click(); @@ -390,8 +337,7 @@ describe('Apply paragraph properties.', function() { }); // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); + helper.selectAllMobile(); // Open mobile wizard cy.get('#tb_actionbar_item_mobile_wizard') @@ -419,10 +365,6 @@ describe('Apply paragraph properties.', function() { }); it('Apply before text indent.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change indent cy.get('#beforetextindent .sinfieldcontrols .plus') .click(); @@ -447,10 +389,6 @@ describe('Apply paragraph properties.', function() { }); it('Apply after text indent.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Change indent cy.get('#aftertextindent .sinfieldcontrols .plus') .click(); @@ -475,10 +413,6 @@ describe('Apply paragraph properties.', function() { }); it('Apply first line indent.', function() { - // Select text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - // Increase firstline indent cy.get('#firstlineindent .sinfieldcontrols .plus') .click(); diff --git a/cypress_test/integration_tests/mobile/insert_field_spec.js b/cypress_test/integration_tests/mobile/insert_field_spec.js index 65e4b732f..81623212d 100644 --- a/cypress_test/integration_tests/mobile/insert_field_spec.js +++ b/cypress_test/integration_tests/mobile/insert_field_spec.js @@ -22,16 +22,7 @@ describe('Insert fields via insertion wizard.', function() { function generateTextHTML() { // Do a new selection - cy.get('#document-container').click(); - cy.get('.leaflet-marker-icon') - .should('not.exist'); - - cy.wait(200); - - cy.get('body').type('{shift}{home}'); - cy.get('.leaflet-marker-icon'); - - cy.wait(200); + helper.selectAllMobile(); // Open context menu cy.get('.leaflet-marker-icon') diff --git a/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js b/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js index 76a68f62e..c09f3202d 100644 --- a/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js +++ b/cypress_test/integration_tests/mobile/insert_formatting_mark_spec.js @@ -22,16 +22,7 @@ describe('Insert formatting mark via insertion wizard.', function() { function generateTextHTML() { // Do a new selection - cy.get('#document-container').click(); - cy.get('.leaflet-marker-icon') - .should('not.exist'); - - cy.wait(200); - - cy.get('body').type('{shift}{home}'); - cy.get('.leaflet-marker-icon'); - - cy.wait(200); + helper.selectAllMobile(); // Open context menu cy.get('.leaflet-marker-icon') commit d95f76438e08c3a454146bec2397c8c0eb00451b Author: Tamás Zolnai <[email protected]> AuthorDate: Wed Jan 29 20:26:43 2020 +0100 Commit: Tamás Zolnai <[email protected]> CommitDate: Thu Jan 30 15:17:39 2020 +0100 cypress: mobile: Remove accidentally pushed it.only() Change-Id: Ib6d747de11be654a86580993f4576d7c329423c1 diff --git a/cypress_test/integration_tests/mobile/insert_object_spec.js b/cypress_test/integration_tests/mobile/insert_object_spec.js index 3fdbeffa9..ba124bf74 100644 --- a/cypress_test/integration_tests/mobile/insert_object_spec.js +++ b/cypress_test/integration_tests/mobile/insert_object_spec.js @@ -134,7 +134,7 @@ describe('Insert objects via insertion wizard.', function() { }); }); - it.only('Insert footer.', function() { + it('Insert footer.', function() { // Get the blinking cursor pos cy.get('#document-container').type('xxxx'); var cursorOrigTop = 0; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
