Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
56 changes: 56 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: End-to-End Tests

on:
schedule:
# 07:00 UTC = 08:00 CET (Europe/Berlin winter time). GitHub cron is UTC only,
# so this fires at 09:00 local during CEST (summer time).
- cron: '0 7 * * *'
workflow_dispatch:
inputs:
step:
description: 'Tutorial step to test'
type: choice
default: all
options:
- all
- '1'
- '2'
- '3'
- '4'
- '5'
- '6'

jobs:
e2e:
name: Playwright suite (Docker)
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: maven

- name: Run end-to-end test suite
env:
E2E_STEP: ${{ inputs.step || 'all' }}
run: bash scripts/run-e2e.sh "$E2E_STEP"

- name: Upload failure artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-artifacts
path: |
*/target/failsafe-reports
*/target/visual-diffs
*/target/playwright-traces
*/target/e2e-artifacts
if-no-files-found: ignore
retention-days: 14
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ hs_err_pid*
replay_pid*

**/target
node_modules/
playwright-report/
test-results/
/.idea
*.iml
/.project
Expand Down
19 changes: 19 additions & 0 deletions 1-creating-a-basic-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ To run the app, ensure the following tools are installed:
- Java 21 or higher
- BBj 26.02 when running with local BBjServices
- Maven
- Docker Desktop (or another Docker engine) for end-to-end tests
- A Java IDE (e.g., IntelliJ IDEA, Eclipse, VSCode)
- Web browser
- Git (recommended)
Expand Down Expand Up @@ -49,6 +50,24 @@ webforj-tutorial
```
3. Open your browser and go to [http://localhost:8080](http://localhost:8080).

## End-to-End and Screenshot Tests

With Docker running, execute this command from this step's directory:

```sh
mvn verify
```

Maven launches the step's Java Playwright tests in the pinned Docker image. Only this step is built and tested. Tests are in `src/test/java/com/webforj/tutorial`, screenshot baselines in `src/test/resources/screenshots`, and reports, traces, and logs under `target`.

To update this step's baselines after an intentional visual change:

```sh
mvn verify -DupdateScreenshots=true
```

Both test execution and baseline generation happen in Docker. `mvn test` runs unit tests; the end-to-end tests run during `mvn verify`.

## Project Highlights

- **Spring Boot integration:** Autowire Spring beans directly into webforJ views and components.
Expand Down
126 changes: 110 additions & 16 deletions 1-creating-a-basic-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<playwright.version>1.50.0</playwright.version>
<junit-jupiter.version>5.11.4</junit-jupiter.version>
<it.test>*IT</it.test>
<updateScreenshots>false</updateScreenshots>
<maven.test.skip>false</maven.test.skip>
<skipTests>${maven.test.skip}</skipTests>
<skipITs>${skipTests}</skipITs>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -53,7 +60,12 @@
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.49.0</version>
<version>${playwright.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -75,21 +87,9 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludeDevtools>true</excludeDevtools>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<trimStackTrace>false</trimStackTrace>
<hotswap>
<hotswapAgent />
</hotswap>
</configuration>
</plugin>
</plugins>
Expand All @@ -105,5 +105,99 @@
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- mvn verify in this step delegates browser tests to the pinned Docker image. -->
<profile>
<id>docker-e2e</id>
<activation>
<property>
<name>!docker.e2e.container</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>docker-e2e</id>
<phase>verify</phase>
<goals><goal>exec</goal></goals>
<configuration>
<skip>${skipITs}</skip>
<executable>docker</executable>
<arguments>
<argument>run</argument>
<argument>--rm</argument>
<argument>--init</argument>
<argument>--ipc=host</argument>
<argument>--workdir=/app</argument>
<argument>-e</argument>
<argument>CI=true</argument>
<argument>-e</argument>
<argument>E2E_IN_DOCKER=true</argument>
<argument>--mount=type=bind,source=${project.basedir},target=/app</argument>
<argument>-v</argument>
<argument>webforj-tutorial-e2e-maven-repo:/var/maven/.m2</argument>
<argument>-e</argument>
<argument>MAVEN_CONFIG=/var/maven/.m2</argument>
<argument>mcr.microsoft.com/playwright/java:v${playwright.version}-noble</argument>
<argument>mvn</argument>
<argument>-B</argument>
<argument>-ntp</argument>
<argument>-Dmaven.repo.local=/var/maven/.m2/repository</argument>
<argument>-Ddocker.e2e.container=true</argument>
<argument>-DupdateScreenshots=${updateScreenshots}</argument>
<argument>-Dit.test=${it.test}</argument>
<argument>clean</argument>
<argument>verify</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- Only the Maven process inside Docker runs browser and screenshot tests. -->
<profile>
<id>container-e2e</id>
<activation>
<property>
<name>docker.e2e.container</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.2.5</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<failIfNoTests>true</failIfNoTests>
<trimStackTrace>false</trimStackTrace>
<useFile>false</useFile>
<systemPropertyVariables>
<e2e.app.dir>${project.basedir}</e2e.app.dir>
<e2e.app.jar>${project.build.directory}/${project.build.finalName}.jar</e2e.app.jar>
<e2e.output.dir>${project.build.directory}</e2e.output.dir>
<visual.baseline.dir>${project.basedir}/src/test/resources/screenshots</visual.baseline.dir>
<visual.artifact.dir>${project.build.directory}/visual-diffs</visual.artifact.dir>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading