Skip to content

Commit

Permalink
Merge branch 'develop' into encounter-notes
Browse files Browse the repository at this point in the history
  • Loading branch information
bodhish committed Jan 2, 2025
2 parents 2765b11 + 1f7410a commit 050a7e2
Show file tree
Hide file tree
Showing 300 changed files with 977 additions and 40,248 deletions.
5 changes: 5 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ General Guidelines
- Care uses TanStack Query for data fetching from the API along with query and mutate utilities for the queryFn and mutationFn. (Docs @ /Utils/request/README.md)
- APIs are defined in the api.tsx file.
- Use raviger for routing.
- Add and reuse proper translations for the components in the en.json file.

# Testing Guidelines

For Cypress testing guidelines, refer to cypress/docs/cypress.md
58 changes: 5 additions & 53 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,14 @@ jobs:
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]
containers: [1]
env:
REACT_CARE_API_URL: http://localhost:9000
REACT_ENABLED_APPS: "ohcnetwork/care_hcx_fe@main,ohcnetwork/care_abdm_fe@main"
REACT_ENABLE_HCX: true
REACT_ENABLE_ABDM: true
REACT_CARE_API_URL: https://care-api.do.ohc.network

steps:
- name: Checkout 📥
uses: actions/checkout@v3

- name: Set backend branch
id: backend-branch
run: |
if [[ '${{ github.event.pull_request.base.ref }}' == 'staging' ]]; then
echo "branch=staging" >> $GITHUB_OUTPUT
else
echo "branch=develop" >> $GITHUB_OUTPUT
fi
- name: Checkout care 📥
uses: actions/checkout@v3
with:
repository: ohcnetwork/care
path: care
ref: ${{ steps.backend-branch.outputs.branch }}

- name: Start care docker containers 🐳
run: |
cd care
echo DISABLE_RATELIMIT=True >> docker/.prebuilt.env
echo "CORS_ALLOWED_ORIGINS=\"[\\\"http://localhost:4000\\\"]\"" >> docker/.prebuilt.env
echo JWKS_BASE64=\"$(cat ../.github/runner-files/jwks.b64.txt)\" >> 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 ..
env:
JWKS_BASE64: ${{ secrets.JWKS_BASE64 }}

- name: Wait for care to be up ♻
uses: nick-fields/retry@v2
with:
timeout_minutes: 1
max_attempts: 5
command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000
on_retry_command: sleep 5

- name: Determine PR Origin
id: pr_origin
run: echo "::set-output name=is_forked::$( echo ${{ github.event.pull_request.head.repo.fork }})"
Expand All @@ -71,17 +33,11 @@ jobs:
node-version: "22.11.0"

- name: Install dependencies 📦
run: npm run install-all
run: npm ci

- name: Build ⚙️
run: npm run build

- name: Install Specific Chrome Version
run: |
sudo apt-get install -y wget
sudo wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt-get install ./google-chrome-stable_current_amd64.deb
- name: Cypress run for Non-Forked PRs 🥬
if: steps.pr_origin.outputs.is_forked == 'false'
uses: cypress-io/github-action@v5
Expand All @@ -91,10 +47,8 @@ jobs:
start: "npx vite preview --host"
wait-on: "http://localhost:4000"
wait-on-timeout: 300
browser: chrome
record: true
parallel: true
group: "UI-Chrome"
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -111,10 +65,8 @@ jobs:
start: "npx vite preview --host"
wait-on: "http://localhost:4000"
wait-on-timeout: 300
browser: chrome
record: true
parallel: true
group: "UI-Chrome"
env:
CYPRESS_SPLIT_TESTS: "true"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -136,4 +88,4 @@ jobs:
if: ${{ failure() && steps.pr_origin.outputs.is_forked == 'true' }}
with:
name: cypress-videos
path: cypress/videos
path: cypress/videos
4 changes: 0 additions & 4 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

- name: Run tests
run: |
echo "running tests..."
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ RUN apt-get update && apt-get install -y git

COPY package.json package-lock.json ./

RUN npm install
RUN npm install --ignore-scripts

COPY . .

RUN npm run postinstall

RUN npm run setup

RUN npm run build


Expand Down
30 changes: 30 additions & 0 deletions cypress/docs/cypress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Cypress Guidelines

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

## 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
128 changes: 0 additions & 128 deletions cypress/e2e/assets_spec/AssetHomepage.cy.ts

This file was deleted.

Loading

0 comments on commit 050a7e2

Please sign in to comment.