Skip to content

Commit

Permalink
Merge branch 'develop' into issues/9668/fix-auto-fill
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobjeevan committed Jan 14, 2025
2 parents c6b1783 + 4f10987 commit d3fb25d
Show file tree
Hide file tree
Showing 309 changed files with 13,462 additions and 196,004 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
6 changes: 5 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +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=""
3 changes: 3 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -67,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"
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
32 changes: 0 additions & 32 deletions .github/workflows/generate-sbom.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ossar-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ jobs:

# Upload results to the Security tab
- name: Upload OSSAR results
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.ossar.outputs.sarifFile }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ src/pluginMap.ts
/apps_backup/*

# Federation Temp files
/.__mf__temp
/.__mf__temp
public/sbom/*
13 changes: 13 additions & 0 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 @@ -98,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 Down
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 d3fb25d

Please sign in to comment.