mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 20:44:31 +00:00
test: migrate suites to e2e coverage layout
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isCloudflareOrHtmlErrorPage } from "./pi-embedded-helpers.js";
|
||||
|
||||
describe("isCloudflareOrHtmlErrorPage", () => {
|
||||
it("detects Cloudflare 521 HTML pages", () => {
|
||||
const htmlError = `521 <!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head><title>Web server is down | example.com | Cloudflare</title></head>
|
||||
<body><h1>Web server is down</h1></body>
|
||||
</html>`;
|
||||
|
||||
expect(isCloudflareOrHtmlErrorPage(htmlError)).toBe(true);
|
||||
});
|
||||
|
||||
it("detects generic 5xx HTML pages", () => {
|
||||
const htmlError = `503 <html><head><title>Service Unavailable</title></head><body>down</body></html>`;
|
||||
expect(isCloudflareOrHtmlErrorPage(htmlError)).toBe(true);
|
||||
});
|
||||
|
||||
it("does not flag non-HTML status lines", () => {
|
||||
expect(isCloudflareOrHtmlErrorPage("500 Internal Server Error")).toBe(false);
|
||||
expect(isCloudflareOrHtmlErrorPage("429 Too Many Requests")).toBe(false);
|
||||
});
|
||||
|
||||
it("does not flag quoted HTML without a closing html tag", () => {
|
||||
const plainTextWithHtmlPrefix = "500 <!DOCTYPE html> upstream responded with partial HTML text";
|
||||
expect(isCloudflareOrHtmlErrorPage(plainTextWithHtmlPrefix)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user