Skip to content

Commit

Permalink
Merge pull request #192 from EyeSeeTea/development
Browse files Browse the repository at this point in the history
Release 0.2.0
  • Loading branch information
adrianq authored Apr 27, 2020
2 parents 4f7639c + 8d924c5 commit eeda80d
Show file tree
Hide file tree
Showing 87 changed files with 23,680 additions and 10,865 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ SKIP_PREFLIGHT_CHECK=true
PORT=8081
BROWSER=false
REACT_APP_DHIS2_BASE_URL=http://dev2.eyeseetea.com:8081
EXTEND_ESLINT=true
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ module.exports = {
"@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": "off",
},
plugins: ["cypress"],
env: { "cypress/globals": true },
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ yarn-error.log*

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

# cypress
cypress/screenshots/
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,13 @@ For cypress tests to work in Travis CI, you will have to create an environment v
```
$ yarn build-webapp
```

## Internals

### Database relationships

A project consist of these Dhis2 metadata:

- 1 organisation unit (level 2). attributes: `PM_PROJECT_DASHBOARD_ID`
- 2 data sets: actual and target. attributes: `PM_ORGUNIT_PROJECT_ID`
- 1 dashboard.
5 changes: 0 additions & 5 deletions config/testSetup.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import moment from "moment";
import { selectInMultiSelector, selectDatePicker, selectOrgUnit } from "../support/utils";

