From 0125e48683037e540b25fe032f1718e8b3e0c311 Mon Sep 17 00:00:00 2001 From: Nimya John <78105113+nimya-aot@users.noreply.github.com> Date: Tue, 25 Feb 2025 14:22:17 -0800 Subject: [PATCH] Test: FORMS- 1787 Added cypress test scripts for Geosearch location feature (#1610) * Added line marker point for Map component * Added tests for line marker points * Added Geosearch location for Map component * Fixed some running issues * Fixed running issues on PR env * Fixed issues with element id for submission closing date * Fixed running issues --- .../cypress/e2e/form-apikey-cdogs.cy.js | 6 +- ...form-design-map-point-circle-markers.cy.js | 55 ++++++++++++++----- .../cypress/e2e/form-manage-form.cy.js | 26 +++------ ...form-submission-assign-revise-status.cy.js | 50 ++--------------- .../e2e/form-submission-assign-status.cy.js | 33 +++-------- 5 files changed, 64 insertions(+), 106 deletions(-) diff --git a/tests/functional/cypress/e2e/form-apikey-cdogs.cy.js b/tests/functional/cypress/e2e/form-apikey-cdogs.cy.js index 18c0b8d48..a99265474 100644 --- a/tests/functional/cypress/e2e/form-apikey-cdogs.cy.js +++ b/tests/functional/cypress/e2e/form-apikey-cdogs.cy.js @@ -54,12 +54,11 @@ describe('Form Designer', () => { }); - 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(); + cy.wait(3000); // Verify Api key functionality cy.get('.mdi-cog').click(); @@ -124,5 +123,4 @@ describe('Form Designer', () => { }) -}) - +}) \ No newline at end of file diff --git a/tests/functional/cypress/e2e/form-design-map-point-circle-markers.cy.js b/tests/functional/cypress/e2e/form-design-map-point-circle-markers.cy.js index 8cfeef16e..054eca726 100644 --- a/tests/functional/cypress/e2e/form-design-map-point-circle-markers.cy.js +++ b/tests/functional/cypress/e2e/form-design-map-point-circle-markers.cy.js @@ -53,9 +53,9 @@ describe('Form Designer', () => { cy.get(marker_elem).click({force: true}); }); cy.get('a[title="No layers to delete"]').then($el => { - const layer_del_btn=$el[0]; - cy.get(layer_del_btn) - .trigger('mousedown', { which: 1}, { force: true }) + const layer_del_btn=$el[0]; + cy.get(layer_del_btn) + .trigger('mousedown', { which: 1}, { force: true }) .trigger('mousemove', coords.x, -30, { force: true }) .trigger('mouseup', { force: true }); }); @@ -129,7 +129,7 @@ describe('Form Designer', () => { cy.get('a[title="Finish drawing"]').click({ force: true }); //To verify line is drwan on map cy.get('g').find('path[fill="none"]').should('exist'); - cy.get(10000); + cy.wait(2000); // To view line drawn on map cy.get('div[class="leaflet-container leaflet-touch leaflet-fade-anim leaflet-touch-zoom leaflet-grab leaflet-touch-drag"]').then($el => { const scroll_in=$el[0]; @@ -141,15 +141,44 @@ describe('Form Designer', () => { cy.get(zoom_in).click({ force: true }); cy.get(zoom_in).dblclick({ force: true }); }); - cy.get(9000); - cy.get('button').contains('Save').click(); + cy.wait(2000); + + }); + it('Checks Map component for Geo search Location', () => { + cy.viewport(1000, 1100); + cy.wait(3000); + cy.get('input[placeholder="Enter address"]').then($el => { + const address_search=$el[0]; + cy.get(address_search).type('2260 sooke rd'); + }); + cy.wait(2000); + cy.get('div').contains('2260 Sooke Rd, Colwood, BC').click(); + //Mark a point on searched address + cy.get('a[title="Draw a marker"]').then($el => { + const marker_elem=$el[0]; + cy.get(marker_elem).click({force: true}); + }); + cy.get('a[title="No layers to delete"]').then($el => { + const coords = $el[0].getBoundingClientRect(); + const layer_del_btn=$el[0]; + cy.get(layer_del_btn) + .trigger('mousedown', { which: 1}, { force: true }) + .trigger('mousemove', coords.x, -30, { force: true }) + .trigger('mouseup', { force: true }); + }); + cy.get('div[class="leaflet-marker-icon leaflet-mouse-marker leaflet-zoom-hide leaflet-interactive"]').click({ force: true }); + + cy.wait(2000); + //verify point is marked on the searched address region + //cy.get('p').contains('(48.43406,-123.49410)').should('exist'); + cy.get('button').contains('Save').click(); // Form saving - let savedButton = cy.get('[data-cy=saveButton]'); - expect(savedButton).to.not.be.null; - savedButton.trigger('click'); - cy.wait(2000); + 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 => { + cy.location('search').then(search => { //let pathName = fullUrl.pathname let arr = search.split('='); let arrayValues = arr[1].split('&'); @@ -171,8 +200,6 @@ describe('Form Designer', () => { shareFormLinkButton.trigger('click'); cy.get('.mx-2 > .v-btn').click(); }) - cy.visit(`/${depEnv}`); - cy.get('[data-cy="userFormsLinks"]').click(); cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`); cy.waitForLoad(); // @@ -181,6 +208,6 @@ describe('Form Designer', () => { 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 7d002146d..3e0680384 100644 --- a/tests/functional/cypress/e2e/form-manage-form.cy.js +++ b/tests/functional/cypress/e2e/form-manage-form.cy.js @@ -43,26 +43,13 @@ describe('Form Designer', () => { .trigger('mousedown', { which: 1}, { force: true }) .trigger('mousemove', coords.x, -550, { force: true }) .trigger('mouseup', { force: true }); - cy.waitForLoad(); - //cy.get('input[name="data[label]"]').type('s'); + cy.waitForLoad(); cy.get('button').contains('Save').click(); - //cy.get('.btn-success').click(); - - + }); - cy.intercept('GET', `/${depEnv}/api/v1/forms/*`).as('getForm'); // Form saving - cy.get('[data-cy=saveButton]').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'); - }); + cy.wait(2000); // Filter the newly created form cy.location('search').then(search => { //let pathName = fullUrl.pathname @@ -106,9 +93,9 @@ describe('Form Designer', () => { //Checking the schedule of closing date settings cy.contains('Schedule a closing date').click(); - cy.get('[data-test="closeSubmissionDateTime"]').should('be.visible'); - cy.get('[data-test="closeSubmissionDateTime"]').click(); - cy.get('[data-test="closeSubmissionDateTime"]').type('2026-09-17'); + cy.get('[data-test="formattedCloseDate"]').should('be.visible'); + cy.get('[data-test="formattedCloseDate"]').click(); + cy.get('[data-test="formattedCloseDate"]').type('2026-09-17'); cy.contains('Allow late submissions').click(); cy.get('[data-test="afterCloseDateFor"]').should('be.visible'); cy.get('[data-test="afterCloseDateFor"]').click(); @@ -201,6 +188,7 @@ describe('Form Designer', () => { it('Checks External API settings', () => { cy.viewport(1000, 1100); cy.waitForLoad(); + cy.get(':nth-child(5) > .v-expansion-panel > .v-expansion-panel-title > .v-expansion-panel-title__overlay').click(); cy.get('.mt-6 > :nth-child(2) > .mdi-help-circle-outline').should('exist'); cy.get('.mdi-plus-circle').click({ force: true }); diff --git a/tests/functional/cypress/e2e/form-submission-assign-revise-status.cy.js b/tests/functional/cypress/e2e/form-submission-assign-revise-status.cy.js index 59bc61ff0..c7d29e28c 100644 --- a/tests/functional/cypress/e2e/form-submission-assign-revise-status.cy.js +++ b/tests/functional/cypress/e2e/form-submission-assign-revise-status.cy.js @@ -11,14 +11,9 @@ Cypress.Commands.add('waitForLoad', () => { 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 @@ -27,20 +22,13 @@ describe('Form Designer', () => { }); }); it('Visits the form settings page', () => { - - cy.viewport(1000, 1100); cy.waitForLoad(); - formsettings(); - - - }); -// Publish a simple form -it('Verify draft submission', () => { + }); + 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(); @@ -51,21 +39,12 @@ it('Verify draft submission', () => { .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.wait(2000); + // Filter the newly created form cy.location('search').then(search => { //let pathName = fullUrl.pathname let arr = search.split('='); @@ -73,20 +52,15 @@ it('Verify draft submission', () => { 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'); @@ -127,9 +101,7 @@ it('Submission revise status Assignment', () => { 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'); - cy.wait(1000); - cy.get('.v-card-actions > .v-btn > .v-btn__content > span').click(); cy.get('.v-alert__content').contains('Sent invite email to nimya.1.john@gov.bc.ca').should('be.visible'); */ @@ -138,7 +110,6 @@ it('Submission revise status Assignment', () => { 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}'); @@ -150,9 +121,7 @@ it('Submission revise status Assignment', () => { 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(); - //Assign status submission - cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`); cy.get('.mdi-list-box-outline').click(); cy.waitForLoad(); @@ -168,22 +137,16 @@ it('Submission revise status Assignment', () => { cy.wait(4000); cy.get('[data-test="showStatusList"] > .v-input__control > .v-field > .v-field__append-inner > .mdi-menu-down').click(); cy.contains('REVISING').click(); - //cy.get('.v-selection-control > .v-label').click(); cy.get('.v-chip__content').contains('chefs.testing@gov.bc.ca').should('be.visible'); cy.get('[data-test="showRecipientEmail"] > .v-input__control > .v-field > .v-field__append-inner > .mdi-menu-down').click(); - /* - cy.contains('John, Nimya 1 CITZ:EX (nimya.1.john@gov.bc.ca)').should('be.visible'); - */ cy.get('label').contains('Notify all submitters').should('be.visible'); cy.get('[data-test="canAttachCommentToEmail"] > .v-input__control > .v-selection-control > .v-label').click(); cy.get('textarea[rows="1"]').type('some comments'); cy.get('button').contains('REVISE').click(); cy.get(':nth-child(1) > .v-checkbox > .v-input__control > .v-selection-control > .v-label').click(); cy.wait(4000); - //Verify Edit submission button is disabled cy.get('button[title="Edit This Submission"]').should('be.disabled'); - //Delete form after test run cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`); cy.waitForLoad(); @@ -191,9 +154,6 @@ it('Submission revise status Assignment', () => { cy.get('[data-test="continue-btn-continue"]').click(); cy.get('#logoutButton > .v-btn__content > span').click(); }); - - }); - - + }); diff --git a/tests/functional/cypress/e2e/form-submission-assign-status.cy.js b/tests/functional/cypress/e2e/form-submission-assign-status.cy.js index dcd5ec6a8..6f86c23b2 100644 --- a/tests/functional/cypress/e2e/form-submission-assign-status.cy.js +++ b/tests/functional/cypress/e2e/form-submission-assign-status.cy.js @@ -30,9 +30,9 @@ describe('Form Designer', () => { formsettings(); }); - it('Add some fields for submission', () => { + it('Form Submission and Updation', () => { - cy.viewport(1000, 1800); + cy.viewport(1000, 1100); cy.waitForLoad(); cy.get('button').contains('Basic Fields').click(); cy.get('div.formio-builder-form').then($el => { @@ -44,29 +44,14 @@ describe('Form Designer', () => { .trigger('mouseup', { force: true }); cy.get('button').contains('Save').click(); }); - - }); - - it('Form Submission and Updation', () => { - cy.viewport(1000, 1100); - cy.wait(4000); - /*cy.intercept('GET', `/${depEnv}/api/v1/forms/*`).as('getForm'); - */ + cy.wait(4000); // Form saving - let savedButton = cy.get('[data-cy=saveButton]'); - expect(savedButton).to.not.be.null; - savedButton.trigger('click'); - cy.waitForLoad(); - cy.wait(4000); - // Go to My forms - /*cy.wait('@getForm').then(()=>{ - let userFormsLinks = cy.get('[data-cy=userFormsLinks]'); - expect(userFormsLinks).to.not.be.null; - userFormsLinks.trigger('click'); - }); - */ + let savedButton = cy.get('[data-cy=saveButton]'); + expect(savedButton).to.not.be.null; + savedButton.trigger('click'); + cy.wait(4000); // Filter the newly created form - cy.location('search').then(search => { + cy.location('search').then(search => { let arr = search.split('='); let arrayValues = arr[1].split('&'); @@ -131,7 +116,7 @@ describe('Form Designer', () => { //view submission cy.get(':nth-child(1) > :nth-child(6) > a > .v-btn > .v-btn__content > .mdi-eye').click(); cy.wait(4000); - }); + }); }); it('Submission status Assignment', () => {