diff --git a/.circleci/config.yml b/.circleci/config.yml index 9566751d6..342abb645 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,6 +51,21 @@ jobs: - codecov/upload: file: generator/target/jacoco-reports/jacoco.xml + test_playground_status: + docker: + - image: circleci/openjdk:8-jdk-browsers + steps: + - checkout + - run: gradle :playground:test + - run: + name: Save test results + command: | + mkdir -p ~/test-results/junit/ + find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \; + when: always + - store_test_results: + path: ~/test-results + # Release generates version x.y.z for: # x - BREAKING CHANGE included in commit message body # y - feat @@ -85,6 +100,17 @@ jobs: workflows: version: 2 +# Commented out to test the job before scheduling it +# nightly: +# triggers: +# - schedule: +# cron: "0 0 * * *" +# filters: +# branches: +# only: +# - master +# jobs: +# - test_playground_status build_and_test: jobs: - build: @@ -99,6 +125,11 @@ workflows: filters: branches: ignore: master +# Temporary to test the job + - test_playground_status: + filters: + branches: + only: task/add-playground-test release: jobs: diff --git a/gradle.properties b/gradle.properties index 812ff3799..b6e641930 100644 --- a/gradle.properties +++ b/gradle.properties @@ -38,5 +38,6 @@ GHERKIN_VERSION=5.0.0 CUCUMBER_VERSION=4.0.0 CUCUMBER_EXPRESSIONS_VERSION=6.0.1 CUCUMBER_PICOCONTAINER_VERSION=1.2.5 +SELENIUM_VERSION=3.141.59 FAKER_VERSION=1.0.2 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 44e7c4d1d..0417afefe 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Thu Aug 27 14:51:34 BST 2020 +distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/playground/.gitignore b/playground/.gitignore new file mode 100644 index 000000000..6e4170320 --- /dev/null +++ b/playground/.gitignore @@ -0,0 +1,3 @@ +build/ +out/ +bin/ \ No newline at end of file diff --git a/playground/build.gradle b/playground/build.gradle new file mode 100644 index 000000000..6539573b8 --- /dev/null +++ b/playground/build.gradle @@ -0,0 +1,27 @@ +plugins { + id 'java' +} + +group 'com.scottlogic.datahelix.generator' + +sourceCompatibility = 1.8 + +repositories { + mavenCentral() +} + +dependencies { + testCompile "org.seleniumhq.selenium:selenium-java:${SELENIUM_VERSION}" + testCompile "org.junit.jupiter:junit-jupiter-api:${JUNIT_JUPITER_VERSION}" + testCompile "junit:junit:${JUNIT_4_VERSION}" + testCompile "org.junit.platform:junit-platform-runner:${JUNIT_PLATFORM_RUNNER_VERSION}" + testCompile "org.junit.vintage:junit-vintage-engine:${JUNIT_JUPITER_VERSION}" + testCompile "org.junit.jupiter:junit-jupiter-params:${JUNIT_JUPITER_VERSION}" + testCompile "org.junit.jupiter:junit-jupiter-engine:${JUNIT_JUPITER_VERSION}" + testImplementation("org.junit.jupiter:junit-jupiter:${JUNIT_JUPITER_VERSION}") +} + +test { + systemProperty "webdriver.gecko.driver", "/usr/local/bin/geckodriver" + useJUnitPlatform() +} \ No newline at end of file diff --git a/playground/src/test/java/PlaygroundTest.java b/playground/src/test/java/PlaygroundTest.java new file mode 100644 index 000000000..dd77824c5 --- /dev/null +++ b/playground/src/test/java/PlaygroundTest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2019 Scott Logic Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.openqa.selenium.support.ui.ExpectedConditions.invisibilityOfElementLocated; + + +class PlaygroundTest { + + private static final String PLAYGROUND_URL = "https://finos.github.io/datahelix/playground/"; + private static WebDriver driver; + private static WebDriverWait wait; + + @BeforeAll + static void before() { + driver = new FirefoxDriver(); + wait = new WebDriverWait(driver, 30); + } + + @AfterAll + static void afterAll() { + driver.quit(); + } + + @BeforeEach + void beforeEach() { + driver.get(PLAYGROUND_URL); + + wait.until(ExpectedConditions.attributeContains(By.id("output-panel"), "textContent", "Click Run")); + driver.findElement(By.id("run")).click(); + wait.until(invisibilityOfElementLocated(By.id("spinner"))); + } + + @Test + void clickRun_showsContentInOutputPanel() { + boolean outputExists = driver.findElements(By.id("output")).size() > 0; + assertTrue(outputExists); + } + + @Test + void clickRun_doesNotShowErrorMessage() { + boolean errorExists = driver.findElements(By.id("error-popup")).size() > 0; + assertFalse(errorExists); + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 525321514..0201c43bf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,4 +26,5 @@ include 'common' include 'orchestrator' include 'output' include 'custom' +include 'playground'