Skip to content

Commit

Permalink
Merge branch 'develop' into search-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrin2005 authored Jan 13, 2025
2 parents b62fffa + a60997c commit 9263384
Show file tree
Hide file tree
Showing 312 changed files with 12,495 additions and 12,505 deletions.
2 changes: 1 addition & 1 deletion .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ General Guidelines

# Testing Guidelines

For Cypress testing guidelines, refer to cypress/docs/cypress.md
For Cypress testing guidelines, refer to cypress/docs/*.md
8 changes: 5 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ REACT_APP_COVER_IMAGE_ALT=https://cdn.ohc.network/care_logo.svg
REACT_PUBLIC_URL=https://care.ohc.network

# Care API URL without the /api prefix
REACT_CARE_API_URL=https://care-api.do.ohc.network
REACT_CARE_API_URL=https://careapi.ohc.network

# Dev envs
ESLINT_NO_DEV_ERRORS=true
CARE_CDN_URL="https://egov-s3-facility-10bedicu.s3.amazonaws.com https://egov-s3-patient-data-10bedicu.s3.amazonaws.com http://localhost:4566"
REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn"

# Remote apps
# Localhost : ohcnetwork/care_scribe_fe@localhost:4173
# Remote URL : ohcnetwork/care_scribe_fe@https://care-scribe-fe.pages.dev
# Repo/Github Pages : ohcnetwork/care_scribe_fe
REACT_ENABLED_APPS=""

REACT_KERALA_GEO_ID=b04b9efa-5972-419a-892d-26169c1eac8a
9 changes: 3 additions & 6 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ REACT_GITHUB_URL=
# OHCN URL (default: https://ohc.network?ref=care)
REACT_OHCN_URL=

# Plausible site domain (default: care.ohc.network)
REACT_PLAUSIBLE_SITE_DOMAIN=

# Plausible server URL (default: https://plausible.ohc.network)
REACT_PLAUSIBLE_SERVER_URL=

# Care Apps. repo@branch seperated by commas
REACT_ENABLED_APPS="ohcnetwork/care_livekit_fe@main,ohcnetwork/care_scribe"

Expand Down Expand Up @@ -73,5 +67,8 @@ REACT_JWT_TOKEN_REFRESH_INTERVAL=
# Minimum encounter date (default: 2020-01-01)
REACT_MIN_ENCOUNTER_DATE=

# Default Encounter Type (default: "hh" - Home Health)
REACT_DEFAULT_ENCOUNTER_TYPE=

# Available languages to switch between (2 Digit language code seperated by comas. See src->Locale->config.ts for available codes)
REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn"
17 changes: 1 addition & 16 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
build:
needs: test
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/staging' || startsWith(github.event.ref, 'refs/tags/v')
if: github.ref == 'refs/heads/develop' || startsWith(github.event.ref, 'refs/tags/v')
name: Build & Push to container registries
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -139,18 +139,3 @@ jobs:
run: |
echo "Release ${{ github.sha }} is ready to be deployed to production"
deploy-staging-gcp:
needs: build
if: github.ref == 'refs/heads/staging'
name: Deploy to staging GCP cluster
runs-on: ubuntu-latest
environment:
name: Staging-GCP
url: https://care-staging.ohc.network/
steps:
- name: Trigger deploy
run: |
COMMIT_SHA=${{ github.sha }}
JSON='{ "substitutions": { "care_be_tag":"", "care_fe_tag": "'"$COMMIT_SHA"'", "metabase_tag": "" } }'
curl --location "${{ secrets.STAGING_GCP_DEPLOY_URL }}" \
--header 'Content-Type: application/json' --data "$JSON"
20 changes: 13 additions & 7 deletions care.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { EncounterClass } from "@/types/emr/encounter";

const env = import.meta.env;

interface ILogo {
Expand Down Expand Up @@ -48,6 +50,9 @@ const careConfig = {
.split(",")
.map((l) => l.trim()),

defaultEncounterType: (env.REACT_DEFAULT_ENCOUNTER_TYPE ||
"hh") as EncounterClass,

gmapsApiKey:
env.REACT_GMAPS_API_KEY || "AIzaSyDsBAc3y7deI5ZO3NtK5GuzKwtUzQNJNUk",

Expand Down Expand Up @@ -82,12 +87,6 @@ const careConfig = {
minEncounterDate: new Date(env.REACT_MIN_ENCOUNTER_DATE || "2020-01-01"),

// Plugins related configs...

plausible: {
server: env.REACT_PLAUSIBLE_SERVER_URL || "https://plausible.ohc.network",
domain: env.REACT_PLAUSIBLE_SITE_DOMAIN || "care.ohc.network",
},

sentry: {
dsn:
env.REACT_SENTRY_DSN ||
Expand All @@ -104,6 +103,14 @@ const careConfig = {
},

appointments: {
/**
* Relative number of days to show in the appointments page by default.
* 0 means today, positive for future days, negative for past days.
*/
defaultDateFilter: env.REACT_APPOINTMENTS_DEFAULT_DATE_FILTER
? parseInt(env.REACT_APPOINTMENTS_DEFAULT_DATE_FILTER)
: 7,

