Skip to content

Commit

Permalink
Test: FORMS- 1787 Added cypress test scripts for Geosearch location f…
Browse files Browse the repository at this point in the history
…eature (bcgov#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
  • Loading branch information
nimya-aot authored Feb 25, 2025
1 parent 977da72 commit 0125e48
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 106 deletions.
6 changes: 2 additions & 4 deletions tests/functional/cypress/e2e/form-apikey-cdogs.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -124,5 +123,4 @@ describe('Form Designer', () => {

})

})

})
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
Expand Down Expand Up @@ -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];
Expand All @@ -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('&');
Expand All @@ -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();
//
Expand All @@ -181,6 +208,6 @@ describe('Form Designer', () => {
cy.get('[data-test="continue-btn-continue"]').click();
cy.get('#logoutButton > .v-btn__content > span').click();

});
});
});
});
26 changes: 7 additions & 19 deletions tests/functional/cypress/e2e/form-manage-form.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -51,42 +39,28 @@ 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('=');
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');
Expand Down Expand Up @@ -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 [email protected]').should('be.visible');
*/
Expand All @@ -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}');
Expand All @@ -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();
Expand All @@ -168,32 +137,23 @@ 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('[email protected]').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 ([email protected])').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();
cy.get('.mdi-delete').click();
cy.get('[data-test="continue-btn-continue"]').click();
cy.get('#logoutButton > .v-btn__content > span').click();
});


});



});
33 changes: 9 additions & 24 deletions tests/functional/cypress/e2e/form-submission-assign-status.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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('&');
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit 0125e48

Please sign in to comment.