-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test/add basic e2e test to test publishing (#758)
* test(e2e): test publishing functionality * test(e2e): various improvements * test(e2e): various improvements * test(e2e): various improvements * test(e2e): various improvements * test(e2e): various improvements (StringEnvelope) * test(e2e): cleanup * test(e2e): cleanup * test(ui): update info component test * fix(e2e): fix after rebase Co-authored-by: Timon Back <[email protected]> --------- Co-authored-by: David Müller <[email protected]>
- Loading branch information
Showing
42 changed files
with
722 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# End-to-End tests for Springwolf | ||
|
||
The end-to-end tests cover test cases that cannot be verified using junitk/jest unit/integration/system tests. | ||
Typical examples are click interactions through `springwolf-ui`. | ||
|
||
## Usage | ||
|
||
This project uses [playwright](https://playwright.dev). | ||
|
||
To install the dependencies, run `npm install` (or `../../gradlew npmInstall`) | ||
|
||
To use the playwright ui, run | ||
```bash | ||
npm run start | ||
``` | ||
|
||
For ci/cd or cli environments, use `../../gradlew npm_run_test` or | ||
```bash | ||
npm run test | ||
``` | ||
|
||
### Example project | ||
The end-to-end tests are run against one example project, which is automatically started using docker. | ||
|
||
To test against the non-default project, specify the environment variable `SPRINGWOLF_EXAMPLE` | ||
For example: | ||
```bash | ||
SPRINGWOLF_EXAMPLE=kafka npm run start | ||
``` | ||
|
||
_Note: The example is re-used between tests. When switching example projects, the docker containers need to be stopped._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
plugins { | ||
id 'java' | ||
id 'com.github.node-gradle.node' version '7.0.2' | ||
} | ||
|
||
node { | ||
version = '18.16.1' | ||
npmVersion = '9.5.1' | ||
download = true | ||
} | ||
|
||
npm_run_test { | ||
dependsOn spotlessCheck | ||
|
||
inputs.files fileTree("tests") | ||
inputs.files fileTree("util") | ||
inputs.file 'playwright.config.ts' | ||
inputs.file 'package.json' | ||
inputs.file 'package-lock.json' | ||
} | ||
|
||
spotless { | ||
encoding 'UTF-8' | ||
|
||
def npmExec = System.getProperty('os.name').toLowerCase().contains('windows') ? '/npm.cmd' : '/bin/npm' | ||
def nodeExec = System.getProperty('os.name').toLowerCase().contains('windows') ? '/node.exe' : '/bin/node' | ||
|
||
format 'styling', { | ||
target 'tests/**/*.ts', 'tests/**/*.js', 'util/**/*.ts', 'util/**/*.js' | ||
|
||
prettier() | ||
.npmExecutable("${tasks.named('npmSetup').get().npmDir.get()}${npmExec}") | ||
.nodeExecutable("${tasks.named('nodeSetup').get().nodeDir.get()}${nodeExec}") | ||
|
||
licenseHeader("/* SPDX-License-Identifier: Apache-2.0 */", "import|export|.* \\{") | ||
|
||
trimTrailingWhitespace() | ||
endWithNewline() | ||
} | ||
} | ||
|
||
tasks.named('spotlessStyling').configure { | ||
it.dependsOn('nodeSetup', 'npmSetup') | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "e2e", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "playwright test --ui", | ||
"test": "playwright test", | ||
"postinstall": "npx playwright install --with-deps chromium" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@playwright/test": "^1.44.0", | ||
"@types/node": "^20.12.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
import { getExampleProject } from './util/example'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
/* 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. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: 'http://localhost:8080/springwolf/asyncapi-ui.html', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* 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'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your loal dev server before starting the tests */ | ||
webServer: { | ||
cwd: '../springwolf-' + getExampleProject() + '-example', | ||
command: 'docker compose up', | ||
url: 'http://127.0.0.1:8080/springwolf/docs.json', | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
import { test, expect } from "@playwright/test"; | ||
import { | ||
monitorDockerLogs, | ||
MonitorDockerLogsResponse, | ||
verifyNoErrorLogs, | ||
} from "../util/external_process"; | ||
|
||
let dockerLogs: MonitorDockerLogsResponse; | ||
test.beforeAll(async () => { | ||
dockerLogs = monitorDockerLogs(); | ||
}); | ||
test.afterAll(async () => { | ||
console.debug("---\nProcessMessages---\n", dockerLogs.messages.join("\n")); | ||
}); | ||
|
||
test("no error nor warn log messages in logs", async ({ page }) => { | ||
// Ensure that logs are available by calling the docs endpoint | ||
await page.goto(""); | ||
|
||
verifyNoErrorLogs(dockerLogs); | ||
expect(dockerLogs.errors).toHaveLength(0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
import { test, expect } from "@playwright/test"; | ||
import { locateChannelItems } from "../util/page_object"; | ||
import { getExampleAsyncApi } from "../util/example"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto(""); | ||
}); | ||
|
||
test("has title", async ({ page }) => { | ||
await expect(page).toHaveTitle(/Springwolf/); | ||
}); | ||
|
||
test("can click download and get original asyncapi.json in new tab", async ({ | ||
page, | ||
}) => { | ||
const newPagePromise = page.waitForEvent("popup"); | ||
|
||
await page.click("text=Download AsyncAPI file"); | ||
await page.waitForTimeout(500); | ||
|
||
const newPage = await newPagePromise; | ||
const content = await newPage.textContent("body pre"); | ||
const asyncApiJson = JSON.parse(content!!); | ||
|
||
expect(asyncApiJson.info.title).toContain("Springwolf example project"); | ||
expect(asyncApiJson).toStrictEqual(getExampleAsyncApi()); | ||
}); | ||
|
||
test("has channels and channel item", async ({ page }) => { | ||
expect(await locateChannelItems(page).count()).toBeGreaterThan(0); | ||
}); |
Oops, something went wrong.