Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Dec 4, 2024
2 parents e749d9a + 9561e0d commit 14aff33
Show file tree
Hide file tree
Showing 56 changed files with 966 additions and 946 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
containers: [1, 2, 3, 4]
env:
REACT_CARE_API_URL: http://localhost:9000
REACT_ENABLED_APPS: "ohcnetwork/care_hcx_fe@main"
REACT_ENABLED_APPS: "ohcnetwork/care_hcx_fe@main,ohcnetwork/care_abdm_fe@main"
REACT_ENABLE_HCX: true
REACT_ENABLE_ABDM: true
steps:
- name: Checkout 📥
uses: actions/checkout@v3
Expand Down Expand Up @@ -135,4 +136,4 @@ jobs:
if: ${{ failure() && steps.pr_origin.outputs.is_forked == 'true' }}
with:
name: cypress-videos
path: cypress/videos
path: cypress/videos
95 changes: 48 additions & 47 deletions .github/workflows/notify-non-core-qn.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
name: Notify Core Team on Non-Core Questions

on:
issue_comment:
types: [created]

permissions:
issues: write
pull-requests: write

jobs:
notify_core_team:
runs-on: ubuntu-latest
env:
ALLOWED_USERNAMES: ${{ vars.ALLOWED_USERNAMES }}
QUESTION_KEYWORDS: ${{ vars.QUESTION_KEYWORDS }}
QUESTION_LABELS: ${{ vars.QUESTION_LABELS }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
ALLOWED_USERNAMES: ${{ vars.ALLOWED_USERNAMES || '' }}
QUESTION_KEYWORDS: ${{ vars.QUESTION_KEYWORDS || '' }}
QUESTION_LABELS: ${{ vars.QUESTION_LABELS || '' }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK || '' }}

