Skip to content

Commit

Permalink
frontend consultation depth
Browse files Browse the repository at this point in the history
  • Loading branch information
hrit2773 committed May 14, 2024
2 parents d601c6b + c7fc607 commit 8e71487
Show file tree
Hide file tree
Showing 71 changed files with 5,411 additions and 6,366 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/auto-testing-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Auto Add Needs Testing Label

on:
pull_request:
types: [opened, reopened, edited]
issue_comment:
types: [created]
pull_request_review:
types: [submitted]

jobs:
auto_label:
runs-on: ubuntu-latest

steps:
- name: Check PR Conditions and Add Label
id: check_conditions
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const isDraft = pr.draft;
const isReadyForTestingComment = context.payload.comment?.body.includes('ready for testing');
const isChangesRequired = context.payload.review?.state === 'changes_requested';
if ((isReadyForTestingComment && !isDraft) || (!isDraft && pr.draft_changed)) {
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['needs testing']
});
}
if (isChangesRequired) {
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: 'Reminder: To add the "needs testing" label, comment "ready for testing" on this PR.'
});
}
1 change: 1 addition & 0 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- name: Start care docker containers 🐳
run: |
cd care
echo DISABLE_RATELIMIT=True >> docker/.prebuilt.env
make docker_config_file=docker-compose.pre-built.yaml up
make docker_config_file=docker-compose.pre-built.yaml load-dummy-data
cd ..
Expand Down
15 changes: 10 additions & 5 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-vite",
options: {
builder: {
core: {
builder: {
name: "@storybook/builder-vite",
options: {
viteConfigPath: "./.storybook/vite.config.mts",
},
},
},
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: "tag",
},
Expand Down
12 changes: 3 additions & 9 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<script>
window.global = window;
</script>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet"
/>
<script>
window.global = window;
</script>
3 changes: 1 addition & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import "../src/style/index.css";

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
date: /Date$/i,
},
},
},
Expand Down
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,33 @@ Authenticate to staging API with any of the following credentials

#### 🧪 Run cypress tests

Ensure that the development server is running and then run the cypress tests in either of the ways described below.
To run cypress tests locally, you'll need to setup the backend to run locally and load dummy data required for cypress to the database. See [docs](https://github.com/coronasafe/care#self-hosting).

Once backend is running locally, you'll have to ensure your local front-end is connected to local backend, by setting the `CARE_API` env.

```env
#.env
CARE_API=http://127.0.0.1:9000
```

Once done, start the development server by running

```sh
npm run dev
```

Once development server is running, then run the cypress tests in either of the ways described below.

```sh
npm run cypress:run # To run all tests in headless mode.
```

```sh
npm run cypress:run:gui # To run all tests in headed mode.
```

```sh
$ npm run cypress:run # To run all tests in headless mode.
$ npm run cypress:run:gui # To run all tests in headed mode.
$ npm run cypress:open # To debug and run tests individually.
npm run cypress:open # To debug and run tests individually.
```