describe("Projects - Create", () => {
before(() => {
Expand Down Expand Up @@ -35,7 +36,7 @@ describe("Projects - Create", () => {
// Funders

cy.contains("Funders");
selectInMultiSelector("funders", "ACWME");
selectInMultiSelector("funders", "ACWME - ACWME");

cy.contains("Next").click();

Expand Down Expand Up @@ -68,17 +69,13 @@ describe("Projects - Create", () => {

cy.waitForStep("Selection of Indicators");

cy.get(".MuiInput-inputTypeSearch").type("market groups formed");
cy.contains("# of market groups formed")
cy.contains("# of agriculture groups receiving support for improved livelihoods")
.parent("td")
.prev("td")
.click();

cy.contains("Livelihood").click();
cy.get(".MuiInput-inputTypeSearch")
.clear()
.type("storage equipment provided");
cy.contains("# of HH-level storage equipment provided")
cy.contains("# of people trained in livelihood topics")
.parent("td")
.prev("td")
.click();
Expand All @@ -89,13 +86,8 @@ describe("Projects - Create", () => {

cy.waitForStep("Selection of MER Indicators");

cy.contains("# of agriculture groups receiving support for improved livelihoods")
.parent("td")
.prev("td")
.click();

cy.contains("Livelihood").click();
cy.contains("# of HH-level storage equipment provided")
cy.contains("# of people trained in livelihood topics")
.parent("td")
.prev("td")
.click();
Expand All @@ -111,7 +103,7 @@ describe("Projects - Create", () => {
cy.contains("00Cypress Project");

cy.contains("Period dates");
cy.contains(`February 1, ${projectYear} -> June 30, ${projectYear}`);
cy.contains(`February ${projectYear} -> June ${projectYear}`);

cy.contains("Description");

Expand All @@ -122,41 +114,16 @@ describe("Projects - Create", () => {
cy.contains("Abaco");

cy.contains("Sectors");
cy.contains("Agriculture");
cy.contains("Livelihood");

cy.contains("# of agriculture groups receiving support for improved livelihoods [MER]");
cy.contains("# of HH-level storage equipment provided [MER]");
cy.contains("# of agriculture groups receiving support for improved livelihoods - B010200");
cy.contains("# of people trained in livelihood topics - P020100 [MER]");

cy.get("[data-wizard-contents] button")
.contains("Save")
.click();

cy.contains("Project saved", { timeout: 20000 });
cy.contains("Project saved", { timeout: 30000 });
});
});

function selectOrgUnit(label) {
cy.contains(label)
.find("input")
.click();
cy.contains(label)
.should("have.css", "color")
.and("equal", "rgb(255, 165, 0)");
}

function selectDatePicker(year, month) {
const pickerSelector = "[class^=MuiPickersBasePicker-pickerView]";
cy.get(pickerSelector)
.contains(year.toString())
.click();
cy.get(pickerSelector)
.contains(month)
.click();
}

function selectInMultiSelector(selectorName, label) {
const prefix = `[data-test-selector='${selectorName}'] > div > div:last`;
cy.get(prefix + " > div select:first").select(label);
cy.contains("Selected")
.next("button")
.click();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,24 @@ describe("Project Configuration - List page", () => {
cy.contains(projectName);
});

it("opens details window when mouse clicked", () => {
it("opens contextual menu when left button mouse is clicked", () => {
cy.contains(projectName).click();

cy.contains("Details");
cy.contains("Add Actual Values");
cy.contains("Go to Dashboard");
cy.contains("Add Target Values");
cy.contains("Download Data");
cy.contains("Edit");
cy.contains("Delete");
});

it("shows details when details action is clicked", () => {
cy.contains(projectName).trigger("contextmenu");
cy.contains("Details").click();

cy.contains("Name");
cy.contains("Code");
cy.contains("Award Number");
cy.contains("Description");
cy.contains("Last Updated");
cy.contains("Last Updated By");
Expand All @@ -27,13 +40,12 @@ describe("Project Configuration - List page", () => {
cy.contains("API Link");
});

it("opens context window when right button mouse is clicked", () => {
it("opens contextual menu when right button mouse is clicked", () => {
cy.contains(projectName).trigger("contextmenu");

cy.contains("Details");
cy.contains("Add Actual Values");
cy.contains("Go to Dashboard");
cy.contains("Reopen Datasets");
cy.contains("Add Target Values");
cy.contains("Download Data");
cy.contains("Edit");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("Projects - Edit", () => {
cy.contains("Name");
cy.contains("00Cypress Project");
cy.contains("Period dates");
cy.contains(`February 1, ${projectYear} -> June 30, ${projectYear}`);
cy.contains(`February ${projectYear} -> June ${projectYear}`);
cy.contains("Description");
cy.contains("Selected country");
cy.contains("Bahamas");
Expand Down
104 changes: 104 additions & 0 deletions cypress/integration/08.project-indicators.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import IndicatorsPage from "../support/pages/indicators-page";
import { selectInMultiSelector } from "../support/utils";

describe("Projects - Indicators", () => {
before(() => {
cy.login("admin");
cy.loadPage();
cy.contains("00Cypress Project").trigger("contextmenu");
cy.contains("Edit").click();
});

it("selects indicators with dependencies", () => {
cy.contains("Sectors").click();
selectInMultiSelector("sectors", "Protection");
selectInMultiSelector("sectors", "Food");
selectInMultiSelector("sectors", "Nutrition");
cy.contains("Next").click();

new IndicatorsPage(cy)
.selectSector("Agriculture")
// De-select initial indicator
.assertExactSelected(["B010200"])
.unselect("B010200")
.assertExactSelected([])

// Select an unpaired benefit sub -> automatic selection of its global in series
.select("B010201")
.assertSelected(["B010201", "B010200"])

// Select an paired benefit sub -> automatic selection of its global in series and their paired
.select("B010301")
.assertSelected(["B010301", "B010300", "P010401", "P010400"])

// Select a cross-sectorial -> select its series in current sector
.select("P020105")
.assertSelected(["P020105", "P010100"])

// Finally check that only the expected indicators are selected
.assertExactSelected([
...["B010201", "B010200", "B010301", "B010300", "P010401"],
...["P010400", "P020105", "P010100"],
])

.selectSector("Livelihood")
// Check that only the initial indicator is selected. The previous selection
// of Agriculture->P020105 should not have modified the indicators in this section
.assertExactSelected(["P020100"])

// Select a global
.select("B020200")
.assertExactSelected(["P020100", "B020200", "P020300"])
// Unselect the global, as it has no subs selected, it should be unselected
.unselect("B020200")
.assertExactSelected(["P020100"])

.selectSector("Agriculture")
// A global with subs cannot be unselected
.unselect("B010200")
.expectSnackbar("Global data elements with selected subs cannot be unselected")

.selectSector("Protection")
// Select an indicator which has a paired sub indicator, its global should be also selected
.select("B100500")
.assertExactSelected(["B100500", "P100701", "P100700"])

.selectSector("Nutrition")
// Select a cross-sectorial indicator which has paired sub indicators in other sectors (Food)
.select("B050102")
.assertExactSelected(["B050102", "P050202", "P040100"])

.selectSector("Food")
// Now check the same cross-sectorial indicator in the other sector
.select("B050102")
.assertExactSelected(["B050102", "P050202", "B050100", "P050200"]);

// MER Indicators
cy.contains("Selection of MER Indicators").click();
new IndicatorsPage(cy)
.selectSector("Agriculture")
.assertVisible([
...["B010201", "B010200", "B010301", "B010300", "P010401"],
...["P010400", "P020105", "P010100"],
])
.selectSector("Livelihood")
.assertVisible(["P020100"])
.assertExactSelected(["P020100"]);

// Check indicators info in summary step
cy.contains("Summary and Save").click();

// Agriculture
cy.contains("B010201");
cy.contains("B010200");
cy.contains("B010301");
cy.contains("B010300");
cy.contains("P010401");
cy.contains("P010400");
cy.contains("P020105");
cy.contains("P010100");

// Livelihood
cy.contains("P020100 [MER]");
});
});
15 changes: 15 additions & 0 deletions cypress/integration/99.project-delete.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe("Projects - Delete", () => {
before(() => {
cy.login("admin");
cy.loadPage();
cy.contains("00Cypress Project").trigger("contextmenu");
cy.contains("Delete").click();
});

it("asks confirmation and deletes", () => {
cy.contains("Are you sure").click();
cy.contains("Proceed").click();

cy.contains("1 projects deleted");
});
});
Loading

0 comments on commit eeda80d

Please sign in to comment.