diff --git a/tests/functional/cypress/e2e/form-design-basicfields.cy.js b/tests/functional/cypress/e2e/form-design-basicfields.cy.js index dea46f40b..eeced0893 100644 --- a/tests/functional/cypress/e2e/form-design-basicfields.cy.js +++ b/tests/functional/cypress/e2e/form-design-basicfields.cy.js @@ -221,7 +221,7 @@ describe('Form Designer', () => { }); cy.waitForLoad(); - cy.get('[data-cy="settingsRouterLink"]').click(); + cy.get('.mdi-cog').click(); cy.get('a > .v-btn > .v-btn__content > .mdi-pencil').click(); cy.wait(4000); diff --git a/tests/functional/cypress/e2e/form-draft-submission-management.cy.js b/tests/functional/cypress/e2e/form-draft-submission-management.cy.js new file mode 100644 index 000000000..505db1568 --- /dev/null +++ b/tests/functional/cypress/e2e/form-draft-submission-management.cy.js @@ -0,0 +1,169 @@ +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(); + }) + //Draft submission and verification + 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'); + //Verify draft delete button exist + cy.get('[icon-size="x-small"] > .v-btn').should('be.exist'); + //View column management + cy.get('.mdi-view-column').click(); + cy.get('[data-test="filter-search"]').type('Status'); + //Remove Status column from draft submission table + cy.get('input[type="checkbox"]').then($el => { + + const rem=$el[1]; + cy.get(rem).click(); + + }); + //Verify Status column is removed from submission table + cy.get('[data-test="save-btn"] > .v-btn__content').click(); + cy.get('.v-data-table__tr > :nth-child(4)').contains('DRAFT').should('not.exist'); + 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(); + //Manage members for draft management + cy.get('form > .v-input > .v-input__control > .v-field > .v-field__field > .v-field__input').click(); + cy.get('form > .v-input > .v-input__control > .v-field > .v-field__field > .v-field__input').type('NIM'); + cy.contains('John, Nimya 1 CITZ:EX (nimya.1.john@gov.bc.ca)').click(); + cy.get('.v-col-3').click(); + cy.get('tbody > :nth-child(2) > :nth-child(1)').contains('John, Nimya 1 CITZ:EX').should('be.visible'); + cy.get(':nth-child(1) > :nth-child(4) > .v-btn > .v-btn__content > .mdi-minus').should('not.be.enabled'); + //Remove added member + cy.get(':nth-child(2) > :nth-child(4) > .v-btn > .v-btn__content > .mdi-minus').click(); + cy.get('[data-test="continue-btn-continue"] > .v-btn__content > span').click(); + cy.get('tbody > :nth-child(2) > :nth-child(1)').should('not.exist'); + cy.wait(4000); + + cy.get('.v-card-actions > .v-btn > .v-btn__content > span').click(); + cy.waitForLoad(); + // Edit draft submission + cy.get('.mt-6 > :nth-child(1) > .v-btn > .v-btn__content > span').click(); + cy.get('.mdi-pencil').click(); + cy.waitForLoad(); + //Form submission + cy.contains('Text Field').click(); + cy.contains('Text Field').type('{selectall}{backspace}'); + cy.contains('Text Field').type('Nancy'); + cy.get('button').contains('Submit').click(); + cy.waitForLoad(); + cy.get('[data-test="continue-btn-continue"]').click({force: true}); + cy.waitForLoad(); + cy.location('pathname').should('eq', `/${depEnv}/form/success`); + cy.contains('h1', 'Your form has been submitted successfully'); + 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('SUBMITTED'); + //Delete form after test run + cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`); + cy.waitForLoad(); + cy.get('.mdi-delete').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/e2e/form-manage-form.cy.js b/tests/functional/cypress/e2e/form-manage-form.cy.js index b08d7cdc8..8b9ad06b9 100644 --- a/tests/functional/cypress/e2e/form-manage-form.cy.js +++ b/tests/functional/cypress/e2e/form-manage-form.cy.js @@ -80,7 +80,8 @@ describe('Form Designer', () => { cy.get('[data-test="text-description"]').type('test description edit'); cy.get('[data-test="canSaveAndEditDraftsCheckbox"]').click(); //Verify form schedule settings is not present - cy.get(':nth-child(5) > .v-card > .v-card-text').should('not.exist'); + + cy.get('span').contains('Form Schedule Settings').should('not.exist'); //cy.get('span').contains('UPDATE').click(); cy.get('.mb-5 > .v-btn--elevated').click(); @@ -164,7 +165,12 @@ describe('Form Designer', () => { //Closing date for submission cy.contains('Set custom closing message').click(); - cy.get('textarea').type('closed for some reasons') + cy.get('textarea').then($el => { + + const rem=$el[0]; + cy.get(rem).type('closed for some reasons'); + }); + //cy.get('textarea').type('closed for some reasons') cy.contains('SEND Reminder email').click(); cy.contains('SEND Reminder email').click(); diff --git a/tests/functional/cypress/support/login.js b/tests/functional/cypress/support/login.js index 08637931b..66ab288da 100644 --- a/tests/functional/cypress/support/login.js +++ b/tests/functional/cypress/support/login.js @@ -55,7 +55,7 @@ export function formsettings(){ cy.get('[data-test="email-test"] > .v-input__control > .v-selection-control > .v-label > div > span').click(); cy.get(':nth-child(4) > .v-card > .v-card-text > .v-text-field > .v-input__control > .v-field > .v-field__field > .v-field__input').type('abc@gmail.com'); - cy.get('.v-row > :nth-child(1) > .v-input > .v-input__control > .v-field > .v-field__field > .v-field__input').click(); + cy.get('.v-row > :nth-child(1) > .v-input > .v-input__control > .v-field > .v-field__append-inner').click(); cy.contains("Citizens' Services (CITZ)").click(); cy.get('[data-test="case-select"]').click();