Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: publish

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag'
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.tag }}
cancel-in-progress: true

permissions:
contents: write

jobs:
publish:
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: semeru
java-version: '25'
cache: 'sbt'
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Cache the target and node_modules folder
uses: actions/cache@v4
with:
path: |
./target
./node_modules
key: ${{ runner.os }}-publish-${{ github.sha }}
restore-keys: |
${{ runner.os }}-publish-
- name: Install Node modules
run: npm install
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish docker image
run: sbt clean stage docker:publish
env:
GIT_TAG: ${{ github.event.inputs.tag }}
71 changes: 71 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: test

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
checks: write

jobs:
test:
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:18.4
env:
POSTGRES_DB: play_fast_test
POSTGRES_USER: play_fast_dev_user
POSTGRES_PASSWORD: dev
ports:
- 5432:5432

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: browser-actions/setup-chrome@v2
with:
chrome-version: '151'
install-chromedriver: true
- uses: actions/setup-java@v4
with:
distribution: semeru
java-version: '25'
cache: 'sbt'
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Cache the target and node_modules folder
uses: actions/cache@v4
with:
path: |
./target
./node_modules
key: ${{ runner.os }}-test-${{ github.sha }}
restore-keys: |
${{ runner.os }}-test-
- name: Install Node modules
run: npm install
- name: Build
run: |
rm -rf ./target/test-reports
sbt test:compile
- name: Run tests
run: |
npm run hmr >/dev/null 2>&1 &
sbt test
env:
HEADLESS: true
- name: Publish Test Report
id: report
uses: mikepenz/action-junit-report@v6
if: success() || failure() # always run even if the previous step fails
with:
report_paths: './target/test-reports/TEST-*.xml'
4 changes: 3 additions & 1 deletion test/base/Base.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ object Base {
lazy val appConfig: Map[String, Any] = Map(
"slick.dbs.default.db.properties.url" -> "postgres://play_fast_dev_user:dev@localhost:5432/play_fast_test",
"play.evolutions.enabled" -> false,
"app.baseUrl" -> s"http://localhost:$PORT"
"app.baseUrl" -> s"http://localhost:$PORT",
"mailgun.apiKey" -> "invalid",
"mailgun.domain" -> "invalid"
)
}

Expand Down
38 changes: 38 additions & 0 deletions test/browsers/Base.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import framework.Instant.MockedTimeChangeListener
import framework.{BaseController, Instant}
import org.openqa.selenium.*
import org.openqa.selenium.chrome.{ChromeDriver, ChromeOptions}
import org.openqa.selenium.interactions.Actions
import org.openqa.selenium.logging.{LogType, LoggingPreferences}
import org.openqa.selenium.support.ui.Select
import play.api.mvc.{DefaultSessionCookieBaker, Session}
import play.api.test.TestServer

Expand Down Expand Up @@ -54,6 +56,7 @@ trait Base extends base.Base with MockedTimeChangeListener {
| return new window.OriginalDate(...args);
| }
|};
|Date.now = function() { return ${time.toEpochMilli} };
|""".stripMargin
)
}
Expand Down Expand Up @@ -159,6 +162,41 @@ trait Base extends base.Base with MockedTimeChangeListener {
el.click()
}

def hover(cssSelector: String, dx: Int, dy: Int): Unit = {
val elementToHover = elem(cssSelector)
var actions = new Actions(webDriver)
actions.moveToElement(elementToHover).moveByOffset(dx, dy).click().perform()
}

def select(cssSelector: String, label: String): Unit = {
val el = elem(cssSelector)

val select = new Select(el)
select.selectByVisibleText(label)
}

def enableCursor(): Unit = {
webDriver.executeScript(
"""
|var seleniumCursor = document.createElement('div');
| seleniumCursor.id = 'selenium-visual-cursor';
| seleniumCursor.style.position = 'absolute';
| seleniumCursor.style.zIndex = '99999';
| seleniumCursor.style.width = '12px';
| seleniumCursor.style.height = '12px';
| seleniumCursor.style.background = 'red';
| seleniumCursor.style.borderRadius = '50%';
| seleniumCursor.style.pointerEvents = 'none'; // Prevents it from interfering with clicks
| document.body.appendChild(seleniumCursor);
|
| document.addEventListener('mousemove', function(e) {
| seleniumCursor.style.left = e.pageX + 'px';
| seleniumCursor.style.top = e.pageY + 'px';
| });
|""".stripMargin
)
}

private[this] def getElem(cssSelector: String, checkDisplay: Boolean): Option[WebElement] = {
val elems = webDriver.findElements(By.cssSelector(cssSelector)).asScala.toList

Expand Down
Loading