Skip to content

Commit

Permalink
Merge branch 'main' into feat-map
Browse files Browse the repository at this point in the history
  • Loading branch information
abhilash-aot authored Nov 22, 2024
2 parents 6ae027c + a86f055 commit 9abd9b6
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/functional/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = defineConfig({
video: false,
fixturesFolder: 'cypress/fixtures',
screenshotsFolder: 'screenshots',
downloadsFolder: 'cypress/downloads',
videosFolder: 'videos',

e2e: {
Expand Down
135 changes: 135 additions & 0 deletions tests/functional/cypress/e2e/form-design-export-import-design.cy.js
Original file line number Diff line number Diff line change
@@ -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();
});



});


});
1 change: 1 addition & 0 deletions tests/functional/cypress/fixtures/test_schema.json
Original file line number Diff line number Diff line change
@@ -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":"<span>{{ item.label }}</span>","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":""}]}

0 comments on commit 9abd9b6

Please sign in to comment.