mirror of
https://github.com/rookiestar28/ComfyUI-OpenClaw.git
synced 2026-08-14 08:52:45 +00:00
Remove low-risk Moltbot aliases and add configurable Playwright E2E port
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
// @ts-check
|
||||
const { defineConfig } = require('@playwright/test');
|
||||
|
||||
const e2ePort = process.env.OPENCLAW_E2E_PORT || '3000';
|
||||
const e2eBase = `http://127.0.0.1:${e2ePort}`;
|
||||
|
||||
module.exports = defineConfig({
|
||||
testDir: 'tests/e2e/specs',
|
||||
timeout: 30_000,
|
||||
retries: 0,
|
||||
use: {
|
||||
baseURL: 'http://127.0.0.1:3000/tests/e2e/',
|
||||
baseURL: `${e2eBase}/tests/e2e/`,
|
||||
headless: true,
|
||||
},
|
||||
webServer: {
|
||||
command: `${process.env.PYTHON || (process.platform === 'win32' ? 'python' : 'python3')} -m http.server 3000`,
|
||||
url: 'http://127.0.0.1:3000/tests/e2e/test-harness.html',
|
||||
// IMPORTANT: allow overriding port for environments where 3000 is blocked/reserved.
|
||||
command: `${process.env.PYTHON || (process.platform === 'win32' ? 'python' : 'python3')} -m http.server ${e2ePort}`,
|
||||
url: `${e2eBase}/tests/e2e/test-harness.html`,
|
||||
reuseExistingServer: true,
|
||||
timeout: 30_000,
|
||||
},
|
||||
|
||||
@@ -35,6 +35,13 @@ npx playwright install chromium
|
||||
npm test
|
||||
```
|
||||
|
||||
If port `3000` is blocked/reserved on your machine, set a custom E2E port:
|
||||
|
||||
```powershell
|
||||
$env:OPENCLAW_E2E_PORT = "3300"
|
||||
npm test
|
||||
```
|
||||
|
||||
### 2.2 WSL2 (bash)
|
||||
|
||||
```bash
|
||||
@@ -63,7 +70,7 @@ TMPDIR=.tmp/playwright TMP=.tmp/playwright TEMP=.tmp/playwright \
|
||||
- Creates a minimal mocked ComfyUI environment (`window.app`)
|
||||
- Mocks `fetch()` for `/openclaw/*` and legacy `/moltbot/*` endpoints (capabilities/health + predictable errors)
|
||||
- Imports `web/openclaw.js` (the real extension entry) and waits for readiness
|
||||
- Sets `window.__moltbotTestReady = true` and dispatches `moltbot-ready`
|
||||
- Sets `window.__openclawTestReady = true` and dispatches `openclaw-ready`
|
||||
|
||||
## 4. Common Troubleshooting
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { mockComfyUiCore, waitForMoltbotReady, clickTab } from '../utils/helpers.js';
|
||||
import { mockComfyUiCore, waitForOpenClawReady, clickTab } from '../utils/helpers.js';
|
||||
|
||||
test.describe('Parameter Lab - Dynamic Dimensions', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// 1. Setup mock environment
|
||||
await mockComfyUiCore(page);
|
||||
await page.goto('test-harness.html');
|
||||
await waitForMoltbotReady(page);
|
||||
await waitForOpenClawReady(page);
|
||||
|
||||
// 2. Inject mock graph with nodes and widgets
|
||||
await page.evaluate(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { mockComfyUiCore, waitForMoltbotReady, clickTab } from '../utils/helpers.js';
|
||||
import { mockComfyUiCore, waitForOpenClawReady, clickTab } from '../utils/helpers.js';
|
||||
|
||||
test.describe('R107 Live Backend Parity', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
@@ -17,7 +17,7 @@ test.describe('R107 Live Backend Parity', () => {
|
||||
});
|
||||
|
||||
await page.goto('test-harness.html');
|
||||
await waitForMoltbotReady(page);
|
||||
await waitForOpenClawReady(page);
|
||||
});
|
||||
|
||||
test('Planner (Submit) critical path - Success', async ({ page }) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { mockComfyUiCore, waitForMoltbotReady, clickTab } from '../utils/helpers.js';
|
||||
import { mockComfyUiCore, waitForOpenClawReady, clickTab } from '../utils/helpers.js';
|
||||
|
||||
test.describe('Settings Tab Stability', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
@@ -60,7 +60,7 @@ test.describe('Settings Tab Stability', () => {
|
||||
});
|
||||
|
||||
await page.goto('test-harness.html');
|
||||
await waitForMoltbotReady(page);
|
||||
await waitForOpenClawReady(page);
|
||||
});
|
||||
|
||||
test('loads settings without flicker and populates fields', async ({ page }) => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { mockComfyUiCore, waitForMoltbotReady, clickTab } from '../utils/helpers.js';
|
||||
import { mockComfyUiCore, waitForOpenClawReady, clickTab } from '../utils/helpers.js';
|
||||
|
||||
test.describe('OpenClaw Sidebar', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await mockComfyUiCore(page);
|
||||
await page.goto('test-harness.html');
|
||||
await waitForMoltbotReady(page);
|
||||
await waitForOpenClawReady(page);
|
||||
});
|
||||
|
||||
test('renders header + tabs', async ({ page }) => {
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
<script type="module">
|
||||
import { createMockComfyUIApp } from './mocks/comfyui-app.js';
|
||||
|
||||
window.__moltbotTestReady = false;
|
||||
window.__moltbotTestError = null;
|
||||
window.__openclawTestReady = false;
|
||||
window.__openclawTestError = null;
|
||||
|
||||
// Mock ComfyUI app BEFORE importing extension
|
||||
window.app = createMockComfyUIApp();
|
||||
|
||||
// Minimal fetch mocks for moltbot UI calls
|
||||
// Minimal fetch mocks for OpenClaw UI calls
|
||||
const realFetch = window.fetch.bind(window);
|
||||
window.fetch = async (input, init) => {
|
||||
const url = typeof input === 'string' ? input : (input?.url || '');
|
||||
@@ -72,14 +72,13 @@
|
||||
// Allow async setup to mount
|
||||
await new Promise(r => setTimeout(r, 500));
|
||||
|
||||
window.__moltbotTestReady = true;
|
||||
window.__openclawTestReady = true;
|
||||
document.getElementById('test-status').textContent = '✓ Ready for Testing';
|
||||
document.getElementById('test-status').className = 'ready';
|
||||
window.dispatchEvent(new CustomEvent('openclaw-ready'));
|
||||
window.dispatchEvent(new CustomEvent('moltbot-ready'));
|
||||
} catch (e) {
|
||||
console.error('[Test Harness] Failed to load OpenClaw UI:', e);
|
||||
window.__moltbotTestError = e;
|
||||
window.__openclawTestError = e;
|
||||
document.getElementById('test-status').textContent = '✗ Load Failed: ' + (e?.message || String(e));
|
||||
document.getElementById('test-status').style.background = '#4c0f0f';
|
||||
}
|
||||
|
||||
@@ -41,14 +41,14 @@ export async function mockComfyUiCore(page) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function waitForMoltbotReady(page) {
|
||||
export async function waitForOpenClawReady(page) {
|
||||
await page.waitForFunction(
|
||||
() => window.__moltbotTestReady === true || window.__moltbotTestError,
|
||||
() => window.__openclawTestReady === true || window.__openclawTestError,
|
||||
null,
|
||||
{ timeout: 30_000 }
|
||||
);
|
||||
|
||||
const error = await page.evaluate(() => window.__moltbotTestError);
|
||||
const error = await page.evaluate(() => window.__openclawTestError);
|
||||
if (error) {
|
||||
throw new Error(`OpenClaw test harness failed to load: ${error?.message || error}`);
|
||||
}
|
||||
|
||||
@@ -635,7 +635,3 @@ export class OpenClawAPI {
|
||||
}
|
||||
|
||||
export const openclawApi = new OpenClawAPI();
|
||||
|
||||
// Legacy compatibility aliases (Moltbot -> OpenClaw)
|
||||
export const MoltbotAPI = OpenClawAPI;
|
||||
export const moltbotApi = openclawApi;
|
||||
|
||||
@@ -47,6 +47,3 @@ export const OpenClawSession = {
|
||||
return !!this.getAdminToken();
|
||||
}
|
||||
};
|
||||
|
||||
// Legacy compatibility alias (Moltbot -> OpenClaw)
|
||||
export const MoltbotSession = OpenClawSession;
|
||||
|
||||
@@ -710,9 +710,3 @@ export const openclawActions = new OpenClawActions(openclawUI);
|
||||
|
||||
const monitor = new QueueMonitor(openclawUI);
|
||||
monitor.start();
|
||||
|
||||
// Legacy compatibility aliases (Moltbot -> OpenClaw)
|
||||
export const MoltbotUI = OpenClawUI;
|
||||
export const moltbotUI = openclawUI;
|
||||
export const MoltbotActions = OpenClawActions;
|
||||
export const moltbotActions = openclawActions;
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
}
|
||||
|
||||
function setDone() {
|
||||
window.__MOLTBOT_E2E_DONE__ = true;
|
||||
window.__MOLTBOT_E2E_RESULTS__ = results;
|
||||
window.__OPENCLAW_E2E_DONE__ = true;
|
||||
window.__OPENCLAW_E2E_RESULTS__ = results;
|
||||
logEl.textContent = JSON.stringify(results, null, 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ const { test, expect } = require('@playwright/test');
|
||||
test('E2E harness passes', async ({ page, baseURL }) => {
|
||||
await page.goto(`${baseURL}/web/tests/e2e-harness.html`);
|
||||
|
||||
await page.waitForFunction(() => window.__MOLTBOT_E2E_DONE__ === true, null, {
|
||||
await page.waitForFunction(() => window.__OPENCLAW_E2E_DONE__ === true, null, {
|
||||
timeout: 30_000,
|
||||
});
|
||||
|
||||
const results = await page.evaluate(() => window.__MOLTBOT_E2E_RESULTS__);
|
||||
const results = await page.evaluate(() => window.__OPENCLAW_E2E_RESULTS__);
|
||||
expect(results.failed, JSON.stringify(results, null, 2)).toBe(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user