-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- First setup of e2e testing with playwright including github workflow - Added dependency on crossmodel-browser-app in e2e-tests - Updated devcontainer with Dockerfile and updated README - Updated decontainer config to support WSLg - Added extra yarn execution before installing playwright deps - Added allure reporting for ci runs and added dependencies - First step for using tabbar toolbar in playwright tests - Implement Theia Tab bar toolbar and Theia single input dialog page object - Create tests for tab bar toolbar actions (entity, relationship & diagram)
- Loading branch information
Showing
24 changed files
with
557 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# We use the Node-16 on Debian Bullseye. | ||
ARG VARIANT="16-bullseye" | ||
FROM mcr.microsoft.com/devcontainers/typescript-node:0-${VARIANT} | ||
|
||
# Install OS packages needed for building Theia. | ||
RUN apt-get update \ | ||
&& export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -y install --no-install-recommends \ | ||
libsecret-1-dev \ | ||
libxkbfile-dev |
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 |
---|---|---|
@@ -1,18 +1,55 @@ | ||
// Dev-Container for CrossModel. | ||
// For format details, see https://aka.ms/devcontainer.json. | ||
{ | ||
"name": "Node.js & TypeScript", | ||
// https://github.com/devcontainers/templates/tree/main/src/typescript-node | ||
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-16-bullseye", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/python:1": { | ||
"version": "3.11.4" | ||
} | ||
}, | ||
|
||
"customizations": { | ||
"vscode": { | ||
// Install a list of extensions in the Dev Container so everything is reasdy to develop and test. | ||
"extensions": [ | ||
"langium.langium-vscode", | ||
"esbenp.prettier-vscode", | ||
"eamodio.gitlens", | ||
"davidanson.vscode-markdownlint", | ||
"ms-playwright.playwright", | ||
"dbaeumer.vscode-eslint", | ||
"orta.vscode-jest" | ||
] | ||
} | ||
}, | ||
// Allow port 3000 to be forwarded. | ||
"forwardPorts": [3000], | ||
|
||
// Install the needed OS libs for building. | ||
"postCreateCommand": "sudo apt-get update && sudo apt-get -y install libsecret-1-dev libxkbfile-dev" | ||
"portsAttributes": { | ||
"3000": { | ||
"label": "Theia Backend" | ||
} | ||
}, | ||
// Install the playwright dependencies. | ||
"postCreateCommand": "yarn && yarn playwright install --with-deps", | ||
// When we want to be able to run playwright headed within the Dev Container, | ||
// we need to setup the mounts and container environment variables like below. | ||
"mounts": [ | ||
{ | ||
"source": "/run/desktop/mnt/host/wslg/.X11-unix", | ||
"target": "/tmp/.X11-unix", | ||
"type": "bind" | ||
}, | ||
{ | ||
"source": "/run/desktop/mnt/host/wslg", | ||
"target": "/mnt/wslg", | ||
"type": "bind" | ||
} | ||
], | ||
"containerEnv": { | ||
"DISPLAY": ":0", | ||
"WAYLAND_DISPLAY": "wayland-0", | ||
"XDG_RUNTIME_DIR": "/mnt/wslg/runtime-dir", | ||
"PULSE_SERVER": "/mnt/wslg/PulseServer" | ||
} | ||
} |
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
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,25 @@ | ||
{ | ||
"name": "crossmodel-e2e-tests", | ||
"version": "0.0.0", | ||
"private": true, | ||
"license": "AGPL-3.0-or-later", | ||
"author": { | ||
"name": "CrossBreeze", | ||
"email": "devops@crossbreeze.nl" | ||
}, | ||
"scripts": { | ||
"build": "tsc -b && npx playwright install chromium", | ||
"clean": "rimraf lib tsconfig.tsbuildinfo", | ||
"lint": "eslint -c ../.eslintrc.js --ext .ts ./src", | ||
"playwright:install": "yarn playwright install --with-deps", | ||
"prepare": "yarn clean && yarn build && yarn lint", | ||
"test": "yarn playwright test" | ||
}, | ||
"dependencies": { | ||
"@playwright/test": "^1.37.1", | ||
"@theia/playwright": "1.43.1" | ||
}, | ||
"devDependencies": { | ||
"allure-playwright": "^2.9.2" | ||
} | ||
} |
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,33 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 CrossBreeze. | ||
********************************************************************************/ | ||
import { defineConfig } from '@playwright/test'; | ||
|
||
export default defineConfig({ | ||
testDir: './src/tests', | ||
testMatch: ['**/*.spec.ts'], | ||
workers: process.env.CI ? 1 : 2, | ||
retries: process.env.CI ? 1 : 0, | ||
// The number of times to repeat each test, useful for debugging flaky tests | ||
repeatEach: 1, | ||
// Timeout for each test in milliseconds: 60 seconds. | ||
timeout: 60 * 1000, | ||
use: { | ||
baseURL: 'http://localhost:3000', | ||
browserName: 'chromium', | ||
screenshot: 'only-on-failure', | ||
viewport: { width: 1920, height: 1080 } | ||
}, | ||
snapshotDir: './src/tests/snapshots', | ||
expect: { | ||
toMatchSnapshot: { threshold: 0.01 } | ||
}, | ||
preserveOutput: 'failures-only', | ||
reporter: process.env.CI ? [['list'], ['allure-playwright'], ['github']] : [['list'], ['html']], | ||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'yarn --cwd ../../ start:browser', | ||
url: 'http://localhost:3000', | ||
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,17 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 CrossBreeze. | ||
********************************************************************************/ | ||
import { test, Page } from '@playwright/test'; | ||
import { CrossModelApp } from '../page-objects/crossmodel-app'; | ||
import { CrossModelWorkspace } from '../page-objects/crossmodel-workspace'; | ||
|
||
export let page: Page; | ||
export let app: CrossModelApp; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
page = await browser.newPage(); | ||
const ws = new CrossModelWorkspace(['src/resources/sample-workspace']); | ||
app = await CrossModelApp.load(page, ws); | ||
}); | ||
|
||
export default test; |
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,6 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 CrossBreeze. | ||
********************************************************************************/ | ||
import { TheiaApp } from '@theia/playwright'; | ||
|
||
export class CrossModelApp extends TheiaApp {} |
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,14 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 CrossBreeze. | ||
********************************************************************************/ | ||
import { TheiaApp, TheiaExplorerView } from '@theia/playwright'; | ||
import { TheiaTabBarToolbar } from './theia-tabbar-toolbar'; | ||
|
||
export class CrossModelExplorerView extends TheiaExplorerView { | ||
public readonly tabBarToolbar: TheiaTabBarToolbar; | ||
|
||
constructor(app: TheiaApp) { | ||
super(app); | ||
this.tabBarToolbar = new TheiaTabBarToolbar(this); | ||
} | ||
} |
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,6 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 CrossBreeze. | ||
********************************************************************************/ | ||
import { TheiaWorkspace } from '@theia/playwright'; | ||
|
||
export class CrossModelWorkspace extends TheiaWorkspace {} |
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,20 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 CrossBreeze. | ||
********************************************************************************/ | ||
import { OSUtil, TheiaDialog, USER_KEY_TYPING_DELAY } from '@theia/playwright'; | ||
|
||
export class TheiaSingleInputDialog extends TheiaDialog { | ||
async enterSingleInput(inputValue: string): Promise<void> { | ||
const inputField = await this.page.waitForSelector(`${this.blockSelector} .theia-input`); | ||
await inputField.press(OSUtil.isMacOS ? 'Meta+a' : 'Control+a'); | ||
await inputField.fill(inputValue); | ||
await this.page.waitForTimeout(USER_KEY_TYPING_DELAY); | ||
} | ||
|
||
async confirm(): Promise<void> { | ||
if (!(await this.validationResult())) { | ||
throw new Error(`Unexpected validation error in TheiaSingleInputDialog: '${await this.getValidationText()}`); | ||
} | ||
await this.clickMainButton(); | ||
} | ||
} |
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,27 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 CrossBreeze. | ||
********************************************************************************/ | ||
import { TheiaToolbarItem, TheiaView } from '@theia/playwright'; | ||
import { TheiaViewObject } from './theia-view-object'; | ||
|
||
export class TheiaTabBarToolbar extends TheiaViewObject { | ||
constructor(view: TheiaView) { | ||
super(view, '.p-TabBar-toolbar'); | ||
} | ||
|
||
async toolBarItem(commandId: string): Promise<TheiaToolbarItem | undefined> { | ||
const toolbarHandle = await this.objectElementHandle(); | ||
if (!toolbarHandle) { | ||
return undefined; | ||
} | ||
const item = await toolbarHandle.$(this.toolBarItemSelector(commandId)); | ||
if (item) { | ||
return new TheiaToolbarItem(this.app, item); | ||
} | ||
return undefined; | ||
} | ||
|
||
protected toolBarItemSelector(toolbarItemId = ''): string { | ||
return `div.item > div${toolbarItemId ? `[id="${toolbarItemId}"]` : ''}`; | ||
} | ||
} |
Oops, something went wrong.