Skip to content

Commit cc83b9a

Browse files
authored
Merge pull request #4770 from Tyriar/tyriar/canvas_tests
Add canvas renderer tests
2 parents 34933d2 + 14872e0 commit cc83b9a

File tree

17 files changed

+177
-40
lines changed

17 files changed

+177
-40
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"addons/xterm-addon-attach/src/tsconfig.json",
1818
"addons/xterm-addon-attach/test/tsconfig.json",
1919
"addons/xterm-addon-canvas/src/tsconfig.json",
20+
"addons/xterm-addon-canvas/test/tsconfig.json",
2021
"addons/xterm-addon-fit/src/tsconfig.json",
2122
"addons/xterm-addon-fit/test/tsconfig.json",
2223
"addons/xterm-addon-image/src/tsconfig.json",

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,12 @@ jobs:
259259
ls -R
260260
- name: Build demo
261261
run: yarn build-demo
262-
- name: Integration tests
263-
run: yarn test-playwright-${{ matrix.browser }} --forbid-only
262+
- name: Integration tests (core)
263+
run: yarn test-playwright-${{ matrix.browser }} --forbid-only --workers 4 --suite=core
264+
- name: Integration tests (xterm-addon-canvas)
265+
run: yarn test-playwright-${{ matrix.browser }} --forbid-only --workers 4 --suite=xterm-addon-canvas
266+
- name: Integration tests (xterm-addon-webgl)
267+
run: yarn test-playwright-${{ matrix.browser }} --forbid-only --workers 4 --suite=xterm-addon-webgl
264268

265269
test-api:
266270
needs: build

addons/xterm-addon-canvas/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"build": "../../node_modules/.bin/tsc -p .",
2020
"prepackage": "npm run build",
2121
"package": "../../node_modules/.bin/webpack",
22-
"prepublishOnly": "npm run package"
22+
"prepublishOnly": "npm run package",
23+
"start-server-only": "node ../../demo/start-server-only"
2324
},
2425
"peerDependencies": {
2526
"xterm": "^5.0.0"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
3+
* @license MIT
4+
*/
5+
6+
import test from '@playwright/test';
7+
import { ISharedRendererTestContext, injectSharedRendererTests } from '../../../out-test/playwright/SharedRendererTests';
8+
import { ITestContext, createTestContext, openTerminal } from '../../../out-test/playwright/TestUtils';
9+
10+
let ctx: ITestContext;
11+
const ctxWrapper: ISharedRendererTestContext = {
12+
value: undefined,
13+
skipCanvasExceptions: true
14+
} as any;
15+
test.beforeAll(async ({ browser }) => {
16+
ctx = await createTestContext(browser);
17+
await openTerminal(ctx);
18+
ctxWrapper.value = ctx;
19+
await ctx.page.evaluate(`
20+
window.addon = new window.CanvasAddon(true);
21+
window.term.loadAddon(window.addon);
22+
`);
23+
});
24+
test.afterAll(async () => await ctx.page.close());
25+
26+
test.describe('Canvas Renderer Integration Tests', () => {
27+
// HACK: The tests fail for an unknown reason
28+
test.skip(({ browserName }) => browserName === 'webkit');
29+
30+
injectSharedRendererTests(ctxWrapper);
31+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { PlaywrightTestConfig } from '@playwright/test';
2+
3+
const config: PlaywrightTestConfig = {
4+
testDir: '.',
5+
timeout: 10000,
6+
projects: [
7+
{
8+
name: 'Chrome Stable',
9+
use: {
10+
browserName: 'chromium',
11+
channel: 'chrome'
12+
}
13+
},
14+
{
15+
name: 'Firefox Stable',
16+
use: {
17+
browserName: 'firefox'
18+
}
19+
},
20+
{
21+
name: 'WebKit',
22+
use: {
23+
browserName: 'webkit'
24+
}
25+
}
26+
],
27+
reporter: 'list',
28+
webServer: {
29+
command: 'npm run start-server-only',
30+
port: 3000,
31+
timeout: 120000,
32+
reuseExistingServer: !process.env.CI
33+
}
34+
};
35+
export default config;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es2015",
5+
"lib": [
6+
"es6",
7+
],
8+
"rootDir": ".",
9+
"outDir": "../out-test",
10+
"sourceMap": true,
11+
"removeComments": true,
12+
"baseUrl": ".",
13+
"paths": {
14+
"common/*": [
15+
"../../../src/common/*"
16+
],
17+
"browser/*": [
18+
"../../../src/browser/*"
19+
]
20+
},
21+
"strict": true,
22+
"types": [
23+
"../../../node_modules/@types/node",
24+
"../../../node_modules/@lunapaint/png-codec",
25+
"../../../out-test/playwright/TestUtils",
26+
"../../../out-test/playwright/SharedRendererTests"
27+
]
28+
},
29+
"include": [
30+
"./**/*",
31+
"../../../typings/xterm.d.ts"
32+
],
33+
"references": [
34+
{
35+
"path": "../../../src/common"
36+
},
37+
{
38+
"path": "../../../src/browser"
39+
}
40+
]
41+
}

addons/xterm-addon-canvas/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"files": [],
33
"include": [],
44
"references": [
5-
{ "path": "./src" }
5+
{ "path": "./src" },
6+
{ "path": "./test" }
67
]
78
}

