Skip to content

Commit

Permalink
Merge pull request #41 from axonivy/playwright
Browse files Browse the repository at this point in the history
Playwright
  • Loading branch information
ivy-rew authored Jan 11, 2024
2 parents dd29fa6 + 33bfe74 commit 88ceb1c
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
node_modules/
target/
/playwright-report/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
8 changes: 7 additions & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
FROM node:18.17.1-bookworm
FROM mcr.microsoft.com/playwright:v1.40.1-jammy

RUN apt-get update &&\
apt-get install software-properties-common -y &&\
apt-add-repository universe -y &&\
apt-get update &&\
apt-get install openjdk-17-jdk maven -y

USER node
12 changes: 12 additions & 0 deletions build/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ pipeline {
}
}
}
stage('NPM:test') {
steps {
script {
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
docker.build('node', '-f build/Dockerfile .').inside {
sh 'npm run test'
}
}
archiveArtifacts artifacts: 'playwright-report/**', allowEmptyArchive: false
}
}
}
stage('Deploy') {
when {
expression { isReleaseOrMasterBranch() && currentBuild.changeSets.size() > 0 }
Expand Down
125 changes: 125 additions & 0 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
"type": "module",
"scripts": {
"start": "vite",
"build": "vite build"
"build": "vite build",
"test": "npx playwright test"
},
"dependencies": {
"swagger-ui": "^5.10.5",
"vite": "^5.0.11"
},
"devDependencies": {
"@playwright/test": "^1.40.1",
"@types/node": "^20.10.8",
"prettier": "^3.1.1"
}
}
32 changes: 32 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { defineConfig, devices } from '@playwright/test';

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
use: {
baseURL: 'http://localhost:5173',
trace: 'on-first-retry',
},

projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],

webServer: {
command: 'npm run start',
url: 'http://localhost:5173',
stdout: 'pipe',
stderr: 'pipe',
reuseExistingServer: !process.env.CI,
},
});
8 changes: 8 additions & 0 deletions tests/swagger.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, expect } from '@playwright/test';

test('swagger ui renderer', async ({ page }) => {
await page.goto('/');

await expect(page).toHaveTitle(/API Browser/);
await expect(page.getByText('Authorize')).toBeVisible();
});

0 comments on commit 88ceb1c

Please sign in to comment.