From 54a20c511ba2e13c094519c98a5015ca08b8c332 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 3 Jul 2024 03:10:51 -0700 Subject: [PATCH 1/2] Simplify GH action names --- .github/workflows/ci.yml | 10 +++++----- package.json | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 439d383f61..fc937f3cb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,7 +112,7 @@ jobs: ./node_modules/.bin/nyc report --reporter=cobertura exit $EXIT_CODE - test-unit-parallel: + test-unit: timeout-minutes: 20 strategy: matrix: @@ -150,7 +150,7 @@ jobs: - name: Unit tests run: yarn test-unit --forbid-only - test-playwright-parallel: + test-integration: timeout-minutes: 20 strategy: matrix: @@ -191,11 +191,11 @@ jobs: - name: Build demo run: yarn build-demo - name: Integration tests (core) # Tests use 50% workers to reduce flakiness - run: yarn test-playwright-${{ matrix.browser }} --workers=50% --forbid-only --suite=core + run: yarn test-integration-${{ matrix.browser }} --workers=50% --forbid-only --suite=core - name: Integration tests (addon-canvas) - run: yarn test-playwright-${{ matrix.browser }} --workers=50% --forbid-only --suite=addon-canvas + run: yarn test-integration-${{ matrix.browser }} --workers=50% --forbid-only --suite=addon-canvas - name: Integration tests (addon-webgl) - run: yarn test-playwright-${{ matrix.browser }} --workers=50% --forbid-only --suite=addon-webgl + run: yarn test-integration-${{ matrix.browser }} --workers=50% --forbid-only --suite=addon-webgl release-dry-run: needs: build diff --git a/package.json b/package.json index c1320d60aa..859198fc37 100644 --- a/package.json +++ b/package.json @@ -34,11 +34,11 @@ "lint-api": "eslint --no-eslintrc -c .eslintrc.json.typings --max-warnings 0 --no-ignore --ext .d.ts typings/", "test": "npm run test-unit", "posttest": "npm run lint", - "test-playwright": "node ./bin/test_playwright.js --workers=75%", - "test-playwright-chromium": "node ./bin/test_playwright.js --workers=75% \"--project=ChromeStable\"", - "test-playwright-firefox": "node ./bin/test_playwright.js --workers=75% \"--project=FirefoxStable\"", - "test-playwright-webkit": "node ./bin/test_playwright.js --workers=75% \"--project=WebKit\"", - "test-playwright-debug": "node ./bin/test_playwright.js --workers=1 --headed --timeout=30000", + "test-integration": "node ./bin/test_playwright.js --workers=75%", + "test-integration-chromium": "node ./bin/test_playwright.js --workers=75% \"--project=ChromeStable\"", + "test-integration-firefox": "node ./bin/test_playwright.js --workers=75% \"--project=FirefoxStable\"", + "test-integration-webkit": "node ./bin/test_playwright.js --workers=75% \"--project=WebKit\"", + "test-integration-debug": "node ./bin/test_playwright.js --workers=1 --headed --timeout=30000", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", "test-unit-dev": "cross-env NODE_PATH='./out' mocha", From f44d68ef4aeca9986b4b4f8e577354d5d373385c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 3 Jul 2024 03:10:58 -0700 Subject: [PATCH 2/2] Remain test/api project --- .eslintrc.json | 1 - test/api/README.md | 1 - test/api/TestUtils.ts | 90 ------------------------------------------ test/api/tsconfig.json | 34 ---------------- tsconfig.all.json | 1 - 5 files changed, 127 deletions(-) delete mode 100644 test/api/README.md delete mode 100644 test/api/TestUtils.ts delete mode 100644 test/api/tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json index 5e49b021bb..958b53a106 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,6 @@ "src/browser/tsconfig.json", "src/common/tsconfig.json", "src/headless/tsconfig.json", - "test/api/tsconfig.json", "test/benchmark/tsconfig.json", "test/playwright/tsconfig.json", "addons/addon-attach/src/tsconfig.json", diff --git a/test/api/README.md b/test/api/README.md deleted file mode 100644 index 1c86815c5f..0000000000 --- a/test/api/README.md +++ /dev/null @@ -1 +0,0 @@ -This project contains helpers for the legacy playwright tests. Currently addons use this as a dependency, when all addons have moved over to use `@playright/test` this can be removed. diff --git a/test/api/TestUtils.ts b/test/api/TestUtils.ts deleted file mode 100644 index cee59cceb1..0000000000 --- a/test/api/TestUtils.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) 2019 The xterm.js authors. All rights reserved. - * @license MIT - */ - -import * as playwright from '@playwright/test'; -import deepEqual = require('deep-equal'); -import { ITerminalInitOnlyOptions, ITerminalOptions } from '@xterm/xterm'; -import { deepStrictEqual } from 'assert'; - -export async function pollFor(page: playwright.Page, evalOrFn: string | (() => Promise), val: T, preFn?: () => Promise, maxDuration?: number): Promise { - if (preFn) { - await preFn(); - } - const result = typeof evalOrFn === 'string' ? await page.evaluate(evalOrFn) : await evalOrFn(); - - if (process.env.DEBUG) { - console.log('pollFor result: ', result); - } - - if (!deepEqual(result, val)) { - if (maxDuration === undefined) { - maxDuration = 2000; - } - if (maxDuration <= 0) { - deepStrictEqual(result, val, 'pollFor max duration exceeded'); - } - return new Promise(r => { - setTimeout(() => r(pollFor(page, evalOrFn, val, preFn, maxDuration! - 10)), 10); - }); - } -} - -export async function writeSync(page: playwright.Page, data: string): Promise { - await page.evaluate(` - window.ready = false; - window.term.write('${data}', () => window.ready = true); - `); - await pollFor(page, 'window.ready', true); -} - -export async function timeout(ms: number): Promise { - return new Promise(r => setTimeout(r, ms)); -} - -export async function openTerminal(page: playwright.Page, options: ITerminalOptions & ITerminalInitOnlyOptions = {}, testOptions: { loadUnicodeGraphemesAddon: boolean } = { loadUnicodeGraphemesAddon: true }): Promise { - await page.evaluate(`window.term = new Terminal(${JSON.stringify({ allowProposedApi: true, ...options })})`); - await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`); - - // HACK: This is a soft layer breaker that's temporarily included until unicode graphemes have - // more complete integration tests. See https://github.com/xtermjs/xterm.js/pull/4519#discussion_r1285234453 - if (testOptions.loadUnicodeGraphemesAddon) { - await page.evaluate(` - window.unicode = new UnicodeGraphemesAddon(); - window.term.loadAddon(window.unicode); - window.term.unicode.activeVersion = '15-graphemes'; - `); - } - await page.waitForSelector('.xterm-rows'); -} - -export function getBrowserType(): playwright.BrowserType | playwright.BrowserType | playwright.BrowserType { - // Default to chromium - let browserType: playwright.BrowserType | playwright.BrowserType | playwright.BrowserType = playwright['chromium']; - - const index = process.argv.indexOf('--browser'); - if (index !== -1 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') { - const string = process.argv[index + 1]; - if (string === 'firefox' || string === 'webkit') { - browserType = playwright[string]; - } - } - - return browserType; -} - -export function launchBrowser(opts?: playwright.LaunchOptions): Promise { - const browserType = getBrowserType(); - const options: playwright.LaunchOptions = { - ...opts, - headless: process.argv.includes('--headless') - }; - - const index = process.argv.indexOf('--executablePath'); - if (index > 0 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') { - options.executablePath = process.argv[index + 1]; - } - - return browserType.launch(options); -} diff --git a/test/api/tsconfig.json b/test/api/tsconfig.json deleted file mode 100644 index bc050db4ff..0000000000 --- a/test/api/tsconfig.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "compilerOptions": { - "lib": [ - "dom", - "es2021" - ], - "rootDir": ".", - "outDir": "../../out-test/api", - "types": [ - "../../node_modules/@types/mocha", - "../../node_modules/@types/node" - ], - "sourceMap": true, - "removeComments": true, - "pretty": true, - "strict": true, - "declaration": true, - "baseUrl": ".", - "paths": { - "browser/*": [ - "../../src/browser/*" - ] - } - }, - "include": [ - "./**/*", - "../../typings/xterm.d.ts" - ], - "references": [ - { - "path": "../../src/browser" - } - ] -} diff --git a/tsconfig.all.json b/tsconfig.all.json index d40761f337..0311a65eda 100644 --- a/tsconfig.all.json +++ b/tsconfig.all.json @@ -4,7 +4,6 @@ "references": [ { "path": "./src/browser" }, { "path": "./src/headless" }, - { "path": "./test/api" }, { "path": "./test/benchmark" }, { "path": "./test/playwright" }, { "path": "./addons/addon-attach" },