Skip to content

Commit

Permalink
Merge branch 'main' into feat/1791-updating-ministry-list-on-formsett…
Browse files Browse the repository at this point in the history
…ings-page
  • Loading branch information
revanth-banala authored Feb 5, 2025
2 parents fa8d5d2 + 6146642 commit 63fb40d
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 39 deletions.
24 changes: 17 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
ARG VARIANT="20.18.1-bookworm"
ARG VARIANT="20.18.2-bookworm"
FROM node:${VARIANT}

# Install some extras such as vim for interactive rebases. Also some
# Cypress prerequisites for running in Debian containers:
# https://docs.cypress.io/app/get-started/install-cypress#UbuntuDebian

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
# Cypress prerequisites for running in Debian containers:
# https://docs.cypress.io/app/get-started/install-cypress#UbuntuDebian
libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 \
libasound2 libxtst6 xauth xvfb \
# For interactive git rebases
vim
libasound2 \
libgbm-dev \
libgtk-3-0 \
libgtk2.0-0 \
libnotify-dev \
libnss3 \
libxss1 \
libxtst6 \
vim \
xauth \
xvfb \
&& apt-get clean
5 changes: 1 addition & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "20.18.1-bookworm"
}
"context": ".."
},

"features": {
Expand Down
19 changes: 12 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
FROM docker.io/node:20.18.1-alpine3.21
FROM docker.io/node:20.18.2-alpine3.21

ENV NO_UPDATE_NOTIFIER=true
WORKDIR /opt/app-root/src/app
COPY . /opt/app-root/src

# Run the npm tasks to set up the various parts of the application. Then create
# the /.npm directory and grant access to group 0 to allow npm v9 to work
# See: https://docs.openshift.com/container-platform/4.11/openshift_images/create-images.html#use-uid_create-images

RUN npm run all:ci \
&& npm run all:build \
&& npm run frontend:purge \
&& npm run components:clean \
&& npm run components:purge
&& npm run components:purge \
&& mkdir /.npm \
&& chgrp -R 0 /.npm \
&& chmod -R g=u /.npm

EXPOSE 8000
# Create the /.npm directory and grant access to group 0 to allow npm v9 to work
# See: https://docs.openshift.com/container-platform/4.11/openshift_images/create-images.html#use-uid_create-images
RUN mkdir /.npm
RUN chgrp -R 0 /.npm && \
chmod -R g=u /.npm

CMD ["npm", "run", "start"]
8 changes: 4 additions & 4 deletions tests/functional/cypress/e2e/form-design-advanceddata.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ it('Checks the Container component', () => {
cy.get('button').contains('Save').click();

});

/*
//Verify Edit Json button
cy.get('[ref=editJson]').then($el => {
Expand All @@ -112,7 +112,7 @@ it('Checks the Container component', () => {
});
let acecont=cy.get('div.ace_content');
/*
cy.get('div.ace_content').then($el => {
cy.get('div.ace_content').type('{selectall}{backspace}');
Expand Down Expand Up @@ -144,10 +144,10 @@ it('Checks the Container component', () => {
cy.get('.ui').click();
cy.contains('Male').should('be.visible');
*/
cy.get('button').contains('Save').click();

*/

//});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ 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(()=>{
Expand All @@ -24,14 +19,9 @@ describe('Form Designer', () => {
});
});
it('Visits the form settings page', () => {


cy.viewport(1000, 1100);
cy.waitForLoad();

formsettings();


});
// Checks Map component functionalities
it('Checks Map component for Point marker', () => {
Expand All @@ -43,7 +33,6 @@ describe('Form Designer', () => {
cy.get('[data-type="map"]')
.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');
Expand All @@ -59,8 +48,6 @@ describe('Form Designer', () => {
cy.get('input[name="data[customClass]"').should('exist');
cy.get(':nth-child(2) > .nav-link').click();
cy.wait(2000);
//cy.get('a[title="Draw a marker"]').then($el => {

cy.get('a[title="Draw a marker"]').then($el => {
const marker_elem=$el[0];
cy.get(marker_elem).click({force: true});
Expand All @@ -70,7 +57,6 @@ describe('Form Designer', () => {
cy.get(layer_del_btn)
.trigger('mousedown', { which: 1}, { force: true })
.trigger('mousemove', coords.x, -30, { force: true })
//.trigger('mousemove', coords.y, +100, { force: true })
.trigger('mouseup', { force: true });
});
cy.get('img[alt="Marker"]').click({ force: true });
Expand Down Expand Up @@ -128,7 +114,6 @@ describe('Form Designer', () => {
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 All @@ -147,4 +132,4 @@ describe('Form Designer', () => {

});

});
});
167 changes: 167 additions & 0 deletions tests/functional/cypress/e2e/form-design-map-polygon-marker.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
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();
});
// Checks Map component functionalities
it('Checks Map component for Polygon marker', () => {
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-type="map"]')
.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.get('textarea[name="data[description]"]').should("have.attr","placeholder","This will appear below the map");
cy.get('textarea[name="data[description]"]').type('Map location above');
cy.wait(2000);
cy.get('textarea[placeholder="Add a tooltip beside the label"]').type('Add your desired location');
cy.wait(2000);
cy.get(':nth-child(2) > .nav-link').click();
cy.wait(2000);
cy.wait(2000);
cy.get('input[value="circle"]').click();
cy.get('input[value="polygon"]').click();
cy.get('input[name="data[numPoints]"').type('{selectall}{backspace}');
cy.get('input[name="data[numPoints]"').type('3');
cy.wait(2000);
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 layer_del_btn=$el[0];
cy.get(layer_del_btn)
.trigger('mousedown', { which: 1}, { force: true })
//.trigger('mousemove', coords.x, -30, { force: true })
.trigger('mousemove', coords.y, +450, { force: true })
.trigger('mouseup', { force: true });
});
cy.get('img[alt="Marker"]').click({ force: true });
cy.wait(2000);
cy.get('a.leaflet-draw-draw-polygon').then($el => {
const draw_polygon=$el[0];

cy.get(draw_polygon).click();
});
cy.get('div[class="leaflet-draw-tooltip leaflet-draw-tooltip-single"]').click();
cy.get('div[class="leaflet-draw-tooltip leaflet-draw-tooltip-single"]').click();
cy.get('div[class="leaflet-draw-tooltip leaflet-draw-tooltip-single"]').click();
cy.get('div[class="leaflet-draw-tooltip leaflet-draw-tooltip-single"]').click();
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 })
//.trigger('mousemove', coords.x, -30, { force: true })
.trigger('mousemove', coords.y, +350, { force: true })
.trigger('mouseup', { force: true });
});
cy.get('.leaflet-interactive').then($el => {
const interactive_btn=$el[1];
cy.get(interactive_btn).click({ force: true });
});
cy.get('div[class="leaflet-marker-icon leaflet-mouse-marker leaflet-zoom-hide leaflet-interactive"]').click({ force: true });

