From 719867250127b41d05a5c2794e8f1e7e62551592 Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Sun, 25 Aug 2024 15:48:34 +0700 Subject: [PATCH 1/4] test(selenium): storybook learning events refs #411 --- .../webapp/WEB-INF/jsp/analytics/main.jsp | 2 +- .../storybook-learning-event/list.jsp | 6 +- .../selenium/analytics/MainAnalyticsPage.java | 5 ++ .../StoryBookLearningEventsPage.java | 19 +++++++ .../StoryBookLearningEventsPageTest.java | 56 +++++++++++++++++++ 5 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 src/test/java/selenium/analytics/StoryBookLearningEventsPage.java create mode 100644 src/test/java/selenium/analytics/StoryBookLearningEventsPageTest.java diff --git a/src/main/webapp/WEB-INF/jsp/analytics/main.jsp b/src/main/webapp/WEB-INF/jsp/analytics/main.jsp index fcebae5f4..1ed8b62d5 100644 --- a/src/main/webapp/WEB-INF/jsp/analytics/main.jsp +++ b/src/main/webapp/WEB-INF/jsp/analytics/main.jsp @@ -36,7 +36,7 @@ book
- (${storyBookLearningEventCount}) + (${storyBookLearningEventCount})
diff --git a/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp b/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp index b6b5672ee..aa2e471a1 100644 --- a/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp +++ b/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp @@ -63,17 +63,17 @@ - ${storyBookLearningEvent.androidId} + ${storyBookLearningEvent.androidId} - ${storyBookLearningEvent.packageName} + ${storyBookLearningEvent.packageName} - ${storyBookLearningEvent.packageName} + ${storyBookLearningEvent.packageName} diff --git a/src/test/java/selenium/analytics/MainAnalyticsPage.java b/src/test/java/selenium/analytics/MainAnalyticsPage.java index 1057d2051..798b1a6e3 100644 --- a/src/test/java/selenium/analytics/MainAnalyticsPage.java +++ b/src/test/java/selenium/analytics/MainAnalyticsPage.java @@ -22,4 +22,9 @@ public void pressWordLearningEventsLink() { WebElement link = driver.findElement(By.id("wordLearningEventsLink")); link.click(); } + + public void pressStoryBookLearningEventsLink() { + WebElement link = driver.findElement(By.id("storyBookLearningEventsLink")); + link.click(); + } } diff --git a/src/test/java/selenium/analytics/StoryBookLearningEventsPage.java b/src/test/java/selenium/analytics/StoryBookLearningEventsPage.java new file mode 100644 index 000000000..9787d55d2 --- /dev/null +++ b/src/test/java/selenium/analytics/StoryBookLearningEventsPage.java @@ -0,0 +1,19 @@ +package selenium.analytics; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; + +import selenium.util.ErrorHelper; + +public class StoryBookLearningEventsPage { + + private WebDriver driver; + + public StoryBookLearningEventsPage(WebDriver driver) { + this.driver = driver; + + driver.findElement(By.id("storyBookLearningEventsPage")); + + ErrorHelper.verifyNoScriptOrMarkupError(driver); + } +} diff --git a/src/test/java/selenium/analytics/StoryBookLearningEventsPageTest.java b/src/test/java/selenium/analytics/StoryBookLearningEventsPageTest.java new file mode 100644 index 000000000..d9675ecd6 --- /dev/null +++ b/src/test/java/selenium/analytics/StoryBookLearningEventsPageTest.java @@ -0,0 +1,56 @@ +package selenium.analytics; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openjdk.tools.javac.main.Main; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; + +import selenium.util.DomainHelper; + +public class StoryBookLearningEventsPageTest { + + private final Logger logger = LogManager.getLogger(); + + private WebDriver driver; + + @BeforeEach + public void setUp() { + logger.info("setUp"); + + ChromeOptions chromeOptions = new ChromeOptions(); + + // Read "headless" property set on the command line: + // mvn clean verify -P regression-testing-ui -D headless=true + String headlessSystemProperty = System.getProperty("headless"); + logger.info("headlessSystemProperty: \"" + headlessSystemProperty + "\""); + if ("true".equals(headlessSystemProperty)) { + chromeOptions.addArguments("headless"); + } + + driver = new ChromeDriver(chromeOptions); + + driver.get(DomainHelper.getBaseUrl() + "/analytics"); + } + + @AfterEach + public void tearDown() { + logger.info("tearDown"); + + driver.quit(); + } + + @Test + public void testStoryBookLearningEventsPage() { + logger.info("testStoryBookLearningEventsPage"); + + MainAnalyticsPage mainAnalyticsPage = new MainAnalyticsPage(driver); + mainAnalyticsPage.pressStoryBookLearningEventsLink(); + + StoryBookLearningEventsPage storyBookLearningEventsPage = new StoryBookLearningEventsPage(driver); + } +} From 4f4251d39d798ee902da7e2a18e0da4564370558 Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Sun, 25 Aug 2024 16:03:03 +0700 Subject: [PATCH 2/4] fix(analytics): nullpointer during csv export refs #1862 --- .../analytics/StoryBookLearningEventCsvExportController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventCsvExportController.java b/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventCsvExportController.java index 37e342d7e..4b6ca72eb 100644 --- a/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventCsvExportController.java +++ b/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventCsvExportController.java @@ -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() From d2977745da90407d554dc88b0c74874f3cb51396 Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Sun, 25 Aug 2024 16:05:53 +0700 Subject: [PATCH 3/4] test(selenium): storybook learning events refs #411 --- .../java/selenium/analytics/StoryBookLearningEventsPageTest.java | 1 - src/test/java/selenium/analytics/WordLearningEventsPageTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/test/java/selenium/analytics/StoryBookLearningEventsPageTest.java b/src/test/java/selenium/analytics/StoryBookLearningEventsPageTest.java index d9675ecd6..c60a30a92 100644 --- a/src/test/java/selenium/analytics/StoryBookLearningEventsPageTest.java +++ b/src/test/java/selenium/analytics/StoryBookLearningEventsPageTest.java @@ -5,7 +5,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.openjdk.tools.javac.main.Main; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; diff --git a/src/test/java/selenium/analytics/WordLearningEventsPageTest.java b/src/test/java/selenium/analytics/WordLearningEventsPageTest.java index e857dd0b4..1762dd86d 100644 --- a/src/test/java/selenium/analytics/WordLearningEventsPageTest.java +++ b/src/test/java/selenium/analytics/WordLearningEventsPageTest.java @@ -5,7 +5,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.openjdk.tools.javac.main.Main; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; From 1772d95d68187ff6fcf988d5f78a59b2b2dc7f65 Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Sun, 25 Aug 2024 16:19:04 +0700 Subject: [PATCH 4/4] refactor(analytics): exclude storybook id #1862 --- .../WEB-INF/jsp/analytics/storybook-learning-event/list.jsp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp b/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp index aa2e471a1..47288a73a 100644 --- a/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp +++ b/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp @@ -52,7 +52,6 @@ timestamp android_id package_name - storybook_id storybook_title learning_event_type @@ -77,9 +76,6 @@ - - ${storyBookLearningEvent.storyBookId} -