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 support to delete location #6996

Merged
merged 35 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
32d7560
Add support to delete location
Pranshu1902 Jan 8, 2024
349d723
fix button widths
Pranshu1902 Jan 9, 2024
4989f92
add modal for delete confirmation
Pranshu1902 Jan 9, 2024
ca63a22
add cypress for delete location functionality
Pranshu1902 Jan 9, 2024
e3ae83a
add confirmation dialog before deleting
Pranshu1902 Jan 11, 2024
85e088a
update cypress tests
Pranshu1902 Jan 11, 2024
7046c61
refactor
Pranshu1902 Jan 12, 2024
0e67b7a
fix cypress tests
Pranshu1902 Jan 13, 2024
959ba1a
Merge branch 'develop' into issue#6976
Pranshu1902 Jan 13, 2024
25f972a
show modal with links to linked assets and beds
Pranshu1902 Jan 19, 2024
8c6f79f
use pom in tests and cover all cases
Pranshu1902 Jan 19, 2024
b408dd8
Merge branch 'develop' into issue#6976
Pranshu1902 Jan 19, 2024
14038a9
Merge branch 'develop' into issue#6976
nihal467 Jan 19, 2024
e112fb9
Merge branch 'develop' into issue#6976
nihal467 Jan 22, 2024
447b6ab
update cypress tests to close notifications
Pranshu1902 Jan 25, 2024
1263a00
Merge branch 'develop' into issue#6976
Pranshu1902 Jan 25, 2024
2e443c1
Merge branch 'develop' into issue#6976
nihal467 Feb 5, 2024
dff5a5f
use id for cypress tests
Pranshu1902 Feb 8, 2024
026dd25
Merge branch 'develop' into issue#6976
Pranshu1902 Feb 8, 2024
a6c91e3
re-order asset creation commands
Pranshu1902 Feb 11, 2024
0e1f119
Merge branch 'develop' into issue#6976
rithviknishad Feb 12, 2024
006e72c
Merge branch 'develop' into issue#6976
nihal467 Feb 12, 2024
0849c5f
add wait for creating asset in tests
Pranshu1902 Feb 12, 2024
c96f510
refactor
Pranshu1902 Feb 12, 2024
c305dd8
verify location creation success
Pranshu1902 Feb 12, 2024
5fbbaa2
update location name in cypress
Pranshu1902 Feb 12, 2024
5cbf654
change facility name
Pranshu1902 Feb 12, 2024
54a37c6
update to dummy shifting facility
Pranshu1902 Feb 12, 2024
8d942ab
Merge branch 'develop' into issue#6976
nihal467 Feb 13, 2024
f558391
load specific facility for test
Pranshu1902 Feb 15, 2024
67b8987
Merge branch 'develop' into issue#6976
Pranshu1902 Feb 15, 2024
0389cac
fix typo
Pranshu1902 Feb 15, 2024
cf5b39b
fix tests for new assets page
Pranshu1902 Feb 15, 2024
1b362cb
Merge branch 'develop' into issue#6976
Pranshu1902 Feb 17, 2024
7d5b1fb
Merge branch 'develop' into issue#6976
nihal467 Feb 21, 2024
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
111 changes: 108 additions & 3 deletions cypress/e2e/facility_spec/locations.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import FacilityLocation from "../../pageobject/Facility/FacilityLocation";
import { AssetPagination } from "../../pageobject/Asset/AssetPagination";
import FacilityHome from "../../pageobject/Facility/FacilityHome";
import { v4 as uuidv4 } from "uuid";