cy.get('a[title="Finish drawing"]').click({ force: true });
cy.get('.leaflet-interactive').should('exist');
cy.wait(2000);
cy.get('g').find('path[stroke-linejoin="round"]').should('exist');

});
cy.waitForLoad();
cy.get('button').contains('Save').click();
});

it('Checks form submission for a Map component', () => {
cy.viewport(1000, 1100);
cy.waitForLoad();
// 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 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');
//Form submission verification
cy.visit(`/${depEnv}/form/submit?f=${arrayValues[0]}`);
cy.wait(2000);
cy.get('button').contains('Submit').should('be.visible');
cy.wait(2000);
cy.get('a.leaflet-draw-draw-circle').then($el => {
const draw_circle=$el[0];
cy.get(draw_circle).click();
});
cy.get('img[alt="Marker"]').then($el => {
const mark_cir=$el[0];
const coords = $el[0].getBoundingClientRect();
cy.get(mark_cir)
.trigger('mousedown', { which: 1}, { force: true })
.trigger('mousemove', coords.x, -5, { force: true })
.trigger('mouseup', coords.x, -5, { force: true })
cy.wait(2000);
});
cy.get('a[title="Draw a marker"]').then($el => {
const marker_elem=$el[0];
cy.get(marker_elem).click({force: true});
});
cy.get('div[class="leaflet-draw-tooltip leaflet-draw-tooltip-single"]').click({ force: true });

cy.get('div[class="leaflet-popup-content"]').find('p').contains('Only 3 features per submission').should('be.visible');
cy.get('button').contains('Submit').click();
cy.wait(4000);
cy.get('button').contains('Submit').click();
cy.waitForLoad();
cy.location('pathname').should('eq', `/${depEnv}/form/success`);
cy.contains('h1', 'Your form has been submitted successfully');
cy.wait(4000);
cy.get('g').find('path[stroke-linejoin="round"]').should('exist');
//Delete form after test run
cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`);
cy.waitForLoad();
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();

});

});

});


2 changes: 1 addition & 1 deletion tests/functional/cypress/e2e/form-submission-export.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("Form Designer", () => {
let arrayValues = arr[1].split("&");
cy.log(arrayValues[0]);
cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`);
cy.waitForLoad();
cy.wait(6000);
//Publish the form
cy.get(".v-label > span").click();

Expand Down

0 comments on commit 63fb40d

Please sign in to comment.