From 4f01c7e4de32a45670c0016aece8bffaaa55d52a Mon Sep 17 00:00:00 2001 From: Neil Guertin Date: Tue, 23 Apr 2024 12:09:53 -0400 Subject: [PATCH] Cypress: Remove beforeAll and rewrite document loading helpers New helpers setupDocument, loadDocument, reloadDocument Clean up beforeEach functions Replace most calls to beforeAll with setupAndLoadDocument Replace calls to reload with reloadDocument Signed-off-by: Neil Guertin Change-Id: I12307f93c8a418e6f55bb36b8afe340d7841b726 --- .../common/desktop_helper.js | 8 +- .../integration_tests/common/helper.js | 306 ++++++++---------- .../common/interference_user_spec.js | 2 +- .../desktop/calc/annotation_spec.js | 23 +- .../desktop/calc/macro_spec.js | 15 +- .../calc/open_different_file_types_spec.js | 39 +-- .../desktop/calc/top_toolbar_spec.js | 11 +- .../desktop/draw/pdf_page_up_down_spec.js | 12 +- .../desktop/impress/annotation_spec.js | 55 ++-- .../impress/open_different_file_types_spec.js | 4 +- .../desktop/writer/annotation_spec.js | 48 ++- .../desktop/writer/top_toolbar_spec.js | 11 +- .../mobile/calc/annotation_spec.js | 7 +- .../mobile/calc/bottom_toolbar_spec.js | 16 +- .../mobile/calc/hamburger_menu_spec.js | 100 ++++-- .../mobile/calc/nextcloud_spec.js | 21 +- .../mobile/impress/annotation_spec.js | 7 +- .../mobile/impress/hamburger_menu_spec.js | 50 +-- .../mobile/impress/nextcloud_spec.js | 25 +- .../mobile/impress/slide_properties_spec.js | 5 +- .../mobile/writer/annotation_spec.js | 9 +- .../mobile/writer/hamburger_menu_spec.js | 7 +- .../mobile/writer/nextcloud_spec.js | 20 +- .../mobile/writer/table_properties_spec.js | 4 +- .../multiuser/calc/invalidations_spec.js | 6 +- .../multiuser/writer/invalidations_spec.js | 4 +- 26 files changed, 354 insertions(+), 461 deletions(-) diff --git a/cypress_test/integration_tests/common/desktop_helper.js b/cypress_test/integration_tests/common/desktop_helper.js index 3b1dafe179..4a6cab6719 100644 --- a/cypress_test/integration_tests/common/desktop_helper.js +++ b/cypress_test/integration_tests/common/desktop_helper.js @@ -420,10 +420,12 @@ function pressKey(n, key) { cy.log('<< pressKey - end'); } -function openReadOnlyFile(type, filename) { +function openReadOnlyFile(subFolder, fileName) { cy.log('>> openReadOnlyFile - start'); - var testFileName = helper.loadTestDocNoIntegration(filename, type, false, false, false); + var newFileName = helper.setupDocument(fileName, subFolder); + // Skip document checks because sidebar does not appear + helper.loadDocument(newFileName, subFolder, true); //check doc is loaded cy.cGet('.leaflet-canvas-container canvas', {timeout : Cypress.config('defaultCommandTimeout') * 2.0}); @@ -433,7 +435,7 @@ function openReadOnlyFile(type, filename) { cy.cGet('#PermissionMode').should('be.visible').should('have.text', ' Read-only '); cy.log('<< openReadOnlyFile - end'); - return testFileName; + return newFileName; } function checkAccessibilityEnabledToBe(state) { diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js index cb1dac5a5c..7b93e690e0 100644 --- a/cypress_test/integration_tests/common/helper.js +++ b/cypress_test/integration_tests/common/helper.js @@ -1,10 +1,97 @@ /* -*- js-indent-level: 8 -*- */ /* global cy Cypress expect */ +/* + * Prepares the test document by copying or uploading it + * fileName: test document file name (without path) + * subFolder: sub folder inside data folder (e.g. writer, calc, impress) + * returns new test document file name (without path) + */ +function setupDocument(fileName, subFolder) { + cy.log('>> setupDocument - start'); + cy.log('Param - fileName: ' + fileName); + cy.log('Param - subFolder: ' + subFolder); + + var newFileName; + if (Cypress.env('INTEGRATION') === 'nextcloud') { + upLoadFileToNextCloud(fileName, subFolder); + newFileName = fileName; + } else if (Cypress.env('SERVER') !== 'localhost') { + newFileName = fileName; + } else { + // Rename and copy file to use a clean test document for every test case. + var randomText = (Math.random() + 1).toString(36).substring(7); + newFileName = Cypress.currentTest.title.replace(/[\/\\ ]/g, '-') + '-'+ randomText + '-' + fileName; + copyFile(fileName, newFileName, subFolder); + } + + cy.log('<< setupDocument - end'); + return newFileName; +} + +/* + * Opens the document and waits for it to be ready + * fileName: test document file name (without path) + * subFolder: sub folder inside data folder (e.g. writer, calc, impress) + * skipDocumentChecks: Skips the document checks that wait for it to be ready. + * This is useful for documents that have an interaction before the + * document is loaded, such as clearing a warning about macros. + * isMultiUser: Set to true for multiuser tests. + */ +function loadDocument(fileName, subFolder, skipDocumentChecks, isMultiUser) { + cy.log('>> loadDocument - start'); + cy.log('Param - fileName: ' + fileName); + cy.log('Param - subFolder: ' + subFolder); + if (skipDocumentChecks) { + cy.log('Param - skipDocumentChecks: ' + skipDocumentChecks); + } + if (isMultiUser) { + cy.log('Param - isMultiUser: ' + isMultiUser); + } + + // Set viewport + doIfOnMobile(function() { + // could be any phone type + cy.viewport('iphone-6'); + }); + if (isMultiUser) { + cy.viewport(2000,660); + } + + // Set active frame + if (isMultiUser) { + cy.cSetActiveFrame('#iframe1'); + } else { + cy.cSetActiveFrame('#coolframe'); + } + + // Load document + if (Cypress.env('INTEGRATION') === 'nextcloud') { + loadDocumentNextcloud(fileName, subFolder); + } else { + loadDocumentNoIntegration(fileName, subFolder, isMultiUser); + } + + // Wait for and verify that document is loaded + if (!skipDocumentChecks) { + if (isMultiUser) { + cy.cSetActiveFrame('#iframe1'); + documentChecks(); + cy.cSetActiveFrame('#iframe2'); + documentChecks(); + } else { + // frame set above + documentChecks(); + } + } + + cy.log('<< loadDocument - end'); +} + /* * Covers most use cases. For more flexibility, * call setupDocument and loadDocument directly - * fileName: Includes subFolder, for example: 'calc/hello-world.ods' + * fullFileName: Includes subFolder, for example: 'calc/hello-world.ods' */ function setupAndLoadDocument(fullFileName, isMultiUser = false) { cy.log('>> setupAndLoadDocument - start'); @@ -20,14 +107,28 @@ function setupAndLoadDocument(fullFileName, isMultiUser = false) { fileName = fullFileName; } - // TODO: replace with loadDocument and setupDocument + var newFileName = setupDocument(fileName, subFolder); if (isMultiUser) { - beforeAll(fileName, subFolder, undefined, isMultiUser); + loadDocument(newFileName, subFolder, undefined, isMultiUser); } else { - beforeAll(fileName, subFolder); + loadDocument(newFileName, subFolder); } cy.log('<< setupAndLoadDocument - end'); + return newFileName; +} + +/* + * Covers most use cases. For more flexibility, + * call closeDocument and loadDocument directly + */ +function reloadDocument(fileName, subFolder) { + cy.log('>> reloadDocument - start'); + + closeDocument(fileName); + loadDocument(fileName, subFolder); + + cy.log('<< reloadDocument - end'); } function copyFile(fileName, newFileName, subFolder) { @@ -48,88 +149,36 @@ function copyFile(fileName, newFileName, subFolder) { } } -function getRandomFileName(noRename, noFileCopy, originalName) { - if (noRename !== true && noFileCopy !== true) { - var randomName = (Math.random() + 1).toString(36).substring(7); - return Cypress.currentTest.title.replace(/[\/\\ ]/g, '-') + '-'+ randomName + '-' + originalName; - } - else { - return originalName; - } -} - function logError(event) { Cypress.log({ name:'error:', message: (event.error.message ? event.error.message : 'no message') + '\n' + (event.error.stack ? event.error.stack : 'no stack') }); } -function logLoadingParameters(fileName, subFolder, noFileCopy, isMultiUser, subsequentLoad, hasInteractionBeforeLoad, noRename) { - cy.log('Param - fileName: ' + fileName); - cy.log('Param - subFolder: ' + subFolder); - if (noFileCopy !== undefined) - cy.log('Param - noFileCopy: ' + noFileCopy); - if (isMultiUser !== undefined) - cy.log('Param - isMultiUser: ' + isMultiUser); - if (subsequentLoad !== undefined) - cy.log('Param - subsequentLoad: ' + subsequentLoad); - if (hasInteractionBeforeLoad !== undefined) - cy.log('Param - hasInteractionBeforeLoad: ' + hasInteractionBeforeLoad); - if (noRename !== undefined) - cy.log('Param - noRename: ' + noRename); -} +/* + * Loads the test document directly in Collabora Online. + */ +function loadDocumentNoIntegration(fileName, subFolder, isMultiUser) { + cy.log('>> loadDocumentNoIntegration - start'); -function generateDocumentURL() { var URI = ''; + if (Cypress.env('INTEGRATION') === 'php-proxy') { URI += 'http://' + Cypress.env('SERVER') + '/richproxy/proxy.php?req='; } - return URI; -} - -function generateDocumentURI(URL, subFolder, newFileName) { - var URI = ''; if (subFolder === undefined) { - URI = URL + '/browser/' + + URI += '/browser/' + Cypress.env('WSD_VERSION_HASH') + '/debug.html?lang=en-US&file_path=' + - Cypress.env('DATA_WORKDIR') + newFileName; + Cypress.env('DATA_WORKDIR') + fileName; } else { - URI = URL + '/browser/' + + URI += '/browser/' + Cypress.env('WSD_VERSION_HASH') + '/debug.html?lang=en-US&file_path=' + - Cypress.env('DATA_WORKDIR') + subFolder + '/' + newFileName; + Cypress.env('DATA_WORKDIR') + subFolder + '/' + fileName; } - return URI; -} - -/* -Loading the test document directly in Collabora Online. -Parameters: - fileName - test document file name (without path) - subFolder - sub folder inside data folder (e.g. writer, calc, impress) - noFileCopy - whether to create a copy of the test file before run the test. - By default, we create a copy to have a clear test document but - but when we test saving functionality we need to open same document - isMultiUser - whether the test is for multiuser - noRename - whether or not to give the file a unique name, if noFileCopy is false. - */ -function loadTestDocNoIntegration(fileName, subFolder, noFileCopy, isMultiUser, noRename) { - cy.log('>> loadTestDocNoIntegration - start'); - - var newFileName = getRandomFileName(noRename, noFileCopy, fileName); - - cy.log('Param - fileName: ' + fileName + ' -> ' + newFileName); - - // Get a clean test document, by creating a copy of it in the workdir. We overwrite this copy everytime we run a new test case. - if (noFileCopy !== true) - copyFile(fileName, newFileName, subFolder); - - var URL = generateDocumentURL(); - var URI = generateDocumentURI(URL, subFolder, newFileName); if (isMultiUser) { - cy.viewport(2000,660); URI = URI.replace('debug.html', 'cypress-multiuser.html'); } @@ -144,25 +193,16 @@ function loadTestDocNoIntegration(fileName, subFolder, noFileCopy, isMultiUser, } }); - cy.log('<< loadTestDocNoIntegration - end'); - - return newFileName; + cy.log('<< loadDocumentNoIntegration - end'); } -// Loading the test document inside a Nextcloud integration. -// Parameters: -// fileName - test document file name (without path) -// subFolder - sub folder inside data folder (e.g. writer, calc, impress) -// subsequentLoad - whether we load a test document for the first time in the -// test case or not. It's important because we need to sign in -// with the username + password only for the first time. -function loadTestDocNextcloud(fileName, subFolder, subsequentLoad) { - cy.log('>> loadTestDocNextcloud - start'); +/* + * Loads the test document inside a Nextcloud integration + */ +function loadDocumentNextcloud(fileName, subFolder) { + cy.log('>> loadDocumentNextcloud - start'); cy.log('Param - fileName: ' + fileName); cy.log('Param - subFolder: ' + subFolder); - cy.log('Param - subsequentLoad: ' + subsequentLoad); - - upLoadFileToNextCloud(fileName, subFolder, subsequentLoad); // Open test document cy.cGet('tr[data-file=\'' + fileName + '\']').click(); @@ -190,7 +230,7 @@ function loadTestDocNextcloud(fileName, subFolder, subsequentLoad) { Cypress.env('IFRAME_LEVEL', '2'); }); - cy.log('<< loadTestDocNextcloud - end'); + cy.log('<< loadDocumentNextcloud - end'); } // Hide NC's first run wizard, which is opened by the first run of @@ -222,11 +262,14 @@ function hideNCFirstRunWizard() { // test case or not. It's important because we need to sign in // with the username + password only for the first time. function upLoadFileToNextCloud(fileName, subFolder, subsequentLoad) { - cy.log('>> loadTestDocNextcloud - start'); + cy.log('>> upLoadFileToNextCloud - start'); cy.log('Param - fileName: ' + fileName); cy.log('Param - subFolder: ' + subFolder); cy.log('Param - subsequentLoad: ' + subsequentLoad); + // TODO: subsequentLoad appears to be unused + // TODO: see if cy.session can handle login + // Open local nextcloud installation var url = 'http://' + Cypress.env('SERVER') + 'nextcloud/index.php/apps/files'; cy.visit(url); @@ -297,7 +340,7 @@ function upLoadFileToNextCloud(fileName, subFolder, subsequentLoad) { cy.cGet('tr[data-file=\'' + fileName + '\']') .should('be.visible'); - cy.log('<< loadTestDocNextcloud - end'); + cy.log('<< upLoadFileToNextCloud - end'); } // Used for interference testing. We wait until the interfering user loads @@ -315,53 +358,10 @@ function waitForInterferingUser() { cy.log('<< waitForInterferingUser - end'); } -// Loading the test document inside Collabora Online (directly or via some integration). -// Parameters: -// fileName - test document file name (without path) -// subFolder - sub folder inside data folder (e.g. writer, calc, impress) -// noFileCopy - whether to create a copy of the test file before run the test. -// By default, we create a copy to have a clear test document but -// but when we test saving functionality we need to open same document -// isMultiUser - whether test is a multiuser test -// subsequentLoad - whether we load a test document for the first time in the -// test case or not. It's important for nextcloud because we need to sign in -// with the username + password only for the first time. -// noRename - whether or not to give the file a unique name, if noFileCopy is false. -function loadTestDoc(fileName, subFolder, noFileCopy, isMultiUser, subsequentLoad, hasInteractionBeforeLoad, noRename) { - cy.log('>> loadTestDoc - start'); - - var server = Cypress.env('SERVER'); - logLoadingParameters(fileName, subFolder, noFileCopy, isMultiUser, subsequentLoad, hasInteractionBeforeLoad, noRename); - - // We set the mobile screen size here. We could use any other phone type here. - doIfOnMobile(function() { - cy.viewport('iphone-6'); - }); - - var destFileName = fileName; - if (Cypress.env('INTEGRATION') === 'nextcloud') { - loadTestDocNextcloud(fileName, subFolder, subsequentLoad); - } else { - if (server !== 'localhost') { - noFileCopy = noRename = true; - } - destFileName = loadTestDocNoIntegration(fileName, subFolder, noFileCopy, isMultiUser, noRename); - } - - // When dialog appears before document load (eg. macro warning, csv import options) - if (hasInteractionBeforeLoad === true) - return; - - checkIfDocIsLoaded(isMultiUser); - - cy.log('<< loadTestDoc - end'); - return destFileName; -} - function documentChecks() { cy.log('>> documentChecks - start'); - cy.cframe().find('#document-canvas', {timeout : Cypress.config('defaultCommandTimeout') * 2.0}); + cy.cGet('#document-canvas', {timeout : Cypress.config('defaultCommandTimeout') * 2.0}); // With php-proxy the client is irresponsive for some seconds after load, because of the incoming messages. if (Cypress.env('INTEGRATION') === 'php-proxy') { @@ -399,27 +399,6 @@ function documentChecks() { cy.log('<< documentChecks - end'); } -function checkIfDocIsLoaded(isMultiUser) { - cy.log('>> checkIfDocIsLoaded - start'); - - if (isMultiUser) { - cy.cSetActiveFrame('#iframe1'); - cy.cframe('#iframe1').its('body').should('not.be.undefined'); - documentChecks(); - - cy.cSetActiveFrame('#iframe2'); - cy.cframe('#iframe2').its('body').should('not.be.undefined'); - documentChecks(); - } - else { - cy.cSetActiveFrame('#coolframe'); - cy.cframe().its('body').should('not.be.undefined'); - documentChecks(); - } - - cy.log('<< checkIfDocIsLoaded - end'); -} - // Assert that NO keyboard input is accepted (i.e. keyboard should be HIDDEN). function assertNoKeyboardInput() { cy.log('>> assertNoKeyboardInput - start'); @@ -554,26 +533,6 @@ function clipboardTextShouldBeDifferentThan(text) { cy.log('<< clipboardTextShouldBeDifferentThan - end'); } -// This is called during a test to reload the same document after -// some modification. The purpose is typically to verify that -// said changes were preserved in the document upon closing. -function reload(fileName, subFolder, noFileCopy, isMultiUser, subsequentLoad, hasInteractionBeforeLoad) { - cy.log('Reloading document: ' + subFolder + '/' + fileName); - cy.log('Reloading document - noFileCopy: ' + noFileCopy); - cy.log('Reloading document - subsequentLoad: ' + subsequentLoad); - closeDocument(fileName); - var noRename = true; - return loadTestDoc(fileName, subFolder, noFileCopy, isMultiUser, subsequentLoad, hasInteractionBeforeLoad, noRename); -} - -// noRename - whether or not to give the file a unique name, if noFileCopy is false. -function beforeAll(fileName, subFolder, noFileCopy, isMultiUser, subsequentLoad, hasInteractionBeforeLoad, noRename) { - // Set defaults here in order to remove checks from cy.cGet function. - cy.cSetActiveFrame('#coolframe'); - - return loadTestDoc(fileName, subFolder, noFileCopy, isMultiUser, subsequentLoad, hasInteractionBeforeLoad, noRename); -} - // This method is intended to call after each test case. // We use this method to close the document, before step // on to the next test case. @@ -1208,9 +1167,11 @@ function copy() { }); } +module.exports.setupDocument = setupDocument; +module.exports.loadDocument = loadDocument; module.exports.setupAndLoadDocument = setupAndLoadDocument; -module.exports.loadTestDoc = loadTestDoc; -module.exports.checkIfDocIsLoaded = checkIfDocIsLoaded; +module.exports.reloadDocument = reloadDocument; +module.exports.documentChecks = documentChecks; module.exports.assertCursorAndFocus = assertCursorAndFocus; module.exports.assertNoKeyboardInput = assertNoKeyboardInput; module.exports.assertHaveKeyboardInput = assertHaveKeyboardInput; @@ -1220,7 +1181,6 @@ module.exports.expectTextForClipboard = expectTextForClipboard; module.exports.matchClipboardText = matchClipboardText; module.exports.clipboardTextShouldBeDifferentThan = clipboardTextShouldBeDifferentThan; module.exports.closeDocument = closeDocument; -module.exports.reload = reload; module.exports.initAliasToNegative = initAliasToNegative; module.exports.doIfInCalc = doIfInCalc; module.exports.doIfInImpress = doIfInImpress; @@ -1228,7 +1188,6 @@ module.exports.doIfInWriter = doIfInWriter; module.exports.doIfNotInCalc = doIfNotInCalc; module.exports.doIfNotInImpress = doIfNotInImpress; module.exports.doIfNotInWriter = doIfNotInWriter; -module.exports.beforeAll = beforeAll; module.exports.typeText = typeText; module.exports.isImageWhite = isImageWhite; module.exports.isCanvasWhite = isCanvasWhite; @@ -1249,7 +1208,6 @@ module.exports.overlayItemHasDifferentBoundsThan = overlayItemHasDifferentBounds module.exports.typeIntoInputField = typeIntoInputField; module.exports.getVisibleBounds = getVisibleBounds; module.exports.assertFocus = assertFocus; -module.exports.loadTestDocNoIntegration = loadTestDocNoIntegration; module.exports.getBlinkingCursorPosition = getBlinkingCursorPosition; module.exports.clickAt = clickAt; module.exports.setDummyClipboardForCopy = setDummyClipboardForCopy; diff --git a/cypress_test/integration_tests/common/interference_user_spec.js b/cypress_test/integration_tests/common/interference_user_spec.js index f3c6f87102..457c43c4be 100644 --- a/cypress_test/integration_tests/common/interference_user_spec.js +++ b/cypress_test/integration_tests/common/interference_user_spec.js @@ -31,7 +31,7 @@ describe('Interfering second user.', function() { .then(function(text) { // We open the same document - helper.beforeAll(text, getComponent(text), true); + helper.loadDocument(text, getComponent(text)); }); cy.get('#toolbar-up #userlist', { timeout: Cypress.config('defaultCommandTimeout') * 2.0 }) diff --git a/cypress_test/integration_tests/desktop/calc/annotation_spec.js b/cypress_test/integration_tests/desktop/calc/annotation_spec.js index 1fa860a194..b63c6a39c7 100644 --- a/cypress_test/integration_tests/desktop/calc/annotation_spec.js +++ b/cypress_test/integration_tests/desktop/calc/annotation_spec.js @@ -98,11 +98,10 @@ describe(['tagdesktop'], 'Annotation Tests', function() { }); describe(['tagdesktop'], 'Annotation Autosave Tests', function() { - var origTestFileName = 'annotation.ods'; - var testFileName; + var newFileName; beforeEach(function() { - testFileName = helper.beforeAll(origTestFileName, 'calc'); + newFileName = helper.setupAndLoadDocument('calc/annotation.ods'); desktopHelper.switchUIToNotebookbar(); }); @@ -112,8 +111,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation-autosavelabel').should('be.visible'); cy.cGet('.cool-annotation-edit.modify-annotation').should('be.visible'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'calc', true, false, false, true); + helper.reloadDocument(newFileName,'calc'); cy.cGet('.cool-annotation').should('exist'); cy.cGet('#comment-container-1').then(function (element) { element[0].style.visibility = ''; @@ -138,8 +136,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#comment-container-1').trigger('mouseover'); cy.cGet('#annotation-content-area-1').should('have.text','some text0'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'calc', true, false, false, true); + helper.reloadDocument(newFileName,'calc'); cy.cGet('.cool-annotation').should('exist'); cy.cGet('#comment-container-1').then(function (element) { element[0].style.visibility = ''; @@ -158,8 +155,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation').should('not.exist'); cy.cGet('.cool-annotation-autosavelabel').should('not.exist'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'calc', true, false, false, true); + helper.reloadDocument(newFileName,'calc'); cy.cGet('.cool-annotation').should('not.exist'); }); @@ -181,8 +177,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation-autosavelabel').should('be.visible'); cy.cGet('.cool-annotation-edit.modify-annotation').should('be.visible'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'calc', true, false, false, true); + helper.reloadDocument(newFileName,'calc'); cy.cGet('.cool-annotation').should('exist'); cy.cGet('#comment-container-1').then(function (element) { element[0].style.visibility = ''; @@ -218,8 +213,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#annotation-content-area-1').should('have.text','some other text, some text0'); cy.cGet('#comment-container-1').should('exist'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'calc', true, false, false, true); + helper.reloadDocument(newFileName,'calc'); cy.cGet('.cool-annotation').should('exist'); cy.cGet('#comment-container-1').then(function (element) { element[0].style.visibility = ''; @@ -255,8 +249,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#annotation-content-area-1').should('have.text','some text0'); cy.cGet('#comment-container-1').should('exist'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'calc', true, false, false, true); + helper.reloadDocument(newFileName,'calc'); cy.cGet('.cool-annotation').should('exist'); cy.cGet('#comment-container-1').then(function (element) { element[0].style.visibility = ''; diff --git a/cypress_test/integration_tests/desktop/calc/macro_spec.js b/cypress_test/integration_tests/desktop/calc/macro_spec.js index c7909a8009..4172666036 100644 --- a/cypress_test/integration_tests/desktop/calc/macro_spec.js +++ b/cypress_test/integration_tests/desktop/calc/macro_spec.js @@ -4,7 +4,14 @@ var helper = require('../../common/helper'); var calcHelper = require('../../common/calc_helper'); describe(['tagdesktop', 'tagproxy'], 'macro dialog tests', function() { - var testFileName = 'macro.ods'; + + beforeEach(function() { + var newFileName = helper.setupDocument('macro.ods','calc'); + // Skip document check to click through accept macro dialog first + helper.loadDocument(newFileName,'calc',true); + acceptMacroExecution(); + helper.documentChecks(); + }); function acceptMacroExecution() { cy.get('#MacroWarnMedium.jsdialog') @@ -13,12 +20,6 @@ describe(['tagdesktop', 'tagproxy'], 'macro dialog tests', function() { cy.cGet('#MacroWarnMedium.jsdialog #ok').click(); } - beforeEach(function() { - helper.beforeAll(testFileName, 'calc', undefined, undefined, undefined, true); - acceptMacroExecution(); - helper.checkIfDocIsLoaded(); - }); - function expandEntryInTreeView(entryText) { cy.cGet().contains('.jsdialog.ui-treeview-cell', entryText) .siblings('.ui-treeview-expander') diff --git a/cypress_test/integration_tests/desktop/calc/open_different_file_types_spec.js b/cypress_test/integration_tests/desktop/calc/open_different_file_types_spec.js index 012fdeb4c2..c1b42d751a 100644 --- a/cypress_test/integration_tests/desktop/calc/open_different_file_types_spec.js +++ b/cypress_test/integration_tests/desktop/calc/open_different_file_types_spec.js @@ -1,21 +1,10 @@ -/* global describe it cy require Cypress */ +/* global describe it cy require */ var helper = require('../../common/helper'); var calcHelper = require('../../common/calc_helper'); -const { insertImage } = require('../../common/desktop_helper'); +var desktopHelper = require('../../common/desktop_helper'); describe.skip(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Open different file types', function () { - function openReadOnlyFile(filename) { - helper.loadTestDocNoIntegration(filename, 'calc', false, false, false); - - //check doc is loaded - cy.cGet('.leaflet-canvas-container canvas', {timeout : Cypress.config('defaultCommandTimeout') * 2.0}); - - helper.isCanvasWhite(false); - - cy.cGet('#PermissionMode').should('be.visible').should('have.text', ' Read-only '); - } - function assertData() { var expectedData = [ '0', 'First Name', 'Last Name', 'Gender', 'Country', 'Age', 'Date', 'Id', @@ -32,7 +21,7 @@ describe.skip(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Open different file t assertData(); - insertImage(); + desktopHelper.insertImage(); }); it('Open xlsx file', { defaultCommandTimeout: 60000 }, function () { @@ -41,23 +30,19 @@ describe.skip(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Open different file t assertData(); }); - //we are not using before because it loads the document and directly asserts if document is loaded but in - //case of csv file 1st when you try to load the doc it opens up jsdialog to import csv which requires user - //input and after click ok the doc starts to load it('Open csv file', { defaultCommandTimeout: 60000 }, function() { //to fit csv jsdialog in window cy.viewport(1280, 960); - helper.loadTestDocNoIntegration('testfile.csv', 'calc', false, false, false); + var newFileName = helper.setupDocument('testfile.csv','calc'); + // Skip document check to click through import csv dialog first + helper.loadDocument(newFileName,'calc',true); cy.cGet('form.jsdialog-container.lokdialog_container').should('exist'); - cy.cGet('.ui-pushbutton.jsdialog.button-primary').click(); //check doc is loaded - cy.cGet('.leaflet-canvas-container canvas', {timeout : Cypress.config('defaultCommandTimeout') * 2.0}); - - helper.isCanvasWhite(false); + helper.documentChecks(); cy.cGet('#mobile-edit-button') .should('be.visible') @@ -69,7 +54,7 @@ describe.skip(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Open different file t }); it('Open xlsb file', { defaultCommandTimeout: 60000 }, function() { - openReadOnlyFile('testfile.xlsb'); + desktopHelper.openReadOnlyFile('testfile.xlsb'); cy.cGet('#mobile-edit-button').should('be.visible').click(); cy.cGet('#modal-dialog-switch-to-edit-mode-modal-overlay').should('be.visible'); @@ -85,17 +70,17 @@ describe.skip(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Open different file t assertData(); - insertImage(); + desktopHelper.insertImage(); }); it('Open xltm file', { defaultCommandTimeout: 60000 }, function() { - openReadOnlyFile('testfile.xltm'); + desktopHelper.openReadOnlyFile('testfile.xltm'); cy.cGet('#mobile-edit-button').should('not.be.visible'); }); it('Open xltx file', { defaultCommandTimeout: 60000 }, function() { - openReadOnlyFile('testfile.xltm'); + desktopHelper.openReadOnlyFile('testfile.xltm'); cy.cGet('#mobile-edit-button').should('not.be.visible'); }); @@ -106,6 +91,6 @@ describe.skip(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Open different file t //select all the content of doc assertData(); - insertImage(); + desktopHelper.insertImage(); }); }); diff --git a/cypress_test/integration_tests/desktop/calc/top_toolbar_spec.js b/cypress_test/integration_tests/desktop/calc/top_toolbar_spec.js index 6739ec345c..ca6f612ec8 100644 --- a/cypress_test/integration_tests/desktop/calc/top_toolbar_spec.js +++ b/cypress_test/integration_tests/desktop/calc/top_toolbar_spec.js @@ -5,21 +5,20 @@ var desktopHelper = require('../../common/desktop_helper'); var calcHelper = require('../../common/calc_helper'); describe(['tagdesktop'], 'Top toolbar tests.', function() { - var origTestFileName = 'top_toolbar.ods'; - var testFileName; + var newFileName; beforeEach(function() { - testFileName = helper.beforeAll(origTestFileName, 'calc'); + newFileName = helper.setupAndLoadDocument('calc/top_toolbar.ods'); desktopHelper.switchUIToCompact(); calcHelper.clickOnFirstCell(); }); - it('Save.', { defaultCommandTimeout: 60000 }, function() { + it('Save.', function() { cy.cGet('#bold').click(); cy.cGet('#save').click(); - helper.reload(testFileName, 'calc', true); - cy.log('reload happened'); + helper.reloadDocument(newFileName,'calc'); + helper.setDummyClipboardForCopy(); calcHelper.selectEntireSheet(); helper.copy(); diff --git a/cypress_test/integration_tests/desktop/draw/pdf_page_up_down_spec.js b/cypress_test/integration_tests/desktop/draw/pdf_page_up_down_spec.js index 15cff5bdc9..7933693ded 100644 --- a/cypress_test/integration_tests/desktop/draw/pdf_page_up_down_spec.js +++ b/cypress_test/integration_tests/desktop/draw/pdf_page_up_down_spec.js @@ -4,11 +4,10 @@ var helper = require('../../common/helper'); var desktopHelper = require('../../common/desktop_helper'); describe(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'PDF View Tests', function() { - var origTestFileName = 'pdf_page_up_down.pdf'; - var testFileName; + var newFileName; beforeEach(function() { - testFileName = helper.beforeAll(origTestFileName, 'draw'); + newFileName = helper.setupAndLoadDocument('draw/pdf_page_up_down.pdf'); }); it('PDF page down', { env: { 'pdf-view': true } }, function() { @@ -27,11 +26,14 @@ describe(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'PDF View Tests', function( cy.cGet('.cool-annotation-content-wrapper').should('exist'); cy.cGet('#annotation-content-area-1').should('contain','some text0'); - // Reload to close and save. PDFs cannot really be edited, + // Close to test save. PDFs cannot really be edited, // only comments can be inserted, so they are not saved // directly, rather save-as is used. This failed because // DocBroker expected to get ModifiedStatus=false, which // never happens with save-as and so we couldn't unload. - helper.reload(testFileName, 'draw', true); + helper.closeDocument(newFileName); + + // TODO: verify comment still exists + // helper.reloadDocument(newFileName,'draw'); }); }); diff --git a/cypress_test/integration_tests/desktop/impress/annotation_spec.js b/cypress_test/integration_tests/desktop/impress/annotation_spec.js index 664d20e7dc..bfd181d7ec 100644 --- a/cypress_test/integration_tests/desktop/impress/annotation_spec.js +++ b/cypress_test/integration_tests/desktop/impress/annotation_spec.js @@ -61,18 +61,19 @@ describe(['tagdesktop'], 'Annotation Tests', function() { }); describe(['tagdesktop'], 'Collapsed Annotation Tests', function() { - var origTestFileName = 'comment_switching.odp'; - var testFileName; + var newFileName; beforeEach(function() { - testFileName = helper.beforeAll(origTestFileName, 'impress'); + newFileName = helper.setupAndLoadDocument('impress/comment_switching.odp'); desktopHelper.switchUIToNotebookbar(); if (Cypress.env('INTEGRATION') === 'nextcloud') { desktopHelper.hideSidebarIfVisible(); } - cy.cGet('#options-modify-page').click(); + // TODO: skip sidebar detection on reload + // cy.cGet('#options-modify-page').click(); + desktopHelper.selectZoomLevel('50'); }); @@ -133,8 +134,7 @@ describe(['tagdesktop'], 'Collapsed Annotation Tests', function() { cy.cGet('#map').focus(); cy.cGet('.cool-annotation-info-collapsed').should('be.not.visible'); - helper.closeDocument(testFileName, ''); - helper.beforeAll(testFileName, 'impress', true, false, false, true); + helper.reloadDocument(newFileName, 'impress'); cy.cGet('.cool-annotation-img').click(); cy.cGet('.cool-annotation-content-wrapper').should('exist'); cy.cGet('#annotation-content-area-1').should('have.text','some text0'); @@ -195,19 +195,19 @@ describe(['tagdesktop'], 'Comment Scrolling',function() { }); describe(['tagdesktop'], 'Annotation Autosave Tests', function() { - var origTestFileName = 'comment_switching.odp'; - var testFileName; + var newFileName; beforeEach(function() { - cy.viewport(1500, 600); - testFileName = helper.beforeAll(origTestFileName, 'impress'); + cy.viewport(2400, 600); + newFileName = helper.setupAndLoadDocument('impress/comment_switching.odp'); desktopHelper.switchUIToNotebookbar(); - if (Cypress.env('INTEGRATION') === 'nextcloud') { - desktopHelper.hideSidebarIfVisible(); - } + // TODO: skip sidebar detection on reload + // if (Cypress.env('INTEGRATION') === 'nextcloud') { + // desktopHelper.hideSidebarIfVisible(); + // } + // cy.cGet('#options-modify-page').click(); - cy.cGet('#options-modify-page').click(); desktopHelper.selectZoomLevel('50'); }); @@ -217,8 +217,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation-autosavelabel').should('be.visible'); cy.cGet('.cool-annotation-edit.modify-annotation').should('be.visible'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'impress', true, false, false, true); + helper.reloadDocument(newFileName,'impress'); cy.cGet('.leaflet-marker-icon').should('exist'); cy.cGet('.cool-annotation-content > div').should('have.text','some text0'); }); @@ -234,8 +233,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.leaflet-marker-icon').should('exist'); cy.cGet('.cool-annotation-content > div').should('have.text','some text0'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'impress', true, false, false, true); + helper.reloadDocument(newFileName,'impress'); cy.cGet('.leaflet-marker-icon').should('exist'); cy.cGet('.cool-annotation-content > div').should('have.text','some text0'); }); @@ -251,8 +249,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.leaflet-marker-icon').should('not.exist'); cy.cGet('.cool-annotation-content > div').should('not.exist'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'impress', true, false, false, true); + helper.reloadDocument(newFileName,'impress'); cy.cGet('.leaflet-marker-icon').should('not.exist'); cy.cGet('.cool-annotation-content > div').should('not.exist'); }); @@ -268,8 +265,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation-autosavelabel').should('be.visible'); cy.cGet('.cool-annotation-edit.modify-annotation').should('be.visible'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'impress', true, false, false, true); + helper.reloadDocument(newFileName,'impress'); cy.cGet('.leaflet-marker-icon').should('exist'); cy.cGet('.cool-annotation-content > div').should('have.text','some other text, some text0'); }); @@ -288,8 +284,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#annotation-content-area-1').should('have.text','some other text, some text0'); cy.cGet('.leaflet-marker-icon').should('exist'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'impress', true, false, false, true); + helper.reloadDocument(newFileName,'impress'); cy.cGet('.leaflet-marker-icon').should('exist'); cy.cGet('.cool-annotation-content > div').should('have.text','some other text, some text0'); }); @@ -308,8 +303,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#annotation-content-area-1').should('have.text','some text0'); cy.cGet('.leaflet-marker-icon').should('exist'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'impress', true, false, false, true); + helper.reloadDocument(newFileName,'impress'); cy.cGet('.leaflet-marker-icon').should('exist'); cy.cGet('.cool-annotation-content > div').should('have.text','some text0'); }); @@ -327,8 +321,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#annotation-modify-textarea-1').should('include.text', 'some text0'); cy.cGet('#annotation-modify-textarea-1').should('include.text', 'some reply text'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'impress', true, false, false, true); + helper.reloadDocument(newFileName,'impress'); cy.cGet('.cool-annotation-edit.reply-annotation').should('be.not.visible'); cy.cGet('.cool-annotation-content > div').should('include.text','some reply text'); }); @@ -351,8 +344,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation-content > div').should('include.text','some text0'); cy.cGet('.cool-annotation-content > div').should('include.text','some reply text'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'impress', true, false, false, true); + helper.reloadDocument(newFileName,'impress'); cy.cGet('.cool-annotation-edit.reply-annotation').should('be.not.visible'); cy.cGet('.cool-annotation-content > div').should('include.text','some reply text'); }); @@ -374,8 +366,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation-edit.reply-annotation').should('be.not.visible'); cy.cGet('.cool-annotation-content > div').should('have.text','some text0'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'impress', true, false, false, true); + helper.reloadDocument(newFileName,'impress'); cy.cGet('.cool-annotation-edit.reply-annotation').should('be.not.visible'); cy.cGet('.cool-annotation-content > div').should('have.text','some text0'); }); diff --git a/cypress_test/integration_tests/desktop/impress/open_different_file_types_spec.js b/cypress_test/integration_tests/desktop/impress/open_different_file_types_spec.js index c0da011a10..e1be148d58 100644 --- a/cypress_test/integration_tests/desktop/impress/open_different_file_types_spec.js +++ b/cypress_test/integration_tests/desktop/impress/open_different_file_types_spec.js @@ -5,8 +5,8 @@ const { selectZoomLevel, openReadOnlyFile } = require('../../common/desktop_help describe.skip(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Open different file types', function() { - function before(filename) { - helper.setupAndLoadDocument('impress/' + filename); + function before(fileName) { + helper.setupAndLoadDocument('impress/' + fileName); selectZoomLevel('50'); diff --git a/cypress_test/integration_tests/desktop/writer/annotation_spec.js b/cypress_test/integration_tests/desktop/writer/annotation_spec.js index 9e4fb7980b..6ccf26e15b 100644 --- a/cypress_test/integration_tests/desktop/writer/annotation_spec.js +++ b/cypress_test/integration_tests/desktop/writer/annotation_spec.js @@ -59,13 +59,14 @@ describe(['tagdesktop'], 'Annotation Tests', function() { }); describe(['tagdesktop'], 'Collapsed Annotation Tests', function() { - var origTestFileName = 'annotation.odt'; - var testFileName; + var newFileName; beforeEach(function() { - testFileName = helper.beforeAll(origTestFileName, 'writer'); + newFileName = helper.setupAndLoadDocument('writer/annotation.odt'); desktopHelper.switchUIToNotebookbar(); - cy.cGet('#optionscontainer div[id$="SidebarDeck.PropertyDeck"]').click(); // Hide sidebar. + + // TODO: skip sidebar detection on reload + // cy.cGet('#optionscontainer div[id$="SidebarDeck.PropertyDeck"]').click(); // Hide sidebar. }); it('Insert', function() { @@ -131,8 +132,7 @@ describe(['tagdesktop'], 'Collapsed Annotation Tests', function() { helper.typeIntoDocument('{home}'); cy.cGet('.cool-annotation-info-collapsed').should('be.not.visible'); - helper.closeDocument(testFileName, ''); - helper.beforeAll(testFileName, 'writer', true, false, false, true); + helper.reloadDocument(newFileName,'writer'); cy.cGet('#optionscontainer div[id$="SidebarDeck.PropertyDeck"]').click(); // show sidebar. cy.cGet('.cool-annotation-img').click(); cy.cGet('.cool-annotation-content-wrapper').should('exist'); @@ -143,16 +143,15 @@ describe(['tagdesktop'], 'Collapsed Annotation Tests', function() { }); describe(['tagdesktop'], 'Annotation Autosave Tests', function() { - var origTestFileName = 'annotation.odt'; - var testFileName; + var newFileName; beforeEach(function() { cy.viewport(1400, 600); - testFileName = helper.beforeAll(origTestFileName, 'writer'); + newFileName = helper.setupAndLoadDocument('writer/annotation.odt'); desktopHelper.switchUIToNotebookbar(); - cy.cGet('#optionscontainer div[id$="SidebarDeck.PropertyDeck"]').click(); // Hide sidebar. + // TODO: skip sidebar detection on reload + //cy.cGet('#optionscontainer div[id$="SidebarDeck.PropertyDeck"]').click(); // Hide sidebar. selectZoomLevel('50'); - }); it('Insert autosave', function() { @@ -161,8 +160,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation-autosavelabel').should('be.visible'); cy.cGet('.cool-annotation-edit.modify-annotation').should('be.visible'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'writer', true, false, false, true); + helper.reloadDocument(newFileName,'writer'); cy.cGet('.cool-annotation-content-wrapper').should('exist'); cy.cGet('#annotation-content-area-1').should('have.text','some text0'); }); @@ -176,8 +174,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#annotation-content-area-1').should('have.text','some text0'); cy.cGet('.cool-annotation-autosavelabel').should('be.not.visible'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'writer', true, false, false, true); + helper.reloadDocument(newFileName,'writer'); cy.cGet('.cool-annotation-content-wrapper').should('exist'); cy.cGet('#annotation-content-area-1').should('have.text','some text0'); }); @@ -191,8 +188,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#comment-container-1').should('not.exist'); cy.cGet('.cool-annotation-autosavelabel').should('not.exist'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'writer', true, false, false, true); + helper.reloadDocument(newFileName,'writer'); cy.cGet('.cool-annotation-content-wrapper').should('not.exist'); cy.cGet('#comment-container-1').should('not.exist'); }); @@ -209,8 +205,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation-autosavelabel').should('be.visible'); cy.cGet('.cool-annotation-edit.modify-annotation').should('be.visible'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'writer', true, false, false, true); + helper.reloadDocument(newFileName,'writer'); cy.cGet('.cool-annotation-content-wrapper').should('exist'); cy.cGet('#annotation-content-area-1').should('have.text','some other text, some text0'); }); @@ -230,8 +225,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#annotation-content-area-1').should('have.text','some other text, some text0'); cy.cGet('.cool-annotation-autosavelabel').should('be.not.visible'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'writer', true, false, false, true); + helper.reloadDocument(newFileName,'writer'); cy.cGet('.cool-annotation-content-wrapper').should('exist'); cy.cGet('#annotation-content-area-1').should('have.text','some other text, some text0'); }); @@ -252,8 +246,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation-autosavelabel').should('be.not.visible'); cy.cGet('#annotation-content-area-1').should('have.text','some text0'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'writer', true, false, false, true); + helper.reloadDocument(newFileName,'writer'); cy.cGet('.cool-annotation-content-wrapper').should('exist'); cy.cGet('#annotation-content-area-1').should('have.text','some text0'); }); @@ -270,8 +263,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('.cool-annotation-autosavelabel').should('be.visible'); cy.cGet('#annotation-modify-textarea-2').should('be.visible'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'writer', true, false, false, true); + helper.reloadDocument(newFileName,'writer'); cy.cGet('.cool-annotation-content-wrapper').should('exist'); cy.cGet('#annotation-content-area-2').should('have.text','some reply text'); }); @@ -294,8 +286,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#annotation-content-area-1').should('have.text','some text0'); cy.cGet('#annotation-content-area-2').should('have.text','some reply text'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'writer', true, false, false, true); + helper.reloadDocument(newFileName,'writer'); cy.cGet('.cool-annotation-content-wrapper').should('exist'); cy.cGet('#annotation-content-area-2').should('have.text','some reply text'); }); @@ -320,8 +311,7 @@ describe(['tagdesktop'], 'Annotation Autosave Tests', function() { cy.cGet('#comment-container-1 .cool-annotation-autosavelabel').should('be.not.visible'); cy.cGet('#comment-container-2 .cool-annotation-autosavelabel').should('not.exist'); - helper.closeDocument(testFileName); - helper.beforeAll(testFileName, 'writer', true, false, false, true); + helper.reloadDocument(newFileName,'writer'); cy.cGet('.cool-annotation-content-wrapper').should('exist'); cy.cGet('#annotation-content-area-1').should('have.text','some text0'); cy.cGet('#annotation-content-area-2').should('not.exist'); diff --git a/cypress_test/integration_tests/desktop/writer/top_toolbar_spec.js b/cypress_test/integration_tests/desktop/writer/top_toolbar_spec.js index 21345b49a7..fb9f6fa6fd 100644 --- a/cypress_test/integration_tests/desktop/writer/top_toolbar_spec.js +++ b/cypress_test/integration_tests/desktop/writer/top_toolbar_spec.js @@ -5,11 +5,10 @@ var desktopHelper = require('../../common/desktop_helper'); var writerHelper = require('../../common/writer_helper'); describe(['tagdesktop'], 'Top toolbar tests.', function() { - var origTestFileName = 'top_toolbar.odt'; - var testFileName; + var newFileName; beforeEach(function() { - testFileName = helper.beforeAll(origTestFileName, 'writer'); + newFileName = helper.setupAndLoadDocument('writer/top_toolbar.odt'); desktopHelper.switchUIToNotebookbar(); if (Cypress.env('INTEGRATION') === 'nextcloud') { @@ -283,14 +282,12 @@ describe(['tagdesktop'], 'Top toolbar tests.', function() { .should('not.exist'); }); - it('Save.', { defaultCommandTimeout: 60000 }, function() { + it('Save.', function() { cy.cGet('.notebookbar > .unoBold > button').click(); cy.cGet('.notebookbar-shortcuts-bar .unoSave').click(); - helper.reload(testFileName, 'writer', true); + helper.reloadDocument(newFileName,'writer'); helper.setDummyClipboardForCopy(); - cy.wait(2000); writerHelper.selectAllTextOfDoc(); - cy.wait(2000); helper.copy(); cy.cGet('#copy-paste-container p b').should('exist'); }); diff --git a/cypress_test/integration_tests/mobile/calc/annotation_spec.js b/cypress_test/integration_tests/mobile/calc/annotation_spec.js index 934a4ce805..3a1e1b4fcc 100644 --- a/cypress_test/integration_tests/mobile/calc/annotation_spec.js +++ b/cypress_test/integration_tests/mobile/calc/annotation_spec.js @@ -4,11 +4,10 @@ var helper = require('../../common/helper'); var mobileHelper = require('../../common/mobile_helper'); describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Annotation Tests',function() { - var origTestFileName = 'annotation.ods'; - var testFileName; + var newFileName; beforeEach(function() { - testFileName = helper.beforeAll(origTestFileName, 'calc'); + newFileName = helper.setupAndLoadDocument('calc/annotation.ods'); // Click on edit button mobileHelper.enableEditingMobile(); @@ -19,7 +18,7 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Annotation Tests',function( cy.cGet('#comment-container-1').should('exist'); mobileHelper.selectHamburgerMenuItem(['File', 'Save']); - helper.reload(testFileName, 'calc', true); + helper.reloadDocument(newFileName, 'calc'); mobileHelper.enableEditingMobile(); mobileHelper.openCommentWizard(); helper.waitUntilIdle('#mobile-wizard-content', undefined); diff --git a/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js b/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js index 1e0e0809de..98aac0b1cf 100644 --- a/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js +++ b/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js @@ -1,4 +1,4 @@ -/* global describe it cy Cypress require */ +/* global describe it cy Cypress require beforeEach */ var helper = require('../../common/helper'); var calcHelper = require('../../common/calc_helper'); @@ -6,8 +6,8 @@ var mobileHelper = require('../../common/mobile_helper'); describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Interact with bottom toolbar.', function() { - function before(fileName) { - helper.setupAndLoadDocument('calc/' + fileName); + beforeEach(function() { + helper.setupAndLoadDocument('calc/bottom_toolbar.ods'); // Click on edit button mobileHelper.enableEditingMobile(); @@ -15,7 +15,7 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Interact with bottom toolba helper.waitUntilIdle('#toolbar-down'); calcHelper.clickOnFirstCell(); - } + }); function getTextEndPosForFirstCell() { calcHelper.dblClickOnFirstCell(); @@ -33,7 +33,6 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Interact with bottom toolba } it('Apply bold.', function() { - before('bottom_toolbar.ods'); helper.setDummyClipboardForCopy(); cy.cGet('#toolbar-down #bold').click(); calcHelper.selectEntireSheet(); @@ -42,7 +41,6 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Interact with bottom toolba }); it('Apply italic.', function() { - before('bottom_toolbar.ods'); helper.setDummyClipboardForCopy(); cy.cGet('#toolbar-down #italic').click(); @@ -52,7 +50,6 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Interact with bottom toolba }); it('Apply underline.', function() { - before('bottom_toolbar.ods'); helper.setDummyClipboardForCopy(); cy.cGet('#toolbar-down #underline').click(); calcHelper.selectEntireSheet(); @@ -61,14 +58,12 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Interact with bottom toolba }); it.skip('Apply strikeout.', function() { - before('bottom_toolbar.ods'); cy.cGet('#toolbar-down #strikeout').click(); calcHelper.selectEntireSheet(); cy.cGet('#copy-paste-container table td s').should('exist'); }); it('Apply font color.', function() { - before('bottom_toolbar.ods'); helper.setDummyClipboardForCopy(); cy.cGet('#toolbar-down #fontcolor').click(); mobileHelper.selectFromColorPalette(0, 5); @@ -78,7 +73,6 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Interact with bottom toolba }); it('Apply highlight color.', function() { - before('bottom_toolbar.ods'); helper.setDummyClipboardForCopy(); cy.cGet('#toolbar-down #backcolor').click(); mobileHelper.selectFromColorPalette(0, 5); @@ -88,7 +82,6 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Interact with bottom toolba }); it.skip('Merge cells', function() { - before('bottom_toolbar.ods'); // Select 100 cells in first row calcHelper.selectCellsInRange('A1:CV1'); // Despite the selection is there, merge cells needs more time here. @@ -99,7 +92,6 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Interact with bottom toolba }); it.skip('Enable text wrapping.', function() { - before('bottom_toolbar.ods'); helper.initAliasToNegative('originalTextEndPos'); getTextEndPosForFirstCell(); cy.get('@currentTextEndPos').as('originalTextEndPos'); diff --git a/cypress_test/integration_tests/mobile/calc/hamburger_menu_spec.js b/cypress_test/integration_tests/mobile/calc/hamburger_menu_spec.js index dc25c9f869..febd4c7892 100644 --- a/cypress_test/integration_tests/mobile/calc/hamburger_menu_spec.js +++ b/cypress_test/integration_tests/mobile/calc/hamburger_menu_spec.js @@ -6,16 +6,11 @@ var mobileHelper = require('../../common/mobile_helper'); var repairHelper = require('../../common/repair_document_helper'); describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { - var testFileName; - - function before(testFile) { - helper.setupAndLoadDocument('calc' + testFile); - - // Click on edit button - mobileHelper.enableEditingMobile(); - } it('Save', { defaultCommandTimeout: 60000 }, function() { + var newFileName = helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); + calcHelper.selectEntireSheet(); cy.cGet('#copy-paste-container table td').should('contain.text', 'Textx'); @@ -27,7 +22,7 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { mobileHelper.selectHamburgerMenuItem(['File', 'Save']); // Reopen the document and check content. - helper.reload(testFileName, 'calc', true); + helper.reloadDocument(newFileName, 'calc'); mobileHelper.enableEditingMobile(); calcHelper.selectEntireSheet(); @@ -35,7 +30,8 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Print', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); // A new window should be opened with the PDF. cy.getFrameWindow() @@ -49,32 +45,41 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Download as PDF', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); + mobileHelper.selectHamburgerMenuItem(['Download as', 'PDF Document (.pdf)']); mobileHelper.pressPushButtonOfDialog('Export'); cy.cGet('iframe').should('have.attr', 'data-src').should('contain', 'download'); }); it('Download as ODS', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); + mobileHelper.selectHamburgerMenuItem(['Download as', 'ODF spreadsheet (.ods)']); cy.cGet('iframe').should('have.attr', 'data-src').should('contain', 'download'); }); it('Download as XLS', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); + mobileHelper.selectHamburgerMenuItem(['Download as', 'Excel 2003 Spreadsheet (.xls)']); cy.cGet('iframe').should('have.attr', 'data-src').should('contain', 'download'); }); it('Download as XLSX', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); + mobileHelper.selectHamburgerMenuItem(['Download as', 'Excel Spreadsheet (.xlsx)']); cy.cGet('iframe').should('have.attr', 'data-src').should('contain', 'download'); }); it('Undo/redo.', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); // Type a new character calcHelper.clickOnFirstCell(true, true); @@ -100,7 +105,8 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Repair Document', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); // Type a new character calcHelper.clickOnFirstCell(true, true); @@ -121,35 +127,45 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Cut.', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); + calcHelper.selectEntireSheet(); mobileHelper.selectHamburgerMenuItem(['Edit', 'Cut']); cy.cGet('#mobile-wizard-content-modal-dialog-copy_paste_warning-box').should('exist'); }); it('Copy.', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); + calcHelper.selectEntireSheet(); mobileHelper.selectHamburgerMenuItem(['Edit', 'Copy']); cy.cGet('#mobile-wizard-content-modal-dialog-copy_paste_warning-box').should('exist'); }); it('Paste.', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); + calcHelper.selectEntireSheet(); mobileHelper.selectHamburgerMenuItem(['Edit', 'Paste']); cy.cGet('#mobile-wizard-content-modal-dialog-copy_paste_warning-box').should('exist'); }); it('Select all.', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); + mobileHelper.selectHamburgerMenuItem(['Edit', 'Select All']); cy.cGet('.spreadsheet-cell-resize-marker').should('be.visible'); cy.cGet('#copy-paste-container table td').should('contain.text', 'Text'); }); it('Search some word.', function() { - before('hamburger_menu_search.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu_search.ods'); + mobileHelper.enableEditingMobile(); + mobileHelper.selectHamburgerMenuItem(['Search']); // Search bar become visible cy.cGet('#mobile-wizard-content').should('not.be.empty'); @@ -162,7 +178,9 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Sheet: insert row before.', function() { - before('hamburger_menu_sheet.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu_sheet.ods'); + mobileHelper.enableEditingMobile(); + calcHelper.clickOnFirstCell(); mobileHelper.selectHamburgerMenuItem(['Sheet', 'Insert Rows', 'Rows Above']); calcHelper.selectEntireSheet(); @@ -177,7 +195,9 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Sheet: insert row after.', function() { - before('hamburger_menu_sheet.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu_sheet.ods'); + mobileHelper.enableEditingMobile(); + calcHelper.clickOnFirstCell(); mobileHelper.selectHamburgerMenuItem(['Sheet', 'Insert Rows', 'Rows Below']); calcHelper.selectEntireSheet(); @@ -192,7 +212,9 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Sheet: insert column before.', function() { - before('hamburger_menu_sheet.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu_sheet.ods'); + mobileHelper.enableEditingMobile(); + calcHelper.clickOnFirstCell(); mobileHelper.selectHamburgerMenuItem(['Sheet', 'Insert Columns', 'Columns Before']); calcHelper.selectEntireSheet(); @@ -207,7 +229,9 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Sheet: insert column after.', function() { - before('hamburger_menu_sheet.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu_sheet.ods'); + mobileHelper.enableEditingMobile(); + calcHelper.clickOnFirstCell(); mobileHelper.selectHamburgerMenuItem(['Sheet', 'Insert Columns', 'Columns After']); calcHelper.selectEntireSheet(); @@ -222,7 +246,9 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Sheet: delete rows.', function() { - before('hamburger_menu_sheet.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu_sheet.ods'); + mobileHelper.enableEditingMobile(); + calcHelper.clickOnFirstCell(); mobileHelper.selectHamburgerMenuItem(['Sheet', 'Delete Rows']); calcHelper.selectEntireSheet(); @@ -235,7 +261,9 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Sheet: delete columns.', function() { - before('hamburger_menu_sheet.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu_sheet.ods'); + mobileHelper.enableEditingMobile(); + calcHelper.clickOnFirstCell(); mobileHelper.selectHamburgerMenuItem(['Sheet', 'Delete Columns']); calcHelper.selectEntireSheet(); @@ -248,7 +276,8 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Data: sort ascending.', function() { - before('hamburger_menu_sort.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu_sort.ods'); + mobileHelper.enableEditingMobile(); // Sort the first column's data calcHelper.selectFirstColumn(); @@ -266,7 +295,8 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Data: sort descending.', function() { - before('hamburger_menu_sort.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu_sort.ods'); + mobileHelper.enableEditingMobile(); // Sort the first column's data calcHelper.selectFirstColumn(); @@ -284,7 +314,8 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Data: grouping / ungrouping.', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); // Group first calcHelper.selectFirstColumn(); @@ -296,7 +327,8 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Data: remove grouping outline.', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); // Group first calcHelper.selectFirstColumn(); @@ -309,7 +341,8 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Data: show / hide grouping details.', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); // Group first calcHelper.selectFirstColumn(); @@ -341,7 +374,8 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Check version information.', function() { - before('hamburger_menu.ods'); + helper.setupAndLoadDocument('calc/hamburger_menu.ods'); + mobileHelper.enableEditingMobile(); mobileHelper.selectHamburgerMenuItem(['About']); diff --git a/cypress_test/integration_tests/mobile/calc/nextcloud_spec.js b/cypress_test/integration_tests/mobile/calc/nextcloud_spec.js index dffb346499..0b13aef8c6 100644 --- a/cypress_test/integration_tests/mobile/calc/nextcloud_spec.js +++ b/cypress_test/integration_tests/mobile/calc/nextcloud_spec.js @@ -5,16 +5,12 @@ var mobileHelper = require('../../common/mobile_helper'); var nextcloudHelper = require('../../common/nextcloud_helper'); describe(['tagnextcloud'], 'Nextcloud specific tests.', function() { - var origTestFileName = 'nextcloud.ods'; - var testFileName; it('Insert image from storage.', function() { - helper.upLoadFileToNextCloud('image_to_insert.png', 'calc'); - - testFileName = helper.beforeAll(origTestFileName, 'calc', undefined, true); - + helper.setupAndLoadDocument('calc/nextcloud.ods'); mobileHelper.enableEditingMobile(); + helper.upLoadFileToNextCloud('image_to_insert.png', 'calc'); nextcloudHelper.insertImageFromStorage('image_to_insert.png'); // TODO @@ -23,12 +19,10 @@ describe(['tagnextcloud'], 'Nextcloud specific tests.', function() { }); it('Save as.', function() { - testFileName = helper.beforeAll(origTestFileName, 'calc'); - - // Click on edit button + var newFileName = helper.setupAndLoadDocument('calc/nextcloud.ods'); mobileHelper.enableEditingMobile(); - nextcloudHelper.saveFileAs('1' + testFileName); + nextcloudHelper.saveFileAs('1' + newFileName); // Close the document cy.cGet('#mobile-edit-button') @@ -41,16 +35,15 @@ describe(['tagnextcloud'], 'Nextcloud specific tests.', function() { Cypress.env('IFRAME_LEVEL', ''); }); - cy.cGet('tr[data-file=\'1' + testFileName + '\']') + cy.cGet('tr[data-file=\'1' + newFileName + '\']') .should('be.visible'); - cy.cGet('tr[data-file=\'' + testFileName + '\']') + cy.cGet('tr[data-file=\'' + newFileName + '\']') .should('be.visible'); }); it('Share.', function() { - testFileName = helper.beforeAll(origTestFileName, 'calc'); - + helper.setupAndLoadDocument('calc/nextcloud.ods'); mobileHelper.enableEditingMobile(); nextcloudHelper.checkAndCloseSharing(); diff --git a/cypress_test/integration_tests/mobile/impress/annotation_spec.js b/cypress_test/integration_tests/mobile/impress/annotation_spec.js index 77ec6c1a5e..e962a4d423 100644 --- a/cypress_test/integration_tests/mobile/impress/annotation_spec.js +++ b/cypress_test/integration_tests/mobile/impress/annotation_spec.js @@ -4,11 +4,10 @@ var helper = require('../../common/helper'); var mobileHelper = require('../../common/mobile_helper'); describe(['tagmobile'], 'Annotation tests.', function() { - var origTestFileName = 'annotation.odp'; - var testFileName; + var newFileName; beforeEach(function() { - testFileName = helper.beforeAll(origTestFileName, 'impress'); + newFileName = helper.setupAndLoadDocument('impress/annotation.odp'); mobileHelper.enableEditingMobile(); }); @@ -18,7 +17,7 @@ describe(['tagmobile'], 'Annotation tests.', function() { mobileHelper.selectHamburgerMenuItem(['File', 'Save']); - helper.reload(testFileName, 'impress', true); + helper.reloadDocument(newFileName,'impress'); mobileHelper.enableEditingMobile(); diff --git a/cypress_test/integration_tests/mobile/impress/hamburger_menu_spec.js b/cypress_test/integration_tests/mobile/impress/hamburger_menu_spec.js index 94fedd7c98..97845d7653 100644 --- a/cypress_test/integration_tests/mobile/impress/hamburger_menu_spec.js +++ b/cypress_test/integration_tests/mobile/impress/hamburger_menu_spec.js @@ -1,4 +1,4 @@ -/* global describe it cy require */ +/* global describe it cy require beforeEach */ var helper = require('../../common/helper'); var impressHelper = require('../../common/impress_helper'); @@ -6,18 +6,16 @@ var mobileHelper = require('../../common/mobile_helper'); var repairHelper = require('../../common/repair_document_helper'); describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { - var testFileName = ''; + var newFileName; - function before(testFile) { - testFileName = helper.beforeAll(testFile, 'impress'); + beforeEach(function() { + newFileName = helper.setupAndLoadDocument('impress/hamburger_menu.odp'); // Click on edit button mobileHelper.enableEditingMobile(); - } + }); it('Save', { defaultCommandTimeout: 60000 }, function() { - before('hamburger_menu.odp'); - // Change the document content and save it impressHelper.selectTextShapeInTheCenter(); @@ -37,7 +35,7 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { mobileHelper.selectHamburgerMenuItem(['File', 'Save']); // Reopen the document and check content. - helper.reload(testFileName, 'impress', true); + helper.reloadDocument(newFileName,'impress'); mobileHelper.enableEditingMobile(); @@ -48,8 +46,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Print', function() { - before('hamburger_menu.odp'); - // A new window should be opened with the PDF. cy.getFrameWindow() .then(function(win) { @@ -62,8 +58,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Download as PDF', function() { - before('hamburger_menu.odp'); - mobileHelper.selectHamburgerMenuItem(['Download as', 'PDF Document (.pdf)']); mobileHelper.pressPushButtonOfDialog('Export'); @@ -73,8 +67,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Download as ODP', function() { - before('hamburger_menu.odp'); - mobileHelper.selectHamburgerMenuItem(['Download as', 'ODF presentation (.odp)']); cy.cGet('iframe') @@ -83,8 +75,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Download as PPT', function() { - before('hamburger_menu.odp'); - mobileHelper.selectHamburgerMenuItem(['Download as', 'PowerPoint 2003 Presentation (.ppt)']); cy.cGet('iframe') @@ -93,8 +83,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Download as PPTX', function() { - before('hamburger_menu.odp'); - mobileHelper.selectHamburgerMenuItem(['Download as', 'PowerPoint Presentation (.pptx)']); cy.cGet('iframe') @@ -103,8 +91,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Undo/redo.', function() { - before('hamburger_menu.odp'); - impressHelper.selectTextShapeInTheCenter(); cy.cGet('.leaflet-pane.leaflet-overlay-pane g.Page .TextPosition tspan') @@ -138,8 +124,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Repair.', function() { - before('hamburger_menu.odp'); - impressHelper.selectTextShapeInTheCenter(); cy.cGet('.leaflet-pane.leaflet-overlay-pane g.Page .TextPosition tspan') @@ -164,8 +148,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Cut.', function() { - before('hamburger_menu.odp'); - impressHelper.selectTextShapeInTheCenter(); impressHelper.selectTextOfShape(); @@ -175,8 +157,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Copy.', function() { - before('hamburger_menu.odp'); - impressHelper.selectTextShapeInTheCenter(); impressHelper.selectTextOfShape(); @@ -186,8 +166,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Paste.', function() { - before('hamburger_menu.odp'); - impressHelper.selectTextShapeInTheCenter(); impressHelper.selectTextOfShape(); @@ -197,8 +175,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Select all.', function() { - before('hamburger_menu.odp'); - impressHelper.selectTextShapeInTheCenter(); impressHelper.dblclickOnSelectedShape(); @@ -214,8 +190,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it.skip('Search some word.', function() { - before('hamburger_menu.odp'); - mobileHelper.selectHamburgerMenuItem(['Search']); // Search bar become visible @@ -238,8 +212,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Slide: New Slide.', function() { - before('hamburger_menu.odp'); - impressHelper.assertNumberOfSlidePreviews(1); mobileHelper.selectHamburgerMenuItem(['Slide', 'New Slide']); @@ -248,8 +220,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Slide: Duplicate Slide.', function() { - before('hamburger_menu.odp'); - impressHelper.assertNumberOfSlidePreviews(1); mobileHelper.selectHamburgerMenuItem(['Slide', 'Duplicate Slide']); @@ -258,8 +228,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Slide: Delete Slide.', function() { - before('hamburger_menu.odp'); - impressHelper.assertNumberOfSlidePreviews(1); mobileHelper.selectHamburgerMenuItem(['Slide', 'New Slide']); @@ -276,8 +244,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Full Screen.', function() { - before('hamburger_menu.odp'); - mobileHelper.selectHamburgerMenuItem(['Full Screen']); // TODO: We can't hit the actual full screen from cypress @@ -285,8 +251,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Fullscreen presentation.', function() { - before('hamburger_menu.odp'); - cy.cGet('iframe.leaflet-slideshow') .should('not.exist'); @@ -297,8 +261,6 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { }); it('Check version information.', function() { - before('hamburger_menu.odp'); - mobileHelper.selectHamburgerMenuItem(['About']); cy.cGet('#mobile-wizard-content') diff --git a/cypress_test/integration_tests/mobile/impress/nextcloud_spec.js b/cypress_test/integration_tests/mobile/impress/nextcloud_spec.js index a5aa9ec2f1..a71439ae0c 100644 --- a/cypress_test/integration_tests/mobile/impress/nextcloud_spec.js +++ b/cypress_test/integration_tests/mobile/impress/nextcloud_spec.js @@ -1,26 +1,28 @@ -/* global describe it cy require Cypress */ +/* global describe it cy require Cypress beforeEach */ var helper = require('../../common/helper'); var mobileHelper = require('../../common/mobile_helper'); var nextcloudHelper = require('../../common/nextcloud_helper'); describe(['tagnextcloud'], 'Nextcloud specific tests.', function() { - var origTestFileName = 'nextcloud.odp'; - var testFileName; + + beforeEach(function() { + }); it('Insert image from storage.', function() { - helper.upLoadFileToNextCloud('image_to_insert.png', 'impress'); - testFileName = helper.beforeAll(origTestFileName, 'impress', undefined, true); + helper.setupAndLoadDocument('impress/nextcloud.odp'); mobileHelper.enableEditingMobile(); + + helper.upLoadFileToNextCloud('image_to_insert.png', 'impress'); nextcloudHelper.insertImageFromStorage('image_to_insert.png'); cy.cGet('.leaflet-pane.leaflet-overlay-pane svg g').should('exist'); }); it('Save as.', function() { - testFileName = helper.beforeAll(origTestFileName, 'impress'); - // Click on edit button + var newFileName = helper.setupAndLoadDocument('impress/nextcloud.odp'); mobileHelper.enableEditingMobile(); - nextcloudHelper.saveFileAs('1' + testFileName); + + nextcloudHelper.saveFileAs('1' + newFileName); // Close the document cy.cGet('#mobile-edit-button').should('be.visible'); cy.cGet('#toolbar-mobile-back').then(function(item) { @@ -29,13 +31,14 @@ describe(['tagnextcloud'], 'Nextcloud specific tests.', function() { Cypress.env('IFRAME_LEVEL', ''); }); - cy.cGet('tr[data-file=\'1' + testFileName + '\']').should('be.visible'); - cy.cGet('tr[data-file=\'' + testFileName + '\']').should('be.visible'); + cy.cGet('tr[data-file=\'1' + newFileName + '\']').should('be.visible'); + cy.cGet('tr[data-file=\'' + newFileName + '\']').should('be.visible'); }); it('Share.', function() { - testFileName = helper.beforeAll(origTestFileName, 'impress'); + helper.setupAndLoadDocument('impress/nextcloud.odp'); mobileHelper.enableEditingMobile(); + nextcloudHelper.checkAndCloseSharing(); }); }); diff --git a/cypress_test/integration_tests/mobile/impress/slide_properties_spec.js b/cypress_test/integration_tests/mobile/impress/slide_properties_spec.js index c36bc09171..c26be91a48 100644 --- a/cypress_test/integration_tests/mobile/impress/slide_properties_spec.js +++ b/cypress_test/integration_tests/mobile/impress/slide_properties_spec.js @@ -293,10 +293,7 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Changing slide properties.' }); it('Apply master slide layout.', function() { - // Wait for mobile wizard menu - cy.wait(500); - - // We have white background by deafult checked by before() method + // We have white background by deafult checked by beforeEach() method // Select a new master slide with a background color cy.cGet('#masterslide .ui-header-left').should('have.text', 'Default'); diff --git a/cypress_test/integration_tests/mobile/writer/annotation_spec.js b/cypress_test/integration_tests/mobile/writer/annotation_spec.js index 70e30b393d..26c9b57a2f 100644 --- a/cypress_test/integration_tests/mobile/writer/annotation_spec.js +++ b/cypress_test/integration_tests/mobile/writer/annotation_spec.js @@ -4,21 +4,18 @@ var helper = require('../../common/helper'); var mobileHelper = require('../../common/mobile_helper'); describe(['tagmobile'], 'Annotation tests.', function() { - var origTestFileName = 'annotation.odt'; - var testFileName; + var newFileName; beforeEach(function() { - testFileName = helper.beforeAll(origTestFileName, 'writer'); + newFileName = helper.setupAndLoadDocument('writer/annotation.odt'); - // Click on edit button mobileHelper.enableEditingMobile(); }); it('Saving comment.', { defaultCommandTimeout: 60000 }, function() { - cy.wait(1000); mobileHelper.insertComment(); mobileHelper.selectHamburgerMenuItem(['File', 'Save']); - helper.reload(testFileName, 'writer', true); + helper.reloadDocument(newFileName, 'writer'); mobileHelper.enableEditingMobile(); mobileHelper.openCommentWizard(); helper.waitUntilIdle('#mobile-wizard-content', undefined); diff --git a/cypress_test/integration_tests/mobile/writer/hamburger_menu_spec.js b/cypress_test/integration_tests/mobile/writer/hamburger_menu_spec.js index 20add56f4f..abbb05f20a 100644 --- a/cypress_test/integration_tests/mobile/writer/hamburger_menu_spec.js +++ b/cypress_test/integration_tests/mobile/writer/hamburger_menu_spec.js @@ -6,11 +6,10 @@ var writerHelper = require('../../common/writer_helper'); var repairHelper = require('../../common/repair_document_helper'); describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { - var origTestFileName = 'hamburger_menu.odt'; - var testFileName; + var newFileName; beforeEach(function() { - testFileName = helper.beforeAll(origTestFileName, 'writer'); + newFileName = helper.setupAndLoadDocument('writer/hamburger_menu.odt'); mobileHelper.enableEditingMobile(); }); @@ -48,7 +47,7 @@ describe.skip(['tagmobile'], 'Trigger hamburger menu options.', function() { helper.expectTextForClipboard('new'); mobileHelper.selectHamburgerMenuItem(['File', 'Save']); // Reopen the document and check content. - helper.reload(testFileName, 'writer', true); + helper.reloadDocument(newFileName, 'writer'); mobileHelper.enableEditingMobile(); writerHelper.selectAllTextOfDoc(); helper.expectTextForClipboard('new'); diff --git a/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js b/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js index 9685387ae9..2d9e1e940a 100644 --- a/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js +++ b/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js @@ -5,16 +5,12 @@ var mobileHelper = require('../../common/mobile_helper'); var nextcloudHelper = require('../../common/nextcloud_helper'); describe(['tagnextcloud'], 'Nextcloud specific tests.', function() { - var origTestFileName = 'nextcloud.odt'; - var testFileName; it('Insert image from storage.', function() { - helper.upLoadFileToNextCloud('image_to_insert.png', 'writer'); - - testFileName = helper.beforeAll(origTestFileName, 'writer', undefined, true); - + helper.setupAndLoadDocument('writer/nextcloud.odt'); mobileHelper.enableEditingMobile(); + helper.upLoadFileToNextCloud('image_to_insert.png', 'writer'); nextcloudHelper.insertImageFromStorage('image_to_insert.png'); cy.get('.leaflet-pane.leaflet-overlay-pane svg g.Graphic') @@ -22,11 +18,10 @@ describe(['tagnextcloud'], 'Nextcloud specific tests.', function() { }); it('Save as.', function() { - testFileName = helper.beforeAll(origTestFileName, 'writer'); - + var newFileName = helper.setupAndLoadDocument('writer/nextcloud.odt'); mobileHelper.enableEditingMobile(); - nextcloudHelper.saveFileAs('1' + testFileName); + nextcloudHelper.saveFileAs('1' + newFileName); // Close the document cy.get('#mobile-edit-button') @@ -39,16 +34,15 @@ describe(['tagnextcloud'], 'Nextcloud specific tests.', function() { Cypress.env('IFRAME_LEVEL', ''); }); - cy.get('tr[data-file=\'1' + testFileName + '\']') + cy.get('tr[data-file=\'1' + newFileName + '\']') .should('be.visible'); - cy.get('tr[data-file=\'' + testFileName + '\']') + cy.get('tr[data-file=\'' + newFileName + '\']') .should('be.visible'); }); it('Share.', function() { - testFileName = helper.beforeAll(origTestFileName, 'writer'); - + helper.setupAndLoadDocument('writer/nextcloud.odt'); mobileHelper.enableEditingMobile(); nextcloudHelper.checkAndCloseSharing(); diff --git a/cypress_test/integration_tests/mobile/writer/table_properties_spec.js b/cypress_test/integration_tests/mobile/writer/table_properties_spec.js index 7f5822e25b..c76ba05383 100644 --- a/cypress_test/integration_tests/mobile/writer/table_properties_spec.js +++ b/cypress_test/integration_tests/mobile/writer/table_properties_spec.js @@ -6,8 +6,8 @@ var writerHelper = require('../../common/writer_helper'); describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Change table properties / layout via mobile wizard.', function() { - function before(testFile) { - helper.setupAndLoadDocument('writer/' + testFile); + function before(fileName) { + helper.setupAndLoadDocument('writer/' + fileName); // Click on edit button mobileHelper.enableEditingMobile(); diff --git a/cypress_test/integration_tests/multiuser/calc/invalidations_spec.js b/cypress_test/integration_tests/multiuser/calc/invalidations_spec.js index 45b69f4185..d8d0558616 100644 --- a/cypress_test/integration_tests/multiuser/calc/invalidations_spec.js +++ b/cypress_test/integration_tests/multiuser/calc/invalidations_spec.js @@ -27,10 +27,14 @@ describe(['tagmultiuser'], 'Joining a document should not trigger an invalidatio const beforeCount = $before.text(); // joining triggered some theme related invalidations + + // Reload page cy.cSetActiveFrame('#iframe2'); cy.get('#form2').submit(); + // Wait for page to unload + cy.wait(1000); // Wait for page to finish loading - helper.checkIfDocIsLoaded(true); + helper.documentChecks(); cy.cSetActiveFrame('#iframe1'); cy.cGet('input#addressInput').should('have.prop', 'value', 'A1'); diff --git a/cypress_test/integration_tests/multiuser/writer/invalidations_spec.js b/cypress_test/integration_tests/multiuser/writer/invalidations_spec.js index 4a8ad1fdc3..d5ededb8d9 100644 --- a/cypress_test/integration_tests/multiuser/writer/invalidations_spec.js +++ b/cypress_test/integration_tests/multiuser/writer/invalidations_spec.js @@ -83,8 +83,10 @@ describe(['tagmultiuser'], 'Joining a document should not trigger an invalidatio // Reload page cy.cSetActiveFrame('#iframe2'); cy.get('#form2').submit(); + // Wait for page to unload + cy.wait(1000); // Wait for page to finish loading - helper.checkIfDocIsLoaded(true); + helper.documentChecks(); cy.cSetActiveFrame('#iframe1'); writerHelper.selectAllTextOfDoc();