addons/xterm-addon-webgl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"prepackage": "npm run build",
2121
"package": "../../node_modules/.bin/webpack",
2222
"prepublishOnly": "npm run package",
23-
"start": "node ../../demo/start"
23+
"start-server-only": "node ../../demo/start-server-only"
2424
},
2525
"peerDependencies": {
2626
"xterm": "^5.0.0"

addons/xterm-addon-webgl/test/WebglRenderer.test.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44
*/
55

66
import test from '@playwright/test';
7-
import { strictEqual } from 'assert';
8-
import { injectSharedRendererTests } from '../../../out-test/playwright/SharedRendererTests';
7+
import { ISharedRendererTestContext, injectSharedRendererTests } from '../../../out-test/playwright/SharedRendererTests';
98
import { ITestContext, createTestContext, openTerminal } from '../../../out-test/playwright/TestUtils';
109
import { platform } from 'os';
1110

1211
let ctx: ITestContext;
13-
const ctxWrapper: { value: ITestContext } = { value: undefined } as any;
12+
const ctxWrapper: ISharedRendererTestContext = { value: undefined } as any;
1413
test.beforeAll(async ({ browser }) => {
1514
ctx = await createTestContext(browser);
1615
await openTerminal(ctx);
1716
ctxWrapper.value = ctx;
1817
await ctx.page.evaluate(`
19-
window.addon = new WebglAddon(true);
18+
window.addon = new window.WebglAddon(true);
2019
window.term.loadAddon(window.addon);
2120
`);
2221
});
@@ -29,16 +28,5 @@ test.describe('WebGL Renderer Integration Tests', async () => {
2928
test.skip(({ browserName }) => browserName === 'firefox');
3029
}
3130

32-
test('dispose removes renderer canvases', async function(): Promise<void> {
33-
strictEqual(await ctx.page.evaluate(`document.querySelectorAll('.xterm canvas').length`), 2);
34-
await ctx.page.evaluate(`addon.dispose()`);
35-
strictEqual(await ctx.page.evaluate(`document.querySelectorAll('.xterm canvas').length`), 0);
36-
// Re-create webgl addon to avoid side effects impacting other tests
37-
await ctx.page.evaluate(`
38-
window.addon = new WebglAddon(true);
39-
window.term.loadAddon(window.addon);
40-
`);
41-
});
42-
4331
injectSharedRendererTests(ctxWrapper);
4432
});

addons/xterm-addon-webgl/test/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const config: PlaywrightTestConfig = {
2626
],
2727
reporter: 'list',
2828
webServer: {
29-
command: 'npm start',
29+
command: 'npm run start-server-only',
3030
port: 3000,
3131
timeout: 120000,
3232
reuseExistingServer: !process.env.CI

0 commit comments

Comments
 (0)