Skip to content

Commit

Permalink
Merge branch 'main' into List-the-letter-sound-correspondences-where-…
Browse files Browse the repository at this point in the history
…a-letter-is-used-#1701
  • Loading branch information
jo-elimu authored Aug 25, 2024
2 parents e09196a + 7166a4a commit 93f5610
Show file tree
Hide file tree
Showing 41 changed files with 624 additions and 349 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Maven Regression Test
name: Maven Regression Test (REST)

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
branches: [ "main" ]

jobs:
regression_test_ENG:
test_ENG:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -19,8 +19,8 @@ jobs:
- run: mvn clean
- run: mvn verify -P regression-testing-rest -D base.url=http://eng.elimu.ai

regression_test_TGL:
needs: regression_test_ENG
test_TGL:
needs: test_ENG
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -32,8 +32,8 @@ jobs:
- run: mvn clean
- run: mvn verify -P regression-testing-rest -D base.url=http://tgl.elimu.ai

regression_test_HIN:
needs: regression_test_TGL
test_HIN:
needs: test_TGL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/maven-regression-test-ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Maven Regression Test (UI)

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test_ENG:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: maven
- run: mvn clean
- run: mvn verify -P regression-testing-ui -D headless=true -D base.url=http://eng.elimu.ai

test_TGL:
needs: test_ENG
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: maven
- run: mvn clean
- run: mvn verify -P regression-testing-ui -D headless=true -D base.url=http://tgl.elimu.ai

