From ed98df4e9cafc7d8c22959906b59b9637a8a8936 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 20:25:46 +0000 Subject: [PATCH 01/19] Bump commons-codec:commons-codec in /software/oqm-core-api Bumps [commons-codec:commons-codec](https://github.com/apache/commons-codec) from 1.17.0 to 1.17.1. - [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.17.0...rel/commons-codec-1.17.1) --- updated-dependencies: - dependency-name: commons-codec:commons-codec dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- software/oqm-core-api/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/oqm-core-api/build.gradle b/software/oqm-core-api/build.gradle index 93ccd7d4f..195c5e175 100644 --- a/software/oqm-core-api/build.gradle +++ b/software/oqm-core-api/build.gradle @@ -56,7 +56,7 @@ dependencies { implementation 'org.apache.commons:commons-compress:1.26.2' implementation 'org.apache.commons:commons-csv:1.11.0' implementation 'org.apache.commons:commons-io:1.3.2' - implementation 'commons-codec:commons-codec:1.17.0' + implementation 'commons-codec:commons-codec:1.17.1' implementation 'org.apache.tika:tika-core:2.9.2' /* From e6d9e86e95a7e88772e99deaee7e13dbf1803d93 Mon Sep 17 00:00:00 2001 From: GregJohnStewart Date: Mon, 22 Jul 2024 20:38:27 -0400 Subject: [PATCH 02/19] Core - Base Station - Minor test tweaks --- .../ebp/oqm/core/baseStation/interfaces/ui/BasicUiTest.java | 5 ----- .../baseStation/testResources/testClasses/WebUiTest.java | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/software/oqm-core-base-station/src/test/java/tech/ebp/oqm/core/baseStation/interfaces/ui/BasicUiTest.java b/software/oqm-core-base-station/src/test/java/tech/ebp/oqm/core/baseStation/interfaces/ui/BasicUiTest.java index 77f8565e1..dbe9371e0 100644 --- a/software/oqm-core-base-station/src/test/java/tech/ebp/oqm/core/baseStation/interfaces/ui/BasicUiTest.java +++ b/software/oqm-core-base-station/src/test/java/tech/ebp/oqm/core/baseStation/interfaces/ui/BasicUiTest.java @@ -13,10 +13,5 @@ public class BasicUiTest extends WebUiTest { public void testPageOverview() { this.getLoggedInPage(this.getTestUserService().getTestUser(), "/"); -// Thread.sleep(5*60*1000); - // TODO:: need to tell keycloak devservice to use testcontainer hostname -// this.getWebDriverWrapper().goTo(""); } - - //TODO:: page lookover test } diff --git a/software/oqm-core-base-station/src/test/java/tech/ebp/oqm/core/baseStation/testResources/testClasses/WebUiTest.java b/software/oqm-core-base-station/src/test/java/tech/ebp/oqm/core/baseStation/testResources/testClasses/WebUiTest.java index 0c9087673..dcc39f7f6 100644 --- a/software/oqm-core-base-station/src/test/java/tech/ebp/oqm/core/baseStation/testResources/testClasses/WebUiTest.java +++ b/software/oqm-core-base-station/src/test/java/tech/ebp/oqm/core/baseStation/testResources/testClasses/WebUiTest.java @@ -78,7 +78,7 @@ public void afterEachUi(TestInfo testInfo) throws InterruptedException, IOExcept outputStream.write(curPage.content().getBytes()); } } - Thread.sleep(750); + Thread.sleep(250); this.context.close(); } From 9b21b9ca9bc4cbb28417161642a7f03515b6b64d Mon Sep 17 00:00:00 2001 From: GregJohnStewart Date: Mon, 22 Jul 2024 20:40:49 -0400 Subject: [PATCH 03/19] Plugin - MSS Controller - Initial test dump --- software/plugins/mss-controller/build.gradle | 3 + .../plugin/interfaces/ui/BasicUiTest.java | 27 ++++ .../testResources/lifecycle/TestCleanup.java | 31 ++++ .../testClasses/RunningServerTest.java | 46 ++++++ .../testClasses/WebServerTest.java | 10 ++ .../testResources/testClasses/WebUiTest.java | 140 ++++++++++++++++++ .../testResources/testUsers/TestUser.java | 26 ++++ .../testUsers/TestUserService.java | 96 ++++++++++++ .../testResources/testUsers/TestUserType.java | 6 + .../testResources/ui/PlaywrightSetup.java | 52 +++++++ 10 files changed, 437 insertions(+) create mode 100644 software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/interfaces/ui/BasicUiTest.java create mode 100644 software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/lifecycle/TestCleanup.java create mode 100644 software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/RunningServerTest.java create mode 100644 software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/WebServerTest.java create mode 100644 software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/WebUiTest.java create mode 100644 software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUser.java create mode 100644 software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUserService.java create mode 100644 software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUserType.java create mode 100644 software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/ui/PlaywrightSetup.java diff --git a/software/plugins/mss-controller/build.gradle b/software/plugins/mss-controller/build.gradle index 5e7d23089..c4e1d8ed0 100644 --- a/software/plugins/mss-controller/build.gradle +++ b/software/plugins/mss-controller/build.gradle @@ -39,6 +39,9 @@ dependencies { testImplementation 'io.quarkus:quarkus-junit5' testImplementation 'io.rest-assured:rest-assured' testImplementation 'net.datafaker:datafaker:2.0.1' + + testImplementation 'com.microsoft.playwright:playwright:1.45.0' + testImplementation 'com.deque.html.axe-core:playwright:4.9.1' } group 'com.ebp.openQuarterMaster.plugin' diff --git a/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/interfaces/ui/BasicUiTest.java b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/interfaces/ui/BasicUiTest.java new file mode 100644 index 000000000..36254a020 --- /dev/null +++ b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/interfaces/ui/BasicUiTest.java @@ -0,0 +1,27 @@ +package com.ebp.openQuarterMaster.plugin.interfaces.ui; + +import com.ebp.openQuarterMaster.plugin.testResources.testClasses.WebUiTest; +import com.ebp.openQuarterMaster.plugin.testResources.testUsers.TestUserService; +import io.quarkus.test.junit.QuarkusTest; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Test; + +@Slf4j +@QuarkusTest +public class BasicUiTest extends WebUiTest { + + @Getter + private final TestUserService testUserService = TestUserService.getInstance(); + + @Test + public void testPageOverview() { + this.getLoggedInPage(this.getTestUserService().getTestUser(), "/"); + +// Thread.sleep(5*60*1000); + // TODO:: need to tell keycloak devservice to use testcontainer hostname +// this.getWebDriverWrapper().goTo(""); + } + + //TODO:: page lookover test +} diff --git a/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/lifecycle/TestCleanup.java b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/lifecycle/TestCleanup.java new file mode 100644 index 000000000..b407c455d --- /dev/null +++ b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/lifecycle/TestCleanup.java @@ -0,0 +1,31 @@ +package com.ebp.openQuarterMaster.plugin.testResources.lifecycle; + +import com.ebp.openQuarterMaster.plugin.testResources.ui.PlaywrightSetup; +import org.apache.commons.io.FileUtils; +import org.junit.platform.engine.TestExecutionResult; +import org.junit.platform.launcher.TestExecutionListener; +import org.junit.platform.launcher.TestIdentifier; +import org.junit.platform.launcher.TestPlan; + +import java.io.IOException; + +public class TestCleanup implements TestExecutionListener { + + @Override + public void testPlanExecutionStarted(TestPlan testPlan) { + TestExecutionListener.super.testPlanExecutionStarted(testPlan); + + try { + FileUtils.deleteDirectory(PlaywrightSetup.RECORDINGS_DIR.toFile()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) { + TestExecutionListener.super.executionFinished(testIdentifier, testExecutionResult); + + PlaywrightSetup.getInstance().close(); + } +} diff --git a/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/RunningServerTest.java b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/RunningServerTest.java new file mode 100644 index 000000000..d74adefce --- /dev/null +++ b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/RunningServerTest.java @@ -0,0 +1,46 @@ +package com.ebp.openQuarterMaster.plugin.testResources.testClasses; + +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; + + +@Slf4j +@Execution(ExecutionMode.SAME_THREAD) +public abstract class RunningServerTest extends WebServerTest { + + @BeforeEach + public void beforeEach(TestInfo testInfo){ + log.info("Before test " + testInfo.getTestMethod().get().getName()); + //TODO:: use our own db? necessary? +// User adminUser = this.getTestUserService().getTestUser(true); +// setupJwtCall(given(), this.getTestUserService().getUserToken(adminUser)) +// .basePath("") +// .get("/api/v1/inventory/manage/db/refreshCache").then().statusCode(200); +// setupJwtCall(given(), this.getTestUserService().getUserToken(adminUser)) +// .basePath("") +// .put("/api/v1/inventory/manage/db/ensure/" + DEFAULT_TEST_DB_NAME).then().statusCode(200); + } + + @AfterEach + public void afterEach( + TestInfo testInfo + ) { + log.info("Running after method for test {}", testInfo.getDisplayName()); + + //TODO:: clear db + // this might be required for +// if("intTest".equals(ConfigProvider.getConfig().getValue("quarkus.profile", String.class))){ +// setupJwtCall(given(), this.getTestUserService().getUserToken(this.getTestUserService().getTestUser(true))) +// .basePath("") +// .delete("/api/v1/inventory/manage/db/" + DEFAULT_TEST_DB_NAME+ "/clearDb").then().statusCode(200); +// } else { +// MongoTestConnector.getInstance().clearDb(); +// } + + log.info("Completed after step."); + } +} diff --git a/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/WebServerTest.java b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/WebServerTest.java new file mode 100644 index 000000000..5a8150504 --- /dev/null +++ b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/WebServerTest.java @@ -0,0 +1,10 @@ +package com.ebp.openQuarterMaster.plugin.testResources.testClasses; + +import net.datafaker.Faker; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; + +@Execution(ExecutionMode.CONCURRENT) +public abstract class WebServerTest { + protected static final Faker FAKER = new Faker(); +} diff --git a/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/WebUiTest.java b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/WebUiTest.java new file mode 100644 index 000000000..4c812f0dc --- /dev/null +++ b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testClasses/WebUiTest.java @@ -0,0 +1,140 @@ +package com.ebp.openQuarterMaster.plugin.testResources.testClasses; + +import com.ebp.openQuarterMaster.plugin.testResources.testUsers.TestUser; +import com.ebp.openQuarterMaster.plugin.testResources.testUsers.TestUserService; +import com.ebp.openQuarterMaster.plugin.testResources.ui.PlaywrightSetup; +import com.microsoft.playwright.*; +import io.quarkus.test.common.http.TestHTTPResource; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestInfo; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.URL; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@Slf4j +@Tag("ui") +public abstract class WebUiTest extends RunningServerTest { + + private static Path getCurTestDir(TestInfo testInfo){ + log.debug("Display name: {}", testInfo.getDisplayName()); + + Path output = PlaywrightSetup.RECORDINGS_DIR.resolve(testInfo.getTestClass().get().getName()); + + if(testInfo.getDisplayName().startsWith("[")){ + return output.resolve(testInfo.getTestMethod().get().getName()) + .resolve(testInfo.getDisplayName().replaceAll("/", "")); + } else { + return output.resolve(testInfo.getDisplayName().replaceAll("\\(\\)", "")); + } + } + + protected static Page.ScreenshotOptions getScreenshotOptions() { + return new Page.ScreenshotOptions().setFullPage(true); + } + + @Getter + @TestHTTPResource("/") + URL index; + + @Getter + private BrowserContext context; + + @Getter + private Path curTestUiResultDir; + + @Getter + private final TestUserService testUserService = TestUserService.getInstance(); + + @BeforeEach + public void beforeEachUi(TestInfo testInfo) { + this.curTestUiResultDir = getCurTestDir(testInfo); + Browser.NewContextOptions newContextOptions = new Browser.NewContextOptions() + .setRecordVideoDir(this.curTestUiResultDir) + .setScreenSize(1920,1080) + .setRecordVideoSize(1920,1080) + .setViewportSize(1920,1080) + ; + + this.context = PlaywrightSetup.getInstance().getBrowser().newContext(newContextOptions); + } + + @AfterEach + public void afterEachUi(TestInfo testInfo) throws InterruptedException, IOException { + + for(int i = 0; i < this.getContext().pages().size(); i++){ + Page curPage = this.getContext().pages().get(i); + Path curPageFinalScreenshot = this.curTestUiResultDir.resolve("page-" + (i + 1) + "-final.png"); + Path curPageHtmlFile = this.curTestUiResultDir.resolve("page-" + (i + 1) + "-final-code.html"); + + curPage.screenshot(getScreenshotOptions().setPath(curPageFinalScreenshot)); + try(OutputStream outputStream = new FileOutputStream(curPageHtmlFile.toFile())){ + outputStream.write(curPage.content().getBytes()); + } + } + Thread.sleep(250); + this.context.close(); + } + + protected Page getLoggedInPage(TestUser user, String page){ + Page output = this.getContext().newPage(); + + if(page.startsWith("/")){ + page = page.substring(1); + } + + String url = this.getIndex().toString() + page; + log.info("Navigating to {}", url); + Response response = output.navigate(url); + + assertEquals("OK", response.statusText()); + output.waitForLoadState(); + + if(output.title().contains("Sign in to Open QuarterMaster")){ + log.info("Need to log in user."); + + Locator locator = output.locator("#password"); + locator.fill(user.getPassword()); + locator = output.locator("#username"); + locator.fill(user.getUsername()); + + output.locator("#kc-login").click(); + output.waitForLoadState(); + + if(!output.locator("#topOqmLogo").isVisible()){ + if(!output.getByText("Invalid username or password.").isVisible()){ + throw new IllegalStateException("Not logged in but not where we thought."); + } + output.locator("#kc-registration").locator("a").click(); + output.waitForLoadState(); + + output.locator("#firstName").fill(user.getFirstname()); + output.locator("#lastName").fill(user.getLastname()); + output.locator("#email").fill(user.getEmail()); + output.locator("#username").fill(user.getUsername()); + output.locator("#password").fill(user.getPassword()); + output.locator("#password-confirm").fill(user.getPassword()); + + output.locator("#kc-form-buttons").locator(".pf-c-button").click(); + output.waitForLoadState(); + + } + + if(!output.locator("#topOqmLogo").isVisible()){ + throw new IllegalStateException("Not logged in."); + } + } else { + log.info("Was already logged in?"); + } + + return output; + } +} diff --git a/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUser.java b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUser.java new file mode 100644 index 000000000..94dbacd0d --- /dev/null +++ b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUser.java @@ -0,0 +1,26 @@ +package com.ebp.openQuarterMaster.plugin.testResources.testUsers; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class TestUser { + + public String firstname; + public String lastname; + public String username = null; + public String email; + public String password; + + public String getUsername(){ + if(username == null){ + return this.firstname + "." + this.lastname; + } + return this.username; + } +} diff --git a/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUserService.java b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUserService.java new file mode 100644 index 000000000..e9d57784a --- /dev/null +++ b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUserService.java @@ -0,0 +1,96 @@ +package com.ebp.openQuarterMaster.plugin.testResources.testUsers; + +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import net.datafaker.Faker; +import org.apache.commons.lang3.RandomStringUtils; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * { + * "exp": 1706447044, + * "iat": 1706445545, + * "auth_time": 1706445544, + * "jti": "0c2d411d-1012-499e-a548-6919f384084a", + * "iss": "http://oqm-dev.local:8115/realms/oqm", + * "aud": "oqm-base-station", + * "sub": "575eb08f-7a8a-41cc-ac87-c41f84e03c84", + * "typ": "ID", + * "azp": "oqm-base-station", + * "session_state": "cfa63d15-f520-4e90-a204-9cafb5cc5621", + * "at_hash": "ry6laHfVyN7hlYTBzpmTAA", + * "acr": "1", + * "sid": "cfa63d15-f520-4e90-a204-9cafb5cc5621", + * "upn": "snappawapa", + * "email_verified": false, + * "name": "Greg Stewart", + * "groups": [ + * "default-roles-oqm", + * "inventoryView", + * "offline_access", + * "itemCheckout", + * "inventoryEdit", + * "uma_authorization", + * "inventoryAdmin", + * "user" + * ], + * "preferred_username": "snappawapa", + * "given_name": "Greg", + * "family_name": "Stewart", + * "email": "contact@gjstewart.net" + * } + */ +@Slf4j +@NoArgsConstructor +public class TestUserService { + private final static Faker FAKER = new Faker(); + + private static String getRandomPassword() { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 16; i += 4) { + sb.append(RandomStringUtils.random(1, "abcdefg")); + sb.append(RandomStringUtils.random(1, "ABCDEFG")); + sb.append(RandomStringUtils.random(1, "1234567")); + sb.append(RandomStringUtils.random(1, "!@#$%^&")); + } + return sb.toString(); + } + + private final static TestUserService INSTANCE = new TestUserService(); + + public static TestUserService getInstance() { + return INSTANCE; + } + + private Map testUsers = new HashMap<>(); + + public TestUser getTestUser(TestUserType type) { + if (!this.testUsers.containsKey(type)) { + testUsers.put( + type, + TestUser.builder() + .email(FAKER.internet().emailAddress()) + .firstname(FAKER.name().firstName()) + .lastname(FAKER.name().lastName()) + .password(getRandomPassword()) + .build() + ); + } + + return this.testUsers.get(type); + } + + public TestUser getTestUser() { + return this.getTestUser(TestUserType.REGULAR); + } + + public List getAllTestUsers(){ + return Arrays.stream(TestUserType.values()) + .map(this::getTestUser) + .toList(); + } +} diff --git a/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUserType.java b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUserType.java new file mode 100644 index 000000000..f57f36b35 --- /dev/null +++ b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/testUsers/TestUserType.java @@ -0,0 +1,6 @@ +package com.ebp.openQuarterMaster.plugin.testResources.testUsers; + +public enum TestUserType { + REGULAR, + ADMIN +} diff --git a/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/ui/PlaywrightSetup.java b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/ui/PlaywrightSetup.java new file mode 100644 index 000000000..b60736071 --- /dev/null +++ b/software/plugins/mss-controller/src/test/java/com/ebp/openQuarterMaster/plugin/testResources/ui/PlaywrightSetup.java @@ -0,0 +1,52 @@ +package com.ebp.openQuarterMaster.plugin.testResources.ui; + +import com.microsoft.playwright.Browser; +import com.microsoft.playwright.Playwright; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.eclipse.microprofile.config.ConfigProvider; + +import java.io.Closeable; +import java.nio.file.Path; + +@Slf4j +public class PlaywrightSetup implements Closeable { + + public static final Path RECORDINGS_DIR = Path.of("build/test-results/"+ ConfigProvider.getConfig().getValue("quarkus.profile", String.class) +"/ui/"); + private static PlaywrightSetup INSTANCE = null; + + public static synchronized PlaywrightSetup getInstance() { + if(INSTANCE == null || INSTANCE.isClosed()){ + INSTANCE = new PlaywrightSetup(); + } + return INSTANCE; + } + + @Getter + private final Playwright playwright; + @Getter + private final Browser browser; + @Getter + private boolean closed = false; + + { + log.info("Setting up playwright for UI tests."); + playwright = Playwright.create(); + //TODO:: choose browser based on config + browser = playwright.firefox().launch(); + + log.info("DONE setting up playwright."); + } + + @Override + public void close() { + if(this.isClosed()){ + return; + } + log.info("Cleaning up playwright."); + browser.close(); + playwright.close(); + log.info("DONE cleaning up playwright."); + this.closed = true; + } +} From 764b0b0e4f72e0b830fedf3e5b316f6dccf3ee75 Mon Sep 17 00:00:00 2001 From: GregJohnStewart Date: Mon, 22 Jul 2024 21:35:57 -0400 Subject: [PATCH 04/19] Plugin - MSS Controller - Tests now working --- .../plugin/LifecycleBean.java | 2 +- .../META-INF/resources/res/css/main.css | 2 +- .../src/main/resources/application.yaml | 1 + .../main/resources/templates/pages/main.html | 2 +- .../src/test/resources/application.yaml | 41 +++++++++++++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 software/plugins/mss-controller/src/test/resources/application.yaml diff --git a/software/plugins/mss-controller/src/main/java/com/ebp/openQuarterMaster/plugin/LifecycleBean.java b/software/plugins/mss-controller/src/main/java/com/ebp/openQuarterMaster/plugin/LifecycleBean.java index 1dd959572..b8ba4b5a2 100644 --- a/software/plugins/mss-controller/src/main/java/com/ebp/openQuarterMaster/plugin/LifecycleBean.java +++ b/software/plugins/mss-controller/src/main/java/com/ebp/openQuarterMaster/plugin/LifecycleBean.java @@ -26,7 +26,7 @@ void onStart( ) throws IOException { log.info( "Finished initting Module Master. Picked up on modules: {}", - moduleMaster.getModuleIds() + this.moduleMaster.getModuleIds() ); // if(this.voiceSearchService.enabled()) { diff --git a/software/plugins/mss-controller/src/main/resources/META-INF/resources/res/css/main.css b/software/plugins/mss-controller/src/main/resources/META-INF/resources/res/css/main.css index 963ffec1e..8fe02c040 100644 --- a/software/plugins/mss-controller/src/main/resources/META-INF/resources/res/css/main.css +++ b/software/plugins/mss-controller/src/main/resources/META-INF/resources/res/css/main.css @@ -1,4 +1,4 @@ -#topLogo{ +#topOqmLogo{ padding-top: 0; padding-bottom: 0; height:42px; diff --git a/software/plugins/mss-controller/src/main/resources/application.yaml b/software/plugins/mss-controller/src/main/resources/application.yaml index 01436a4c0..949d75aae 100644 --- a/software/plugins/mss-controller/src/main/resources/application.yaml +++ b/software/plugins/mss-controller/src/main/resources/application.yaml @@ -4,6 +4,7 @@ service: gitLink: https://github.com/Epic-Breakfast-Productions/OpenQuarterMaster voiceSearch: + enabled: false container: engineUri: "unix:///run/user/1000/docker.sock" image: "synesthesiam/voice2json" diff --git a/software/plugins/mss-controller/src/main/resources/templates/pages/main.html b/software/plugins/mss-controller/src/main/resources/templates/pages/main.html index a8d5c7fa1..4b207477c 100644 --- a/software/plugins/mss-controller/src/main/resources/templates/pages/main.html +++ b/software/plugins/mss-controller/src/main/resources/templates/pages/main.html @@ -110,7 +110,7 @@