Skip to content

Commit

Permalink
bcgov#1478/Draft submission
Browse files Browse the repository at this point in the history
  • Loading branch information
nimya-aot committed Oct 1, 2024
1 parent 9e68aa7 commit dc01c69
Showing 1 changed file with 125 additions and 0 deletions.
125 changes: 125 additions & 0 deletions tests/functional/cypress/e2e/form-submission-draft-management.cy.js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
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
it('Verify draft submission', () => {
cy.viewport(1000, 1100);
cy.waitForLoad();

cy.get('button').contains('Basic Fields').click();
cy.get('div.formio-builder-form').then($el => {
const coords = $el[0].getBoundingClientRect();
cy.get('span.btn').contains('Text Field')

.trigger('mousedown', { which: 1}, { force: true })
.trigger('mousemove', coords.x, -50, { force: true })
.trigger('mouseup', { force: true });
cy.get('button').contains('Save').click();
});
cy.intercept('GET', `/${depEnv}/api/v1/forms/*`).as('getForm');
// Form saving
let savedButton = cy.get('[data-cy=saveButton]');
expect(savedButton).to.not.be.null;
savedButton.trigger('click');
cy.waitForLoad();


// Go to My forms
cy.wait('@getForm').then(()=>{
let userFormsLinks = cy.get('[data-cy=userFormsLinks]');
expect(userFormsLinks).to.not.be.null;
userFormsLinks.trigger('click');
});
// Filter the newly created form
cy.location('search').then(search => {
//let pathName = fullUrl.pathname
let arr = search.split('=');
let arrayValues = arr[1].split('&');
cy.log(arrayValues[0]);
cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`);
cy.waitForLoad();


//Publish the form
cy.get('.v-label > span').click();

cy.get('span').contains('Publish Version 1');

cy.contains('Continue').should('be.visible');
cy.contains('Continue').trigger('click');
//Share link verification
let shareFormButton = cy.get('[data-cy=shareFormButton]');
expect(shareFormButton).to.not.be.null;
shareFormButton.trigger('click').then(()=>{
//let shareFormLinkButton = cy.get('[data-cy=shareFormLinkButtonss]');
let shareFormLinkButton=cy.get('.mx-2');
expect(shareFormLinkButton).to.not.be.null;
shareFormLinkButton.trigger('click');
cy.get('.mx-2 > .v-btn').click();
})
//Form submission and verification for public forms
cy.visit(`/${depEnv}/form/submit?f=${arrayValues[0]}`);
cy.waitForLoad();
cy.get('button').contains('Submit').should('be.visible');
cy.waitForLoad();
cy.waitForLoad();
cy.contains('Text Field').click();
cy.contains('Text Field').type('Alex');
cy.get('.mt-6 > :nth-child(1) > .v-btn > .v-btn__content > span').click();
cy.get('div > .bg-primary').click();
cy.get('.v-data-table__tr > :nth-child(4)').contains('DRAFT');
cy.get('.mdi-pencil').click();
cy.get('.mdi-content-save').click();
cy.get('.v-alert__content > div').contains('Draft Saved');
cy.get(':nth-child(2) > :nth-child(4) > :nth-child(1) > .v-btn').click();
//cy.get('.mt-6 > :nth-child(1) > .v-btn > .v-btn__content > span').click();
//cy.get('div > .bg-primary').click();


//Delete form after test run
//cy.get('.mdi-delete').click();
//cy.get(':nth-child(5) > .v-btn > .v-btn__content > .mdi-delete').click();
//cy.get('[data-test="continue-btn-continue"]').click();
//cy.get('#logoutButton > .v-btn__content > span').click();


});

});

});

0 comments on commit dc01c69

Please sign in to comment.