Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,28 @@ module.exports = {
settings: {
'import/resolver': { node: { extensions: ['.js', '.jsx'] } },
},
overrides: [
{
files: [
'**/*.cy.{js,jsx,ts,tsx}',
'**/cypress/**/*.{js,jsx,ts,tsx}',
],
env: {
'cypress/globals': true,
},
extends: ['plugin:cypress/recommended'],
plugins: ['cypress'],
rules: {
// Allow Cypress globals like cy, Cypress, expect, etc.
'no-undef': 'off',
// Cypress-specific rules
'cypress/no-assigning-return-values': 'error',
'cypress/no-unnecessary-waiting': 'error',
'cypress/assertion-before-screenshot': 'warn',
'cypress/no-force': 'warn',
'cypress/no-async-tests': 'error',
'cypress/no-pause': 'error',
},
},
],
}
48 changes: 39 additions & 9 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,47 @@ jobs:
test:
uses: dhis2/workflows-platform/.github/workflows/test.yml@v1

# -- e2e tests are currently not implemented
# e2e:
# uses: dhis2/workflows-platform/.github/workflows/legacy-e2e.yml@v1
# # Skips forks and dependabot PRs
# if: '!github.event.push.repository.fork'
# secrets: inherit
# with:
# api_version: 42
cypress-component:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run Cypress component tests
run: yarn cy:run:component

cypress-e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run Cypress e2e tests
uses: cypress-io/github-action@v6
with:
start: yarn start
wait-on: 'http://localhost:3000'
wait-on-timeout: 300
browser: chrome
record: true
env:
CI: true
BROWSER: none
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_dhis2BaseUrl: https://test.e2e.dhis2.org/anly-e2e-42
CYPRESS_dhis2InstanceVersion: 42
CYPRESS_dhis2Username: ${{ secrets.CYPRESS_DHIS2_USERNAME }}
CYPRESS_dhis2Password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
needs: [lint-commits, lint, test] # Add e2e here when implemented
needs: [lint-commits, lint, test, cypress-component, cypress-e2e]
uses: dhis2/workflows-platform/.github/workflows/release.yml@v1
# Skips forks and dependabot PRs
if: '!github.event.push.repository.fork'
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ src/locales
build
.DS_Store
.vscode

cypress.env.json
67 changes: 59 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,83 @@
## DHIS2 Climate app
# DHIS2 Climate App

This app allows you to explore and import temperature and precipitation data in DHIS2. The data source is "ERA5-Land", which is considered the most accurate and complete global climate dataset available.
---

## General Documentation

### Overview

This app allows you to explore and import climate/weather data into DHIS2.

### Data Sources

- **ERA5-Land**: By default, the app uses ERA5-Land, a highly accurate and complete global climate dataset.
- **ENACTS**: If ENACTS is configured (see Admin Documentation), the app can also use ENACTS DST as a data source for local climate data.

> ![Screenshot](public/images/explore.png)

---

![Screenshot](public/images/explore.png)
## Admin Documentation

### ENACTS Setup Instructions

The ENACTS API is made available to this app using a DHIS2 route. To set up ENACTS integration, follow these steps:

1. **Follow the [DHIS2 Routes documentation](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/route.html)** to set up the route. Make sure to use the documentation specific to your DHIS2 version, as there are some differences between versions.

2. **Route configuration fields:**

- The following fields must be set in the route configuration. Note that the `code` must be `enacts`.
- **name**: Choose a name that indicates this route is to ENACTS DST
- **code**: `enacts`
- **url**: The URL where your ENACTS DST is hosted. You must append `/**` to the URL.
- **headers**:
- `Content-Type`: `application/json`
- `X-API-Key`: _Your ENACTS API key here_
- **disabled**: `false`

3. **Example configuration:**

```json
{
"name": "ENACTS API",
"code": "enacts",
"url": "https://your-enacts-dst-url/**",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "Your enacts api key here"
},
"disabled": false
}
```

After configuring the route, the ENACTS API will be available for use in the Climate app.

---

## Developer Documentation

This project was bootstrapped with [DHIS2 Application Platform](https://github.com/dhis2/app-platform).

## Available Scripts
### Available Scripts

In the project directory, you can run:

### `yarn start`
#### `yarn start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `yarn test`
#### `yarn test`

Launches the test runner and runs all available tests found in `/src`.<br />

See the section about [running tests](https://platform.dhis2.nu/#/scripts/test) for more information.

### `yarn build`
#### `yarn build`

Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
Expand All @@ -36,7 +87,7 @@ A deployable `.zip` file can be found in `build/bundle`!

See the section about [building](https://platform.dhis2.nu/#/scripts/build) for more information.

### `yarn deploy`
#### `yarn deploy`

Deploys the built app in the `build` folder to a running DHIS2 instance.<br />
This command will prompt you to enter a server URL as well as the username and password of a DHIS2 user with the App Management authority.<br/>
Expand Down
28 changes: 28 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineConfig } from 'cypress'
import viteConfig from './vite-cypress.config.js'

export default defineConfig({
projectId: 'itnqpp',
defaultCommandTimeout: 15000,
component: {
devServer: {
framework: 'react',
bundler: 'vite',
viteConfig,
},
specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'cypress/support/component.js',
indexHtmlFile: 'cypress/support/component-index.html',
},
e2e: {
baseUrl: 'http://localhost:3000',
setupNodeEvents() {
// args are _on, _config
// implement node event listeners here
},
specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'cypress/support/e2e.js',
},
video: false,
screenshotOnRunFailure: false,
})
6 changes: 6 additions & 0 deletions cypress.env.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dhis2Username": "admin",
"dhis2Password": "district",
"dhis2BaseUrl": "https://test.e2e.dhis2.org/anly-e2e-42",
"dhis2InstanceVersion": "42"
}
Loading
Loading