cypress_test/.eslintignore | 2 cypress_test/.gitignore | 3 cypress_test/Makefile.am | 56 + cypress_test/README | 15 cypress_test/cypress.json | 4 cypress_test/data/desktop/simple.odt |binary cypress_test/data/mobile/empty.odt |binary cypress_test/integration_tests/desktop/example_desktop_test_spec.js | 50 - cypress_test/integration_tests/desktop/example_desktop_test_spec2.js | 50 - cypress_test/integration_tests/mobile/toolbar_spec.js | 392 +++++----- cypress_test/package.json | 4 cypress_test/plugins/index.js | 13 cypress_test/plugins/tasks.js | 19 13 files changed, 357 insertions(+), 251 deletions(-)
New commits: commit 504cc5296478aee08d53ec3b2bd04e9ea98c4bad Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Tue Jan 14 19:37:17 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Jan 14 19:40:41 2020 +0100 cypress: Introduce make rules for running group of tests. It can handle dependencies and can use environment variables. Change-Id: Ib386cb7019d85b3dbd6c28417b3a481944b18aca diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index 5af4c338e..529939da9 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -7,11 +7,34 @@ MOBILE_USER_AGENT = "cypress mobile test" if HAVE_LO_PATH check-local: @JAILS_PATH@ @npm install - @echo "Checking for loleaflet JS errors..." - @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 + $(call run_JS_error_check) + $(call start_loolwsd) + $(call run_desktop_tests) + $(call run_mobile_tests) + @pkill loolwsd || true + +check-desktop: @JAILS_PATH@ + @npm install + $(call run_JS_error_check) + $(call start_loolwsd) + $(call run_desktop_tests) + @pkill loolwsd || true + +check-mobile: @JAILS_PATH@ + @npm install + $(call run_JS_error_check) + $(call start_loolwsd) + $(call run_mobile_tests) + @pkill loolwsd || true +define run_JS_error_check + @echo "Checking for cypress JS errors..." + @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 + +define start_loolwsd @pkill loolwsd || true @echo "Launching loolwsd for testing.." @fc-cache "@LO_PATH@"/share/fonts/truetype @@ -25,6 +48,10 @@ check-local: @JAILS_PATH@ --o:logging.file[@enable]=true --o:logging.level=trace > /dev/null 2>&1 & @sleep 10 @echo +endef + +define run_desktop_tests + @echo @echo "Running cypress desktop tests..." @echo $(CYPRESS_BINARY) run --browser chrome \ @@ -32,6 +59,9 @@ check-local: @JAILS_PATH@ --headless \ --env DATA_FOLDER=$(abs_srcdir)/data/desktop/,WORKDIR=$(abs_srcdir)/workdir/desktop/ || \ (pkill loolwsd && false) +endef + +define run_mobile_tests @echo @echo "Running cypress mobile tests..." @echo @@ -40,7 +70,8 @@ check-local: @JAILS_PATH@ --headless \ --env DATA_FOLDER=$(abs_srcdir)/data/mobile/,WORKDIR=$(abs_srcdir)/workdir/mobile/ || \ (pkill loolwsd && false) - @pkill loolwsd || true +endef + endif clean-local: diff --git a/cypress_test/README b/cypress_test/README index 86f1c77b2..c5841b9dc 100644 --- a/cypress_test/README +++ b/cypress_test/README @@ -20,11 +20,11 @@ command under cypress_test\ folder. To run all desktop tests: - npm run cyrun_desktop + make check-desktop To run all mobile tests: - npm run cyrun_mobile + make check-mobile To run one specific test suit of desktop tests: commit 2f81c9ebb91ed1d3106a239fdc5ae0180d5e302e Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Tue Jan 14 19:14:18 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Jan 14 19:36:16 2020 +0100 cypress: Use eslint to check coding conventions during build. Use loleaflet's config file to have the same conventions under cypress_test folder too. Update test code to pass esling check. Change-Id: Iade932e6d3cd8941b5fc0897c56c68d2493f0dce diff --git a/cypress_test/.eslintignore b/cypress_test/.eslintignore new file mode 100644 index 000000000..308b8fdc1 --- /dev/null +++ b/cypress_test/.eslintignore @@ -0,0 +1,2 @@ +# We only directly edit toolbar.js in dist/ +**/cypress diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index cbee18e7d..5af4c338e 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -1,4 +1,4 @@ -CYPRESS_BINARY = ${top_srcdir}/cypress_test/node_modules/cypress/bin/cypress +CYPRESS_BINARY = ${abs_srcdir}/node_modules/cypress/bin/cypress DESKTOP_TEST_FOLDER = integration_tests/desktop MOBILE_TEST_FOLDER = integration_tests/mobile @@ -7,6 +7,10 @@ MOBILE_USER_AGENT = "cypress mobile test" if HAVE_LO_PATH check-local: @JAILS_PATH@ @npm install + @echo "Checking for loleaflet JS errors..." + @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 @pkill loolwsd || true @echo "Launching loolwsd for testing.." @@ -26,7 +30,7 @@ check-local: @JAILS_PATH@ $(CYPRESS_BINARY) run --browser chrome \ --config integrationFolder=$(DESKTOP_TEST_FOLDER) \ --headless \ - --env DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/desktop/,WORKDIR=$(abs_top_srcdir)/cypress_test/workdir/desktop/ || \ + --env DATA_FOLDER=$(abs_srcdir)/data/desktop/,WORKDIR=$(abs_srcdir)/workdir/desktop/ || \ (pkill loolwsd && false) @echo @echo "Running cypress mobile tests..." @@ -34,7 +38,7 @@ check-local: @JAILS_PATH@ $(CYPRESS_BINARY) run --browser chrome \ --config integrationFolder=$(MOBILE_TEST_FOLDER),userAgent=$(MOBILE_USER_AGENT) \ --headless \ - --env DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/mobile/,WORKDIR=$(abs_top_srcdir)/cypress_test/workdir/mobile/ || \ + --env DATA_FOLDER=$(abs_srcdir)/data/mobile/,WORKDIR=$(abs_srcdir)/workdir/mobile/ || \ (pkill loolwsd && false) @pkill loolwsd || true endif 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 c09604996..8a39b455f 100644 --- a/cypress_test/integration_tests/desktop/example_desktop_test_spec.js +++ b/cypress_test/integration_tests/desktop/example_desktop_test_spec.js @@ -1,37 +1,39 @@ +/* global describe it cy Cypress */ + describe('Example test suit 1', function() { - it('Example test case 1', function() { - // Get a clean test document - cy.task('copyFile', { - source_dir: Cypress.env('DATA_FOLDER'), - dest_dir: Cypress.env('WORKDIR'), - file_name: 'simple.odt', - }); + 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/fc04ba550/loleaflet.html?file_path=file://' + - Cypress.env('WORKDIR') + 'simple.odt') + // Open test document + cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file://' + + Cypress.env('WORKDIR') + 'simple.odt') - // Wait for the document to fully load - cy.get('.leaflet-tile-loaded') + // Wait for the document to fully load + cy.get('.leaflet-tile-loaded') - // Select a text - cy.get('#document-container').dblclick() - cy.get(".leaflet-marker-icon") + // Select a text + cy.get('#document-container').dblclick() + cy.get('.leaflet-marker-icon') - // Click on bold toolbar button - cy.get('#tb_editbar_item_bold').click() + // Click on bold toolbar button + cy.get('#tb_editbar_item_bold').click() - // Remove selection and do a reselection - cy.get('#document-container').click() - cy.get('.leaflet-marker-icon').should('not.be.visible'); + // 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") + cy.get('#document-container').dblclick() + cy.get('.leaflet-marker-icon') - // Bold toolbar button is checked - cy.get('#tb_editbar_item_bold table.w2ui-button.checked') + // Bold toolbar button is checked + cy.get('#tb_editbar_item_bold table.w2ui-button.checked') - // Click on bold toolbar button - cy.get('#tb_editbar_item_bold').click() - }) + // Click on bold toolbar button + cy.get('#tb_editbar_item_bold').click() + }) }) 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 63a9a43ca..163a28c84 100644 --- a/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js +++ b/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js @@ -1,37 +1,39 @@ +/* global describe it cy Cypress */ + describe('Example test suit 2', function() { - it('Example test case 1', function() { - // Get a clean test document - cy.task('copyFile', { - source_dir: Cypress.env('DATA_FOLDER'), - dest_dir: Cypress.env('WORKDIR'), - file_name: 'simple.odt', - }); + 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/fc04ba550/loleaflet.html?file_path=file://' + - Cypress.env('WORKDIR') + 'simple.odt') + // Open test document + cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file://' + + Cypress.env('WORKDIR') + 'simple.odt') - // Wait for the document to fully load - cy.get('.leaflet-tile-loaded') + // Wait for the document to fully load + cy.get('.leaflet-tile-loaded') - // Select a text - cy.get('#document-container').dblclick() - cy.get(".leaflet-marker-icon") + // 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() + // 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'); + // 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") + 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') + // 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() - }) + // Click on bold toolbar button + cy.get('#tb_editbar_item_italic').click() + }) }) diff --git a/cypress_test/integration_tests/mobile/toolbar_spec.js b/cypress_test/integration_tests/mobile/toolbar_spec.js index a7df48fa4..3ef580d3a 100644 --- a/cypress_test/integration_tests/mobile/toolbar_spec.js +++ b/cypress_test/integration_tests/mobile/toolbar_spec.js @@ -1,201 +1,203 @@ +/* global describe it cy Cypress beforeEach*/ + describe('Toolbar tests', function() { - beforeEach(function() { - // Get a clean test document - cy.task('copyFile', { - source_dir: Cypress.env('DATA_FOLDER'), - dest_dir: Cypress.env('WORKDIR'), - file_name: 'empty.odt', - }); - - // Open test document - cy.viewport('iphone-3') - cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file://' + - Cypress.env('WORKDIR') + 'empty.odt') - - // Wait for the document to fully load - cy.get('.leaflet-tile-loaded') - }); - - it('State of mobile wizard toolbar item.', function() { - // Mobile wizard toolbar button is disabled by default - cy.get('#tb_actionbar_item_mobile_wizard') - .should('have.class', 'disabled') - - // Click on edit button - cy.get('#mobile-edit-button').click() - - // Button should be enabled now - cy.get('#tb_actionbar_item_mobile_wizard') - .should('not.have.class', 'disabled') - }) - - it('State of insertion mobile wizard toolbar item.', function() { - // Insertion mobile wizard toolbar button is disabled by default - cy.get('#tb_actionbar_item_insertion_mobile_wizard') - .should('have.class', 'disabled') - - // Click on edit button - cy.get('#mobile-edit-button').click() - - // Button should be enabled now - cy.get('#tb_actionbar_item_insertion_mobile_wizard') - .should('not.have.class', 'disabled') - }) - - it('State of insert comment toolbar item.', function() { - // Insertion mobile wizard toolbar button is disabled by default - cy.get('#tb_actionbar_item_insertcomment') - .should('have.class', 'disabled') - - // Click on edit button - cy.get('#mobile-edit-button').click() - - // Button should be enabled now - cy.get('#tb_actionbar_item_insertcomment') - .should('not.have.class', 'disabled') - }) - - it('State of undo toolbar item.', function() { - // Insertion mobile wizard toolbar button is disabled by default - cy.get('#tb_actionbar_item_undo') - .should('have.class', 'disabled') - - // Click on edit button - cy.get('#mobile-edit-button').click() - - // Button should be still disabled - cy.get('#tb_actionbar_item_undo') - .should('have.class', 'disabled') - - // Type somthing in the document - cy.get('#document-container').type("x") - - // Button should become enabled - cy.get('#tb_actionbar_item_undo') - .should('not.have.class', 'disabled') - }) - - it('State of redo toolbar item.', function() { - // Insertion mobile wizard toolbar button is disabled by default - cy.get('#tb_actionbar_item_redo') - .should('have.class', 'disabled') - - // Click on edit button - cy.get('#mobile-edit-button').click() - - // Button should be still disabled - cy.get('#tb_actionbar_item_redo') - .should('have.class', 'disabled') - - // Type somthing in the document - cy.get('#document-container').type("x") - - // Button should be still disabled - cy.get('#tb_actionbar_item_redo') - .should('have.class', 'disabled') - - // Do an undo - cy.get('#tb_actionbar_item_undo') - .should('not.have.class', 'disabled') - cy.get('#tb_actionbar_item_undo').click() - - // Button should become enabled - cy.get('#tb_actionbar_item_redo') - .should('not.have.class', 'disabled') - }) - - it('Open and close mobile wizard by toolbar item.', function() { - // Click on edit button - cy.get('#mobile-edit-button').click() - - // Click on mobile wizard toolbar item - cy.get('#tb_actionbar_item_mobile_wizard') - .should('not.have.class', 'disabled') - .click() - - // Mobile wizard is opened and it has any content - cy.get('#mobile-wizard-content') - .should('not.be.empty'); - - // Toolbar button is checked - cy.get('#tb_actionbar_item_mobile_wizard table') - .should('have.class', 'checked') - - cy.get('#tb_actionbar_item_mobile_wizard') - .click() - - // Mobile wizard is closed - cy.get('#mobile_wizard') - .should('not.be.visible'); - - cy.get('#tb_actionbar_item_mobile_wizard table') - .should('not.have.class', 'checked') - - // Open mobile wizard again - cy.get('#tb_actionbar_item_mobile_wizard') - .click() - - // Mobile wizard is opened and it has any content - // TODO: fix this bug - /*cy.get('#mobile-wizard-content') - .should('not.be.empty'); */ - }) - - it('Open and close insertion mobile wizard by toolbar item.', function() { - // Click on edit button - cy.get('#mobile-edit-button').click() - - // Click on toolbar item - cy.get('#tb_actionbar_item_insertion_mobile_wizard') - .should('not.have.class', 'disabled') - .click() - - // Mobile wizard is opened and it has any content - cy.get('#mobile-wizard-content') - .should('not.be.empty'); - - // Toolbar button is checked - cy.get('#tb_actionbar_item_insertion_mobile_wizard table') - .should('have.class', 'checked') - - // Click on toolbar item again - cy.get('#tb_actionbar_item_insertion_mobile_wizard') - .click() - - // Mobile wizard is closed - cy.get('#mobile_wizard') - .should('not.be.visible'); - - cy.get('#tb_actionbar_item_insertion_mobile_wizard table') - .should('not.have.class', 'checked') - - // Open mobile wizard again - cy.get('#tb_actionbar_item_insertion_mobile_wizard') - .click() - - // Mobile wizard is opened and it has any content - cy.get('#mobile-wizard-content') - .should('not.be.empty'); - }) - - it('Open insert comment dialog by toolbar item.', function() { - // Click on edit button - cy.get('#mobile-edit-button').click() - - // Click on toolbar item - cy.get('#tb_actionbar_item_insertcomment') - .should('not.have.class', 'disabled') - .click() - - // Comment insertion dialog is opened - cy.get('.loleaflet-annotation-table') - .should('be.visible'); - - // Close the dialog - cy.contains('Cancel') - .click() - - cy.get('.loleaflet-annotation-table') - .should('be.not.visible'); - }) + 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/fc04ba550/loleaflet.html?file_path=file://' + + Cypress.env('WORKDIR') + 'empty.odt') + + // Wait for the document to fully load + cy.get('.leaflet-tile-loaded') + }); + + it('State of mobile wizard toolbar item.', function() { + // Mobile wizard toolbar button is disabled by default + cy.get('#tb_actionbar_item_mobile_wizard') + .should('have.class', 'disabled') + + // Click on edit button + cy.get('#mobile-edit-button').click() + + // Button should be enabled now + cy.get('#tb_actionbar_item_mobile_wizard') + .should('not.have.class', 'disabled') + }) + + it('State of insertion mobile wizard toolbar item.', function() { + // Insertion mobile wizard toolbar button is disabled by default + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .should('have.class', 'disabled') + + // Click on edit button + cy.get('#mobile-edit-button').click() + + // Button should be enabled now + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .should('not.have.class', 'disabled') + }) + + it('State of insert comment toolbar item.', function() { + // Insertion mobile wizard toolbar button is disabled by default + cy.get('#tb_actionbar_item_insertcomment') + .should('have.class', 'disabled') + + // Click on edit button + cy.get('#mobile-edit-button').click() + + // Button should be enabled now + cy.get('#tb_actionbar_item_insertcomment') + .should('not.have.class', 'disabled') + }) + + it('State of undo toolbar item.', function() { + // Insertion mobile wizard toolbar button is disabled by default + cy.get('#tb_actionbar_item_undo') + .should('have.class', 'disabled') + + // Click on edit button + cy.get('#mobile-edit-button').click() + + // Button should be still disabled + cy.get('#tb_actionbar_item_undo') + .should('have.class', 'disabled') + + // Type somthing in the document + cy.get('#document-container').type('x') + + // Button should become enabled + cy.get('#tb_actionbar_item_undo') + .should('not.have.class', 'disabled') + }) + + it('State of redo toolbar item.', function() { + // Insertion mobile wizard toolbar button is disabled by default + cy.get('#tb_actionbar_item_redo') + .should('have.class', 'disabled') + + // Click on edit button + cy.get('#mobile-edit-button').click() + + // Button should be still disabled + cy.get('#tb_actionbar_item_redo') + .should('have.class', 'disabled') + + // Type somthing in the document + cy.get('#document-container').type('x') + + // Button should be still disabled + cy.get('#tb_actionbar_item_redo') + .should('have.class', 'disabled') + + // Do an undo + cy.get('#tb_actionbar_item_undo') + .should('not.have.class', 'disabled') + cy.get('#tb_actionbar_item_undo').click() + + // Button should become enabled + cy.get('#tb_actionbar_item_redo') + .should('not.have.class', 'disabled') + }) + + it('Open and close mobile wizard by toolbar item.', function() { + // Click on edit button + cy.get('#mobile-edit-button').click() + + // Click on mobile wizard toolbar item + cy.get('#tb_actionbar_item_mobile_wizard') + .should('not.have.class', 'disabled') + .click() + + // Mobile wizard is opened and it has any content + cy.get('#mobile-wizard-content') + .should('not.be.empty'); + + // Toolbar button is checked + cy.get('#tb_actionbar_item_mobile_wizard table') + .should('have.class', 'checked') + + cy.get('#tb_actionbar_item_mobile_wizard') + .click() + + // Mobile wizard is closed + cy.get('#mobile_wizard') + .should('not.be.visible'); + + cy.get('#tb_actionbar_item_mobile_wizard table') + .should('not.have.class', 'checked') + + // Open mobile wizard again + cy.get('#tb_actionbar_item_mobile_wizard') + .click() + + // Mobile wizard is opened and it has any content + // TODO: fix this bug + /*cy.get('#mobile-wizard-content') + .should('not.be.empty'); */ + }) + + it('Open and close insertion mobile wizard by toolbar item.', function() { + // Click on edit button + cy.get('#mobile-edit-button').click() + + // Click on toolbar item + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .should('not.have.class', 'disabled') + .click() + + // Mobile wizard is opened and it has any content + cy.get('#mobile-wizard-content') + .should('not.be.empty'); + + // Toolbar button is checked + cy.get('#tb_actionbar_item_insertion_mobile_wizard table') + .should('have.class', 'checked') + + // Click on toolbar item again + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click() + + // Mobile wizard is closed + cy.get('#mobile_wizard') + .should('not.be.visible'); + + cy.get('#tb_actionbar_item_insertion_mobile_wizard table') + .should('not.have.class', 'checked') + + // Open mobile wizard again + cy.get('#tb_actionbar_item_insertion_mobile_wizard') + .click() + + // Mobile wizard is opened and it has any content + cy.get('#mobile-wizard-content') + .should('not.be.empty'); + }) + + it('Open insert comment dialog by toolbar item.', function() { + // Click on edit button + cy.get('#mobile-edit-button').click() + + // Click on toolbar item + cy.get('#tb_actionbar_item_insertcomment') + .should('not.have.class', 'disabled') + .click() + + // Comment insertion dialog is opened + cy.get('.loleaflet-annotation-table') + .should('be.visible'); + + // Close the dialog + cy.contains('Cancel') + .click() + + cy.get('.loleaflet-annotation-table') + .should('be.not.visible'); + }) }) diff --git a/cypress_test/package.json b/cypress_test/package.json index 7bc27e046..70f7f46fe 100644 --- a/cypress_test/package.json +++ b/cypress_test/package.json @@ -4,7 +4,8 @@ "description": "Cypress integration test suit", "license": "MPL-2.0", "dependencies": { - "cypress": "3.8.1" + "cypress": "3.8.1", + "eslint": "6.8.0" }, "repository": { "type": "git", diff --git a/cypress_test/plugins/index.js b/cypress_test/plugins/index.js index 60070efcb..8bf86dcba 100644 --- a/cypress_test/plugins/index.js +++ b/cypress_test/plugins/index.js @@ -1,10 +1,13 @@ -const tasks = require('./tasks'); +/* global require */ -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - on('task', { - copyFile: tasks.copyFile, - }); +var tasks = require('./tasks'); - return config; -}; +function plugin(on, config) { + on('task', { + copyFile: tasks.copyFile + }); + + return config; +} + +module.exports = plugin; diff --git a/cypress_test/plugins/tasks.js b/cypress_test/plugins/tasks.js index 2488d610c..1f2f52a53 100644 --- a/cypress_test/plugins/tasks.js +++ b/cypress_test/plugins/tasks.js @@ -1,16 +1,19 @@ -const fs = require('fs'); +/* global require Promise */ -const copyFile = args => - new Promise(resolve => { - var source_file = args.source_dir + args.file_name - var dest_file = args.dest_dir + args.file_name +var fs = require('fs'); - if (fs.existsSync(source_file)) { - fs.mkdirSync(args.dest_dir, { recursive: true }); - fs.writeFileSync(dest_file, fs.readFileSync(source_file)); - resolve(`File ${source_file} copied to ${dest_file}`); - } - resolve(`File ${source_file} does not exist`); - }); +function copyFile(args) { + return new Promise(function(resolve) { + var sourceFile = args.sourceDir + args.fileName; + var destFile = args.destDir + args.fileName; -module.exports = { copyFile }; + if (fs.existsSync(sourceFile)) { + fs.mkdirSync(args.destDir, { recursive: true }); + fs.writeFileSync(destFile, fs.readFileSync(sourceFile)); + resolve('File ${sourceFile} copied to ${destFile}'); + } + resolve('File ${sourceFile} does not exist'); + }); +} + +module.exports.copyFile = copyFile; commit ab854f96d2e1f2da6f3860063dee64df5d38934e Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Tue Jan 14 18:19:09 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Jan 14 18:19:09 2020 +0100 cypress: Move general cypress options to cypress.json Change-Id: Iad6263f31ec9ef813424e4aab673c2ade1f7f3e5 diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index 4efdfea24..cbee18e7d 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -24,7 +24,7 @@ check-local: @JAILS_PATH@ @echo "Running cypress desktop tests..." @echo $(CYPRESS_BINARY) run --browser chrome \ - --config integrationFolder=$(DESKTOP_TEST_FOLDER),video=false,pluginsFile=plugins/index.js \ + --config integrationFolder=$(DESKTOP_TEST_FOLDER) \ --headless \ --env DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/desktop/,WORKDIR=$(abs_top_srcdir)/cypress_test/workdir/desktop/ || \ (pkill loolwsd && false) @@ -32,7 +32,7 @@ check-local: @JAILS_PATH@ @echo "Running cypress mobile tests..." @echo $(CYPRESS_BINARY) run --browser chrome \ - --config integrationFolder=$(MOBILE_TEST_FOLDER),video=false,userAgent=$(MOBILE_USER_AGENT),pluginsFile=plugins/index.js \ + --config integrationFolder=$(MOBILE_TEST_FOLDER),userAgent=$(MOBILE_USER_AGENT) \ --headless \ --env DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/mobile/,WORKDIR=$(abs_top_srcdir)/cypress_test/workdir/mobile/ || \ (pkill loolwsd && false) @@ -43,3 +43,4 @@ clean-local: rm -rf node_modules rm -rf workdir rm -rf cypress + rm -rf package-lock.json diff --git a/cypress_test/cypress.json b/cypress_test/cypress.json index 92401d400..c4e304f82 100644 --- a/cypress_test/cypress.json +++ b/cypress_test/cypress.json @@ -1,3 +1,5 @@ { - "integrationFolder": "integration_tests" + "integrationFolder" : "integration_tests", + "video" : false, + "pluginsFile" : "plugins/index.js" } commit 8e93a7f351021a352deef5a0006bf957237a76ae Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Tue Jan 14 18:14:23 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Jan 14 18:14:28 2020 +0100 cypress: Move plugins folder out of cypress subfolder Change-Id: Ia3a9a58b7f7e5e64c1e2f4211b75a33bbbb00c0e diff --git a/cypress_test/.gitignore b/cypress_test/.gitignore index 007b3cfbe..3e5e8dbd2 100644 --- a/cypress_test/.gitignore +++ b/cypress_test/.gitignore @@ -1,8 +1,4 @@ node_modules -cypress/fixtures -cypress/integration -cypress/screenshots -cypress/support -cypress/videos +cypress package-lock.json workdir diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index 4a6e77930..4efdfea24 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -24,7 +24,7 @@ check-local: @JAILS_PATH@ @echo "Running cypress desktop tests..." @echo $(CYPRESS_BINARY) run --browser chrome \ - --config integrationFolder=$(DESKTOP_TEST_FOLDER),video=false \ + --config integrationFolder=$(DESKTOP_TEST_FOLDER),video=false,pluginsFile=plugins/index.js \ --headless \ --env DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/desktop/,WORKDIR=$(abs_top_srcdir)/cypress_test/workdir/desktop/ || \ (pkill loolwsd && false) @@ -32,7 +32,7 @@ check-local: @JAILS_PATH@ @echo "Running cypress mobile tests..." @echo $(CYPRESS_BINARY) run --browser chrome \ - --config integrationFolder=$(MOBILE_TEST_FOLDER),video=false,userAgent=$(MOBILE_USER_AGENT) \ + --config integrationFolder=$(MOBILE_TEST_FOLDER),video=false,userAgent=$(MOBILE_USER_AGENT),pluginsFile=plugins/index.js \ --headless \ --env DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/mobile/,WORKDIR=$(abs_top_srcdir)/cypress_test/workdir/mobile/ || \ (pkill loolwsd && false) @@ -42,8 +42,4 @@ endif clean-local: rm -rf node_modules rm -rf workdir - rm -rf cypress/fixtures - rm -rf cypress/integration - rm -rf cypress/screenshots - rm -rf cypress/support - rm -rf cypress/videos + rm -rf cypress diff --git a/cypress_test/cypress/plugins/index.js b/cypress_test/plugins/index.js similarity index 100% rename from cypress_test/cypress/plugins/index.js rename to cypress_test/plugins/index.js diff --git a/cypress_test/cypress/plugins/tasks.js b/cypress_test/plugins/tasks.js similarity index 100% rename from cypress_test/cypress/plugins/tasks.js rename to cypress_test/plugins/tasks.js commit 782cb53bdb8c295cf0b503b7f0e8e7064aea9c56 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Tue Jan 14 18:08:51 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Jan 14 18:08:51 2020 +0100 cypress: Always create a copy of the test document. Before test execution. So the modifications won't change the test documents. Change-Id: I1b04fe96e8182033d44aeeaa3a7632dd81031a05 diff --git a/cypress_test/.gitignore b/cypress_test/.gitignore index 27d395a6a..007b3cfbe 100644 --- a/cypress_test/.gitignore +++ b/cypress_test/.gitignore @@ -1,3 +1,8 @@ node_modules -cypress/ +cypress/fixtures +cypress/integration +cypress/screenshots +cypress/support +cypress/videos package-lock.json +workdir diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index ec992c254..4a6e77930 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -26,7 +26,7 @@ check-local: @JAILS_PATH@ $(CYPRESS_BINARY) run --browser chrome \ --config integrationFolder=$(DESKTOP_TEST_FOLDER),video=false \ --headless \ - --env TEST_DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/desktop/ || \ + --env DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/desktop/,WORKDIR=$(abs_top_srcdir)/cypress_test/workdir/desktop/ || \ (pkill loolwsd && false) @echo @echo "Running cypress mobile tests..." @@ -34,11 +34,16 @@ check-local: @JAILS_PATH@ $(CYPRESS_BINARY) run --browser chrome \ --config integrationFolder=$(MOBILE_TEST_FOLDER),video=false,userAgent=$(MOBILE_USER_AGENT) \ --headless \ - --env TEST_DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/mobile/ || \ + --env DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/mobile/,WORKDIR=$(abs_top_srcdir)/cypress_test/workdir/mobile/ || \ (pkill loolwsd && false) @pkill loolwsd || true endif clean-local: rm -rf node_modules - rm -rf cypress + rm -rf workdir + rm -rf cypress/fixtures + rm -rf cypress/integration + rm -rf cypress/screenshots + rm -rf cypress/support + rm -rf cypress/videos diff --git a/cypress_test/cypress/plugins/index.js b/cypress_test/cypress/plugins/index.js new file mode 100644 index 000000000..60070efcb --- /dev/null +++ b/cypress_test/cypress/plugins/index.js @@ -0,0 +1,10 @@ +const tasks = require('./tasks'); + +module.exports = (on, config) => { + // `on` is used to hook into various events Cypress emits + on('task', { + copyFile: tasks.copyFile, + }); + + return config; +}; diff --git a/cypress_test/cypress/plugins/tasks.js b/cypress_test/cypress/plugins/tasks.js new file mode 100644 index 000000000..2488d610c --- /dev/null +++ b/cypress_test/cypress/plugins/tasks.js @@ -0,0 +1,16 @@ +const fs = require('fs'); + +const copyFile = args => + new Promise(resolve => { + var source_file = args.source_dir + args.file_name + var dest_file = args.dest_dir + args.file_name + + if (fs.existsSync(source_file)) { + fs.mkdirSync(args.dest_dir, { recursive: true }); + fs.writeFileSync(dest_file, fs.readFileSync(source_file)); + resolve(`File ${source_file} copied to ${dest_file}`); + } + resolve(`File ${source_file} does not exist`); + }); + +module.exports = { copyFile }; 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 d8b4f52a4..c09604996 100644 --- a/cypress_test/integration_tests/desktop/example_desktop_test_spec.js +++ b/cypress_test/integration_tests/desktop/example_desktop_test_spec.js @@ -1,8 +1,15 @@ describe('Example test suit 1', function() { it('Example test case 1', function() { + // Get a clean test document + cy.task('copyFile', { + source_dir: Cypress.env('DATA_FOLDER'), + dest_dir: Cypress.env('WORKDIR'), + file_name: 'simple.odt', + }); + // Open test document cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file://' + - Cypress.env('TEST_DATA_FOLDER') + 'simple.odt') + Cypress.env('WORKDIR') + 'simple.odt') // Wait for the document to fully load cy.get('.leaflet-tile-loaded') 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 37ffc5dc6..63a9a43ca 100644 --- a/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js +++ b/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js @@ -1,8 +1,15 @@ describe('Example test suit 2', function() { it('Example test case 1', function() { + // Get a clean test document + cy.task('copyFile', { + source_dir: Cypress.env('DATA_FOLDER'), + dest_dir: Cypress.env('WORKDIR'), + file_name: 'simple.odt', + }); + // Open test document cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file://' + - Cypress.env('TEST_DATA_FOLDER') + 'simple.odt') + Cypress.env('WORKDIR') + 'simple.odt') // Wait for the document to fully load cy.get('.leaflet-tile-loaded') diff --git a/cypress_test/integration_tests/mobile/toolbar_spec.js b/cypress_test/integration_tests/mobile/toolbar_spec.js index 8dc950dd9..a7df48fa4 100644 --- a/cypress_test/integration_tests/mobile/toolbar_spec.js +++ b/cypress_test/integration_tests/mobile/toolbar_spec.js @@ -1,9 +1,16 @@ describe('Toolbar tests', function() { beforeEach(function() { + // Get a clean test document + cy.task('copyFile', { + source_dir: Cypress.env('DATA_FOLDER'), + dest_dir: Cypress.env('WORKDIR'), + file_name: 'empty.odt', + }); + // Open test document cy.viewport('iphone-3') cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file://' + - Cypress.env('TEST_DATA_FOLDER') + 'empty.odt') + Cypress.env('WORKDIR') + 'empty.odt') // Wait for the document to fully load cy.get('.leaflet-tile-loaded') commit 5b30be8a57cdb39c32e3fb7fbd35b2e445674bb1 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Tue Jan 14 17:10:07 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Jan 14 17:11:04 2020 +0100 cypress: Use env variable to get file path. Instead of a hard coded one. Also create new test documents for cypress tests. Change-Id: I5f9b2c6914669f77742e1a011d736bbf18c54877 diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index ae5725cca..ec992c254 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -11,9 +11,6 @@ check-local: @JAILS_PATH@ @pkill loolwsd || true @echo "Launching loolwsd for testing.." @fc-cache "@LO_PATH@"/share/fonts/truetype - @cp $(top_srcdir)/test/data/hello.odt $(top_srcdir)/test/data/hello-world.odt - @cp $(top_srcdir)/test/data/hello.ods $(top_srcdir)/test/data/hello-world.ods - @cp $(top_srcdir)/test/data/hello.odp $(top_srcdir)/test/data/hello-world.odp @echo ../loolwsd --o:sys_template_path="@SYSTEMPLATE_PATH@" \ --o:child_root_path="@JAILS_PATH@" --o:storage.filesystem[@allow]=true \ @@ -28,14 +25,16 @@ check-local: @JAILS_PATH@ @echo $(CYPRESS_BINARY) run --browser chrome \ --config integrationFolder=$(DESKTOP_TEST_FOLDER),video=false \ - --headless || \ + --headless \ + --env TEST_DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/desktop/ || \ (pkill loolwsd && false) @echo @echo "Running cypress mobile tests..." @echo $(CYPRESS_BINARY) run --browser chrome \ --config integrationFolder=$(MOBILE_TEST_FOLDER),video=false,userAgent=$(MOBILE_USER_AGENT) \ - --headless || \ + --headless \ + --env TEST_DATA_FOLDER=$(abs_top_srcdir)/cypress_test/data/mobile/ || \ (pkill loolwsd && false) @pkill loolwsd || true endif diff --git a/cypress_test/data/desktop/simple.odt b/cypress_test/data/desktop/simple.odt new file mode 100644 index 000000000..833aa18fa Binary files /dev/null and b/cypress_test/data/desktop/simple.odt differ diff --git a/cypress_test/data/mobile/empty.odt b/cypress_test/data/mobile/empty.odt new file mode 100644 index 000000000..b8fe3d9dc Binary files /dev/null and b/cypress_test/data/mobile/empty.odt differ 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 68d6b4f18..d8b4f52a4 100644 --- a/cypress_test/integration_tests/desktop/example_desktop_test_spec.js +++ b/cypress_test/integration_tests/desktop/example_desktop_test_spec.js @@ -1,7 +1,8 @@ describe('Example test suit 1', function() { it('Example test case 1', function() { - // Open test documnt - cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file:///home/zolnai/libreoffice/online/test/data/hello-world.odt') + // Open test document + cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file://' + + Cypress.env('TEST_DATA_FOLDER') + 'simple.odt') // Wait for the document to fully load cy.get('.leaflet-tile-loaded') 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 fde36a757..37ffc5dc6 100644 --- a/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js +++ b/cypress_test/integration_tests/desktop/example_desktop_test_spec2.js @@ -1,7 +1,8 @@ describe('Example test suit 2', function() { it('Example test case 1', function() { - // Open test documnt - cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file:///home/zolnai/libreoffice/online/test/data/hello-world.odt') + // Open test document + cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file://' + + Cypress.env('TEST_DATA_FOLDER') + 'simple.odt') // Wait for the document to fully load cy.get('.leaflet-tile-loaded') diff --git a/cypress_test/integration_tests/mobile/toolbar_spec.js b/cypress_test/integration_tests/mobile/toolbar_spec.js index 83851f976..8dc950dd9 100644 --- a/cypress_test/integration_tests/mobile/toolbar_spec.js +++ b/cypress_test/integration_tests/mobile/toolbar_spec.js @@ -1,8 +1,9 @@ describe('Toolbar tests', function() { beforeEach(function() { - // Open test documnt + // Open test document cy.viewport('iphone-3') - cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file:///home/zolnai/libreoffice/online/test/data/hello-world.odt') + cy.visit('http://localhost:9980/loleaflet/fc04ba550/loleaflet.html?file_path=file://' + + Cypress.env('TEST_DATA_FOLDER') + 'empty.odt') // Wait for the document to fully load cy.get('.leaflet-tile-loaded') commit 720504ad1498ff99da7cb0a2a9978e989b1784f1 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Tue Jan 14 16:05:33 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Jan 14 16:36:39 2020 +0100 cypress: Make sure loolwsd is killed after make check. Even if ony of the tests fails. Change-Id: I18e7daff854fd51d4ba374d9d537ba76e171269c diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index bb4740348..ae5725cca 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -26,11 +26,17 @@ check-local: @JAILS_PATH@ @echo @echo "Running cypress desktop tests..." @echo - $(CYPRESS_BINARY) run --browser chrome --config integrationFolder=$(DESKTOP_TEST_FOLDER),video=false --headless + $(CYPRESS_BINARY) run --browser chrome \ + --config integrationFolder=$(DESKTOP_TEST_FOLDER),video=false \ + --headless || \ + (pkill loolwsd && false) @echo @echo "Running cypress mobile tests..." @echo - $(CYPRESS_BINARY) run --browser chrome --config integrationFolder=$(MOBILE_TEST_FOLDER),video=false,userAgent=$(MOBILE_USER_AGENT) --headless + $(CYPRESS_BINARY) run --browser chrome \ + --config integrationFolder=$(MOBILE_TEST_FOLDER),video=false,userAgent=$(MOBILE_USER_AGENT) \ + --headless || \ + (pkill loolwsd && false) @pkill loolwsd || true endif commit a815a0ce4f7f1f5f0b82dad7ce7da728ee1bac05 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Tue Jan 14 14:19:06 2020 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Jan 14 14:20:45 2020 +0100 cypress: Running make check locally works better then cyrun. Change-Id: Ifcbefa925b3b46e7955cd3cfb107b105f053cf59 diff --git a/cypress_test/README b/cypress_test/README index efeb6e10a..86f1c77b2 100644 --- a/cypress_test/README +++ b/cypress_test/README @@ -5,22 +5,19 @@ Running tests ------------------ All tests are part of the make check build. So you can -just execute it from the root folder of online repository. +just execute it from the root folder or under the +cypress_test folder to run cypress tests only. make check -To run only cypress test cases, you need to start loolwsd +To run cypress test cases selectively, you need to start loolwsd server first. To do that you can call make run on a separate command line window, so LibreOffice online is started. -After the server is running you can execute the test, +After the server is running you can execute the tests, calling the given run command. You need to run the command under cypress_test\ folder. -To run all cypress tests: - - npm run cyrun - To run all desktop tests: npm run cyrun_desktop diff --git a/cypress_test/package.json b/cypress_test/package.json index a9d281112..7bc27e046 100644 --- a/cypress_test/package.json +++ b/cypress_test/package.json @@ -11,7 +11,6 @@ "url": "git://gerrit.libreoffice.org/online.git" }, "scripts": { - "cyrun": "npm run cyrun_desktop && npm run cyrun_mobile", "cyrun_desktop": "node_modules/cypress/bin/cypress run --browser chrome --config integrationFolder=integration_tests/desktop --headless", "cyrun_mobile": "node_modules/cypress/bin/cypress run --browser chrome --config integrationFolder=integration_tests/mobile,userAgent=\"cypress mobile test\" --headless", "cyopen_desktop": "node_modules/cypress/bin/cypress open --config integrationFolder=integration_tests/desktop", _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits