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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,10 @@ application-local.yml
/repomix-output.txt
src/main/resources/application-docker-keycloak.yml
.vscode/

# Playwright
playwright/node_modules/
playwright/test-results/
playwright/playwright-report/
playwright/reports/
playwright/.env
41 changes: 40 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repositories {

dependencies {
// DigitalSanctuary Spring User Framework
implementation 'com.digitalsanctuary:ds-spring-user-framework:4.0.2'
implementation 'com.digitalsanctuary:ds-spring-user-framework:4.0.3'

// Spring Boot starters
implementation 'org.springframework.boot:spring-boot-starter-actuator'
Expand Down Expand Up @@ -127,3 +127,42 @@ bootRun {
environment SPRING_PROFILES_ACTIVE: profiles
}
}

// Playwright Test Integration
tasks.register('playwrightInstall', Exec) {
description = 'Install Playwright dependencies'
group = 'verification'
workingDir 'playwright'
commandLine 'npm', 'install'
}

tasks.register('playwrightBrowsers', Exec) {
description = 'Install Playwright browsers'
group = 'verification'
workingDir 'playwright'
commandLine 'npx', 'playwright', 'install'
dependsOn 'playwrightInstall'
}

tasks.register('playwrightTest', Exec) {
description = 'Run Playwright E2E tests'
group = 'verification'
workingDir 'playwright'
commandLine 'npx', 'playwright', 'test'
dependsOn 'playwrightBrowsers'
}

tasks.register('playwrightTestChromium', Exec) {
description = 'Run Playwright E2E tests on Chromium only'
group = 'verification'
workingDir 'playwright'
commandLine 'npx', 'playwright', 'test', '--project=chromium'
dependsOn 'playwrightBrowsers'
}

tasks.register('playwrightReport', Exec) {
description = 'Show Playwright test report'
group = 'verification'
workingDir 'playwright'
commandLine 'npx', 'playwright', 'show-report'
}
11 changes: 11 additions & 0 deletions playwright/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Playwright Test Configuration
# Copy this file to .env and update values as needed

# Base URL for the application under test
BASE_URL=http://localhost:8080

# Test API endpoint for test data management
TEST_API_URL=http://localhost:8080/api/test

# Set to 'true' when running in CI environment
CI=false
23 changes: 23 additions & 0 deletions playwright/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Dependencies
node_modules/

# Build output
dist/

# Test results
reports/
test-results/
playwright-report/
blob-report/

# Environment files
.env
.env.local

# IDE
.idea/
.vscode/

# OS
.DS_Store
Thumbs.db
128 changes: 128 additions & 0 deletions playwright/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions playwright/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "spring-user-framework-playwright-tests",
"version": "1.0.0",
"description": "Playwright E2E tests for Spring User Framework Demo App",
"scripts": {
"test": "playwright test",
"test:chromium": "playwright test --project=chromium",
"test:firefox": "playwright test --project=firefox",
"test:webkit": "playwright test --project=webkit",
"test:headed": "playwright test --headed",
"test:ui": "playwright test --ui",
"test:debug": "playwright test --debug",
"report": "playwright show-report",
"codegen": "playwright codegen http://localhost:8080"
},
"devDependencies": {
"@playwright/test": "^1.58.0",
"@types/node": "^20.10.0",
"typescript": "^5.3.0",
"dotenv": "^16.3.0"
},
"engines": {
"node": ">=18"
}
}
125 changes: 125 additions & 0 deletions playwright/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { defineConfig, devices } from '@playwright/test';
import * as dotenv from 'dotenv';
import * as path from 'path';

dotenv.config();

/**
* Unique project identifier for session isolation.
* This ensures this project's Playwright instance doesn't conflict with other projects.
*/
const PROJECT_ID = 'spring-demo-app';

/**
* Playwright configuration for Spring User Framework Demo App E2E tests.
* @see https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
testDir: './tests',

/* Unique output directories for this project */
outputDir: path.join(__dirname, 'test-results', PROJECT_ID),

/* Run tests in files in parallel */
fullyParallel: true,

/* Fail the build on CI if you accidentally left test.only in the source code */
forbidOnly: !!process.env.CI,

/* Retry on CI only */
retries: process.env.CI ? 2 : 0,

/* Opt out of parallel tests on CI */
workers: process.env.CI ? 1 : undefined,

/* Reporter to use */
reporter: [
['html', { outputFolder: 'reports/html' }],
['json', { outputFile: 'reports/results.json' }],
['list']
],

/* Shared settings for all the projects below */
use: {
/* Base URL to use in actions like `await page.goto('/')` */
baseURL: process.env.BASE_URL || 'http://localhost:8080',

/* Collect trace when retrying the failed test */
trace: 'on-first-retry',

/* Capture screenshot on failure */
screenshot: 'only-on-failure',

/* Capture video on failure */
video: 'on-first-retry',

/* Default timeout for actions */
actionTimeout: 10000,

/* Default navigation timeout */
navigationTimeout: 30000,

/* Session isolation: unique browser launch options per project */
launchOptions: {
args: [
/* Disable shared memory usage for better isolation in containers/parallel runs */
'--disable-dev-shm-usage',
/* Disable GPU to prevent shared resource conflicts */
'--disable-gpu',
],
},

/* Unique context options for session isolation */
contextOptions: {
/* Ignore HTTPS errors for local development */
ignoreHTTPSErrors: true,
},
},

/* Configure global timeout */
timeout: 60000,

/* Expect timeout */
expect: {
timeout: 10000,
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports */
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},

{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] },
},
],

/* Run your local dev server before starting the tests */
webServer: {
command: 'cd .. && ./gradlew bootRun --args="--spring.profiles.active=local,playwright-test"',
url: 'http://localhost:8080',
reuseExistingServer: !process.env.CI,
timeout: 120000,
stdout: 'pipe',
stderr: 'pipe',
},
});
11 changes: 11 additions & 0 deletions playwright/src/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export {
test,
expect,
generateTestEmail,
generateTestPassword,
generateTestUser,
loginUser,
registerAndVerifyUser,
createAndLoginUser,
type TestUser,
} from './test-fixtures';
Loading
Loading