Skip to content

Commit

Permalink
Merge branch 'develop' into fix-6079
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Sep 12, 2023
2 parents c70cfc3 + dd1dcc3 commit f5f72a7
Show file tree
Hide file tree
Showing 27 changed files with 1,543 additions and 1,367 deletions.
7 changes: 3 additions & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Whitelabelling envs

REACT_APP_TITLE="CARE"
REACT_APP_META_DESCRIPTION="CoronaSafe Network is an open-source public utility designed by a multi-disciplinary team of innovators and volunteers. CoronaSafe Care is a Digital Public Good recognised by United Nations."
REACT_APP_TITLE=CARE
REACT_APP_META_DESCRIPTION=CoronaSafe Network is an open-source public utility designed by a multi-disciplinary team of innovators and volunteers. CoronaSafe Care is a Digital Public Good recognised by United Nations.
REACT_APP_COVER_IMAGE=https://cdn.coronasafe.network/care_logo.svg
REACT_APP_COVER_IMAGE_ALT=https://cdn.coronasafe.network/care_logo.svg
REACT_APP_CONFIG=""
REACT_PUBLIC_URL="https://care.coronasafe.in"
REACT_PUBLIC_URL=https://care.coronasafe.in

# Dev envs
ESLINT_NO_DEV_ERRORS=true
11 changes: 6 additions & 5 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ jobs:
path: care

- name: Run docker compose up on care 🐳
run: cd care && touch .env && make docker_config_file=docker-compose.pre-built.yaml up && cd .. && sleep 60s
# Voluntarily kept 60 seconds delay to wait for migrations to complete.

- name: Run Django collectstatic and load dummy data on care 🐍
run: |
docker exec care python manage.py load_dummy_data
cd care
make docker_config_file=docker-compose.pre-built.yaml up
sleep 60s
docker compose exec backend bash -c "python manage.py load_dummy_data"
cd ..
# Voluntarily kept 60 seconds delay to wait for migrations to complete.

- name: Check care is up ♻
run: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public/build-meta.json
# Using NPM
yarn.lock
pnpm-lock.yaml
bun.lockb

# Cypress
cypress/downloads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch";
import { AssetQRScanPage } from "../../pageobject/Asset/AssetQRScan";
import { AssetPagination } from "../../pageobject/Asset/AssetPagination";
import { AssetFilters } from "../../pageobject/Asset/AssetFilters";
import LoginPage from "../../pageobject/Login/LoginPage";
import { v4 as uuidv4 } from "uuid";

