From f426e601cecedac77b733532030d57830c48103d Mon Sep 17 00:00:00 2001 From: nimya-aot Date: Wed, 30 Oct 2024 09:42:54 -0700 Subject: [PATCH] #1547 test scripts for export/imprt design --- .../form-design-export-import-design.cy.js | 103 ++++++++++++++++++ .../cypress/fixtures/test_schema.json | 1 + 2 files changed, 104 insertions(+) create mode 100644 tests/functional/cypress/e2e/form-design-export-import-design.cy.js create mode 100644 tests/functional/cypress/fixtures/test_schema.json diff --git a/tests/functional/cypress/e2e/form-design-export-import-design.cy.js b/tests/functional/cypress/e2e/form-design-export-import-design.cy.js new file mode 100644 index 000000000..1e93ce848 --- /dev/null +++ b/tests/functional/cypress/e2e/form-design-export-import-design.cy.js @@ -0,0 +1,103 @@ +import 'cypress-keycloak-commands'; +import 'cypress-drag-drop'; +import { formsettings } from '../support/login.js'; + +const depEnv = Cypress.env('depEnv'); + + +Cypress.Commands.add('waitForLoad', () => { + const loaderTimeout = 60000; + + cy.get('.nprogress-busy', { timeout: loaderTimeout }).should('not.exist'); +}); + + + +describe('Form Designer', () => { + + beforeEach(()=>{ + + + + cy.on('uncaught:exception', (err, runnable) => { + // Form.io throws an uncaught exception for missing projectid + // Cypress catches it as undefined: undefined so we can't get the text + console.log(err); + return false; + }); + }); + it('Visits the form settings page', () => { + + + cy.viewport(1000, 1100); + cy.waitForLoad(); + + formsettings(); + + + }); +// Publish a simple form with Simplebc Address component + it('Checks Export/Import design functionality', () => { + cy.viewport(1000, 1100); + cy.waitForLoad(); + + cy.get('button').contains('BC Government').click(); + cy.get('div.formio-builder-form').then($el => { + const coords = $el[0].getBoundingClientRect(); + cy.get('[data-key="simplebcaddress"]') + .trigger('mousedown', { which: 1}, { force: true }) + .trigger('mousemove', coords.x, -550, { force: true }) + //.trigger('mousemove', coords.y, +100, { force: true }) + .trigger('mouseup', { force: true }); + cy.waitForLoad(); + //cy.get('input[name="data[label]"]').type('s'); + cy.get('button').contains('Save').click(); + //cy.get('.btn-success').click(); + + + }); + + cy.get('.mdi-publish').click(); + let fileUploadInputField = cy.get('input[type=file]'); + cy.get('input[type=file]').should('not.to.be.null'); + fileUploadInputField.attachFile('test_schema.json'); + cy.wait(2000); + cy.get('input[name="data[simplebcaddress]"]').should('not.exist'); + + cy.get('.mdi-download').click(); + cy.wait(2000); + //Verifies design downloads into download folder + cy.get("h3").then(($elem) => { + const rem = $elem.text(); + let arr = rem.split(':'); + + cy.log(arr); + let remname = arr[1] + "_schema.json"; + cy.wait(2000); + cy.readFile(`cypress\\downloads\\${remname}`).should("exist"); + }); + //Verify visibility of right side buttons on design page + cy.get('[data-cy="saveButton"] > .v-btn').should('be.enabled'); + cy.get('[data-cy="previewRouterLink"] > .v-btn').should('be.enabled'); + cy.get('[data-cy="undoButton"] > .v-btn').should('be.enabled'); + cy.get('[data-cy="redoButton"] > .v-btn').should('not.be.enabled'); + cy.get('.mdi-undo').click(); + cy.get('[data-cy="redoButton"] > .v-btn').should('be.enabled'); + cy.get('.float-button > :nth-child(1) > .v-btn').should('be.enabled'); + cy.get('.float-button > :nth-child(1) > .v-btn').click(); + cy.get('.mdi-arrow-down').should('not.exist'); + + cy.get('.mdi-arrow-up').should('exist'); + cy.get('.mdi-close').click(); + cy.get('[data-cy="saveButton"] > .v-btn').should('not.exist'); + cy.get('.mdi-undo').should('not.exist'); + cy.get('.mdi-redo').should('not.exist'); + cy.get('.mdi-menu').should('be.visible'); + cy.get('.mdi-arrow-up').should('be.visible'); + cy.get('#logoutButton > .v-btn__content > span').click(); + + +}); + + +}); \ No newline at end of file diff --git a/tests/functional/cypress/fixtures/test_schema.json b/tests/functional/cypress/fixtures/test_schema.json new file mode 100644 index 000000000..fc7e4b30b --- /dev/null +++ b/tests/functional/cypress/fixtures/test_schema.json @@ -0,0 +1 @@ +{"display":"form","type":"form","components":[{"label":"Text Field","labelPosition":"top","placeholder":"","description":"","tooltip":"","inputMask":"","allowMultipleMasks":false,"hideLabel":false,"showWordCount":false,"showCharCount":false,"spellcheck":true,"disabled":false,"multiple":false,"case":"","validate":{"isUseForCopy":false,"required":false,"customMessage":"","minLength":"","maxLength":"","custom":"","customPrivate":false,"strictDateValidation":false,"multiple":false,"unique":false,"pattern":""},"key":"simpletextfield","conditional":{"show":null,"when":null,"eq":"","json":""},"customConditional":"","type":"simpletextfield","input":true,"prefix":"","customClass":"","suffix":"","protected":false,"unique":false,"persistent":true,"hidden":false,"clearOnHide":true,"refreshOn":"","redrawOn":"","tableView":false,"modalEdit":false,"dataGridLabel":false,"errorLabel":"","tabindex":"","autofocus":false,"dbIndex":false,"customDefaultValue":"","calculateValue":"","calculateServer":false,"widget":{"type":"input"},"attributes":{},"validateOn":"change","overlay":{"style":"","left":"","top":"","width":"","height":""},"allowCalculateOverride":false,"encrypted":false,"properties":{},"addons":[],"mask":false,"inputType":"text","inputFormat":"plain","displayMask":"","truncateMultipleSpaces":false,"id":"e06ab8h","defaultValue":null},{"label":"Select List","labelPosition":"top","placeholder":"","description":"","tooltip":"","hideLabel":false,"disabled":false,"multiple":false,"data":{"values":[{"label":"","value":""}],"json":"","url":"","resource":"","custom":""},"validate":{"isUseForCopy":false,"required":false,"customMessage":"","custom":"","customPrivate":false,"strictDateValidation":false,"multiple":false,"unique":false,"onlyAvailableItems":false},"key":"simpleselect","conditional":{"show":null,"when":null,"eq":"","json":""},"customConditional":"","type":"simpleselect","input":true,"prefix":"","customClass":"","suffix":"","protected":false,"unique":false,"persistent":true,"hidden":false,"clearOnHide":true,"refreshOn":"","redrawOn":"","tableView":true,"modalEdit":false,"dataGridLabel":false,"errorLabel":"","tabindex":"","autofocus":false,"dbIndex":false,"customDefaultValue":"","calculateValue":"","calculateServer":false,"widget":"choicesjs","attributes":{},"validateOn":"change","overlay":{"style":"","left":"","top":"","width":"","height":""},"allowCalculateOverride":false,"encrypted":false,"showCharCount":false,"showWordCount":false,"properties":{},"allowMultipleMasks":false,"addons":[],"dataSrc":"values","authenticate":false,"ignoreCache":false,"template":"{{ item.label }}","idPath":"id","clearOnRefresh":false,"limit":100,"valueProperty":"","lazyLoad":true,"filter":"","searchEnabled":true,"searchDebounce":0.3,"searchField":"","minSearch":0,"readOnlyValue":false,"selectFields":"","selectThreshold":0.3,"uniqueOptions":false,"fuseOptions":{"include":"score","threshold":0.3},"indexeddb":{"filter":{}},"customOptions":{},"useExactSearch":false,"dataType":"auto","searchThreshold":0.3,"id":"e1sd0mn","defaultValue":""},{"type":"button","label":"Submit","key":"submit","size":"md","block":false,"action":"submit","disableOnInvalid":true,"theme":"primary","id":"efoc92","input":true,"placeholder":"","prefix":"","customClass":"","suffix":"","multiple":false,"defaultValue":null,"protected":false,"unique":false,"persistent":false,"hidden":false,"clearOnHide":true,"refreshOn":"","redrawOn":"","tableView":false,"modalEdit":false,"dataGridLabel":true,"labelPosition":"top","description":"","errorLabel":"","tooltip":"","hideLabel":false,"tabindex":"","disabled":false,"autofocus":false,"dbIndex":false,"customDefaultValue":"","calculateValue":"","calculateServer":false,"widget":{"type":"input"},"attributes":{},"validateOn":"change","validate":{"required":false,"custom":"","customPrivate":false,"strictDateValidation":false,"multiple":false,"unique":false},"conditional":{"show":null,"when":null,"eq":""},"overlay":{"style":"","left":"","top":"","width":"","height":""},"allowCalculateOverride":false,"encrypted":false,"showCharCount":false,"showWordCount":false,"properties":{},"allowMultipleMasks":false,"addons":[],"leftIcon":"","rightIcon":""}]} \ No newline at end of file