Skip to content

Commit

Permalink
test: FORMS-1527 Cypress test scripts for both export and print templ…
Browse files Browse the repository at this point in the history
…ate functionality for submission files (bcgov#1518)

* #FORMS-974

* bcgov#974 updates

* bcgov#980 modification to cypress config

* FORMS-980

* bcgov#992

* bcgov#992 Fix cypress scripts

* bcgov#1011 Form design page

* bcgov#1011 test scripts

* bcgov#1023 cypress scripts

* bcgov#1023 advanced data components

* bcgov#1023 Updated scripts

* bcgov#1023 updation

* Updated json file

* Test/forms (bcgov#1011)(bcgov#1023) (bcgov#1307)

* #FORMS-974

* bcgov#974 updates

* bcgov#980 modification to cypress config

* FORMS-980

* bcgov#992

* bcgov#992 Fix cypress scripts

* bcgov#1011 Form design page

* bcgov#1011 test scripts

* bcgov#1023 cypress scripts

* bcgov#1023 advanced data components

* bcgov#1023 Updated scripts

* bcgov#1023 updation

* Updated json file

* bcgov#1059 workflow file for cypress

* bcgov#1059 updated the base url

* bcgov#1059 updated workflow

* Updated node version

* updated

* updated

* Updation

* updated file

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* updated package file

* Update cypress-ci.yaml

* Updated config file

* Update cypress-ci.yaml

* bcgov#1059 updated package

* bcgov#1060 scripts for Advanced fields and BC Gov components

* Fixing review comments

* Updated changes

* # Updated with PR comments

* updated

* Update form-design-basicfields.cy.js

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Modifies test scripts

* Updated files

* Fixed errors during CI/CD Run

* Updated browser type

* Updated Simple BC address component

* Updated

* Fields updated

* Test script changed

* Updated

* Updated fields

* Updated env variable

* Update form-design-basicfields.cy.js

* Updated

* Update cypress-ci.yaml

* Updated email input

* screenshots

* Updated path

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Updated version on workflow

* Fix to failed tests

* Fix to BC address component

* Updated the  component

* Changed button element

* Fixed BC components

* Modified submission

* Modified components

* Updated attribute

* Updated

* Changed simpleBC address component

* Update package.json

* Update package-lock.json

* Test scripts

* Updated

* Pushed the changes

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Env change

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Update cypress-ci.yaml

* Updated

* Updated to take default env variable

* Updated with current workflow

* updated

* Formatted

* Update cypress.config.js

* updated

* Test scripts for updating submission data

* Scripts for adding notes

* Added scripts for logout after each run

* Adding statuses to submission

* Fixed alert message for subscription settings

* Fixing CI/CD running issues

* Fixed issues on schedule date verification

* bcgov#1488 public form submission

* bcgov#1488 form for public

* form settings page for public form

* Added scripts for public forms with no status assign ability

* Changes with login page

* Removed additional login page

* bcgov#1478/Draft submission

* Scripts for draft submission

* bcgov#1478 Added column management functionality and delete button

* Fixed some CI/Cd issues

* bcgov#1527 Export submission files

* bcgov#1527 updated wait time function

* Removed downloads folder from git

* bcgov#1527 Added print template functionalities

* bcgov#1527 Updated submission status visibility check

* bcgov#1527 Modified Edit grid components

---------

Co-authored-by: jasonchung1871 <[email protected]>
  • Loading branch information
nimya-aot and jasonchung1871 authored Oct 28, 2024
1 parent 5f754dc commit de7389e
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dist
**/src/formio
**/cypress/**/videos
screenshots
downloads
node_modules

# Ignore only top-level package-lock.json
Expand Down
21 changes: 2 additions & 19 deletions tests/functional/cypress/e2e/form-design-advanceddata.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,8 @@ it('Checks the Container component', () => {
"key": "dataGrid",
"type": "datagrid",
"input": true,
"components": [
{
"label": "Children",
"key": "children",
"type": "datagrid",
"input": true,



"components": [
{
"label": "First Name",
"key": "firstName",
"type": "textfield",
"input": true,
"tableView": true
},
{
"label": "Gender",
"key": "gender",
Expand All @@ -123,10 +109,7 @@ it('Checks the Container component', () => {

}
]
}
]

})
})

cy.get('div.ace_content').type(pretty,{ parseSpecialCharSequences: false });
cy.get('button').contains('Save').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ it('Verify draft submission', () => {
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');
cy.get('.v-data-table__tr > :nth-child(4)').contains('SUBMITTED').should('not.exist');
//Delete form after test run
cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`);
cy.waitForLoad();
Expand Down
251 changes: 251 additions & 0 deletions tests/functional/cypress/e2e/form-submission-export.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
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();
});
it("Add some fields for submission", () => {
cy.viewport(1000, 1800);
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();
});
// Form saving
});
it("Form Submission and Updation", () => {
cy.viewport(1000, 1100);
cy.waitForLoad();
cy.waitForLoad();
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 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");
//Submit the form
cy.visit(`/${depEnv}/form/submit?f=${arrayValues[0]}`);
cy.waitForLoad();
cy.waitForLoad();
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");
//form submission
cy.get("button").contains("Submit").click();
cy.waitForLoad();
cy.get('[data-test="continue-btn-continue"]').click({ force: true });
cy.waitForLoad();
cy.waitForLoad();
cy.waitForLoad();
cy.get("label").contains("Text Field").should("be.visible");
cy.get("label").contains("Text Field").should("be.visible");
cy.location("pathname").should("eq", `/${depEnv}/form/success`);
cy.contains("h1", "Your form has been submitted successfully");
cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`);
cy.waitForLoad();
cy.waitForLoad();
cy.waitForLoad();
cy.visit(`/${depEnv}/form/submit?f=${arrayValues[0]}`);
cy.wait(2000);
cy.get("button").contains("Submit").should("be.visible");
cy.waitForLoad();
cy.contains("Text Field").click();
cy.contains("Text Field").type("Alex");
cy.get("button").contains("Submit").click();
cy.waitForLoad();
cy.get('[data-test="continue-btn-continue"]').should("be.visible");
cy.get('[data-test="continue-btn-continue"]').should("exist");
cy.get('[data-test="continue-btn-continue"]').click({ force: true });
cy.location("pathname").should("eq", `/${depEnv}/form/success`);
cy.contains("h1", "Your form has been submitted successfully");
cy.waitForLoad();
//view submission
cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`);
cy.wait(2000);
});
});
it("Verify export submission", () => {
cy.viewport(1000, 1100);
cy.waitForLoad();
cy.get(".mdi-list-box-outline").click();
cy.waitForLoad();
//Export submission files
cy.get(".mdi-download").click();
//Verify submission file name
cy.get("h3").then(($elem) => {
const rem = $elem.text();
cy.log(rem);
const remname = rem + "_submissions.json";
cy.get(".ml-1").contains(remname);
});
cy.get(':nth-child(2) > .v-col > .v-input > .v-input__control > .v-selection-control-group > :nth-child(2) > .v-label > .radioboxLabelStyle').click();
cy.get('.v-col > .v-input > .v-input__control > .v-field > .v-field__field > .v-field__input').contains('1');
cy.contains('form.submissionId').should('be.visible');
cy.contains('form.confirmationId').should('be.visible');
cy.contains('form.formName').should('be.visible');
cy.contains('form.version').should('be.visible');
cy.contains('form.createdAt').should('be.visible');
cy.contains('form.fullName').should('exist');
cy.contains('form.username').should('exist');
cy.contains('form.email').should('exist');

cy.get('.v-input.mt-3 > .v-input__control > .v-field').type('status');
cy.contains('form.status').should('be.visible');
cy.contains('form.submissionId').should('not.exist');
cy.contains('form.confirmationId').should('not.exist');
cy.contains('form.formName').should('not.exist');
cy.contains('form.version').should('not.exist');
cy.contains('form.createdAt').should('not.exist');
//Close filter option
cy.get('.mdi-close-circle').click();
cy.contains('form.submissionId').should('be.visible');
cy.contains('form.confirmationId').should('be.visible');
cy.contains('form.formName').should('be.visible');
cy.contains('form.version').should('be.visible');
cy.contains('form.createdAt').should('be.visible');
//Select Date range
cy.get('input[type="radio"]').then($el => {

const rem=$el[3];
const rem1=$el[4];
cy.get(rem).click();
//Default first Radio button for csv format is enabled
cy.get(rem1).should('be.checked');

});
//verify csv format options
cy.get('input[type="date"]').should('have.length',2);
cy.get('span').contains('1 - Multiple rows per submission with indentation spaces');
cy.get('span').contains('2 - Multiple rows per submission');
cy.get('span').contains('3 - Single row per submission');
cy.get('span').contains('4 - Unformatted');
cy.get("h3").then(($elem) => {
const rem = $elem.text();
cy.log(rem);
const remname = rem + "_submissions.csv";
cy.get(".ml-1").contains(remname);
});
//verify export button is enabled
cy.get('.mb-5').should('be.enabled');
});

it("Verify print template functionality", () => {
cy.viewport(1000, 1100);
cy.waitForLoad();
cy.get(".mdi-list-box-outline").click();


cy.get(':nth-child(1) > :nth-child(6) > a > .v-btn').click();
//print option
cy.get('.mdi-printer').click();
cy.get('.flex-container > .v-btn--elevated').should('be.enabled');
cy.get('.text-textLink').should('be.enabled');
cy.get('.text-textLink').click();
cy.get('.v-overlay__content > .v-card').should('not.exist');
cy.get('.mdi-printer').click();
cy.get('.v-label > span').contains('Expand text fields');
cy.get('.v-slide-group-item--active > .v-btn__content').contains('Browser Print');
cy.get('[tabindex="-1"] > .v-btn__content').contains('Template Print');
cy.get('input[type="checkbox"]').should('not.be.checked');
cy.get('input[type="checkbox"]').click();
cy.get('input[type="checkbox"]').should('be.checked');

cy.get('.v-window-item--active > .flex-container > .more-info-link').should('exist');

//print option for submission files
cy.get('[tabindex="-1"] > .v-btn__content').click();
let fileUploadInputField = cy.get('input[type=file]');
cy.get('input[type=file]').should('not.to.be.null');
fileUploadInputField.attachFile('add1.png');
cy.waitForLoad();
//cy.get('label').contains('Upload template file').click({multiple:true,force:true});
//cy.get('.v-messages__message').contains('The template must use one of the following extentions: .txt, .docx, .html, .odt, .pptx, .xlsx');
cy.get('#file-input-submit').should('not.be.enabled');
//
cy.waitForLoad();
//Upload print template
cy.get('[tabindex="-1"] > .v-btn__content').click();
cy.get('.v-slide-group__content > [tabindex="-1"]').click();
cy.waitForLoad();
cy.get('.mdi-close-circle').click();
cy.get('input[type=file]').attachFile('test.docx');
cy.waitForLoad();
//cy.get('.v-selection-control-group > .v-input--dirty > .v-input__control > .v-field > .v-field__append-inner > .mdi-menu-down').click();
cy.get('.v-selection-control-group > .v-text-field > .v-input__control > .v-field').click();
cy.contains('pdf').should('be.visible');
//cy.get('span').contains('docx').should('exist');
cy.contains('pdf').click();
cy.get('#file-input-submit').should('be.enabled');
cy.get('.v-card-actions > .flex-container > .text-textLink').should('be.enabled');
cy.get('.v-card-actions > .flex-container > .text-textLink').click();
cy.get('.mdi-printer').click();
cy.get('#file-input-submit').click({force: true});
// Verify cdogs template uplaod success message
cy.get('body').click(0,0);
cy.wait(2000);
cy.get('.v-alert__content').contains('Document generated successfully').should('be.visible');

//Delete form after test run
cy.get('.mdi-list-box-outline').click();
cy.location("search").then((search) => {
let arr = search.split("=");
cy.visit(`/${depEnv}/form/manage?f=${arr[1]}`);
cy.waitForLoad();
cy.get('.mdi-delete').click();
cy.get('[data-test="continue-btn-continue"]').click();
cy.get('#logoutButton > .v-btn__content > span').click();
})


});
});
6 changes: 6 additions & 0 deletions tests/functional/cypress/support/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export function formsettings(){
cy.get('#user').type(username);
cy.get('#password').type(password);
cy.get('.btn').click();
cy.get('[data-cy="help"]')
.should("have.attr", "href", "https://developer.gov.bc.ca/docs/default/component/chefs-techdocs")
.should("have.text", "Help");
cy.get('[data-cy="feedback"]')
.should("have.attr", "href", "https://chefs-fider.apps.silver.devops.gov.bc.ca/")
.should("have.text", "Feedback");
cy.get('[data-cy="createNewForm"]').click();
cy.get('.v-row > :nth-child(1) > .v-card > .v-card-title > span').contains('Form Title');

Expand Down

0 comments on commit de7389e

Please sign in to comment.