Skip to content

Commit 8b22272

Browse files
committed
testing: Add Theia Playwright framework (#10337)
Co-authored-by: Nina Doschek <[email protected]> Co-authored-by: Johannes Faltermeier <[email protected]> Co-authored-by: Martin Fleck <[email protected]> Co-authored-by: Simon Graband <[email protected]> Co-authored-by: Tobias Ortmayr <[email protected]> Fixes #10337
1 parent d7cdb85 commit 8b22272

File tree

63 files changed

+4547
-858
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+4547
-858
lines changed

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@
176176
"outFiles": [
177177
"${workspaceFolder}/../.js"
178178
]
179+
},
180+
{
181+
"name": "Debug selected system test file with Playwright",
182+
"type": "node",
183+
"request": "launch",
184+
"program": "${workspaceFolder}/examples/playwright/node_modules/.bin/playwright",
185+
"args": [
186+
"test",
187+
"--debug",
188+
"--config=./configs/playwright.debug.config.ts",
189+
"${fileBasenameNoExtension}"
190+
],
191+
"cwd": "${workspaceFolder}/examples/playwright",
192+
"console": "integratedTerminal",
193+
"internalConsoleOptions": "neverOpen"
179194
}
180195
],
181196
"compounds": [

examples/playwright/.eslintrc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** @type {import('eslint').Linter.Config} */
2+
module.exports = {
3+
extends: [
4+
'../../configs/build.eslintrc.json',
5+
'./configs/ui-tests.eslintrc.json',
6+
'./configs/ui-tests.playwright.eslintrc.json'
7+
],
8+
parserOptions: {
9+
tsconfigRootDir: __dirname,
10+
project: 'tsconfig.json'
11+
}
12+
};

examples/playwright/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
allure-results
2+
test-results

examples/playwright/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Theia 🎭 Playwright: A System Testing Framework for Theia
2+
3+
Theia 🎭 Playwright is a [page object](https://martinfowler.com/bliki/PageObject.html) framework based on [Playwright](https://github.com/microsoft/playwright) for developing system tests of [Theia](https://github.com/eclipse-theia/theia)-based applications. See it in action below.
4+
5+
<div style='margin:0 auto;width:70%;'>
6+
7+
![Theia System Testing in Action](./docs/images/teaser.gif)
8+
9+
</div>
10+
11+
The Theia 🎭 Playwright page objects introduce abstraction over Theia's user interfaces, encapsulating the details of the user interface interactions, wait conditions, etc., to help keeping your tests more concise, maintainable, and stable.
12+
Ready for an [example](./docs/GETTING_STARTED.md)?
13+
14+
The actual interaction with the Theia application is implemented with 🎭 Playwright in Typescript. Thus, we can take advantage of [Playwright's benefits](https://playwright.dev/docs/why-playwright/) and run or debug tests headless or headful across all modern browsers.
15+
Check out [Playwright's documentation](https://playwright.dev/docs/intro) for more information.
16+
17+
This page object framework not only covers Theia's generic capabilities, such as handling views, the quick command palette, file explorer etc.
18+
It is [extensible](./docs/EXTENSIBILITY.md) so you can add dedicated page objects for custom Theia components, such as custom views, editors, menus, etc.
19+
20+
## Documentation
21+
22+
- [Getting Started](./docs/GETTING_STARTED.md)
23+
- [Extensibility](./docs/EXTENSIBILITY.md)
24+
- [Building and Developing Theia 🎭 Playwright](./docs/DEVELOPING.md)
25+
26+
## Get in touch
27+
28+
If you have problems, find bugs or have questions, feel free to get in contact via the bugs and discussions.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/********************************************************************************
2+
* Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the Eclipse
10+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
* with the GNU Classpath Exception which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
********************************************************************************/
16+
17+
import { PlaywrightTestConfig } from '@playwright/test';
18+
19+
const config: PlaywrightTestConfig = {
20+
testDir: '../lib/tests',
21+
testMatch: ['**/*.js'],
22+
workers: 2,
23+
// Timeout for each test in milliseconds.
24+
timeout: 60 * 1000,
25+
use: {
26+
baseURL: 'http://localhost:3000',
27+
browserName: 'chromium',
28+
screenshot: 'only-on-failure',
29+
viewport: { width: 1920, height: 1080 }
30+
},
31+
snapshotDir: '../tests/snapshots',
32+
expect: {
33+
toMatchSnapshot: { threshold: 0.15 }
34+
},
35+
preserveOutput: 'failures-only',
36+
reporter: [
37+
['list'],
38+
['allure-playwright']
39+
]
40+
};
41+
42+
export default config;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/********************************************************************************
2+
* Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the Eclipse
10+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
* with the GNU Classpath Exception which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
********************************************************************************/
16+
17+
import { PlaywrightTestConfig } from '@playwright/test';
18+
19+
import baseConfig from './playwright.config';
20+
21+
const debugConfig: PlaywrightTestConfig = {
22+
...baseConfig,
23+
workers: 1,
24+
timeout: 15000000
25+
};
26+
27+
export default debugConfig;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/********************************************************************************
2+
* Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the Eclipse
10+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
* with the GNU Classpath Exception which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
********************************************************************************/
16+
17+
import { PlaywrightTestConfig } from '@playwright/test';
18+
19+
import baseConfig from './playwright.config';
20+
21+
const headfulConfig: PlaywrightTestConfig = {
22+
...baseConfig,
23+
workers: 1,
24+
use: {
25+
...baseConfig.use,
26+
headless: false
27+
}
28+
};
29+
30+
export default headfulConfig;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// override existing rules for ui-tests package
3+
"rules": {
4+
"no-undef": "off", // disabled due to 'browser', '$', '$$'
5+
"no-unused-expressions": "off"
6+
}
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
// override existing rules for ui-tests playwright package
3+
"rules": {
4+
"no-null/no-null": "off"
5+
}
6+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Building and developing Theia 🎭 Playwright
2+
3+
## Building
4+
5+
Run `yarn` in the root directory of the repository.
6+
7+
## Executing the tests
8+
9+
### Prerequisites
10+
11+
To work with the tests the Theia Application under test needs to be running.
12+
13+
Run `yarn browser start` to start the browser-app located in this repository.
14+
15+
You may also use the `Launch Browser Backend` launch configuration in VS Code.
16+
17+
### Running the tests headless
18+
19+
To start the tests run `yarn ui-tests` in the root of this repository. This will start the tests located in `tests` in a headless mode.
20+
21+
To only run a single test file, the path of a test file can be set with `yarn ui-tests <path-to-file>` or `yarn ui-tests -g "<partial test file name>"`.
22+
See the [Playwright Test command line documentation](https://playwright.dev/docs/intro#command-line).
23+
24+
### Debugging the tests
25+
26+
Please refer to the section [debugging tests](./GETTING_STARTED.md#debugging-the-tests).

0 commit comments

Comments
 (0)