Skip to content

Commit

Permalink
Merge branch 'develop' into issues/9720/cover-image-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
modamaan authored Jan 10, 2025
2 parents b7c6123 + 86eba9b commit 3876755
Show file tree
Hide file tree
Showing 242 changed files with 9,395 additions and 5,829 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
4 changes: 1 addition & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ 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"

REACT_ENABLED_APPS=""

REACT_KERALA_GEO_ID=b04b9efa-5972-419a-892d-26169c1eac8a
REACT_ENABLED_APPS="https://care-scribe-fe.pages.dev|ohcnetwork/care_scribe_fe"
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"
12 changes: 5 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 Down Expand Up @@ -120,7 +119,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
32 changes: 32 additions & 0 deletions cypress/docs/best-practices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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

## 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

## Performance Considerations
- Minimize unnecessary API calls
- Use efficient selectors
- Batch similar operations
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.
39 changes: 39 additions & 0 deletions cypress/docs/file-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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/
└── 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
50 changes: 50 additions & 0 deletions cypress/docs/patterns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Testing Patterns

## Element Interaction
### Preferred Command Usage
```typescript
// Correct
cy.verifyAndClickElement('[data-cy="element"]', "Button Text");

// Avoid
cy.get('[data-cy="element"]').should('be.visible').click();
```

## Navigation Patterns
```typescript
// Good
navigateToOrganization(orgName: string) {
cy.verifyAndClickElement('[data-cy="organization-list"]', orgName);
}

navigateToFacilitiesList() {
cy.verifyAndClickElement('[data-testid="org-nav-facilities"]', "Facilities");
}
```

## Test Data Management
```typescript
// Constants for fixed values
const facilityType = "Primary Health Centre";

// Generator functions for dynamic data
const phoneNumber = generatePhoneNumber();
```

## Test Structure
```typescript
describe("Feature Name", () => {
const page = new PageObject();
const facilityType = "Primary Health Centre";
const testData = generateTestData();

beforeEach(() => {
// Setup
});

it("should perform action", () => {
page.navigateToOrganization("Kerala");
page.navigateToFacilitiesList();
});
});
```
Loading

0 comments on commit 3876755

Please sign in to comment.