// Kill switch in-case the heatmap API doesn't scale as expected
useAvailabilityStatsAPI: boolean(
"REACT_APPOINTMENTS_USE_AVAILABILITY_STATS_API",
Expand All @@ -120,7 +127,6 @@ const careConfig = {

plotsConfigUrl:
env.REACT_OBSERVATION_PLOTS_CONFIG_URL || "/config/plots.json",
keralaGeoId: env.REACT_KERALA_GEO_ID || "",
} as const;

export default careConfig;
7 changes: 3 additions & 4 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
files:
- source: /public/locale/{{lang}}.json
translation: /public/locale/%two_letters_code%/%original_file_name%
- source: public/locale//{{lang}}.json
translation: /public/locale/%two_letters_code%.json
bundles:
- 2

- 2
52 changes: 52 additions & 0 deletions cypress/docs/best-practices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Best Practices

## Test Independence

- Each test should be independent and isolated
- Clean up test data after tests
- Don't rely on the state from other tests

## API Testing

- Use cy.intercept() for API verification
- Use waitUntil() for API completion
- Avoid cy.wait() except for API responses

## Element Interaction

- Always verify element state before interaction
- Use data-cy attributes for selectors
- Verify button text before clicking
- Always verify loading states before and after interactions

## Code Organization

- Keep tests focused and concise
- Follow AAA pattern (Arrange, Act, Assert)
- Use meaningful test descriptions

## Common Pitfalls to Avoid

- Redundant visibility checks with verifyAndClickElement
- Hardcoded values in page objects
- Unnecessary waits
- Test interdependencies
- Skipping API verifications
- Using arbitrary timeouts instead of proper waits

## Performance Considerations

- Minimize unnecessary API calls
- Use efficient selectors
- Batch similar operations

## Testing Checklist

Before submitting your test, verify:

- [ ] All API calls are intercepted and verified
- [ ] Loading states are handled properly
- [ ] Success/error states are verified
- [ ] No arbitrary timeouts used
- [ ] Search operations include debounce handling
- [ ] Form submissions verify both request and response
131 changes: 21 additions & 110 deletions cypress/docs/cypress.md
Original file line number Diff line number Diff line change
@@ -1,114 +1,25 @@
# Cypress Guidelines
# Cypress Testing Documentation

## File Structure
## Overview
This documentation covers the testing standards and patterns for our Cypress test suite.

```
cypress/
├── docs/
│ └── cypress.md
├── e2e/ # Test files grouped by modules
│ ├── patient/ # Patient module tests
│ │ ├── search.cy.ts
│ │ ├── create.cy.ts
│ │ └── edit.cy.ts
│ ├── facility/ # Facility module tests
│ │ ├── list.cy.ts
│ │ └── details.cy.ts
│ └── user/ # User module tests
│ ├── login.cy.ts
│ └── profile.cy.ts
├── fixtures/ # Test data files by module
│ ├── patient/
│ │ └── patient-data.json
│ └── facility/
│ └── facility-data.json
├── pageObject/ # Page Objects by module
│ ├── patient/
│ │ ├── SearchPage.ts
│ │ └── CreatePage.ts
│ ├── facility/
│ │ ├── ListPage.ts
│ │ └── DetailsPage.ts
│ └── utils/ # Common helpers and global functions
│ ├── CommonActions.ts # Shared actions across pages
│ ├── CommonAssertions.ts # Shared assertions
│ └── GlobalHelpers.ts # Platform-wide utility functions
├── support/ # Core support files
│ ├── commands.ts # Custom Cypress commands
│ ├── e2e.ts # e2e test configuration
│ └── index.ts # Main support file
└── tsconfig.json
```

## Support Files

- `commands.ts`: Custom Cypress commands and their TypeScript definitions
- `e2e.ts`: e2e specific configurations and imports
- `index.ts`: Main support file that loads commands and configurations

## Page Objects Utils

The `pageObjects/utils` folder contains:

- Common helper functions used across different page objects
- Global utility functions for platform-wide operations
- Shared assertions and verifications
- Reusable action patterns

## Module-based Organization

Each module (patient, facility, user, etc.) should have its own:

- Test files in `e2e/<module-name>/`
- Page Objects in `pageObjects/<module-name>/`
- Fixtures in `fixtures/<module-name>/`

This organization helps:

- Keep related tests and page objects together
- Maintain clear separation between module-specific and common utilities
- Enable better code reuse through common utilities
- Keep core support files focused and minimal
## Quick Links
- [File Structure and Organization](./file-structure.md)
- [Testing Patterns](./patterns.md)
- [Best Practices](./best-practices.md)

## Core Principles

- Create, use and modify Reusable Commands and Functions for Cypress as needed
- Provide Id for the elements using data-cy attributes
- When interacting with a button, verify the button is enabled and visible before interacting with it
- when interacting with a button, verify the text of the button is correct
- Use Page Object Model for Cypress
- Use built-in assertions for Cypress
- Use beforeEach, afterEach and all relevant hooks for Cypress on every test file

## File Naming Conventions

- Test files: `feature-name.cy.ts`
- Page Objects: `FeatureNamePage.ts`
- Custom Commands: `feature-name.ts`
- Fixtures: `feature-name-data.json`

## Storage Management

- Use cy.saveLocalStorage() and cy.restoreLocalStorage() for Cypress
- If we are using same element id to verify presence, interact and assert, make a reusable structure for it

## API Testing

- Use cy.intercept() for Cypress to verify API calls
- Use waitUntil() for Cypress to wait for API calls to complete
- Never use cy.wait() for Cypress except for API responses

## Best Practices

- Keep tests independent and isolated
- Use meaningful test descriptions
- Follow AAA pattern (Arrange, Act, Assert)
- Use fixtures for test data
- Implement custom commands for repetitive actions

### Code Editing Guidelines

- When suggesting code edits, provide only the relevant file and changes
- Don't create separate folders for each edit
- Keep the existing file structure intact
- Provide clear comments for what's being changed
- Create and use reusable commands and functions
- Use data-cy attributes for element identification
- Follow Page Object Model pattern
- Write independent and isolated tests
- Use TypeScript for better type safety

## Getting Started
1. Familiarize yourself with the file structure
2. Review the testing patterns
3. Follow the best practices
4. Use the provided examples as templates

## Support
For questions or clarifications, refer to the specific documentation sections or reach out to the team.
51 changes: 51 additions & 0 deletions cypress/docs/file-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# File Structure and Organization

## Directory Structure

```
cypress/
├── docs/
│ ├── README.md
│ ├── file-structure.md
│ ├── patterns.md
│ └── best-practices.md
├── e2e/ # Test files grouped by modules
│ ├── patient/
│ ├── facility/
│ └── user/
├── fixtures/
├── pageObject/ # Page Objects grouped by modules
│ ├── patient/
│ ├── facility/
│ └── user/
├── utils/ # Utility functions and helpers
│ ├── facilityData.ts # Facility-related utility functions
│ └── commonUtils.ts # Shared utility functions
└── support/
```

## Module Organization

Each module (patient, facility, user, etc.) should have:

- Test files in `e2e/<module-name>/`
- Page Object in `pageObject/<module-name>/`
- Fixtures in `fixtures/<module-name>/`

## File Naming Conventions

- Test files: `feature-name.cy.ts`
- Page Object: `FeatureNamePage.ts`
- Custom Commands: `feature-name.ts`
- Fixtures: `feature-name-data.json`

## Support Files

- `commands.ts`: Custom Cypress commands
- `e2e.ts`: e2e configurations
- `index.ts`: Main support file

## Storage Management

- Use cy.saveLocalStorage() and cy.restoreLocalStorage()
- Manage test data cleanup
Loading

0 comments on commit 9263384

Please sign in to comment.