Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

test(desktop): capture network probe diagnostics and check Windows in CI

Leggett8ddbd1358fc9
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5d1a1d84..ddaa1b0d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -161,3 +161,32 @@ jobs:
- run: pnpm perf:check
env:
OPENCREATOR_PERFORMANCE_RESULTS_REQUIRED: '1'
+
+ desktop-network-windows:
+ if: needs.classify.outputs.release-only != 'true'
+ needs: classify
+ runs-on: windows-latest
+ timeout-minutes: 10
+ steps:
+ - uses: actions/checkout@v4
+ - uses: pnpm/action-setup@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: pnpm
+ - run: pnpm install --frozen-lockfile
+ - name: Build Desktop network test inputs
+ run: |
+ pnpm --filter @opencreator/protocol build
+ pnpm --filter @opencreator/config build
+ pnpm --filter @opencreator/desktop build:main
+ - name: Verify Electron networking on Windows
+ run: pnpm --filter @opencreator/desktop exec playwright test --config playwright.config.ts e2e/desktop-network.spec.ts
+ - name: Preserve network test diagnostics
+ if: always()
+ uses: actions/upload-artifact@v4
+ with:
+ name: desktop-network-windows-diagnostics
+ path: test-results/desktop-playwright-report/
+ if-no-files-found: ignore
+ retention-days: 14
diff --git a/apps/desktop/e2e/desktop-network.spec.ts b/apps/desktop/e2e/desktop-network.spec.ts
index 133e1396..d539da39 100644
--- a/apps/desktop/e2e/desktop-network.spec.ts
+++ b/apps/desktop/e2e/desktop-network.spec.ts
@@ -1,5 +1,5 @@
import { execFile } from 'node:child_process';
-import { mkdtempSync, rmSync } from 'node:fs';
+import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
import { createServer } from 'node:http';
import { createRequire } from 'node:module';
import type { AddressInfo } from 'node:net';
@@ -13,7 +13,7 @@ const run = promisify(execFile);
const e2eDir = dirname(fileURLToPath(import.meta.url));
const electronExecutable = createRequire(import.meta.url)('electron') as string;
-test('@package-smoke Desktop 网络在 Socket QoS 抛出 EINVAL 时仍可请求、上传和取消', async () => {
+test('@package-smoke Desktop 网络在 Socket QoS 抛出 EINVAL 时仍可请求、上传和取消', async ({}, testInfo) => {
const userData = mkdtempSync(join(tmpdir(), 'opencreator-desktop-network-'));
const server = createServer((request, response) => {
if (request.url === '/wait') return;
@@ -38,17 +38,27 @@ test('@package-smoke Desktop 网络在 Socket QoS 抛出 EINVAL 时仍可请求
});
await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve));
try {
- const env = { ...process.env };
+ const resultPath = join(userData, 'network-test-result.json');
+ const env: NodeJS.ProcessEnv = { ...process.env, OPENCREATOR_DESKTOP_NETWORK_TEST_RESULT: resultPath };
delete env.ELECTRON_RUN_AS_NODE;
- const result = await run(electronExecutable, [
- resolve(e2eDir, 'fixtures/desktop-network.mjs'),
- pathToFileURL(resolve(e2eDir, '../dist/main/desktop-network.js')).href,
- `http://127.0.0.1:${(server.address() as AddressInfo).port}`,
- userData
- ], { env, timeout: 30_000, windowsHide: true });
-
- expect(result.stdout).toContain('DESKTOP_NETWORK_QOS_REGRESSION_PASSED');
- expect(result.stderr).not.toContain('setTypeOfService EINVAL');
+ let processFailure: unknown;
+ let stderr = '';
+ try {
+ const result = await run(electronExecutable, [
+ resolve(e2eDir, 'fixtures/desktop-network.mjs'),
+ pathToFileURL(resolve(e2eDir, '../dist/main/desktop-network.js')).href,
+ `http://127.0.0.1:${(server.address() as AddressInfo).port}`,
+ userData
+ ], { env, timeout: 30_000, windowsHide: true });
+ stderr = result.stderr;
+ } catch (error) { processFailure = error; }
+ // GUI executables do not reliably expose console output on Windows.
+ const report = existsSync(resultPath) ? readFileSync(resultPath, 'utf8') : 'No network test result file';
+ await testInfo.attach('desktop-network-result', { body: report, contentType: 'application/json' });
+ expect(processFailure, report).toBeUndefined();
+ expect(existsSync(resultPath), report).toBe(true);
+ expect(JSON.parse(report)).toMatchObject({ ok: true, phase: 'complete' });
+ expect(stderr).not.toContain('setTypeOfService EINVAL');
} finally {
server.closeAllConnections();
await new Promise<void>(resolve => server.close(() => resolve()));
diff --git a/apps/desktop/e2e/fixtures/desktop-network.mjs b/apps/desktop/e2e/fixtures/desktop-network.mjs
index b5c01ba8..0b26713d 100644
--- a/apps/desktop/e2e/fixtures/desktop-network.mjs
+++ b/apps/desktop/e2e/fixtures/desktop-network.mjs
@@ -1,26 +1,33 @@
import assert from 'node:assert/strict';
+import { writeFileSync } from 'node:fs';
import { Socket } from 'node:net';
import { app } from 'electron';
-app.setPath('userData', process.argv[4]);
-
-Socket.prototype.setTypeOfService = () => {
- throw Object.assign(new Error('setTypeOfService EINVAL'), { code: 'EINVAL' });
-};
-globalThis.fetch = () => {
- throw new Error('Built-in Undici fetch must not handle Desktop requests');
-};
+let phase = 'initialization';
+const report = result => writeFileSync(process.env.OPENCREATOR_DESKTOP_NETWORK_TEST_RESULT, `${JSON.stringify({ phase, ...result }, null, 2)}\n`);
void (async () => {
+ app.setPath('userData', process.argv[4]);
+ Socket.prototype.setTypeOfService = () => {
+ throw Object.assign(new Error('setTypeOfService EINVAL'), { code: 'EINVAL' });
+ };
+ globalThis.fetch = () => {
+ throw new Error('Built-in Undici fetch must not handle Desktop requests');
+ };
await app.whenReady();
+ phase = 'load network module';
const { fetchDesktopRequest } = await import(process.argv[2]);
const origin = process.argv[3];
+ phase = 'JSON request';
const json = await fetchDesktopRequest(`${origin}/json`);
assert.deepEqual(await json.json(), { ok: true });
+ phase = 'binary request';
const binary = await fetchDesktopRequest(`${origin}/binary`);
assert.deepEqual([...new Uint8Array(await binary.arrayBuffer())], [0, 255, 17, 23]);
+ phase = 'SSE request';
const events = await fetchDesktopRequest(`${origin}/events`);
assert.equal(await events.text(), 'data: first\n\ndata: second\n\n');
+ phase = 'streaming upload';
const upload = await fetchDesktopRequest(`${origin}/upload`, {
method: 'POST',
headers: { 'Content-Type': 'application/octet-stream' },
@@ -34,13 +41,17 @@ void (async () => {
duplex: 'half'
});
assert.deepEqual(await upload.json(), { bytes: 12288 });
+ phase = 'cancellation';
const cancellation = new AbortController();
const pending = fetchDesktopRequest(`${origin}/wait`, { signal: cancellation.signal });
setTimeout(() => cancellation.abort(), 50);
await assert.rejects(pending, { name: 'AbortError' });
+ phase = 'complete';
+ report({ ok: true });
console.log('DESKTOP_NETWORK_QOS_REGRESSION_PASSED');
app.exit(0);
})().catch(error => {
+ report({ ok: false, error: error?.stack ?? String(error) });
console.error(error);
app.exit(1);
});