Skip to content

Commit

Permalink
Merge pull request #7 from EyeSeeTea/development
Browse files Browse the repository at this point in the history
Release 0.0.1
  • Loading branch information
ifoche authored Apr 2, 2020
2 parents f41fa9b + 547a5f4 commit 989cb21
Show file tree
Hide file tree
Showing 102 changed files with 21,654 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
> 0.5%
last 2 versions
Firefox ESR
ie 11
not dead
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SKIP_PREFLIGHT_CHECK=true
PORT=8081
BROWSER=false
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/**/*.d.ts
/src/locales
37 changes: 37 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/** @format */

module.exports = {
extends: [
"react-app",
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
"plugin:cypress/recommended",
],
rules: {
"no-console": "off",
"@typescript-eslint/explicit-function-return-type": ["off"],
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"react/prop-types": "off",
"no-unused-expressions": "off",
"no-useless-concat": "off",
"no-useless-constructor": "off",
"default-case": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-empty-function": "off",
"react-hooks/exhaustive-deps": "warn",
},
plugins: ["cypress"],
env: { "cypress/globals": true },
settings: {
react: {
pragma: "React",
version: "16.6.0",
},
},
};
16 changes: 16 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### :pushpin: References

- **Issue:** Closes #?

### :memo: Implementation

-

### :art: Screenshots

### :fire: How to test it? (If there is any special consideration or the reviewer does not know how to test it)

### :bookmark_tabs: Others

- [ ] Any change in the [API repo](https://github.com/EyeSeeTea/d2-api)? If so, what branch/PR?
- [ ] Any change in the [GUI library](https://github.com/EyeSeeTea/d2-ui-components)? If so, what branch/PR?
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
manifest.webapp
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
*.sublime-project
*.sublime-workspace
*.code-workspace

npm-debug.log*
yarn-debug.log*
yarn-error.log*

src/locales/
src/react-app.d.ts
src/react-app-env.d.ts

# cypress
cypress/screenshots/
cypress/videos/

# IntelliJ
.idea/*

# Custom
bak
18 changes: 18 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @format */

module.exports = {
printWidth: 100,
tabWidth: 4,
useTabs: false,
semi: true,
singleQuote: false,
trailingComma: 'es5',
bracketSpacing: true,
jsxBracketSameLine: false,
arrowParens: 'avoid',
rangeStart: 0,
rangeEnd: Infinity,
proseWrap: 'preserve',
requirePragma: false,
insertPragma: false,
}
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: node_js
node_js:
- 12.13.0
dist: bionic
cache:
directories:
- "$HOME/.cache"
install:
- yarn install --frozen-lockfile
- yarn build-webapp
addons:
apt:
packages:
- libgconf-2-4
notifications:
slack:
secure: eyeseetea:ftMfk0oeXVhQVbdks9mZVunc
92 changes: 91 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,92 @@
# dhis2-gee-app
DHIS2 webapp that extracts values from Google Earth Engine for a given subset of DHIS2 OUs, a certain period and datasets/variables mapping and injects them into DHIS2

DHIS2 webapp that extracts values from Google Earth Engine for a given subset of DHIS2 OUs, a certain period and datasets/variables mapping and injects them into DHIS2.

## Setup

```
$ yarn install
```

## Development

Start development server:

```
$ PORT=8082 REACT_APP_DHIS2_BASE_URL="https://play.dhis2.org/dev" yarn start
```

Linting:

```
$ yarn lint
```

## Tests

Run unit tests:

```
$ yarn test
```

Run integration tests locally:

```
$ export CYPRESS_DHIS2_AUTH='admin:district'
$ export CYPRESS_EXTERNAL_API="http://localhost:8080"
$ export CYPRESS_ROOT_URL=http://localhost:8081
# non-interactive
$ yarn cy:e2e:run
# interactive UI
$ yarn cy:e2e:open
```

For this to work in Travis CI, you will have to create an environment variable CYPRESS_DHIS2_AUTH (Settings -> Environment Variables) with the password used in your testing DHIS2 instance.

Travis project: https://travis-ci.org/EyeSeeTea/dhis2-gee-app/builds

Cypress Dashboard: https://dashboard.cypress.io/projects/49be3z

## Build app ZIP

```
$ yarn build-webapp
```

## Some development tips

### Structure

- `i18n/`: Contains literal translations (gettext format)
- `public/`: Main app folder with a `index.html`, exposes the APP, contains the feedback-tool
- `src/pages`: Main React components.
- `src/components`: Reusable React components.
- `src/models`: Models that hold all the logic of the app (pages/components only should contain view logic).
- `src/types`: `.d.ts` file definitions for modules without Typescript definitions.
- `src/utils`: Misc utilities.
- `src/locales`: Auto-generated, don't change nor add to version control.
- `cypress/integration/`: Contains the integration Cypress tests.

### i18n

```
$ yarn update-po
# ... add/edit translations in i18n/*.po files ...
$ yarn localize
```

### App context

File `src/contexts/app-context.ts` holds some general App context so typical infrastructure objects (`api`, `d2`, `currentUser`...) are readily available. Add your own objects if necessary.

```
import { useAppContext } from "./path/to/contexts/app-context";
const SomeComponent: React.FunctionComponent = () => {
const { d2, api, currentUser } = useAppContext();
...
}
```
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = process.env.CYPRESS_ENV ? {} : {
"presets": ["babel-preset-react-app"]
}
3 changes: 3 additions & 0 deletions config/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Turns file imports into dummy objects

module.exports = "test-file-stub";
3 changes: 3 additions & 0 deletions config/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Turns style imports into empty objects

module.exports = {};
8 changes: 8 additions & 0 deletions config/testHelpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function getD2Stub() {
return {
system: {
systemInfo: {},
},
currentUser: {},
};
}
5 changes: 5 additions & 0 deletions config/testSetup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import "@testing-library/jest-dom/extend-expect";

configure({ adapter: new Adapter() });
4 changes: 4 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"projectId": "49be3z",
"defaultCommandTimeout": 10000
}
12 changes: 12 additions & 0 deletions cypress/integration/example-page.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference types='Cypress' />

context("Example page", () => {
before(() => {
cy.login("who");
cy.visit("#/");
});

it("has page title", () => {
cy.title().should("equal", "GEE App");
});
});
23 changes: 23 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config

on("task", {
logRequest(req) {
console.debug(req, config);
},
});
};
Loading

0 comments on commit 989cb21

Please sign in to comment.