Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,31 @@ jobs:
uses: ./.github/workflows/workflow-test.yml
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
name: Playwright (${{ matrix.config.name }})
name: Playwright ${{ matrix.thread }}-${{ matrix.render }} (${{ matrix.shard }}/4)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
strategy:
fail-fast: false
matrix:
config:
- name: Default
env: []
- name: MULTI_THREAD
env:
- ENABLE_MULTI_THREAD=true
- name: FP only
env:
- ENABLE_SSR=true
- TEST_FP_ONLY=true
- name: SSR-ALL-ON-UI
env:
- ENABLE_SSR=true
thread: [MULTI_THREAD, ALL_ON_UI]
render: [SSR, CSR]
shard: [1, 2, 3, 4]
exclude:
- thread: MULTI_THREAD
render: SSR
Comment thread
colinaaa marked this conversation as resolved.
with:
runs-on: lynx-custom-container
is-web: true
web-report-name: "playwright-${{ matrix.thread }}-${{ matrix.render }}-shard${{ matrix.shard }}"
codecov-flags: "e2e"
run: |
export NODE_OPTIONS="--max-old-space-size=32768" ${{ join(matrix.config.env, ' ') }}
if [ "${{ matrix.thread }}" = "MULTI_THREAD" ]; then
export ENABLE_MULTI_THREAD=true
fi
if [ "${{ matrix.render }}" = "SSR" ]; then
export ENABLE_SSR=true
fi
export NODE_OPTIONS="--max-old-space-size=32768"
export PLAYWRIGHT_JUNIT_OUTPUT_NAME=test-report.junit.xml
pnpm --filter @lynx-js/web-tests run test --reporter='github,dot,junit,html'
pnpm --filter @lynx-js/web-tests run test --reporter='github,dot,junit,html' --shard=${{ matrix.shard }}/4
Comment thread
PupilTong marked this conversation as resolved.
pnpm --filter @lynx-js/web-tests run coverage:ci
test-api:
needs: build
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/workflow-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ on:
required: false
type: boolean
default: false
web-report-name:
required: false
type: string
default: "playwright-report"
codecov-flags:
required: false
type: string
Expand Down Expand Up @@ -88,7 +92,7 @@ jobs:
if: ${{ inputs.is-web && failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: playwright-report
name: ${{ inputs.web-report-name }}
path: packages/web-platform/web-tests/playwright-report
if-no-files-found: error
retention-days: 1
Expand Down
42 changes: 16 additions & 26 deletions packages/web-platform/web-tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,34 @@

import { defineConfig, devices } from '@playwright/test';
import os from 'node:os';
import fs from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = fileURLToPath(import.meta.url);
const dir = path.join(__dirname, '..', '.nyc_output');
fs.mkdir(dir, { recursive: true }).catch(() => {/* */});
process.env['LIBGL_ALWAYS_SOFTWARE'] = 'true'; // https://github.com/microsoft/playwright/issues/32151
process.env['GALLIUM_HUD_SCALE'] = '1';
const isCI = !!process.env.CI;
const enableMultiThread = !!process.env.ENABLE_MULTI_THREAD;
const enableSSR = !!process.env.ENABLE_SSR;
const testFPOnly = !!process.env.TEST_FP_ONLY;
const port = process.env.PORT ?? 3080;
const workerLimit = Math.floor(((cpuCount, envCPULimit) => {
if (envCPULimit) {
return envCPULimit / 2;
} else {
if (cpuCount <= 32) {
return cpuCount / 2;
if (isCI) {
if (envCPULimit) {
return envCPULimit / 2;
} else {
return 16 + (cpuCount - 32) / 6;
if (cpuCount <= 32) {
return 8;
} else {
return 8 + (cpuCount - 32) / 6;
}
}
}
return cpuCount / 2;
})(os.cpus().length, parseFloat(process.env['cpu_limit'] ?? '0')));
Comment thread
PupilTong marked this conversation as resolved.

const testMatch: string | undefined = (() => {
if (testFPOnly) {
return '**/fp-only.spec.ts';
}
if (enableSSR) {
return '**/react.{test,spec}.ts';
}
if (enableMultiThread) {
return '**/{react,web-core,main-thread-apis}.{test,spec}.ts';
}
return undefined;
})();

const testIgnore: string[] = (() => {
const ignore = ['**vitest**'];
if (isCI && !testFPOnly) {
ignore.push('**/fp-only.spec.ts'); // fp-only tests has its own test steps
}
return ignore;
})();

Expand All @@ -58,7 +48,7 @@ export default defineConfig({
/** global timeout https://playwright.dev/docs/test-timeouts#global-timeout */
globalTimeout: 20 * 60 * 1000,
testDir: './tests',
testMatch,
// testMatch,
testIgnore,
/* Run tests in files in parallel */
fullyParallel: true,
Expand Down
5 changes: 4 additions & 1 deletion packages/web-platform/web-tests/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ const config = {
},
watchFiles: isCI
? []
: ['./node_modules/@lynx-js/**/*'],
: ['./node_modules/@lynx-js/**/*.js'],
static: [
{
directory: path.join(__dirname, 'resources'),
Expand Down Expand Up @@ -236,6 +236,9 @@ const config = {
hot: false,
},
watch: false,
watchOptions: {
ignored: isCI ? /.*/ : undefined,
},
module: {
rules: [
{
Expand Down
5 changes: 2 additions & 3 deletions packages/web-platform/web-tests/tests/coverage-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

export const test: typeof base = base.extend({
context: async ({ browserName, context }, use, testInfo) => {
const dir = path.join(__dirname, '..', '..', '..', '.nyc_output');
await fs.mkdir(dir, { recursive: true });
if (browserName !== 'chromium') {
// Coverage is not supported on non-chromium browsers
return use(context);
Expand All @@ -18,7 +20,7 @@
const pages = new Set<Page>();

context.on('page', async (page) => {
await page.coverage.startJSCoverage({

Check failure on line 23 in packages/web-platform/web-tests/tests/coverage-fixture.ts

View workflow job for this annotation

GitHub Actions / Playwright ALL_ON_UI-CSR (2/4) / check

[chromium] › tests/react.spec.ts:1735:7 › reactlynx3 tests › elements › text › basic-element-text-bindlayout

5) [chromium] › tests/react.spec.ts:1735:7 › reactlynx3 tests › elements › text › basic-element-text-bindlayout Error: coverage.startJSCoverage: Test ended. at coverage-fixture.ts:23 21 | 22 | context.on('page', async (page) => { > 23 | await page.coverage.startJSCoverage({ | ^ 24 | reportAnonymousScripts: true, 25 | resetOnNavigation: true, 26 | }); at BrowserContext.<anonymous> (/__w/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/coverage-fixture.ts:23:27)

Check failure on line 23 in packages/web-platform/web-tests/tests/coverage-fixture.ts

View workflow job for this annotation

GitHub Actions / Playwright ALL_ON_UI-CSR (2/4) / check

[chromium] › tests/react.spec.ts:1477:5 › reactlynx3 tests › configs › config-splitchunk-split-by-module

4) [chromium] › tests/react.spec.ts:1477:5 › reactlynx3 tests › configs › config-splitchunk-split-by-module Error: coverage.startJSCoverage: Test ended. at coverage-fixture.ts:23 21 | 22 | context.on('page', async (page) => { > 23 | await page.coverage.startJSCoverage({ | ^ 24 | reportAnonymousScripts: true, 25 | resetOnNavigation: true, 26 | }); at BrowserContext.<anonymous> (/__w/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/coverage-fixture.ts:23:27)

Check failure on line 23 in packages/web-platform/web-tests/tests/coverage-fixture.ts

View workflow job for this annotation

GitHub Actions / Playwright ALL_ON_UI-CSR (2/4) / check

[chromium] › tests/react.spec.ts:1451:5 › reactlynx3 tests › configs › config-splitchunk-single-vendor

3) [chromium] › tests/react.spec.ts:1451:5 › reactlynx3 tests › configs › config-splitchunk-single-vendor Error: coverage.startJSCoverage: Test ended. at coverage-fixture.ts:23 21 | 22 | context.on('page', async (page) => { > 23 | await page.coverage.startJSCoverage({ | ^ 24 | reportAnonymousScripts: true, 25 | resetOnNavigation: true, 26 | }); at BrowserContext.<anonymous> (/__w/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/coverage-fixture.ts:23:27)

Check failure on line 23 in packages/web-platform/web-tests/tests/coverage-fixture.ts

View workflow job for this annotation

GitHub Actions / Playwright ALL_ON_UI-CSR (3/4) / check

[chromium] › tests/web-elements.spec.ts:3965:5 › web-elements test suite › x-textarea › method-select

2) [chromium] › tests/web-elements.spec.ts:3965:5 › web-elements test suite › x-textarea › method-select Error: coverage.startJSCoverage: Test ended. at coverage-fixture.ts:23 21 | 22 | context.on('page', async (page) => { > 23 | await page.coverage.startJSCoverage({ | ^ 24 | reportAnonymousScripts: true, 25 | resetOnNavigation: true, 26 | }); at BrowserContext.<anonymous> (/__w/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/coverage-fixture.ts:23:27)
reportAnonymousScripts: true,
resetOnNavigation: true,
});
Expand All @@ -27,9 +29,6 @@

await use(context);

const dir = path.join(__dirname, '..', '..', '..', '.nyc_output');
await fs.mkdir(dir, { recursive: true });

await Promise.all(
Array.from(pages.values()).flatMap(async (page, index) => {
const coverage = await page.coverage.stopJSCoverage();
Expand Down
4 changes: 3 additions & 1 deletion packages/web-platform/web-tests/tests/fp-only.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test, expect } from './coverage-fixture.js';
import type { Page } from '@playwright/test';

const ENABLE_MULTI_THREAD = !!process.env['ENABLE_MULTI_THREAD'];
const isSSR = !!process.env['ENABLE_SSR'];
Comment thread
colinaaa marked this conversation as resolved.
const wait = async (ms: number) => {
await new Promise((resolve) => {
setTimeout(resolve, ms);
Expand Down Expand Up @@ -44,6 +45,7 @@ const goto = async (
};

test.describe('SSR no Javascript tests', () => {
test.skip(isSSR || ENABLE_MULTI_THREAD, 'no difference for different mode');
test.beforeEach(({ browserName }) => {
test.skip(browserName === 'firefox', 'firefox does not support @container');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import type { Page } from '@playwright/test';

const ENABLE_MULTI_THREAD = !!process.env.ENABLE_MULTI_THREAD;
const isSSR = !!process.env['ENABLE_SSR'];
Comment thread
PupilTong marked this conversation as resolved.

const wait = async (ms: number) => {
await new Promise((resolve) => {
Expand All @@ -15,6 +16,7 @@
};

test.describe('main thread api tests', () => {
test.skip(isSSR, 'mts api tests not support ssr');
test.beforeEach(async ({ page }) => {
await page.goto(`/main-thread-test.html`, {
waitUntil: 'domcontentloaded',
Expand All @@ -23,7 +25,7 @@
});

test.afterEach(async ({ page }) => {
const fiberTree = await page.evaluate(() => {

Check failure on line 28 in packages/web-platform/web-tests/tests/main-thread-apis.test.ts

View workflow job for this annotation

GitHub Actions / Playwright ALL_ON_UI-CSR (1/4) / check

[webkit] › tests/main-thread-apis.test.ts:806:3 › main thread api tests › __ReplaceElements_3

2) [webkit] › tests/main-thread-apis.test.ts:806:3 › main thread api tests › __ReplaceElements_3 ─ Error: page.evaluate: TypeError: globalThis.genFiberElementTree is not a function. (In 'globalThis.genFiberElementTree()', 'globalThis.genFiberElementTree' is undefined) 26 | 27 | test.afterEach(async ({ page }) => { > 28 | const fiberTree = await page.evaluate(() => { | ^ 29 | return globalThis.genFiberElementTree() as Record<string, unknown>; 30 | }); 31 | const domTree = await page.evaluate(() => { at /__w/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/main-thread-apis.test.ts:28:34

Check failure on line 28 in packages/web-platform/web-tests/tests/main-thread-apis.test.ts

View workflow job for this annotation

GitHub Actions / Playwright ALL_ON_UI-CSR (1/4) / check

[webkit] › tests/main-thread-apis.test.ts:422:3 › main thread api tests › __GetAttributeByName

1) [webkit] › tests/main-thread-apis.test.ts:422:3 › main thread api tests › __GetAttributeByName Error: page.evaluate: TypeError: globalThis.genFiberElementTree is not a function. (In 'globalThis.genFiberElementTree()', 'globalThis.genFiberElementTree' is undefined) 26 | 27 | test.afterEach(async ({ page }) => { > 28 | const fiberTree = await page.evaluate(() => { | ^ 29 | return globalThis.genFiberElementTree() as Record<string, unknown>; 30 | }); 31 | const domTree = await page.evaluate(() => { at /__w/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/main-thread-apis.test.ts:28:34
return globalThis.genFiberElementTree() as Record<string, unknown>;
});
const domTree = await page.evaluate(() => {
Expand Down Expand Up @@ -802,7 +804,7 @@
});

test('__ReplaceElements_3', async ({ page }, { title }) => {
const ret = await page.evaluate(() => {

Check failure on line 807 in packages/web-platform/web-tests/tests/main-thread-apis.test.ts

View workflow job for this annotation

GitHub Actions / Playwright MULTI_THREAD-CSR (1/4) / check

[webkit] › tests/main-thread-apis.test.ts:806:3 › main thread api tests › __ReplaceElements_3

2) [webkit] › tests/main-thread-apis.test.ts:806:3 › main thread api tests › __ReplaceElements_3 ─ Error: page.evaluate: TypeError: globalThis.__CreatePage is not a function. (In 'globalThis.__CreatePage('page', 0)', 'globalThis.__CreatePage' is undefined) 805 | 806 | test('__ReplaceElements_3', async ({ page }, { title }) => { > 807 | const ret = await page.evaluate(() => { | ^ 808 | let res = true; 809 | let root = globalThis.__CreatePage('page', 0); 810 | let view_0 = globalThis.__CreateView(0); at /__w/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/main-thread-apis.test.ts:807:28

Check failure on line 807 in packages/web-platform/web-tests/tests/main-thread-apis.test.ts

View workflow job for this annotation

GitHub Actions / Playwright ALL_ON_UI-CSR (1/4) / check

[webkit] › tests/main-thread-apis.test.ts:806:3 › main thread api tests › __ReplaceElements_3

2) [webkit] › tests/main-thread-apis.test.ts:806:3 › main thread api tests › __ReplaceElements_3 ─ Error: page.evaluate: TypeError: globalThis.__CreatePage is not a function. (In 'globalThis.__CreatePage('page', 0)', 'globalThis.__CreatePage' is undefined) 805 | 806 | test('__ReplaceElements_3', async ({ page }, { title }) => { > 807 | const ret = await page.evaluate(() => { | ^ 808 | let res = true; 809 | let root = globalThis.__CreatePage('page', 0); 810 | let view_0 = globalThis.__CreateView(0); at /__w/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/main-thread-apis.test.ts:807:28
let res = true;
let root = globalThis.__CreatePage('page', 0);
let view_0 = globalThis.__CreateView(0);
Expand Down
3 changes: 3 additions & 0 deletions packages/web-platform/web-tests/tests/performance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import { test, expect } from './coverage-fixture.js';

const ENABLE_MULTI_THREAD = !!process.env['ENABLE_MULTI_THREAD'];
const isSSR = !!process.env['ENABLE_SSR'];
Comment thread
PupilTong marked this conversation as resolved.
const isCI = !!process.env['CI'];

const wait = async (ms: number) => {
Expand Down Expand Up @@ -63,6 +65,7 @@
};

test.describe('performance', () => {
test.skip(isSSR || ENABLE_MULTI_THREAD, 'no difference for different mode');
test.describe.configure({ mode: 'serial', retries: 5 });
test('simple-one-div', async ({ page, browserName, context }, { title }) => {
/**
Expand Down Expand Up @@ -118,7 +121,7 @@
const cdpSession = await goto({ page, browserName, context }, title);
const metrics = await getMetrics(cdpSession, page);
expect(metrics.LayoutCount, 'layout count').toBeLessThanOrEqual(3);
expect(metrics.RecalcStyleCount, 'recalc count').toBeLessThanOrEqual(3);

Check failure on line 124 in packages/web-platform/web-tests/tests/performance.test.ts

View workflow job for this annotation

GitHub Actions / Playwright ALL_ON_UI-CSR (2/4) / check

[chromium] › tests/performance.test.ts:120:3 › performance › x-view-10000

2) [chromium] › tests/performance.test.ts:120:3 › performance › x-view-10000 ───────────────────── Error: recalc count expect(received).toBeLessThanOrEqual(expected) Expected: <= 3 Received: 4 122 | const metrics = await getMetrics(cdpSession, page); 123 | expect(metrics.LayoutCount, 'layout count').toBeLessThanOrEqual(3); > 124 | expect(metrics.RecalcStyleCount, 'recalc count').toBeLessThanOrEqual(3); | ^ 125 | console.log(metrics); 126 | }); 127 | test( at /__w/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/performance.test.ts:124:54
console.log(metrics);
});
test(
Expand Down
3 changes: 3 additions & 0 deletions packages/web-platform/web-tests/tests/rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ function waitImpl(ms: number): Promise<void> {
setTimeout(() => resolve(), ms);
return promise;
}
const ENABLE_MULTI_THREAD = !!process.env['ENABLE_MULTI_THREAD'];
const isSSR = !!process.env['ENABLE_SSR'];
Comment thread
PupilTong marked this conversation as resolved.

test.describe('rpc tests', () => {
test.skip(isSSR || ENABLE_MULTI_THREAD, 'no difference for different mode');
test.beforeEach(async ({ page }) => {
await page.goto('/rpc-test.html');
await waitImpl(100);
Expand Down
3 changes: 3 additions & 0 deletions packages/web-platform/web-tests/tests/web-core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { test, expect } from './coverage-fixture.js';
import type { Page, Worker } from '@playwright/test';

const ENABLE_MULTI_THREAD = !!process.env.ENABLE_MULTI_THREAD;
const isSSR = !!process.env['ENABLE_SSR'];
Comment thread
PupilTong marked this conversation as resolved.

const wait = async (ms: number) => {
await new Promise((resolve) => {
setTimeout(resolve, ms);
Expand Down Expand Up @@ -61,6 +63,7 @@ async function getBackgroundThreadWorker(
}

test.describe('web core tests', () => {
test.skip(isSSR, 'not support ssr');
test('selectComponent', async ({ page, browserName }) => {
// firefox not support
test.skip(browserName === 'firefox');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { swipe, dragAndHold } from './utils.js';
import { test, expect } from './coverage-fixture.js';
import type { Page } from '@playwright/test';
import path from 'node:path';

const ENABLE_MULTI_THREAD = !!process.env['ENABLE_MULTI_THREAD'];
const isSSR = !!process.env['ENABLE_SSR'];
Comment thread
PupilTong marked this conversation as resolved.
const wait = async (ms: number) => {
await new Promise((resolve) => {
setTimeout(resolve, ms);
Expand Down Expand Up @@ -40,6 +41,7 @@ const getTitle = (titlePath: string[]) => {
};

test.describe('web-elements test suite', () => {
test.skip(isSSR || ENABLE_MULTI_THREAD, 'no difference for different mode');
test.describe('layout', () => {
test('layout/percentage-cyclic', async ({ page }, { title }) => {
await gotoWebComponentPage(page, title);
Expand Down
Loading