steps:
- name: Check and Notify
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
console.log('Script started');
const isOrgMember = (commenter, allowedUsers) => {
return allowedUsers.split(',').map(u => u.trim()).includes(commenter);
};
const containsQuestionKeywords = (text, keywords) => {
return keywords.split(',').map(k => k.trim()).some(keyword =>
const isOrgMember = (commenter, allowedUsers) =>
allowedUsers.split(',').map(u => u.trim()).includes(commenter);
const containsQuestionKeywords = (text, keywords) =>
keywords.split(',').map(k => k.trim()).some(keyword =>
text.toLowerCase().includes(keyword.toLowerCase())
);
};
const addLabelsToIssue = async (github, context, labelsString) => {
const labels = labelsString.split(',').map(label => label.trim()).filter(label => label);
const labels = labelsString.split(',').map(label => label.trim()).filter(Boolean);
if (labels.length > 0) {
console.log('Adding labels:', labels);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -40,48 +42,47 @@ jobs:
});
}
};
const sendSlackNotification = async (webhook, payload) => {
const sendSlackNotification = async (webhook, commentUrl) => {
const payload = { commentUrl };
const response = await fetch(webhook, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
throw new Error(`Slack notification failed with status: ${response.status}`);
}
};
const isBot = async (github, commenter) => {
try {
const { data: user } = await github.rest.users.getByUsername({ username: commenter });
return user.type === 'Bot';
} catch {
return false;
}
};
const commenter = context.payload.comment.user.login;
console.log('Commenter:', commenter);
if (!isOrgMember(commenter, process.env.ALLOWED_USERNAMES)) {
const commentBody = context.payload.comment.body;
const sanitizedComment = commentBody
?.replace(/[^\w\s?]/gi, '')
.toLowerCase();
console.log('Comment body:', sanitizedComment);
if (containsQuestionKeywords(sanitizedComment, process.env.QUESTION_KEYWORDS)) {
try {
console.log('Adding labels to the issue');
await addLabelsToIssue(github, context, process.env.QUESTION_LABELS);
console.log('Labels added successfully');
const issueUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/issues/${context.payload.issue.number}`;
const issueTitle = context.payload.issue.title;
const issueNumber = context.payload.issue.number;
console.log('Issue URL:', issueUrl);
console.log('Issue Title:', issueTitle);
console.log('Issue Number:', issueNumber);
const payload = {
link: issueUrl,
Question: commentBody,
"issue-number": issueNumber,
title: issueTitle,
user: commenter
};
await sendSlackNotification(process.env.SLACK_WEBHOOK, payload);
console.log('Slack notification sent successfully');
} catch (error) {
console.error('Workflow failed:', error.message);
core.setFailed(`Workflow failed: ${error.message}`);
const allowedUsers = process.env.ALLOWED_USERNAMES;
const keywords = process.env.QUESTION_KEYWORDS;
const labels = process.env.QUESTION_LABELS;
const webhook = process.env.SLACK_WEBHOOK;
if (await isBot(github, commenter)) return;
if (allowedUsers && !isOrgMember(commenter, allowedUsers)) {
const commentBody = context.payload.comment.body.trim();
const filteredCommentBody = commentBody.split('\n').filter(line => !line.startsWith('>')).join('\n');
if (keywords && containsQuestionKeywords(filteredCommentBody, keywords)) {
if (labels) {
await addLabelsToIssue(github, context, labels);
}
if (webhook) {
const commentUrl = context.payload.comment.html_url;
await sendSlackNotification(webhook, commentUrl);
}
}
}
console.log('Script ended');
226 changes: 121 additions & 105 deletions cypress/e2e/assets_spec/AssetHomepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,112 +2,128 @@ import { advanceFilters } from "pageobject/utils/advanceFilterHelpers";
import { pageNavigation } from "pageobject/utils/paginationHelpers";
import { v4 as uuidv4 } from "uuid";

import { AssetPage } from "../../pageobject/Asset/AssetCreation";
import { AssetFilters } from "../../pageobject/Asset/AssetFilters";
import { AssetQRScanPage } from "../../pageobject/Asset/AssetQRScan";
import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch";
import { AssetHome } from "../../pageobject/Asset/AssetHome";
import LoginPage from "../../pageobject/Login/LoginPage";

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

before(() => {
loginPage.loginAsDistrictAdmin();
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/assets");
});

// search for a element

it("Search Asset Name/QR_ID/Serial_number", () => {
assetSearchPage.typeSearchKeyword(assetName);
assetSearchPage.pressEnter();
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

it("Scan Asset QR", () => {
assetQRScanPage.scanAssetQR();
});

// filter the asset and verify the badges are there

it("Filter Asset", () => {
assetFilters.filterAssets(
"Dummy Facility 40",
"ACTIVE",
"ONVIF Camera",
"Camera Loc",
);
advanceFilters.clickAdvancedFiltersButton();
assetFilters.clickslideoverbackbutton(); // to verify the back button doesn't clear applied filters
assetFilters.assertFacilityText("Dummy Facility 40");
assetFilters.assertAssetClassText("ONVIF");
assetFilters.assertStatusText("ACTIVE");
assetFilters.assertLocationText("Camera Loc");
advanceFilters.clickAdvancedFiltersButton();
assetFilters.clearFilters();
});

// Verify the pagination in the page

it("Next/Previous Page", () => {
pageNavigation.navigateToNextPage();
pageNavigation.verifyCurrentPageNumber(2);
pageNavigation.navigateToPreviousPage();
pageNavigation.verifyCurrentPageNumber(1);
});

it("Import new asset", () => {
assetPage.selectassetimportbutton();
assetPage.selectImportOption();
assetPage.selectImportFacility("Dummy Facility 40");
assetPage.importAssetFile();
assetPage.selectImportLocation("Camera Loc");
assetPage.clickImportAsset();
});

it("verify imported asset", () => {
assetSearchPage.typeSearchKeyword("New Test Asset");
assetSearchPage.pressEnter();
assetSearchPage.verifyAssetIsPresent("New Test Asset");
});

it("Export asset", () => {
assetPage.selectassetimportbutton();
cy.wait(2000);
assetPage.selectJsonExportButton();
assetPage.selectassetimportbutton();
assetPage.selectCsvExportButton();
});

afterEach(() => {
cy.saveLocalStorage();
import { nonAdminRoles } from "../../pageobject/utils/userConfig";

const rolesToTest: Array<"districtAdmin" | (typeof nonAdminRoles)[number]> = [
"districtAdmin",
...nonAdminRoles,
];

rolesToTest.forEach((role) => {
describe(`Asset Tab Tests for Role: ${role}`, () => {
const assetHome = new AssetHome();
const assetFilters = new AssetFilters();
const loginPage = new LoginPage();
const assetName = "Dummy Camera 10";
const assetStatus = "ACTIVE";
const assetClass = "ONVIF";
const assetLocation = "Camera Loc";
const facilityName = "Dummy Facility 40";
const newImportAssetName = "New Test Asset";
const qrCode = uuidv4();
const serialNumber = Math.floor(Math.random() * 10 ** 10).toString();

before(() => {
loginPage.loginByRole(role);
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/assets");
});

it("Search Asset Name/QR_ID/Serial_number", () => {
assetHome.typeAssetSearch(assetName);
advanceFilters.verifyFilterBadgePresence(
"Name/Serial No./QR ID",
assetName,
true,
);
assetHome.clickAssetByName(assetName);
assetHome.clickAssetDetailsUpdateButton();
assetHome.clearAndTypeQRCode(qrCode);
assetHome.clearAndTypeSerialNumber(serialNumber);
assetHome.clickAssetUpdateSubmitButton();
assetHome.navigateToAssetsPage();
assetHome.typeAssetSearch(qrCode);
assetHome.verifyAssetListContains(assetName);
advanceFilters.verifyFilterBadgePresence(
"Name/Serial No./QR ID",
qrCode,
true,
);
assetHome.typeAssetSearch(serialNumber);
assetHome.verifyAssetListContains(assetName);
advanceFilters.verifyFilterBadgePresence(
"Name/Serial No./QR ID",
serialNumber,
true,
);
});

it("Scan Asset QR", () => {
assetHome.scanAssetQR();
});

it("Advance Filter Asset", () => {
advanceFilters.clickAdvancedFiltersButton();
advanceFilters.typeFacilityName(facilityName);
assetFilters.filterAssets(assetStatus, assetClass, assetLocation);
advanceFilters.applySelectedFilter();
advanceFilters.clickAdvancedFiltersButton();
advanceFilters.clickslideoverbackbutton(); // to verify the back button doesn't clear applied filters
advanceFilters.verifyFilterBadgePresence("Facility", facilityName, true);
advanceFilters.verifyFilterBadgePresence("Asset Class", assetClass, true);
advanceFilters.verifyFilterBadgePresence("Status", assetStatus, true);
advanceFilters.verifyFilterBadgePresence("Location", assetLocation, true);
advanceFilters.clickAdvancedFiltersButton();
advanceFilters.clickClearAdvanceFilters();
});

it("Next/Previous Page", () => {
pageNavigation.navigateToNextPage();
pageNavigation.verifyCurrentPageNumber(2);
pageNavigation.navigateToPreviousPage();
pageNavigation.verifyCurrentPageNumber(1);
});

it("Import new asset and verify its presence", () => {
if (role === "districtAdmin") {
assetHome.selectAssetImportButton("click");
assetHome.selectImportOption();
assetHome.selectImportFacility(facilityName);
assetHome.importAssetFile();
assetHome.selectImportLocation(assetLocation);
assetHome.clickImportAsset();
cy.verifyNotification("Assets imported successfully");
cy.closeNotification();
assetHome.navigateToAssetsPage();
assetHome.typeAssetSearch(newImportAssetName);
assetHome.verifyAssetIsPresent(newImportAssetName);
} else {
assetHome.selectAssetImportButton("verifyNotExist");
}
});

it("Export the list of assets in CSV & Json", () => {
if (role === "districtAdmin") {
assetHome.selectAssetImportButton("click");
cy.wait(2000);
assetHome.selectJsonExportButton();
assetHome.selectAssetImportButton("click");
assetHome.selectCsvExportButton();
} else {
assetHome.selectAssetImportButton("verifyNotExist");
}
});

afterEach(() => {
cy.saveLocalStorage();
});
});
});
Loading

0 comments on commit 14aff33

Please sign in to comment.