describe("Location Management Section", () => {
const assetPage = new AssetPage();
Expand Down Expand Up @@ -40,6 +41,9 @@ describe("Location Management Section", () => {
const bedModifiedType = "Isolation";
const numberOfBeds = 10;
const numberOfModifiedBeds = 25;
const qr_id_1 = uuidv4();
const phone_number = "9999999999";
const serialNumber = Math.floor(Math.random() * 10 ** 10).toString();

before(() => {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
Expand All @@ -51,9 +55,7 @@ describe("Location Management Section", () => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/");
facilityPage.visitAlreadyCreatedFacility();
facilityPage.clickManageFacilityDropdown();
facilityLocation.clickFacilityLocationManagement();
facilityLocation.loadLocationManagementPage("Dummy Shifting Center");
});

it("Add a Bed to facility location along with duplication and deleting a bed", () => {
Expand Down Expand Up @@ -103,6 +105,7 @@ describe("Location Management Section", () => {
facilityLocation.verifyBedNameBadge(bedModifiedName);
facilityLocation.verifyBedBadge(bedModifiedType);
facilityLocation.verifyBedBadge(bedStatus);
facilityLocation.closeNotification();
});

it("Adds Location to a facility and modify it", () => {
Expand Down Expand Up @@ -134,6 +137,7 @@ describe("Location Management Section", () => {
facilityLocation.verifyLocationType(locationModifiedType);
facilityLocation.verifyLocationDescription(locationModifiedDescription);
facilityLocation.verifyLocationMiddleware(locationModifiedMiddleware);
facilityLocation.closeNotification();
});

it("Multiple Bed to a facility location and delete a bed", () => {
Expand All @@ -155,6 +159,7 @@ describe("Location Management Section", () => {
facilityLocation.deleteBedRequest();
assetPage.clickassetupdatebutton();
facilityLocation.deleteBedRequest();
facilityLocation.closeNotification();
});

it("Add Multiple Bed to a facility location and verify pagination", () => {
Expand All @@ -169,6 +174,106 @@ describe("Location Management Section", () => {
// pagination
assetPagination.navigateToNextPage();
assetPagination.navigateToPreviousPage();
facilityLocation.closeNotification();
});

it("Delete location", () => {
facilityLocation.clickAddNewLocationButton();
facilityLocation.enterLocationName("Test Location");
facilityLocation.selectLocationType("OTHER");
assetPage.clickassetupdatebutton();
facilityLocation.deleteLocation("Test Location");
assetPage.clickassetupdatebutton();
facilityLocation.verifyNotification(
"Location Test Location deleted successfully"
);
facilityLocation.closeNotification();
});

it("Delete location with linked beds", () => {
facilityLocation.clickAddNewLocationButton();
facilityLocation.enterLocationName("Test Location with Beds");
facilityLocation.selectLocationType("OTHER");
assetPage.clickassetupdatebutton();
facilityLocation.clickManageBedButton();
facilityLocation.clickAddBedButton();
facilityLocation.enterBedName("Bed 1");
facilityLocation.selectBedType("Regular");
assetPage.clickassetupdatebutton();
facilityLocation.loadLocationManagementPage("Dummy Shifting Center");
facilityLocation.deleteLocation("Test Location with Beds");
assetPage.clickassetupdatebutton();
facilityLocation.verifyNotification(
"Cannot delete a Location with associated Beds"
);
facilityLocation.closeNotification();

// delete bed
facilityLocation.clickManageBeds();
facilityLocation.deleteFirstBed();
assetPage.clickassetupdatebutton();
facilityLocation.closeNotification();

// delete location
facilityLocation.loadLocationManagementPage("Dummy Shifting Center");
facilityLocation.deleteLocation("Test Location with Beds");
assetPage.clickassetupdatebutton();
facilityLocation.verifyNotification(
"Location Test Location with Beds deleted successfully"
);
facilityLocation.closeNotification();
});

it("Delete location with linked assets", () => {
facilityLocation.clickAddNewLocationButton();
facilityLocation.enterLocationName("Test Location with linked Assets");
facilityLocation.selectLocationType("OTHER");
assetPage.clickassetupdatebutton();
facilityLocation.verifyNotification("Location created successfully");
facilityLocation.closeNotification();
// create asset and link it to location
cy.awaitUrl("/assets");
assetPage.createAsset();
assetPage.selectFacility("Dummy Shifting Center");
assetPage.selectLocation("Test Location with linked Assets");
assetPage.enterAssetDetails(
"Test Asset linked to Facility",
"Test Description",
"Working",
qr_id_1,
"Manufacturer's Name",
"2025-12-25",
"Customer Support's Name",
phone_number,
"[email protected]",
"Vendor's Name",
serialNumber,
"25122021",
"Test note for asset creation!"
);
assetPage.clickassetupdatebutton();
facilityLocation.loadLocationManagementPage("Dummy Shifting Center");
facilityLocation.deleteLocation("Test Location with linked Assets");
assetPage.clickassetupdatebutton();
facilityLocation.verifyNotification(
"Cannot delete a Location with associated Assets"
);
facilityLocation.closeNotification();

// delete asset
facilityLocation.clickManageAssets();
assetPage.openCreatedAsset();
assetPage.deleteAsset();
facilityLocation.closeNotification();

// delete location
facilityLocation.loadLocationManagementPage("Dummy Shifting Center");
facilityLocation.deleteLocation("Test Location with linked Assets");
assetPage.clickassetupdatebutton();
facilityLocation.verifyNotification(
"Location Test Location with linked Assets deleted successfully"
);
facilityLocation.closeNotification();
});

afterEach(() => {
Expand Down
43 changes: 43 additions & 0 deletions cypress/pageobject/Facility/FacilityLocation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
class FacilityLocation {
loadLocationManagementPage(name: string) {
cy.awaitUrl("/");
cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities");
cy.get("[id='facility-name-card']").contains(name).click();
cy.wait("@getFacilities").its("response.statusCode").should("eq", 200);
cy.get("h1.text-3xl.font-bold", { timeout: 10000 }).should("be.visible");
cy.get("#manage-facility-dropdown button").should("be.visible");
cy.get("[id='manage-facility-dropdown']").scrollIntoView().click();
cy.get("[id=location-management]").click();
}

closeNotification() {
cy.get(".pnotify")
.should("exist")
.each(($div) => {
cy.wrap($div).click();
});
}

clickAddNewLocationButton() {
cy.get("#add-new-location").click();
}
Expand All @@ -19,6 +38,14 @@ class FacilityLocation {
cy.get("#description").clear().click().type(description);
}

clickText(name: string) {
cy.get("div").contains(name).click();
Pranshu1902 marked this conversation as resolved.
Show resolved Hide resolved
}

enterLocationName(name: string) {
cy.get("input[id=name]").type(name);
}

selectLocationType(type: string) {
cy.get("#location-type").click();
cy.get("li[role=option]").contains(type).click();
Expand Down Expand Up @@ -101,6 +128,22 @@ class FacilityLocation {
}
}

clickManageBeds() {
cy.get("#manage-beds").click();
}

clickManageAssets() {
cy.get("#manage-assets").click();
}

deleteLocation(name: string) {
cy.contains("div", name)
.should("exist")
.then(($div) => {
$div.parents("div").eq(2).find("button#delete-location-button").click();
});
}

deleteFirstBed() {
cy.get("#delete-bed-button").first().click();
}
Expand Down
Loading
Loading