Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
chore(#1696): Test playground is up and running
Browse files Browse the repository at this point in the history
  • Loading branch information
cuthullu committed Aug 28, 2020
1 parent 2a0f0bb commit df233e7
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 2 deletions.
31 changes: 31 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions playground/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
out/
bin/
27 changes: 27 additions & 0 deletions playground/build.gradle
Original file line number Diff line number Diff line change
@@ -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()
}
68 changes: 68 additions & 0 deletions playground/src/test/java/PlaygroundTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ include 'common'
include 'orchestrator'
include 'output'
include 'custom'
include 'playground'

0 comments on commit df233e7

Please sign in to comment.