- Failed test screenshots are saved in `cypress/screenshots`
Expand Down
10 changes: 5 additions & 5 deletions cypress/e2e/assets_spec/assets_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("Asset", () => {
"Vendor's Name",
serialNumber,
"25122021",
"Test note for asset creation!"
"Test note for asset creation!",
);

assetPage.clickCreateAddMore();
Expand All @@ -80,7 +80,7 @@ describe("Asset", () => {
"Vendor's Name",
serialNumber,
"25122021",
"Test note for asset creation!"
"Test note for asset creation!",
);

assetPage.interceptAssetCreation();
Expand All @@ -106,7 +106,7 @@ describe("Asset", () => {
"Customer Support's Name Edited",
"Vendor's Name Edited",
"Test note for asset creation edited!",
"25122021"
"25122021",
);

assetPage.clickUpdateAsset();
Expand All @@ -128,7 +128,7 @@ describe("Asset", () => {
"192.168.1.64",
"remote_user",
"2jCkrCRSeahzKEU",
"d5694af2-21e2-4a39-9bad-2fb98d9818bd"
"d5694af2-21e2-4a39-9bad-2fb98d9818bd",
);
assetPage.clickConfigureAsset();
assetPage.verifyAssetConfiguration(200);
Expand All @@ -155,7 +155,7 @@ describe("Asset", () => {
"Vendor's Name",
serialNumber,
"25122021",
"Test note for asset creation!"
"Test note for asset creation!",
);
assetPage.interceptAssetCreation();
assetPage.clickCreateAsset();
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("Facility Creation", () => {
initialTriageValue,
initialTriageValue,
initialTriageValue,
initialTriageValue
initialTriageValue,
);
manageUserPage.clickSubmit();
// edit the entry and verify reflection
Expand All @@ -106,7 +106,7 @@ describe("Facility Creation", () => {
modifiedTriageValue,
modifiedTriageValue,
modifiedTriageValue,
modifiedTriageValue
modifiedTriageValue,
);
manageUserPage.clickSubmit();
facilityPage.scrollToFacilityTriage();
Expand Down Expand Up @@ -318,7 +318,7 @@ describe("Facility Creation", () => {
facilityPage.fillMiddleWareAddress("dev_middleware.coronasafe.live");
facilityPage.clickupdateMiddleWare();
facilityPage.verifySuccessNotification(
"Facility middleware updated successfully"
"Facility middleware updated successfully",
);
});

Expand Down
24 changes: 12 additions & 12 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ describe("Facility Manage Functions", () => {
// verify mandatory field error message
facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton);
facilityManage.checkErrorMessageVisibility(
"Middleware Address is required"
"Middleware Address is required",
);
// add middleware and verify the notification
facilityManage.typeMiddlewareAddress(facilityMiddleware);
facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityMiddlewareSuccessfullNotification
facilityMiddlewareSuccessfullNotification,
);
// update the existing middleware
facilityPage.clickManageFacilityDropdown();
Expand All @@ -68,7 +68,7 @@ describe("Facility Manage Functions", () => {
facilityManage.typeMiddlewareAddress(facilityUpdatedMiddleware);
facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityMiddlewareSuccessfullNotification
facilityMiddlewareSuccessfullNotification,
);
// verify the updated middleware
facilityPage.clickManageFacilityDropdown();
Expand All @@ -83,21 +83,21 @@ describe("Facility Manage Functions", () => {
facilityManage.clearHfrId();
facilityManage.clickButtonWithText(facilityHfridUpdateButton);
facilityManage.checkErrorMessageVisibility(
"Health Facility Id is required"
"Health Facility Id is required",
);
// add facility health ID and verify notification
facilityManage.typeHfrId(facilityHfrId);
facilityManage.clickButtonWithText(facilityHfridUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityHfridToastNotificationText
facilityHfridToastNotificationText,
);
// update the existing middleware
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.typeHfrId(facilityUpdatedHfrId);
facilityManage.clickButtonWithText(facilityHfridUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityHfridToastNotificationText
facilityHfridToastNotificationText,
);
// verify its reflection
facilityPage.clickManageFacilityDropdown();
Expand All @@ -112,22 +112,22 @@ describe("Facility Manage Functions", () => {
facilityPage.fillDoctorCount(doctorCapacity);
facilityPage.saveAndExitDoctorForm();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Doctor count added successfully"
"Doctor count added successfully",
);
facilityManage.verifyTotalDoctorCapacity(doctorCapacity);
// edit a existing doctor
facilityManage.clickEditFacilityDoctorCapacity();
facilityPage.fillDoctorCount(doctorModifiedCapacity);
facilityPage.clickdoctorcapacityaddmore();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Doctor count updated successfully"
"Doctor count updated successfully",
);
facilityManage.verifyTotalDoctorCapacity(doctorModifiedCapacity);
// delete a bed
facilityManage.clickDeleteFacilityDoctorCapacity();
facilityManage.clickButtonWithText("Delete");
facilityManage.verifySuccessMessageVisibilityAndContent(
"Doctor specialization type deleted successfully"
"Doctor specialization type deleted successfully",
);
});

Expand All @@ -139,7 +139,7 @@ describe("Facility Manage Functions", () => {
facilityPage.fillCurrentlyOccupied(currentOccupied);
facilityPage.saveAndExitBedCapacityForm();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Bed capacity added successfully"
"Bed capacity added successfully",
);
cy.closeNotification();
facilityManage.verifyFacilityBedCapacity(totalCapacity);
Expand All @@ -150,7 +150,7 @@ describe("Facility Manage Functions", () => {
facilityPage.fillCurrentlyOccupied(currentUpdatedOccupied);
facilityPage.clickbedcapcityaddmore();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Bed capacity updated successfully"
"Bed capacity updated successfully",
);
cy.closeNotification();
facilityManage.verifyFacilityBedCapacity(totalUpdatedCapacity);
Expand All @@ -159,7 +159,7 @@ describe("Facility Manage Functions", () => {
facilityManage.clickDeleteFacilityBedCapacity();
facilityManage.clickButtonWithText("Delete");
facilityManage.verifySuccessMessageVisibilityAndContent(
"Bed type deleted successfully"
"Bed type deleted successfully",
);
});

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/facility_spec/inventory.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe("Inventory Management Section", () => {
facilityPage.fillInventoryMinimumDetails(inventoryName, "1");
facilityPage.clickSetButton();
facilityPage.verifySuccessNotification(
"Minimum quantiy updated successfully"
"Minimum quantiy updated successfully",
);
}
});
Expand Down
Loading

0 comments on commit 8e71487

Please sign in to comment.