test_HIN:
needs: test_TGL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: maven
- run: mvn clean
- run: mvn verify -P regression-testing-ui -D headless=true -D base.url=http://hin.elimu.ai
19 changes: 1 addition & 18 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,7 @@ Next, to access the application in your browser, go to [http://localhost:8080/we
## Test 🚨

### Unit testing

Run all tests:

mvn clean test

Run individual tests:

mvn clean test -D test=WordDaoTest

### Code coverage

[![codecov](https://codecov.io/gh/elimu-ai/webapp/branch/main/graph/badge.svg?token=T1F9OTQVOH)](https://codecov.io/gh/elimu-ai/webapp)

[![](https://codecov.io/gh/elimu-ai/webapp/branch/main/graphs/tree.svg?token=T1F9OTQVOH)](https://codecov.io/gh/elimu-ai/webapp)

mvn test
open target/site/jacoco/index.html
See [`TEST.md`](./TEST.md)

## Test server

Expand Down
83 changes: 83 additions & 0 deletions TEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
## Test Instructions

### Unit testing ☑️

Run all tests:

mvn clean test

Run individual tests:

mvn clean test -D test=WordDaoTest

#### Code coverage 📊

[![codecov](https://codecov.io/gh/elimu-ai/webapp/branch/main/graph/badge.svg?token=T1F9OTQVOH)](https://codecov.io/gh/elimu-ai/webapp)

[![](https://codecov.io/gh/elimu-ai/webapp/branch/main/graphs/tree.svg?token=T1F9OTQVOH)](https://codecov.io/gh/elimu-ai/webapp)

mvn test
open target/site/jacoco/index.html

### Regression testing

#### REST API

First, launch the webapp on localhost:

mvn jetty:run

Then, in another terminal window run all the regression tests against the REST API:

mvn verify -P regression-testing-rest

> [!TIP]
> If you want to run the tests against another URL, set the `base.url` system property:
>
> mvn verify -P regression-testing-rest -D base.url=https://eng.elimu.ai
#### UI

First, launch the webapp on localhost:

mvn jetty:run

Then, in another terminal window run all the regression tests against the UI:

mvn verify -P regression-testing-ui

> [!TIP]
> If you want to run the tests against another URL, set the `base.url` system property:
>
> mvn verify -P regression-testing-ui -D base.url=https://eng.elimu.ai
##### Headless 😶‍🌫️

If you don't want the automated test software to open browser windows, you can disable that by setting the `headless` system property:

mvn verify -P regression-testing-ui -D headless=true

![](https://private-user-images.githubusercontent.com/1451036/361187317-35e99a19-f42d-4934-a0ba-f3d1e06ed6f6.png)

---

<p align="center">
<img src="https://github.com/elimu-ai/webapp/blob/main/src/main/webapp/static/img/logo-text-256x78.png" />
</p>
<p align="center">
elimu.ai - Free open-source learning software for out-of-school children 🚀✨
</p>
<p align="center">
<a href="https://elimu.ai">Website 🌐</a>
&nbsp;&nbsp;
<a href="https://github.com/elimu-ai/wiki#readme">Wiki 📃</a>
&nbsp;&nbsp;
<a href="https://github.com/orgs/elimu-ai/projects?query=is%3Aopen">Projects 👩🏽‍💻</a>
&nbsp;&nbsp;
<a href="https://github.com/elimu-ai/wiki/milestones">Milestones 🎯</a>
&nbsp;&nbsp;
<a href="https://github.com/elimu-ai/wiki#open-source-community">Community 👋🏽</a>
&nbsp;&nbsp;
<a href="https://www.drips.network/app/drip-lists/41305178594442616889778610143373288091511468151140966646158126636698">Support 💜</a>
</p>

51 changes: 0 additions & 51 deletions Test.md

This file was deleted.

6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>ai.elimu</groupId>
<artifactId>webapp</artifactId>
<packaging>war</packaging>
<version>2.4.35-SNAPSHOT</version>
<version>2.4.39-SNAPSHOT</version>

<properties>
<java.version>17</java.version>
Expand Down Expand Up @@ -575,8 +575,8 @@
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.141.59</version>
<artifactId>selenium-java</artifactId>
<version>4.23.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void handleRequest(
storyBookLearningEvent.getId(),
storyBookLearningEvent.getTimestamp().getTimeInMillis(),
storyBookLearningEvent.getAndroidId(),
storyBookLearningEvent.getApplication().getPackageName(),
storyBookLearningEvent.getPackageName(),
storyBookLearningEvent.getStoryBook().getId(),
storyBookLearningEvent.getStoryBookTitle(),
storyBookLearningEvent.getLearningEventType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

import ai.elimu.dao.StoryBookLearningEventDao;
import ai.elimu.model.analytics.StoryBookLearningEvent;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -26,6 +33,36 @@ public String handleRequest(Model model) {

List<StoryBookLearningEvent> storyBookLearningEvents = storyBookLearningEventDao.readAllOrderedByTime();
model.addAttribute("storyBookLearningEvents", storyBookLearningEvents);

// Prepare chart data
List<String> monthList = new ArrayList<>();
List<Integer> eventCountList = new ArrayList<>();
if (!storyBookLearningEvents.isEmpty()) {
// Group event count by month (e.g. "Aug-2024", "Sep-2024")
Map<String, Integer> eventCountByMonthMap = new HashMap<>();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM-yyyy");
for (StoryBookLearningEvent event : storyBookLearningEvents) {
String eventMonth = simpleDateFormat.format(event.getTimestamp().getTime());
eventCountByMonthMap.put(eventMonth, eventCountByMonthMap.getOrDefault(eventMonth, 0) + 1);
}

// Iterate each month from 4 years ago until now
Calendar calendar4YearsAgo = Calendar.getInstance();
calendar4YearsAgo.add(Calendar.YEAR, -4);
Calendar calendarNow = Calendar.getInstance();
Calendar month = calendar4YearsAgo;
while (!month.after(calendarNow)) {
String monthAsString = simpleDateFormat.format(month.getTime());
monthList.add(monthAsString);

eventCountList.add(eventCountByMonthMap.getOrDefault(monthAsString, 0));

// Increase the date by 1 month
month.add(Calendar.MONTH, 1);
}
}
model.addAttribute("monthList", monthList);
model.addAttribute("eventCountList", eventCountList);

return "analytics/storybook-learning-event/list";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

import ai.elimu.dao.WordLearningEventDao;
import ai.elimu.model.analytics.WordLearningEvent;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -27,6 +34,36 @@ public String handleRequest(Model model) {
List<WordLearningEvent> wordLearningEvents = wordLearningEventDao.readAll();
model.addAttribute("wordLearningEvents", wordLearningEvents);

// Prepare chart data
List<String> monthList = new ArrayList<>();
List<Integer> eventCountList = new ArrayList<>();
if (!wordLearningEvents.isEmpty()) {
// Group event count by month (e.g. "Aug-2024", "Sep-2024")
Map<String, Integer> eventCountByMonthMap = new HashMap<>();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM-yyyy");
for (WordLearningEvent event : wordLearningEvents) {
String eventMonth = simpleDateFormat.format(event.getTimestamp().getTime());
eventCountByMonthMap.put(eventMonth, eventCountByMonthMap.getOrDefault(eventMonth, 0) + 1);
}

// Iterate each month from 4 years ago until now
Calendar calendar4YearsAgo = Calendar.getInstance();
calendar4YearsAgo.add(Calendar.YEAR, -4);
Calendar calendarNow = Calendar.getInstance();
Calendar month = calendar4YearsAgo;
while (!month.after(calendarNow)) {
String monthAsString = simpleDateFormat.format(month.getTime());
monthList.add(monthAsString);

eventCountList.add(eventCountByMonthMap.getOrDefault(monthAsString, 0));

// Increase the date by 1 month
month.add(Calendar.MONTH, 1);
}
}
model.addAttribute("monthList", monthList);
model.addAttribute("eventCountList", eventCountList);

return "analytics/word-learning-event/list";
}
}
Loading

0 comments on commit 93f5610

Please sign in to comment.