cypress_test/data/desktop/empty.odt |binary cypress_test/data/mobile/empty.odt |binary cypress_test/integration_tests/common/helper.js | 25 cypress_test/integration_tests/desktop/copy_paste_spec.js | 35 + cypress_test/integration_tests/desktop/example_desktop_test_spec.js | 20 cypress_test/integration_tests/desktop/example_desktop_test_spec2.js | 41 - cypress_test/integration_tests/desktop/shape_operations_spec.js | 30 + cypress_test/integration_tests/mobile/focus_spec.js | 21 cypress_test/integration_tests/mobile/insert_object_spec.js | 265 ++++++++++ cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js | 21 cypress_test/integration_tests/mobile/toolbar_spec.js | 21 11 files changed, 371 insertions(+), 108 deletions(-)
New commits: commit 38d2bd876837c293e81b7e383c30421798559b01 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Sun Jan 26 06:33:14 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Sun Jan 26 06:42:53 2020 +0100 cypress: mobile: Basic tests of insertion mobile wizard. Change-Id: I2c2b2406ae390856c001dff1b4827586a40e05be diff --git a/cypress_test/integration_tests/mobile/insert_object_spec.js b/cypress_test/integration_tests/mobile/insert_object_spec.js new file mode 100644 index 000000000..ef551323e --- /dev/null +++ b/cypress_test/integration_tests/mobile/insert_object_spec.js @@ -0,0 +1,265 @@ +/* global describe it cy beforeEach require expect afterEach*/ + +var helper = require('../common/helper'); + +describe('Insert objects via insertion wizard.', function() { + beforeEach(function() { + helper.loadTestDoc('empty.odt', true); + + // Click on edit button + cy.get('#mobile-edit-button').click(); + + // Open insertion wizard + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .should('not.have.class', 'disabled') + .click(); + }); + + afterEach(function() { + cy.get('.closemobile').click(); + cy.wait(200); // wait some time to actually release the document + }); + + it('Insert local image.', function() { + // We check whether the entry is there + cy.get('.menu-entry-with-icon') + .contains('Local Image...'); + // We not not test the insertion, it might depend on the system. + }); + + it('Insert comment.', function() { + cy.get('.menu-entry-with-icon') + .contains('Comment') + .click(); + + // Comment insertion dialog is opened + cy.get('.loleaflet-annotation-table') + .should('exist'); + + // Push cancel to close the dialog + cy.get('.vex-dialog-button-secondary.vex-dialog-button.vex-last') + .click(); + // TODO: fix console error here + }); + + it('Insert table.', function() { + // Open Table submenu + cy.get('.sub-menu-title') + .contains('Table') + .click(); + cy.get('.mobile-wizard.ui-text') + .should('be.visible'); + + // Scroll to the bottom + cy.get('#mobile-wizard-content').scrollTo(0, 1000); + + // Push insert table button + cy.get('.inserttablecontrols button') + .should('be.visible') + .click(); + + // Table is inserted with the markers shown + cy.get('.leaflet-marker-icon.table-column-resize-marker') + .should('exist') + .should('have.length', 3); + cy.get('.leaflet-marker-icon.table-row-resize-marker') + .should('exist') + .should('have.length', 2); + }); + + it('Insert field.', function() { + // Open fields submenu + cy.get('.sub-menu-title') + .contains('More Fields...') + .click(); + cy.get('.menu-entry-with-icon') + .contains('Page Number') + .click(); + + // Do a selection to see something is inserted + cy.get('body').type('{shift}{leftarrow}'); + cy.get('.leaflet-marker-icon') + .should('exist') + .should('have.length', 2); + }); + + it('Insert header.', function() { + // Get the blinking cursor pos + cy.get('#document-container').type('xxxx'); + var cursorOrigLeft = 0; + cy.get('.blinking-cursor') + .then(function(cursor) { + expect(cursor).to.have.lengthOf(1) ; + cursorOrigLeft = cursor[0].getBoundingClientRect().left; + }); + + // Open header/footer submenu + cy.get('.sub-menu-title') + .contains('Header and Footer') + .click(); + cy.get('.ui-header.level-1.mobile-wizard.ui-widget') + .should('be.visible'); + + // Open header submenu + cy.get('.ui-header.level-1.mobile-wizard.ui-widget .sub-menu-title') + .contains('Header') + .click(); + + // Insert header for All + cy.get('.menu-entry-no-icon') + .contains('All') + .click(); + + cy.wait(100); + + // Check that the cursor was moved + cy.get('.blinking-cursor') + .then(function(cursor) { + expect(cursor).to.have.lengthOf(1); + expect(cursor[0].getBoundingClientRect().left).to.be.lessThan(cursorOrigLeft); + }); + }); + + it('Insert footnote.', function() { + // Get the blinking cursor pos + cy.get('#document-container').type('xxxx'); + var cursorOrigTop = 0; + cy.get('.blinking-cursor') + .then(function(cursor) { + expect(cursor).to.have.lengthOf(1); + cursorOrigTop = cursor[0].getBoundingClientRect().top; + }); + + // Insert footnote + cy.get('.menu-entry-with-icon') + .contains('Footnote') + .click(); + + cy.wait(100); + + // Check that the cursor was moved down + cy.get('.blinking-cursor') + .then(function(cursor) { + expect(cursor).to.have.lengthOf(1); + expect(cursor[0].getBoundingClientRect().top).to.be.greaterThan(cursorOrigTop); + }); + }); + + it('Insert endnote.', function() { + // Get the blinking cursor pos + cy.get('#document-container').type('xxxx'); + var cursorOrigTop = 0; + cy.get('.blinking-cursor') + .then(function(cursor) { + expect(cursor).to.have.lengthOf(1); + cursorOrigTop = cursor[0].getBoundingClientRect().top; + }); + + // Insert endnote + cy.get('.menu-entry-with-icon') + .contains('Endnote') + .click(); + + cy.wait(100); + + // Check that the cursor was moved down + cy.get('.blinking-cursor') + .then(function(cursor) { + expect(cursor).to.have.lengthOf(1); + expect(cursor[0].getBoundingClientRect().top).to.be.greaterThan(cursorOrigTop); + }); + }); + + it('Insert page break.', function() { + // Get the blinking cursor pos + cy.get('#document-container').type('xxxx'); + var cursorOrigTop = 0; + cy.get('.blinking-cursor') + .then(function(cursor) { + expect(cursor).to.have.lengthOf(1); + cursorOrigTop = cursor[0].getBoundingClientRect().top; + }); + + // Insert endnote + cy.get('.menu-entry-with-icon') + .contains('Page Break') + .click(); + + cy.wait(100); + + // Check that the cursor was moved down + cy.get('.blinking-cursor') + .then(function(cursor) { + expect(cursor).to.have.lengthOf(1); + expect(cursor[0].getBoundingClientRect().top).to.be.greaterThan(cursorOrigTop); + }); + }); + + it('Insert column break.', function() { + // Get the blinking cursor pos + cy.get('#document-container').type('xxxx'); + var cursorOrigTop = 0; + cy.get('.blinking-cursor') + .then(function(cursor) { + expect(cursor).to.have.lengthOf(1); + cursorOrigTop = cursor[0].getBoundingClientRect().top; + }); + + // Do insertion + cy.get('.menu-entry-with-icon') + .contains('Column Break') + .click(); + + cy.wait(100); + + // Check that the cursor was moved down + cy.get('.blinking-cursor') + .then(function(cursor) { + expect(cursor).to.have.lengthOf(1); + expect(cursor[0].getBoundingClientRect().top).to.be.greaterThan(cursorOrigTop); + }); + }); + + it('Insert hyperlink.', function() { + // Open hyperlink dialog + cy.get('.menu-entry-with-icon') + .contains('Hyperlink...') + .click(); + + // Dialog is opened + cy.get('.vex-content.hyperlink-dialog') + .should('exist'); + + // Push cancel to close the dialog + cy.get('.vex-dialog-button-secondary.vex-dialog-button.vex-last') + .click(); + }); + + it('Insert shape.', function() { + // Do insertion + // TODO: it crashes + cy.get('.menu-entry-with-icon') + .contains('Shape') + .click(); + // regression from: 298f4297c21f4b7cd5836b90bafcc803f13adb00 + }); + + it('Insert formatting mark.', function() { + // Open formatting marks + cy.get('.sub-menu-title') + .contains('Formatting Mark') + .click(); + + // Do the insertion + cy.get('.menu-entry-no-icon') + .contains('Non-breaking space') + .should('be.visible') + .click(); + + // Do a selection to see something is inserted + cy.get('body').type('{shift}{leftarrow}'); + cy.get('.leaflet-marker-icon') + .should('exist') + .should('have.length', 2); + }); +}); commit 4bbcd50bc82b541f92eacf177c3878373cfdfd04 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Sun Jan 26 03:24:35 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Sun Jan 26 06:42:53 2020 +0100 cypress: Make empty.odt test docs actually empty. Change-Id: Ib6ab2da2b5dd2fa48b3aeedb8760a0acf5b6b5d7 diff --git a/cypress_test/data/desktop/empty.odt b/cypress_test/data/desktop/empty.odt index b8fe3d9dc..c9e0377fd 100644 Binary files a/cypress_test/data/desktop/empty.odt and b/cypress_test/data/desktop/empty.odt differ diff --git a/cypress_test/data/mobile/empty.odt b/cypress_test/data/mobile/empty.odt index b8fe3d9dc..550752605 100644 Binary files a/cypress_test/data/mobile/empty.odt and b/cypress_test/data/mobile/empty.odt differ commit 517ebe5f2faebc4c6a7c22994b61bc7b899b89aa Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Sat Jan 25 20:39:52 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Sun Jan 26 06:42:38 2020 +0100 cypress: Add a test case of shape insertion. Change-Id: Ic76be157b6fb61c1fbc098ab4d2e627f9b25664e diff --git a/cypress_test/data/desktop/empty.odt b/cypress_test/data/desktop/empty.odt new file mode 100644 index 000000000..b8fe3d9dc Binary files /dev/null and b/cypress_test/data/desktop/empty.odt differ diff --git a/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js b/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js deleted file mode 100644 index 7425d4871..000000000 --- a/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js +++ /dev/null @@ -1,29 +0,0 @@ -/* global describe it cy require*/ - -var helper = require('../common/helper'); - -describe('Example test suit 2', function() { - it('Example test case 1', function() { - helper.loadTestDoc('simple.odt'); - - // Select a text - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - - // Click on bold toolbar button - cy.get('#tb_editbar_item_italic').click(); - - // Remove selection and do a reselection - cy.get('#document-container').click(); - cy.get('.leaflet-marker-icon').should('not.be.visible'); - - cy.get('#document-container').dblclick(); - cy.get('.leaflet-marker-icon'); - - // Bold toolbar button is checked - cy.get('#tb_editbar_item_italic table.w2ui-button.checked'); - - // Click on bold toolbar button - cy.get('#tb_editbar_item_italic').click(); - }); -}); diff --git a/cypress_test/integration_tests/desktop/shape_operations_spec.js b/cypress_test/integration_tests/desktop/shape_operations_spec.js new file mode 100644 index 000000000..afeaf79b3 --- /dev/null +++ b/cypress_test/integration_tests/desktop/shape_operations_spec.js @@ -0,0 +1,30 @@ +/* global describe it cy require expect*/ + +var helper = require('../common/helper'); + +describe('Shape operations', function() { + it('Insert a simple shape.', function() { + helper.loadTestDoc('empty.odt'); + + // Scroll on the up toolbar + cy.get('#toolbar-up .w2ui-scroll-right').click(); + cy.get('.w2ui-tb-image.w2ui-icon.basicshapes_ellipse') + .should('be.visible') + .click(); + + // Insert a rectangle + cy.get('.col.w2ui-icon.basicshapes_rectangle') + .click({force : true}); + + cy.get('.leaflet-pane.leaflet-overlay-pane svg g') + .should('exist'); + + // Check whether the rectangle was inserted as an SVG + cy.get('.leaflet-pane.leaflet-overlay-pane svg') + .then(function(svg) { + expect(svg).to.have.lengthOf(1); + expect(svg[0].getBBox().width).to.be.greaterThan(0); + expect(svg[0].getBBox().height).to.be.greaterThan(0); + }); + }); +}); commit 18511101392846319453f02d5b82b55017ae19f4 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Sat Jan 25 19:28:17 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Sun Jan 26 02:41:06 2020 +0100 cypress: Add an example for copy-ing. Unfortunatly cypress does not support clipboard events by now. Change-Id: Iffdaf0f15275ecb27aa3ebf2731c72cf4bdd46de diff --git a/cypress_test/integration_tests/desktop/copy_paste_spec.js b/cypress_test/integration_tests/desktop/copy_paste_spec.js new file mode 100644 index 000000000..015905d31 --- /dev/null +++ b/cypress_test/integration_tests/desktop/copy_paste_spec.js @@ -0,0 +1,35 @@ +/* global describe it cy beforeEach require expect*/ + +var helper = require('../common/helper'); + +describe('Clipboard operations.', function() { + beforeEach(function() { + helper.loadTestDoc('simple.odt'); + }); + + it('Copy and Paste text.', function() { + // Select some text + cy.get('#document-container').dblclick(); + cy.get('.leaflet-marker-icon') + .should('exist'); + + 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.wait(200); + cy.get('body').rightclick(XPos, YPos); + }); + + cy.get('.context-menu-list').should('be.visible') + .get('.context-menu-item .context-menu-link') + .contains('Copy') + .click(); + + // Loleaflet code can not execute document.execCommand() when executed by cypress + // https://github.com/cypress-io/cypress/issues/2851 + cy.get('.vex-dialog-message p') + .contains('Your browser has very limited access to the clipboard, so use these keyboard shortcuts:'); + }); +}); commit b64907e918ae621e2b10872531018f185382dfdf Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Fri Jan 24 17:13:51 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Sun Jan 26 02:41:06 2020 +0100 cypress: Extract test document loading code. Change-Id: I77b2097bd9406ec63fbb9133678456444457ca2b diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js new file mode 100644 index 000000000..5ecd678a8 --- /dev/null +++ b/cypress_test/integration_tests/common/helper.js @@ -0,0 +1,25 @@ +/* global cy Cypress */ + +function loadTestDoc(fileName, mobile) { + // Get a clean test document + cy.task('copyFile', { + sourceDir: Cypress.env('DATA_FOLDER'), + destDir: Cypress.env('WORKDIR'), + fileName: fileName, + }); + + if (mobile === true) { + cy.viewport('iphone-3'); + } + + // Open test document + cy.visit('http://localhost:9980/loleaflet/' + + Cypress.env('WSD_VERSION_HASH') + + '/loleaflet.html?file_path=file://' + + Cypress.env('WORKDIR') + fileName); + + // Wait for the document to fully load + cy.get('.leaflet-tile-loaded', {timeout : 10000}); +} + +module.exports.loadTestDoc = loadTestDoc; diff --git a/cypress_test/integration_tests/desktop/example_desktop_test_spec.js b/cypress_test/integration_tests/desktop/example_desktop_test_spec.js index 49db7b13d..dafad9dad 100644 --- a/cypress_test/integration_tests/desktop/example_desktop_test_spec.js +++ b/cypress_test/integration_tests/desktop/example_desktop_test_spec.js @@ -1,22 +1,10 @@ -/* global describe it cy Cypress */ +/* global describe it cy require*/ + +var helper = require('../common/helper'); describe('Example test suit 1', function() { it('Example test case 1', function() { - // Get a clean test document - cy.task('copyFile', { - sourceDir: Cypress.env('DATA_FOLDER'), - destDir: Cypress.env('WORKDIR'), - fileName: 'simple.odt', - }); - - // Open test document - cy.visit('http://localhost:9980/loleaflet/' + - Cypress.env('WSD_VERSION_HASH') + - '/loleaflet.html?file_path=file://' + - Cypress.env('WORKDIR') + 'simple.odt'); - - // Wait for the document to fully load - cy.get('.leaflet-tile-loaded', {timeout : 10000}); + helper.loadTestDoc('simple.odt'); // Select a text cy.get('#document-container').dblclick(); diff --git a/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js b/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js index 125ef1b74..7425d4871 100644 --- a/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js +++ b/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js @@ -1,22 +1,10 @@ -/* global describe it cy Cypress */ +/* global describe it cy require*/ + +var helper = require('../common/helper'); describe('Example test suit 2', function() { it('Example test case 1', function() { - // Get a clean test document - cy.task('copyFile', { - sourceDir: Cypress.env('DATA_FOLDER'), - destDir: Cypress.env('WORKDIR'), - fileName: 'simple.odt', - }); - - // Open test document - cy.visit('http://localhost:9980/loleaflet/' + - Cypress.env('WSD_VERSION_HASH') + - '/loleaflet.html?file_path=file://' + - Cypress.env('WORKDIR') + 'simple.odt'); - - // Wait for the document to fully load - cy.get('.leaflet-tile-loaded', {timeout : 10000}); + helper.loadTestDoc('simple.odt'); // Select a text cy.get('#document-container').dblclick(); diff --git a/cypress_test/integration_tests/mobile/focus_spec.js b/cypress_test/integration_tests/mobile/focus_spec.js index 99a15cb94..f79e6cb4a 100644 --- a/cypress_test/integration_tests/mobile/focus_spec.js +++ b/cypress_test/integration_tests/mobile/focus_spec.js @@ -1,23 +1,10 @@ -/* global describe it cy Cypress beforeEach*/ +/* global describe it cy beforeEach require*/ + +var helper = require('../common/helper'); describe('Focus tests', function() { beforeEach(function() { - // Get a clean test document - cy.task('copyFile', { - sourceDir: Cypress.env('DATA_FOLDER'), - destDir: Cypress.env('WORKDIR'), - fileName: 'empty.odt', - }); - - // Open test document - cy.viewport('iphone-3'); - cy.visit('http://localhost:9980/loleaflet/' + - Cypress.env('WSD_VERSION_HASH') + - '/loleaflet.html?file_path=file://' + - Cypress.env('WORKDIR') + 'empty.odt'); - - // Wait for the document to fully load - cy.get('.leaflet-tile-loaded', {timeout : 10000}); + helper.loadTestDoc('empty.odt', true); }); it('Focus after document fully loaded.', 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 3d9e15ebd..a679afd5a 100644 --- a/cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js +++ b/cypress_test/integration_tests/mobile/mobile_wizard_state_spec.js @@ -1,23 +1,10 @@ -/* global describe it cy Cypress beforeEach*/ +/* global describe it cy beforeEach require*/ + +var helper = require('../common/helper'); describe('Mobile wizard state tests', function() { beforeEach(function() { - // Get a clean test document - cy.task('copyFile', { - sourceDir: Cypress.env('DATA_FOLDER'), - destDir: Cypress.env('WORKDIR'), - fileName: 'empty.odt', - }); - - // Open test document - cy.viewport('iphone-3'); - cy.visit('http://localhost:9980/loleaflet/' + - Cypress.env('WSD_VERSION_HASH') + - '/loleaflet.html?file_path=file://' + - Cypress.env('WORKDIR') + 'empty.odt'); - - // Wait for the document to fully load - cy.get('.leaflet-tile-loaded', {timeout : 10000}); + helper.loadTestDoc('empty.odt', true); }); it('Open and close mobile wizard by toolbar item.', function() { diff --git a/cypress_test/integration_tests/mobile/toolbar_spec.js b/cypress_test/integration_tests/mobile/toolbar_spec.js index c42b58f78..1cdee9678 100644 --- a/cypress_test/integration_tests/mobile/toolbar_spec.js +++ b/cypress_test/integration_tests/mobile/toolbar_spec.js @@ -1,23 +1,10 @@ -/* global describe it cy Cypress beforeEach*/ +/* global describe it cy beforeEach require*/ + +var helper = require('../common/helper'); describe('Toolbar tests', function() { beforeEach(function() { - // Get a clean test document - cy.task('copyFile', { - sourceDir: Cypress.env('DATA_FOLDER'), - destDir: Cypress.env('WORKDIR'), - fileName: 'empty.odt', - }); - - // Open test document - cy.viewport('iphone-3'); - cy.visit('http://localhost:9980/loleaflet/' + - Cypress.env('WSD_VERSION_HASH') + - '/loleaflet.html?file_path=file://' + - Cypress.env('WORKDIR') + 'empty.odt'); - - // Wait for the document to fully load - cy.get('.leaflet-tile-loaded', {timeout : 10000}); + helper.loadTestDoc('empty.odt', true); }); it('State of mobile wizard toolbar item.', function() { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits