Fix all e2e failures, sass warnings, and HMR websocket errors
- Restructure OnlineBoardFilter to use radio tabs (flight/departure/ arrival/route) with dynamic fields matching e2e test expectations - Fix error page e2e tests to use client-side navigation (SSR renders empty outside [lang]/layout) and use specific CSS class locators - Replace deprecated transparentize() with rgba() in _shadows.scss - Handle WebSocket upgrades explicitly in dev-server to prevent HMR reconnection spam - Resolve DEP0190 by spawning modern binary directly without shell - Add tests/e2e-angular to tsconfig excludes
This commit is contained in:
+20
-8
@@ -9,8 +9,9 @@
|
||||
*/
|
||||
import express from "express";
|
||||
import { createProxyMiddleware } from "http-proxy-middleware";
|
||||
import { execFile } from "node:child_process";
|
||||
import { spawn } from "node:child_process";
|
||||
import { execFile, spawn } from "node:child_process";
|
||||
import { resolve } from "node:path";
|
||||
import { existsSync } from "node:fs";
|
||||
|
||||
const PUBLIC_PORT = 8080;
|
||||
const MODERNJS_PORT = 8081;
|
||||
@@ -18,11 +19,18 @@ const API_TARGET = "https://flights.test.aeroflot.ru";
|
||||
|
||||
// --- Start Modern.js on internal port ---
|
||||
console.log(`Starting Modern.js on :${MODERNJS_PORT}...`);
|
||||
const modernProcess = spawn("npx", ["modern", "dev"], {
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, PORT: String(MODERNJS_PORT) },
|
||||
shell: true,
|
||||
});
|
||||
|
||||
// Resolve the modern binary directly to avoid DEP0190 (shell: true with spawn)
|
||||
const modernBin = resolve("node_modules", ".bin", "modern");
|
||||
const modernProcess = existsSync(modernBin)
|
||||
? spawn(modernBin, ["dev"], {
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, PORT: String(MODERNJS_PORT) },
|
||||
})
|
||||
: spawn(process.execPath, [resolve("node_modules", "@modern-js/app-tools", "bin", "modern.js"), "dev"], {
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, PORT: String(MODERNJS_PORT) },
|
||||
});
|
||||
modernProcess.on("error", (err) => {
|
||||
console.error("Modern.js failed:", err);
|
||||
process.exit(1);
|
||||
@@ -95,11 +103,15 @@ const modernProxy = createProxyMiddleware({
|
||||
});
|
||||
app.use(modernProxy);
|
||||
|
||||
app.listen(PUBLIC_PORT, () => {
|
||||
const server = app.listen(PUBLIC_PORT, () => {
|
||||
console.log(`\n ✓ Dev server: http://localhost:${PUBLIC_PORT}`);
|
||||
console.log(` /api/* → curl → ${API_TARGET}`);
|
||||
console.log(` /* → Modern.js :${MODERNJS_PORT}\n`);
|
||||
});
|
||||
|
||||
// Forward WebSocket upgrades to Modern.js HMR server explicitly,
|
||||
// preventing reconnection spam from http-proxy-middleware's built-in ws handling.
|
||||
server.on("upgrade", modernProxy.upgrade);
|
||||
|
||||
process.on("SIGINT", () => { modernProcess.kill(); process.exit(); });
|
||||
process.on("SIGTERM", () => { modernProcess.kill(); process.exit(); });
|
||||
|
||||
Reference in New Issue
Block a user