describe("Asset Tab", () => {
const assetSearchPage = new AssetSearchPage();
const assetQRScanPage = new AssetQRScanPage();
const assetPagination = new AssetPagination();
const assetFilters = new AssetFilters();
const loginPage = new LoginPage();
const assetName = "Dummy Camera 10";
const qrCode = uuidv4();
const serialNumber = Math.floor(Math.random() * 10 ** 10).toString();

before(() => {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

Expand All @@ -24,11 +30,23 @@ describe("Asset Tab", () => {

// search for a element

it("Search Asset Name", () => {
const initialUrl = cy.url();
assetSearchPage.typeSearchKeyword("dummy camera 30");
it("Search Asset Name/QR_ID/Serial_number", () => {
assetSearchPage.typeSearchKeyword(assetName);
assetSearchPage.pressEnter();
assetSearchPage.verifyUrlChanged(initialUrl);
assetSearchPage.verifyBadgeContent(assetName);
assetSearchPage.clickAssetByName(assetName);
assetSearchPage.clickUpdateButton();
assetSearchPage.clearAndTypeQRCode(qrCode);
assetSearchPage.clearAndTypeSerialNumber(serialNumber);
assetSearchPage.clickAssetSubmitButton();
assetSearchPage.visitAssetsPage();
assetSearchPage.typeSearchKeyword(qrCode);
assetSearchPage.pressEnter();
assetSearchPage.verifyAssetListContains(assetName);
assetSearchPage.verifyBadgeContent(qrCode);
assetSearchPage.typeSearchKeyword(serialNumber);
assetSearchPage.verifyAssetListContains(assetName);
assetSearchPage.verifyBadgeContent(serialNumber);
});

// scan a asset qr code
Expand Down
47 changes: 42 additions & 5 deletions cypress/pageobject/Asset/AssetSearch.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,58 @@
export class AssetSearchPage {
typeSearchKeyword(keyword: string) {
cy.get("[name='search']").type(keyword);
cy.get("#search").clear();
cy.get("#search").click().type(keyword);
}

pressEnter() {
cy.get("[name='search']").type("{enter}");
}

verifyUrlChanged(initialUrl: string) {
cy.url().should((currentUrl) => {
expect(currentUrl).not.to.equal(initialUrl);
});
clickAssetByName(assetName: string) {
cy.get("[data-testid='created-asset-list']").contains(assetName).click();
}

verifyBadgeContent(expectedText: string) {
cy.get("[data-testid='Name/Serial No./QR ID']").should(
"contain",
expectedText
);
}

verifyAssetIsPresent(assetName: string) {
cy.get("[data-testid=created-asset-list]")
.first()
.should("contain", assetName);
}

clickUpdateButton() {
cy.get("[data-testid='asset-update-button']").contains("Update").click();
}

clearAndTypeQRCode(qrCode: string) {
cy.get("#qr_code_id").clear();
cy.get("#qr_code_id").click().type(qrCode);
}

clearAndTypeSerialNumber(serialNumber: string) {
cy.get("#serial-number").clear();
cy.get("#serial-number").click().type(serialNumber);
}

clickAssetSubmitButton() {
cy.intercept("GET", "**/api/v1/asset/**").as("getAssets");
cy.get("#submit").click();
cy.wait("@getAssets").its("response.statusCode").should("eq", 200);
}

visitAssetsPage() {
cy.visit("/assets");
}

verifyAssetListContains(dummyCameraText: string) {
cy.get("[data-testid='created-asset-list']").should(
"contain",
dummyCameraText
);
}
}
10 changes: 4 additions & 6 deletions src/Common/hooks/useAppHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ export default function useAppHistory() {
const resetHistory = useContext(ResetHistoryContext);

const goBack = (fallbackUrl?: string) => {
if (history.length > 1)
// Navigate to history present in the app navigation history stack.
return navigate(history[1]);

if (fallbackUrl)
// Otherwise, use provided fallback url if provided.
// use provided fallback url if provided.
return navigate(fallbackUrl);

if (history.length > 1)
// Otherwise, navigate to history present in the app navigation history stack.
return navigate(history[1]);
// Otherwise, fallback to browser's go back behaviour.
window.history.back();
};
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Assets/AssetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ function AssetFilter(props: any) {
const applyFilter = () => {
const data = {
facility: facilityId,
asset_type: asset_type,
asset_class: asset_class,
status: asset_status,
asset_type: asset_type ?? "",
asset_class: asset_class ?? "",
status: asset_status ?? "",
location: locationId,
};
onChange(data);
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Assets/AssetManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { useTranslation } from "react-i18next";
const PageTitle = lazy(() => import("../Common/PageTitle"));
const Loading = lazy(() => import("../Common/Loading"));
import * as Notification from "../../Utils/Notifications.js";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import AuthorizeFor, { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import Uptime from "../Common/Uptime";
import useAuthUser from "../../Common/hooks/useAuthUser";
import dayjs from "dayjs";
Expand Down Expand Up @@ -452,7 +452,7 @@ const AssetManage = (props: AssetManageProps) => {
}
id="configure-asset"
data-testid="asset-configure-button"
authorizeFor={NonReadOnlyUsers}
authorizeFor={AuthorizeFor(["DistrictAdmin", "StateAdmin"])}
>
<CareIcon className="care-l-setting h-4" />
{t("configure")}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/AddLocationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const AddLocationForm = (props: LocationFormProps) => {
/>
</div>
</div>
<div className="mt-4 flex flex-col gap-3 sm:flex-row sm:justify-between">
<div className="mt-4 cui-form-button-group">
<Cancel
onClick={() =>
navigate(`/facility/${facilityId}/location`, {
Expand Down
Loading

0 comments on commit f5f72a7

Please sign in to comment.