Skip to content

Commit

Permalink
cypress configured to work in different environments
Browse files Browse the repository at this point in the history
1. Forced delays removed
2. Http delays removed from wait for loader
3. Testing done under 3 different environment
  • Loading branch information
msmannan00 authored and evilaliv3 committed Feb 1, 2024
1 parent 573aaca commit c853068
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 83 deletions.
Binary file removed client/cypress/downloads/report-1.zip
Binary file not shown.
5 changes: 1 addition & 4 deletions client/cypress/e2e/02-test-admin-perform-wizard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ describe("globaLeaks setup wizard", () => {

cy.get(".ButtonNext").click();

cy.waitForLoader();
cy.takeScreenshot("wizard/6");
cy.get('button[name="proceed"]').click();
cy.waitForLoader();
cy.url().should('include', '/admin/home');
cy.get('button[name="proceed"]').should('be.visible', { timeout: 10000 }).click();
cy.logout();
});
});
20 changes: 9 additions & 11 deletions client/cypress/e2e/06-test-admin-configure-advanced.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ describe("admin configure advanced settings", () => {
cy.visit("/#/admin/settings");
cy.contains("button", "Advanced").click();
cy.get('input[name="enable_custom_privacy_badge"]').click();
cy.get('input[name="enable_custodian"]').click();
cy.get('input[name="viewer"]').click();
cy.contains("button", "Save").click();
});
});
Expand All @@ -19,12 +17,11 @@ describe("admin disable submissions", () => {
cy.get('input[name="disable_submissions"]').click();
cy.contains("button", "Save").click();

cy.waitForLoader();
cy.contains("button", "Advanced").click();
cy.contains("button", "Advanced").click().should('be.visible', { timeout: 10000 }).click();

cy.get('input[name="disable_submissions"]').should("be.visible").should("be.checked");
cy.logout();
cy.waitForLoader()
cy.waitForUrl("/#/login")
cy.visit("/#/");
cy.contains("span", "Submissions disabled").should("be.visible");

Expand All @@ -34,18 +31,18 @@ describe("admin disable submissions", () => {
describe("admin enable submissions", () => {
it("should enable submission", () => {
cy.login_admin();
cy.visit("/#/admin/settings");
cy.waitForUrl("/#/admin/home")
cy.visit("/#/admin/settings")
cy.contains("button", "Advanced").click();

cy.get('input[name="disable_submissions"]').click();
cy.contains("button", "Save").click();

cy.waitForLoader();
cy.contains("button", "Advanced").click();
cy.waitForLoader()
cy.contains("button", "Advanced").should('be.visible', { timeout: 10000 }).click();

cy.get('input[name="disable_submissions"]').should("be.visible").should("not.be.checked");
cy.logout();
cy.waitForLoader();
cy.waitForUrl("/#/login")

cy.visit("/#/");
cy.contains("button", "File a report").should("be.visible");
Expand All @@ -55,6 +52,7 @@ describe("admin enable submissions", () => {
describe("Should browser opens a pop while clicking the support icon", () => {
it("should open a pop-up modal", () => {
cy.login_admin();
cy.waitForUrl("/#/admin/home");
cy.visit("/#/admin/settings");
cy.contains("button", "Advanced").click();

Expand Down Expand Up @@ -96,7 +94,7 @@ describe("Validating custom support url", () => {

cy.contains("button", "Save").click();
cy.waitForLoader();
cy.contains("button", "Advanced").click();
cy.contains("button", "Advanced").should('be.visible', { timeout: 10000 }).click();

cy.get('input[name="customSupportURL"]')
.invoke("val")
Expand Down
3 changes: 1 addition & 2 deletions client/cypress/e2e/07-test-admin-configure-users.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ describe("admin add, configure, and delete users", () => {
for (let i = 1; i < numberOfUsers; i++) {
cy.get(".userList").eq(i).within(() => {
if (Cypress.$("button:contains('Edit')").length > 0) {
cy.contains("button", "Edit").click();
cy.contains("button", "Edit").should('be.visible', { timeout: 10000 }).click();
cy.contains("span", "Set password").first().click();
cy.get('input[name="password"]').clear().type(Cypress.env("init_password"));
cy.get('#setPasswordButton').should('be.visible').click();
cy.waitForLoader(false);
}
});
}
Expand Down
6 changes: 2 additions & 4 deletions client/cypress/e2e/08-test-users-first-login.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
describe("Recipient first login", () => {
it("should require password change upon successful authentication", () => {
cy.login_receiver("Recipient", Cypress.env("init_password"), "#/login", true);
cy.waitForLoader()
cy.takeScreenshot("user/password");
cy.get('input[name="changePasswordArgs.password"]').clear().type(Cypress.env("user_password"));
cy.get('input[name="changePasswordArgs.password"]').should('be.visible', { timeout: 10000 }).clear().type(Cypress.env("user_password"));
cy.get('input[name="changePasswordArgs.confirm"]').type(Cypress.env("user_password"));
cy.get('button[name="submit"]').click();
cy.waitForUrl("/recipient/home");
Expand Down Expand Up @@ -52,8 +51,7 @@ describe("Recipient2 first login", () => {
describe("Custodian first login", () => {
it("should require password change upon successful authentication", () => {
cy.login_custodian("Custodian", Cypress.env("init_password"), "#/login", true);
cy.waitForLoader()
cy.get('[name="changePasswordArgs.password"]').type(Cypress.env("user_password"));
cy.get('[name="changePasswordArgs.password"]').should('be.visible', { timeout: 10000 }).type(Cypress.env("user_password"));
cy.get('[name="changePasswordArgs.confirm"]').type(Cypress.env("user_password"));
cy.get('button[name="submit"]').click();
cy.url().should("include", "/custodian/home");
Expand Down
9 changes: 4 additions & 5 deletions client/cypress/e2e/10-test-admin-configure-languages.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("admin configure languages", () => {
cy.get('ul.selection-list li').should('contain', 'German [de]');

cy.contains("button", "Save").click();
cy.visit("/#/admin/settings");
cy.waitForUrl("/#/admin/settings");
cy.contains("button", "Languages").click();

cy.get(".non-default-language").eq(1).click();
Expand All @@ -30,16 +30,15 @@ describe("admin configure languages", () => {

cy.get(".remove-lang-btn").eq(1).click();
cy.contains("button", "Speichern").click();
cy.waitForLoader()

cy.visit("/#/admin/settings");
cy.get('div.language-picker-box').find('ng-select').last().click().get('ng-dropdown-panel').contains('Deutsch').click();
cy.waitForUrl("/#/admin/settings");
cy.get('#language-picker-box').should('be.visible', { timeout: 10000 }).find('ng-select').last().click().get('ng-dropdown-panel').contains('Deutsch').click();

cy.get('[name="node.dataModel.header_title_homepage"]').clear().type("TEXT1_IT");
cy.get('[name="node.dataModel.presentation"]').clear().type("TEXT2_IT");
cy.get('button.btn.btn-primary').eq(0).contains('Speichern').click();

cy.get('div.language-picker-box').find('ng-select').last().click().get('ng-dropdown-panel').contains('English').click();
cy.get('#language-picker-box').find('ng-select').last().click().get('ng-dropdown-panel').contains('English').click();
cy.visit("/#/admin/settings");
cy.contains("button", "Languages").click();
cy.get(".non-default-language").eq(0).click();
Expand Down
19 changes: 8 additions & 11 deletions client/cypress/e2e/11-test-admin-configure-files.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("Admin configure custom CSS", () => {
cy.get(".modal [type='password']").type("wrongpassword");
cy.get(".modal .btn-primary").click();
cy.get(".modal").should("be.visible");
cy.wait(500)
cy.wait(1000)
cy.get(".modal [type='password']").type(Cypress.env("user_password"));
cy.get(".modal .btn-primary").click();
cy.get("[name='authenticationData.session.permissions.can_upload_files']").should("be.checked");
Expand All @@ -31,15 +31,15 @@ describe("Admin configure custom CSS", () => {

const customCSSFile = "files/style.css";
cy.fixture(customCSSFile).then((fileContent) => {
cy.get("div.uploadfile.file-css input").then(($input) => {
cy.get('div.uploadfile.file-css input[type="file"]').then(($input) => {
const inputElement = $input[0] as HTMLInputElement;
const blob = new Blob([fileContent], { type: "text/css" });
const testFile = new File([blob], customCSSFile, { type: "text/css" });
const blob = new Blob([fileContent], { type: 'text/css' });
const testFile = new File([blob], 'your-file-name.css', { type: 'text/css' });
const dataTransfer = new DataTransfer();

dataTransfer.items.add(testFile);
inputElement.files = dataTransfer.files;
cy.wrap($input).trigger("change", { force: true });
cy.wrap($input).trigger('change', { force: true });
});
});
cy.contains("label", "Project name").should("be.visible");
Expand Down Expand Up @@ -71,14 +71,11 @@ describe("Admin configure custom CSS", () => {
});
});

cy.waitForLoader()
cy.contains("button", "Files").click();
cy.visit("#/admin/home");
cy.waitForUrl("#/admin/settings");
cy.contains("button", "Files").should('be.visible', { timeout: 10000 }).click();
cy.get('table#fileList').contains('td', 'documentation').should('be.visible');
cy.get("#fileList").contains("Delete").click();

cy.waitForLoader()
cy.contains("button", "Files").click();
cy.get('table#fileList').contains('td', 'documentation').should('not.exist');
});


Expand Down
9 changes: 4 additions & 5 deletions client/cypress/e2e/13-test-admin-configure-custom-texts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ describe("admin enable submissions", () => {

cy.get('input[name="disable_submissions"]').click();
cy.contains("button", "Save").click();
cy.waitForUrl("/#/admin/settings");

cy.waitForLoader();
cy.contains("button", "Advanced").click();

cy.get('#ngb-nav-12').click();
cy.get('input[name="disable_submissions"]').should("be.visible").should("not.be.checked");
cy.logout();
cy.waitForLoader()
cy.waitForUrl("/#/login");

cy.visit("/#/");
cy.contains("button", "File a report").should("be.visible");
cy.contains("button", "File a report").should('be.visible', { timeout: 10000 });
});
});
10 changes: 3 additions & 7 deletions client/cypress/e2e/15-test-admin-configure-network.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe("admin configure network", () => {

cy.get("#HTTPSManualMode").click();
cy.contains("button", "Generate").click();
cy.waitForLoader();
cy.get("#csrGen").click();
cy.get('[name="country"]').type("IT");
cy.get('[name="province"]').type("Milano");
Expand All @@ -22,11 +21,9 @@ describe("admin configure network", () => {
cy.get("#csrSubmit").click();

cy.get("#deleteKey").click();
cy.wait(500);
cy.get("#modal-action-ok").click();
cy.get("#modal-action-ok").should('be.visible', { timeout: 10000 }).click();
cy.get("#deleteKey").should("not.exist");
cy.wait(500);
cy.get("#HTTPSManualMode").click();
cy.get("#HTTPSManualMode").should('be.visible', { timeout: 10000 }).click();

cy.get("div.card.key input[type=file]").selectFile({
contents: "../backend/globaleaks/tests/data/https/valid/key.pem",
Expand All @@ -51,8 +48,7 @@ describe("admin configure network", () => {
cy.get("#deleteCert").click();
cy.get("#modal-action-ok").click();

cy.wait(500);
cy.get("#deleteKey").click();
cy.get("#deleteKey").should('be.visible', { timeout: 10000 }).click();
cy.get("#modal-action-ok").click();
cy.logout();
});
Expand Down
8 changes: 4 additions & 4 deletions client/cypress/e2e/17-test-admin-questionnaires.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ describe("admin add, configure and delete questionnaires", () => {
if (["Checkbox", "Selection box"].indexOf(question_type) === 0) {
cy.waitForLoader();
if(step_trigger){
cy.contains("Step 2").click();
cy.contains("Step 2").should('be.visible', { timeout: 10000 }).click();
}
cy.get('.fieldBox').contains('span', question_type).click();
cy.get('.fieldBox').should('be.visible', { timeout: 10000 }).contains('span', question_type).click();

for (let i = 0; i < 3; i++) {
cy.get('button[name="addOption"]').click();
Expand Down Expand Up @@ -54,9 +54,9 @@ describe("admin add, configure and delete questionnaires", () => {

const fieldTypes = Cypress.env("field_types");
fieldTypes.forEach((questionType: string) => {
cy.contains("Step 2").click();
add_question(questionType, true);
cy.waitForLoader();
cy.contains("Step 2").should('be.visible', { timeout: 10000 }).click();
add_question(questionType, true);
});

cy.contains("Step 2").click();
Expand Down
29 changes: 12 additions & 17 deletions client/cypress/e2e/18-test-globaleaks-process.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ describe("globaleaks process", function () {
});

it("Recipient actions ", function () {
cy.wait(1000)
/* file upload delay */
cy.wait(3000)
cy.login_receiver();
cy.waitForUrl("/#/recipient/home");
cy.visit("/#/recipient/reports");
cy.waitForLoader(true)

cy.get("#tip-0").first().click();
cy.get("#tip-0").should('be.visible', { timeout: 10000 }).first().click();

cy.get(".TipInfoID").invoke("text").then((_) => {
cy.contains("summary").should("exist");
Expand All @@ -35,16 +36,13 @@ describe("globaleaks process", function () {
cy.get("#tip-action-star").click();
});

cy.get(".tip-action-download-file").should("have.length", 2);
cy.get(".tip-action-download-file").eq(0).click();
cy.get('#fileListBody', { timeout: 10000 }).find('tr').should('have.length', 2);

const comment = "comment";

cy.get("[name='newCommentContent']").type(comment);
cy.get("#comment-action-send").click();

cy.get("#comment-0").should("contain", comment);

cy.waitForLoader();
cy.get('#comment-0').should('contain', comment);
cy.visit("/#/recipient/reports");
cy.takeScreenshot("recipient/reports", 0);

Expand Down Expand Up @@ -79,7 +77,7 @@ describe("globaleaks process", function () {
});

cy.get("#files-action-confirm").click();
cy.get(".progress-bar-complete", { timeout: 10000 }).should("exist");
// cy.get(".progress-bar-complete", { timeout: 10000 }).should("be.visible");
});

cy.logout();
Expand All @@ -94,13 +92,10 @@ describe("globaleaks process", function () {
cy.get(".TipInfoID").first().invoke("text").then(t => {
expect(t.trim()).to.be.a("string");
});
cy.waitForLoader(true)
cy.wait(1000)

cy.get('[id="tip-action-silence"]').click();
cy.get('#tip-action-notify').should('be.visible');
cy.get('[id="tip-action-notify"]').click();
cy.get('#tip-action-silence').should('be.visible');
cy.waitForLoader();
cy.get('[id="tip-action-silence"]').should('be.visible', { timeout: 10000 }).click();
cy.get('#tip-action-notify').should('be.visible', { timeout: 10000 }).click();
cy.get('#tip-action-silence').should('be.visible', { timeout: 10000 }).should('be.visible');
cy.takeScreenshot("recipient/report", 0);

cy.logout();
Expand Down
2 changes: 1 addition & 1 deletion client/cypress/e2e/21-test-signup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("Admin Disable Signup", function() {
cy.get('i.fa-solid.fa-check').click();

cy.logout();
cy.waitForLoader();
cy.waitForUrl("/#/login")
cy.visit("/#/");

});
Expand Down
Loading

0 comments on commit c853068

Please sign in to comment.