Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Test suit for Image Upload Functionality #9373

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions cypress/e2e/facility_spec/FacilityCoverImage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import FacilityPage from "pageobject/Facility/FacilityCreation";
import FacilityHome from "pageobject/Facility/FacilityHome";
import FacilityManage from "pageobject/Facility/FacilityManage";
import LoginPage from "pageobject/Login/LoginPage";
import { users } from "pageobject/utils/userConfig";

interface IRoleAndFacility {
role: keyof typeof users;
facilityName: string;
}

const rolesAndFacility: IRoleAndFacility[] = [
{
role: "districtAdmin",
facilityName: "Dummy Facility 40",
},
{
role: "devDoctor",
facilityName: "Dummy Facility 4",
},
];

describe("Facility Cover Image Upload Functionality", () => {
const loginPage = new LoginPage();
const facilityPage = new FacilityPage();
const facilityHome = new FacilityHome();
const facilityManage = new FacilityManage();
const successUploadNotificationText = "Cover image updated.";

rolesAndFacility.forEach(({ role, facilityName }) => {
before(() => {
loginPage.loginByRole(role);
cy.saveLocalStorage();
});

beforeEach(() => {
cy.viewport(1920, 1080);
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/");
facilityHome.typeFacilitySearch(facilityName);
facilityPage.visitAlreadyCreatedFacility();
});
JavidSumra marked this conversation as resolved.
Show resolved Hide resolved

it(`Upload and Verify Cover Image Upload Functionality as ${role}`, () => {
// Test Visibility of Pop-up
facilityManage.clickCoverImage();
facilityManage.verifyUploadButtonVisible();
facilityManage.clickCancelCoverImage();
// Test Functionality of Upload Cover Image
facilityManage.interceptImageUploadRequest();
facilityManage.clickCoverImage();
facilityManage.uploadCoverImage("facility-cover-image.jpg");
facilityManage.clickSaveCoverImage();
facilityManage.verifyImageUploadRequest();
facilityManage.verifySuccessMessageVisibilityAndContent(
successUploadNotificationText,
);
// Test Edit Cover Image Functionality
facilityManage.interceptImageUploadRequest();
facilityManage.clickCoverImage();
facilityManage.uploadCoverImage("facility-cover-image-1.jpg");
facilityManage.clickSaveCoverImage();
facilityManage.verifyImageUploadRequest();
facilityManage.verifySuccessMessageVisibilityAndContent(
successUploadNotificationText,
);
// Test Delete Cover Image Functionality
facilityManage.clickCoverImage();
facilityManage.interceptImageDeleteRequest();
facilityManage.clickDeleteCoverImage();
facilityManage.verifyImageDeleteRequest();
});
JavidSumra marked this conversation as resolved.
Show resolved Hide resolved

afterEach(() => {
cy.saveLocalStorage();
});
});
});
Binary file added cypress/fixtures/facility-cover-image-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/fixtures/facility-cover-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions cypress/pageobject/Facility/FacilityManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ class FacilityManage {
cy.get("#save-cover-image").click();
}

clickCancelCoverImage() {
cy.verifyAndClickElement("#cancel", "Cancel");
}

clickDeleteCoverImage() {
cy.verifyAndClickElement("#delete-cover-image", "Delete");
}

verifyTotalDoctorCapacity(expectedCapacity: string) {
cy.get("#facility-doctor-totalcapacity").contains(expectedCapacity);
}
Expand Down Expand Up @@ -100,6 +108,26 @@ class FacilityManage {
cy.get("#facility-add-bedtype").click();
}

interceptImageUploadRequest() {
cy.intercept("POST", "**/api/v1/facility/*/cover_image/").as(
"imageUploadReq",
);
}

verifyImageUploadRequest() {
cy.wait("@imageUploadReq").its("response.statusCode").should("eq", 200);
}

interceptImageDeleteRequest() {
cy.intercept("DELETE", "**/api/v1/facility/*/cover_image/").as(
"imageDeleteReq",
);
}

verifyImageDeleteRequest() {
cy.wait("@imageDeleteReq").its("response.statusCode").should("eq", 204);
}
JavidSumra marked this conversation as resolved.
Show resolved Hide resolved

visitViewPatients() {
cy.intercept("GET", "**/api/v1/facility/**").as("getFacilityPatients");
cy.get("#view-patient-facility-list").scrollIntoView().click();
Expand Down
4 changes: 2 additions & 2 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@
"asset_type": "Asset Type",
"assets": "Assets",
"assign": "Assign",
"unassign":"Unassign",
"assign_a_volunteer_to": "Assign a volunteer to {{name}}",
"assign_bed": "Assign Bed",
"assign_to_volunteer": "Assign to a Volunteer",
Expand Down Expand Up @@ -1444,6 +1443,7 @@
"type_your_comment": "Type your comment",
"type_your_reason_here": "Type your reason here",
"unable_to_get_current_position": "Unable to get current position.",
"unassign": "Unassign",
"unconfirmed": "Unconfirmed",
"unique_id": "Unique Id",
"unknown": "Unknown",
Expand Down Expand Up @@ -1558,8 +1558,8 @@
"voice_autofill": "Voice Autofill",
"volunteer_assigned": "Volunteer assigned successfully",
"volunteer_contact": "Volunteer Contact",
"volunteer_update" : "Volunteer updated successfully",
"volunteer_unassigned": "Volunteer unassigned successfully",
"volunteer_update": "Volunteer updated successfully",
"ward": "Ward",
"warranty_amc_expiry": "Warranty / AMC Expiry",
"weekly_working_hours_error": "Average weekly working hours must be a number between 0 and 168",
Expand Down
1 change: 1 addition & 0 deletions src/components/Common/AvatarEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ const AvatarEditModal = ({
/>
{imageUrl && (
<ButtonV2
id="delete-cover-image"
variant="danger"
onClick={deleteAvatar}
disabled={isProcessing}
Expand Down
Loading