From a86f055a5679f7f5aaa9b0bc913794b3938feeac Mon Sep 17 00:00:00 2001 From: Nimya John <78105113+nimya-aot@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:34:22 -0800 Subject: [PATCH] test:FORMS-1547 Cypress test scripts for design export/import design functionality (#1530) * #FORMS-974 * #974 updates * #980 modification to cypress config * FORMS-980 * #992 * #992 Fix cypress scripts * #1011 Form design page * #1011 test scripts * #1023 cypress scripts * #1023 advanced data components * #1023 Updated scripts * #1023 updation * Updated json file * Test/forms (#1011)(#1023) (#1307) * #FORMS-974 * #974 updates * #980 modification to cypress config * FORMS-980 * #992 * #992 Fix cypress scripts * #1011 Form design page * #1011 test scripts * #1023 cypress scripts * #1023 advanced data components * #1023 Updated scripts * #1023 updation * Updated json file * #1059 workflow file for cypress * #1059 updated the base url * #1059 updated workflow * Updated node version * updated * updated * Updation * updated file * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * updated package file * Update cypress-ci.yaml * Updated config file * Update cypress-ci.yaml * #1059 updated package * #1060 scripts for Advanced fields and BC Gov components * Fixing review comments * Updated changes * # Updated with PR comments * updated * Update form-design-basicfields.cy.js * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Modifies test scripts * Updated files * Fixed errors during CI/CD Run * Updated browser type * Updated Simple BC address component * Updated * Fields updated * Test script changed * Updated * Updated fields * Updated env variable * Update form-design-basicfields.cy.js * Updated * Update cypress-ci.yaml * Updated email input * screenshots * Updated path * Update cypress-ci.yaml * Update cypress-ci.yaml * Updated version on workflow * Fix to failed tests * Fix to BC address component * Updated the component * Changed button element * Fixed BC components * Modified submission * Modified components * Updated attribute * Updated * Changed simpleBC address component * Update package.json * Update package-lock.json * Test scripts * Updated * Pushed the changes * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Env change * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Update cypress-ci.yaml * Updated * Updated to take default env variable * Updated with current workflow * updated * Formatted * Update cypress.config.js * updated * Test scripts for updating submission data * Scripts for adding notes * Added scripts for logout after each run * Adding statuses to submission * Fixed alert message for subscription settings * Fixing CI/CD running issues * Fixed issues on schedule date verification * #1488 public form submission * #1488 form for public * form settings page for public form * Added scripts for public forms with no status assign ability * Changes with login page * Removed additional login page * #1478/Draft submission * Scripts for draft submission * #1478 Added column management functionality and delete button * Fixed some CI/Cd issues * #1478 Renamed public form * Removed duplicate files * # Fixed issues after implimenting custom metadata * Updated settings button * #1540 Test scripts for revise status changes * Modified scripts * Fixed CI/Cd issue * #1547 test scripts for export/imprt design * #1547 added preview form * Added downloads folder to config file * Added downloads folder * Fixed spacing issue * Removed downloaded files * Modified download folder path * Fixed some fornmatting issue * Updated component check --------- Co-authored-by: jasonchung1871 <101672465+jasonchung1871@users.noreply.github.com> --- tests/functional/cypress.config.js | 1 + .../form-design-export-import-design.cy.js | 135 ++++++++++++++++++ .../cypress/fixtures/test_schema.json | 1 + 3 files changed, 137 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.config.js b/tests/functional/cypress.config.js index f2fccdbea..6837e51a7 100644 --- a/tests/functional/cypress.config.js +++ b/tests/functional/cypress.config.js @@ -16,6 +16,7 @@ module.exports = defineConfig({ video: false, fixturesFolder: 'cypress/fixtures', screenshotsFolder: 'screenshots', + downloadsFolder: 'cypress/downloads', videosFolder: 'videos', e2e: { 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..7a3e33276 --- /dev/null +++ b/tests/functional/cypress/e2e/form-design-export-import-design.cy.js @@ -0,0 +1,135 @@ +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); + const path = require("path"); + const downloadsFolder=Cypress.config("downloadsFolder"); + cy.readFile(path.join(downloadsFolder,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('[data-cy="redoButton"] > .v-btn').click(); + 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('.mdi-menu').click(); + + + // Form saving + let savedButton = cy.get('[data-cy=saveButton]'); + expect(savedButton).to.not.be.null; + savedButton.trigger('click'); + cy.wait(2000); + + // Filter the newly created form + cy.location('search').then(search => { + let arr = search.split('='); + let arrayValues = arr[1].split('&'); + cy.log(arrayValues[0]); + let dval=arr[2].split('&'); + cy.log(dval); + //Form preview + cy.visit(`/${depEnv}/form/preview?f=${arrayValues[0]}&d=${dval[0]}`); + cy.waitForLoad(); + //Verify new design is updated in the form + cy.get('label').contains('Select List').should('be.visible'); + + //Delete form after test run + cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`); + cy.waitForLoad(); + cy.get('[data-test="canRemoveForm"]').click(); + cy.get('[data-test="continue-btn-continue"]').click(); + 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